-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Bundle failure on decorators #19955
Comments
@haani104 I am experiencing the same issue. Might be worth to wait until 56 is stable. |
I think this is a duplicate of #19789, and in particular I think you should take a look at this comment |
The comment unfortunately doesn’t help—as mentioned above, I am using the new |
Uhm could it be then that maybe some react-native only lib is still on babel 6, or something like that? In our app we had to add this babel-bridge and enforce yarn resolutions in order to make sure that everything was being bundled properly. That said, we will release 0.56.0 today (if nothing goes wrong) in order to increase the surface of devs using it, and hopefully lead to faster fixes for issues like yours. |
After purging some old Babel plugins, pinning the versions of all |
Attempted everything that @haggholm did but can't get past the "bundling failed: TypeError: Property right of AssignmentExpression". I am going to attempt getting around this for a little while else I will have to revert to older version again. |
I have another problem with decorators with 0.56 in release build only: function test() {}
class Test {
@test val;
}
P.S. "Old Version" tag should be removed. |
Same problem here after upgrading to RN 0.56. The app works in package.json
.babelrc
But in
|
was exactly in the situation @haggholm mentioned, It seems the error is caused by a dependency version missmatch between the plugins used in Be sure to check that all the babel package are actually installed with the beta.47 version:
The problem in our case was that some babel packages where installed using a caret range |
I was actually talking with the main dev behind Babel over the weekend and I think using the fixed dependency may be a solution. Can anyone else test if it fixes the issue? |
Using {
"presets": ["react-native"],
"plugins": [
["@babel/proposal-decorators", {"legacy": true}],
["@babel/transform-runtime", {
"polyfill": false,
"regenerator": false
}]
]
} "devDependencies": {
...
"@babel/plugin-proposal-decorators": "7.0.0-beta.47",
"@babel/plugin-transform-runtime": "7.0.0-beta.47",
"@babel/runtime": "7.0.0-beta.47"
...
} Thanks to @alessandro-bottamedi. But this brings another problem:
|
@farwayer Do you have other packages installed? for icons? If yes, try to disable its... |
@alessandro-bottamedi |
@farwayer |
@thientnc-ibl I still have the same problem.
|
@SurpassRabbit
|
@thientnc-ibl Thank you, you are right. |
👋 Just to double down on it, yes, as @thientnc-ibl wrote all the deps babel related must be fixed to |
@kelset It should be doc'ed of course but what about errors in RELEASE bundle transformation? Build should work as is without using Not sure but look like it is trimming error while bundle optimization. Should we open new issue for this? @thientnc-ibl I already have same babel config as @alessandro-bottamedi. It's another error I got while using |
I'm not sure my current issue on RELEASE build is related with @farwayer above comment
It is ok on DEBUG, but throws the below exception log on RELEASE I MUST change my code to use
@kelset , Can you investigate this case? :( |
I've solved it using beta.47 version of babel (like the ReactNative'one) |
I'm having the same issue with RN 0.57 |
I'm also having this problem in RN 0.57 which uses the stable version 7.0.0 of Babel. My debug builds works, but when doing a release build it crashes on startup with:
This is my {
"presets": ["module:metro-react-native-babel-preset"],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-transform-runtime", { "helpers": true }]
]
} and the relevant part of "@babel/plugin-proposal-decorators": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/runtime": "^7.0.0", Currently trying to figure out what's wrong and where the fix should be applied... |
Okay, the problem is that React Native is bundling its own version of babel-helpers (exposed as a global variable named This will be fixed when this PR lands in Metro, and when React Native upgrades to that version of Metro. (I'm guessing React Native 0.58) In the meantime, you can use this workaround: diff --git a/index.js b/index.js
index 77f0986..8d0a685 100644
--- a/index.js
+++ b/index.js
@@ -1,7 +1,13 @@
+import applyDecoratedDescriptor from '@babel/runtime/helpers/esm/applyDecoratedDescriptor'
+import initializerDefineProperty from '@babel/runtime/helpers/esm/initializerDefineProperty'
+
import { AppRegistry } from 'react-native'
-import App from './App'
+
+Object.assign(babelHelpers, { applyDecoratedDescriptor, initializerDefineProperty })
+
+const App = require('./App').default
AppRegistry.registerComponent('Ctrlpanel', () => App) Together with |
@kelset I'm working on a Brownfield app and I've just updated to 0.57. I receive this error when doing the release (both iOS and Android):
I've applied the workaround by @LinusU but it does not work. The
Here my package.json.
Here my
Any idea? |
@flexaddicted, i got same error Here my
|
@Fendoro Thank you very much! Removing |
I just mimicked "LinusU commented".
My So, I also did the command.
now I have them in my
But, doesn't work yet.. |
I also did
But, doesn't work yet.. I don't use |
I also use |
|
I don't know why resolve. My ReactNative project is created like this. my
what I did is.
My
I mimicked what "Alessandro Bottamedi" answered in the site |
inspired by @Fendoro 's comment I got my react native build back working by not adding plugins that are already present in I don't really use anything not in the preset to begin with lol. Hope this helps someone else. Ironically this even made my test suite faster lol. Go figure. I also run a node server our of the same repo that builds with the same babel config too |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions. |
It seems like this shouldn't be an issue any more with the latest versions of RN and there are workarounds mostly related to babel. |
Environment
Description
Multi-platform app with both regular React (Webpack) and React Native builds. I upgraded RN to 0.56, which of course necessitated changes to the Babel environment, e.g.
babel-plugin-transform-decorators-legacy
→@babel/plugin-proposal-decorators
({legacy:true}
). The Webpack version builds fine. The RN version fails bundling:What puzzles me is that, again, the Webpack version works, so presumably there’s nothing inherently problematic about our Babel setup, and migration to Babel 7 was successful. The only difference in Babel configuration here is
babel-preset-react-native
(5.0.2) versus@babel/preset-env
. (The thought occurred to me that this might be due to the RN preset importingproposal-class-properties
before-decorators
, but modifyingbabel-preset-react-native/configs/main.js
to include the decorator plugin does not help.)Looking at the AST in Babel, it looks like it’s failing with both class and method decorators.
Unfortunately I do not have a demo and can’t share the (proprietary) source, but any suggestions on how to go about debugging this would be welcome.
The text was updated successfully, but these errors were encountered: