-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Define custom pragma as global setting? #5152
Comments
I'd like to second this. I'm currently looking at a way to define it using a I ended up here : https://github.com/facebook/create-react-app/blob/master/packages/babel-preset-react-app/create.js#L95-L103 It would be great to add the pragma option here and to give us a parameter / env variable to set it properly. 😄 This would be enough so we can hook into the webpack config and pass the option from a rewired plugin :
EDIT : We can actually make it works today by redefining In term of dependencies to add : yarn add --dev @wordpress/babel-plugin-import-jsx-pragma babel-plugin-emotion@next babel-plugin-transform-react-jsx
Here is the const { override, addBabelPlugin } = require('customize-cra')
module.exports = override(
addBabelPlugin(['emotion', options]),
addBabelPlugin([
'@wordpress/babel-plugin-import-jsx-pragma',
{
scopeVariable: 'jsx',
source: '@emotion/core',
isDefault: false
}
]),
addBabelPlugin([
'@babel/transform-react-jsx',
{
pragma: 'jsx'
}
])
) I still think it would be better to have a proper API from CRA rather than relying on webpack's execution priority. |
I wonder if we could use the Yarn
|
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
As of today there is still no easy solution to this issue. |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
Hey stale bot stop with this shit. |
Anyway, for what is worth, if you don't make use of the |
@FezVrasta Is there an example of that somewhere? |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
I'm losing faith in the open source community with all these stale bots that close perfectly legit issues for no apparent reason... I promise I will never add one to my own projects. We went from the "+1" comments to the "no bot please don't close this" ones 🤷♂️ |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
NO STALE! NO _ STALE 👏 IT 👏ISN'T 👏 STALE 👏IT IS NOT STALE |
We have no plans to implement this right now. |
@iansu is there any particular reason you're able to share with us? |
We don't want to add options to customize our webpack config and we avoid making changes to accommodate individual libraries or tools. You can still use Emotion, or countless other CSS-in-JS libraries, without this. |
An option of this kind would allow to use also other React-like libraries such as Preact. Honestly I wouldn't dismiss this issue that quickly, but I guess it's up to you. |
Something like https://github.com/sharegate/craco/ might enable the custom config you want. |
Emotion 10 is going to provide a custom
createElement
function and to work, the app needs to use it as custom pragma.emotion-js/emotion#637
Is there any way to override the default React
createElement
in a global manner to avoid to define the custom pragma on every single file?The text was updated successfully, but these errors were encountered: