-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Bundlejs error on release build #19788
Comments
It would be very helpful if you can provide sample repo that can replicate this error. This error can be caused by too many things... For now I can only suggest one thing (if this error only in release build, but debug build works as expected): try to play with various versions of uglifyjs. uglifyjs used only in release builds... |
I will try to strip away everything to give a sample repo. Thanks for the suggestion, how would I change the version of uglifyjs? I don't see this in my dependencies list. |
See this thread: #17348 (comment) for some suggestions. uglify-es (yes its "es" variant) used by metro-minify-uglify used by metro :-) |
@vovkasm I had high hopes but unfortunately downgrading my uglify-es yielded the same error :( |
Ok, if you can give a sample repo, I will look at it... Again there are too many causes. |
I appreciate that, I stripped the code down and the error disappeared so I need to figure out a way to securely strip the app but still keep the error. |
Anyway you can try to debug yourself. What you need is to find the source of the problem. You can find |
I was experiencing this same error, and (at least for me) it turned out to be an issue with the metro bundler's dependency on Babel 7 and the I was able to resolve the error by:
I hope this helps! |
@mattpetrie Thank you so much for the guidance. Do you have any tips to make sure everything is running the way it should so I can go on and try something else? I've done the following but not sure if it did anything. I did:
Added this to my package.json file
And created a
EDIT: Hmm now I get this: |
This is the beginning of the source of the problem when I did a search (found it in my bundlejs file):
|
Hmm... this code definitely incorrect but still we don't know where is it come from. Can you try to locate same (or similar) pattern in debug bundle? there is something like BTW. I'm just generated production bundle from our app, and found similar pattern (it is sure different), see (formatted for easy reading): var e, r;
((r = this.babelHelpers = {}).typeof =
"function" == typeof Symbol &&
"symbol" ==
typeof ("function" == typeof Symbol ? Symbol.iterator : "@@iterator")
? function(e) {
return typeof e;
}
: function(e) {
return e &&
"function" == typeof Symbol &&
e.constructor === Symbol &&
e !== ("function" == typeof Symbol ? Symbol.prototype : "@@prototype")
? "symbol"
: typeof e;
}),
(r.createRawReactElement = ((e =
("function" == typeof Symbol &&
("function" == typeof Symbol ? Symbol.for : "@@for") &&
("function" == typeof Symbol ? Symbol.for : "@@for")("react.element")) ||
60103),
function(r, t, n) {
return { $$typeof: e, type: r, key: t, ref: null, props: n, _owner: null };
})),
(r.classCallCheck = function(e, r) {
if (!(e instanceof r))
throw new TypeError("Cannot call a class as a function");
}),
// ... etc... Then I can locate this chunk of code in debug bandle: (function (global) {
var babelHelpers = global.babelHelpers = {};
babelHelpers.typeof = typeof Symbol === "function" && typeof (typeof Symbol === "function" ? Symbol.iterator : "@@iterator") === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== (typeof Symbol === "function" ? Symbol.prototype : "@@prototype") ? "symbol" : typeof obj;
};
babelHelpers.createRawReactElement = function () {
var REACT_ELEMENT_TYPE = typeof Symbol === "function" && (typeof Symbol === "function" ? Symbol.for : "@@for") && (typeof Symbol === "function" ? Symbol.for : "@@for")("react.element") || 0xeac7;
return function createRawReactElement(type, key, props) {
return {
$$typeof: REACT_ELEMENT_TYPE,
type: type,
key: key,
ref: null,
props: props,
_owner: null
};
};
}();
babelHelpers.classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
// etc... It is definitely
Also, I can see babel 7 helpers (in case it is matter):
Both of packages was deduped and actually located in top level of project So question. Can you post |
First off @vovkasm , I'd like to thank you for taking the time to respond. It really is appreciated. I'm not going to lie, I have no idea where to find the bundlejs dev file I ran this:
And found the following:
When doing a
Here is my package.json My My EDIT: For some reason I am getting the same exact error when loading the dev bundle into my Xcode as well. (If I'm doing it right) |
Hmm... I need to think some time... Can you try this steps (may be it helps without deep dive into this):
Test it. |
Looks like everything broke now :( @vovkasm now it seems my Metro Bundler won't start and I get the following error
So I ran
Tried doing |
But it shouldn't if only your dependency info written right.
It is sure because you don't have native code linked. But not related to original issue. |
I solved this issue by completely restarting my application from scratch using:
Then installing all my dependencies one-by-one. Thank you so much @vovkasm for taking the time to help. |
Good to hear. Anyway it is acceptable solution for problem that take 12 days :-) |
My app isn't even using babel 7, and I'm getting this error. |
+1 |
Hi there @bgold0 @vovkasm @codejamninja @ronal2do , I had the same pb and I fix it by replacing the content of my Before (with the bug from babelHelpers) : { "presets": ["env", "react-native"] } After (🎉) : { "presets": ["react-native"] } |
@padupuy it means: you just remove preset "env", right ? |
@Winglonelion yup |
@padupuy You made my day, bro. I tried hundred configs without success and just remove presets env made my project working perfectly again. It like a dream. :lol:. |
put it in main index.js |
Note: I've gone through other issues but it doesn't seem like they are getting the same error.
Environment
Environment:
OS: macOS High Sierra 10.13.4
Node: 9.11.1
Yarn: Not Found
npm: 5.6.0
Watchman: 4.9.1
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: Not Found
Packages: (wanted => installed)
react: ^16.3.1 => 16.3.1
react-native: ^0.55.4 => 0.55.4
Description
For some reason I am getting the following error when building a release version of my application via react-native.
I have tried the following:
react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
I get the same error for both of these. And of course, this is after I change my AppDelegate.m to the following:
The text was updated successfully, but these errors were encountered: