Comments (7)
If someone actually makes a babel plugin out of dom-chef I'd love to actually see JSX converted into plain DOM calls like Svelte does. That stuff is amazing:
<h1>Hello {{name}}!</h1>
// ...
create: function () {
h1 = createElement( 'h1' );
text = createText( "Hello " );
text_1 = createText( text_1_value = state.name );
text_2 = createText( "!" );
},
mount: function ( target, anchor ) {
insertNode( h1, target, anchor );
appendNode( text, h1 );
appendNode( text_1, h1 );
appendNode( text_2, h1 );
},
// ...
Svelte unfortunately adds a little unnecessary boilerplate to keep it dynamic and app-like, otherwise I'd have used that in Refined GitHub instead.
from dom-chef.
Apparently babel 7.9.0 automatically imports React:
Due to:
I think our config would be:
[
"@babel/preset-react",
{
"pragma": "h",
"pragmaFrag": "DocumentFragment",
"runtime": "automatic", // enables auto-import
"importSource": "dom-chef"
}
]
]
From: https://babeljs.io/docs/en/babel-preset-react#with-a-configuration-file-recommended
So now this is a documentation-only issue, which would follow #56 and then #57
from dom-chef.
Bingo: https://github.com/treycordova/nativejsx and https://github.com/treycordova/nativejsx-loader
export const check = <svg aria-hidden="true" class="octicon octicon-check" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>;
export const check = function () {
const _a = document.createElement('svg');
_a.setAttribute('aria-hidden', 'true');
_a.setAttribute('class', 'octicon octicon-check');
_a.setAttribute('height', '16');
_a.setAttribute('version', '1.1');
_a.setAttribute('viewBox', '0 0 12 16');
_a.setAttribute('width', '12');
const _b = document.createElement('path');
_b.setAttribute('d', 'M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z');
_a.appendChild(_b);
return _a;
}.call(this);
Two issues:
- no SVG support at the moment treycordova/nativejsx#26
I can't get it to work with async/await treycordova/nativejsx#27✓
from dom-chef.
@sindresorhus Great idea! Agree with every point.
@bfred-it That stuff is great, I'll keep that in mind.
from dom-chef.
Apologies for a perhaps noob question, however, according to babel docs, pragma
and pragmaFrag
cannot be set with runtime: "automatic"
. Is dom-chef therefore not compatible with automatic runtime?
docs: https://babeljs.io/docs/en/babel-preset-react#with-a-configuration-file-recommended
from dom-chef.
from dom-chef.
@fregante understood! appreciate the prompt reply
from dom-chef.
Related Issues (20)
- Add support for boolean attributes HOT 3
- Accept plain strings as style HOT 1
- Improve TypeScript types for JSX HOT 11
- Add support for `htmlFor`
- Skip undefined attributes
- Skip `null` attributes
- Skip children that aren't Nodes, strings, or numbers
- Add support for dashed event types via `on` attributes HOT 3
- Turn into real ESM module and write in TypeScript
- Support <Function>
- Support new `React.jsx()` syntax
- Improve TypeScript documentation HOT 1
- Feature. Add jsx/jsxs exports for babel automatic runtime HOT 1
- Fix type:module support
- Add support for CSS Custom Properties (variables) via `style` attribute HOT 1
- Support camelCase props
- Pass props to child components? HOT 4
- Add `"sideEffects": false` to `package.json` HOT 1
- Pass attributes to create HOT 3
- onClick and others have incorrect function signature
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dom-chef.