-
Notifications
You must be signed in to change notification settings - Fork 4.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
@wordpress/babel-preset-default@4.0.0 is causing an "Identifier 'createElement' has already been declared" error #14381
Comments
Currently facing the same issue at ampproject/amp-wp#1952 |
Ah, it seems the issue may then be that there's two separate instances of the It makes sense, though in retrospect I don't think was as consciously considered as it should have been (i.e. upgrade instructions for those using both the preset and the plugin already). Furthermore, perhaps the plugin could be made more tolerant to being run twice. I suspect the issue is that, by the implementation, both encounter and decide at the occurrence of the JSX tag to add the import. |
Anything to do here? Since |
I think the changelog is quite clear. One just has to read it :-) |
Got it, let's close :) |
I'm glad it was a version upgrade issue. The latest implementation should auto-detect whether |
https://github.com/WordPress/gutenberg/blob/master/packages/babel-plugin-import-jsx-pragma/README.md#usage should still get an update. |
How should it be updated exactly? The referenced usage looks legitimate. I mean, I can update but I want to learn what’s is wrong there. |
As mentioned in the issue, when you use both plugins (as mentioned in Usage) or copy the example configuration from Options, you get the error due to the duplicate declaration. |
It looks like the README is not using both presets at the same time, it seems correct as is for me? Anything I'm missing? |
@youknowriad Updated steps from #14381 (comment) to reproduce:
diff --git .babelrc .babelrc
index dcff30b..20fabb0 100644
--- .babelrc
+++ .babelrc
@@ -3,6 +3,14 @@
"@wordpress/default"
],
"plugins": [
+ [
+ "@wordpress/babel-plugin-import-jsx-pragma",
+ {
+ "scopeVariable": "createElement",
+ "source": "@wordpress/element",
+ "isDefault": false
+ }
+ ],
[
"@babel/transform-react-jsx", {
"pragma": "createElement"
|
The difference is that this README does not mention The changelog for So, to be clear, are you suggesting to add a note to https://www.npmjs.com/package/@wordpress/babel-plugin-import-jsx-pragma#options a la "Not needed when already using |
Yes, let’s do it. There might be some issues when versions of the plugin differ between preset and the plugin itself. |
I hope #14482 will help. |
Describe the bug
After upgrading to
@wordpress/babel-preset-default
4.0.0 I'm seeing with the setup from here this error:To Reproduce
git clone --single-branch --branch gutenberg git@github.com:wearerequired/wp-team-list.git
cd wp-team-list
npm run build:js
-- everything worksnpm install @wordpress/babel-preset-default@4.0.0 --save
npm run build:js
-- build is brokenExpected behavior
Step 3 and 5 should both successfully produce a build.
Additional context
Might be related to #13809 and/or #14106.
The text was updated successfully, but these errors were encountered: