-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Babel preset #7
Comments
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. |
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:
|
@sindresorhus Great idea! Agree with every point. @bfred-it That stuff is great, I'll keep that in mind. |
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, |
Apologies for a perhaps noob question, however, according to babel docs, docs: https://babeljs.io/docs/en/babel-preset-react#with-a-configuration-file-recommended |
@fregante understood! appreciate the prompt reply |
Would be nice if there was a
babel-preset-dom-chef
that set everything up for you.Should contain:
babel-plugin-jsx
andbabel-plugin-transform-react-jsx
dependenciesbabel-plugin-transform-react-jsx
configimport {h} from 'dom-chef';
. Something like https://github.com/jmm/babel-plugin-jsx-pragmatic, but that actually works. Make it ;)From refined-github/refined-github#558 (comment)
The text was updated successfully, but these errors were encountered: