-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
General JSX Transformer #178
Comments
Nice work. Any chance you'd be interested in making the property names configurable? Preact VNodes use {
"plugins": [
["transform-jsx", { "function": "h", "useVariables": true }]
]
} Or another thought - provide a "to hyperscript" option. Preact's |
I do this in webpack: Babel loader: {
loader: 'babel',
test: /\.jsx?$/,
exclude: /node_modules/,
query: {
cacheDirectory: true,
presets: ['es2015'],
plugins: [
'transform-class-properties',
['transform-react-jsx', {
pragma: 'jsx'
}]
]
}
} Provide plugin: new ProvidePlugin({
jsx: resolve('src/jsx.js'),
}) and const preact = require('preact');
module.exports = preact.h; This way I don't need to define any pragma nor import Preact everytime when I need to use JSX. Probably makes sense to provide |
Nice! Might steal that. |
would be nice if you could inline that somehow, not requiring the extra file but I don't think my IDE or ESLint would agree with providing Component that way also is the |
I just had a PR merged into webpack to eliminate that extra file So in the next webpack release you can just do: new ProvidePlugin({
jsx: ['preact', 'h']
}) |
@gdub22 very nice |
It can be this way right now: new ProvidePlugin({
preact: 'preact'
}) {
loader: 'babel',
test: /\.jsx?$/,
exclude: /node_modules/,
query: {
cacheDirectory: true,
presets: ['es2015'],
plugins: [
'transform-class-properties',
['transform-react-jsx', {
pragma: 'preact.h'
}]
]
}
}
That's great! But anyway, I'm totally fine with an additional file since it doesn't harm anything for me. |
Take it! Take it! 😄 |
It was just a thought though, but I think such things are customizable in many tools. In my projects I use subclass of preact's
It's |
well, yeah, I'm currently using the imports-loader ['transform-react-jsx', { pragma: 'preact.h' }] {
test : /\.jsx$/,
loader: 'imports-loader',
query : {
preact: 'preact',
},
} but just h will be nice with the next version of webpack and with the provide plugin I feel like this loader is kinda unnecessary |
I think we can close this out now - there are 3 or 4 great solutions including the original posted here :) |
Just to leave it here.
|
Fix previous shouldComponentUpdate calls blocking future updates
Great project! I made a general JSX transformer, babel-plugin-transform-jsx if you are interested in recommending that and avoiding
/* @jsx h */
comments and even repetitive imports.The text was updated successfully, but these errors were encountered: