-
Notifications
You must be signed in to change notification settings - Fork 1.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
v2.8.8 breaks React Native #1573
Comments
@brentvatne can you share/specify the input file to |
I'll try to get that for you now. Until this is resolved could you possibly mark 2.8.7 as the latest on npm? It will avoid frustration for many people |
@brentvatne not exactly familiar with how to do that on |
|
@brentvatne thanks. I'll be releasing |
@alexlamsl - can you let me know before you do so that I can test it? |
You can test the current |
Same error on master. I'll get you that pre-uglify JS |
@alexlamsl Release 2.8.9 anyway. Someone will have to provide a proper repro so we can fix it. |
@alexlamsl @kzc - here is a (fairly large) file pre-uglify: https://exp-bundles.s3.amazonaws.com/%40community/rediscover/1.2.1/d0eb4b3f6483f41e32b9db0f116c6cda-14.0.0-ios.js this is how react-native uses uglify-js: https://github.com/facebook/react-native/blob/a2c84d14ce80baeffc50d5f576a07efb6a7230ef/packager/src/JSTransformer/worker/minify.js (don't worry about the source map) as mentioned above, the minified result should include a string like |
@brentvatne Could you try out the 2.8.8 workaround in #1575 and tell us if that works? |
sure, trying it. |
that fixes the problem @kzc! it looks like |
It's supposed to be enabled by default. Just a matter of fixing it. |
Docs seem inconsistent about that, maybe I'm missing something:
|
Thanks for pointing that out. The docs will be updated. |
OK thanks. I just wanted to point out that while this is an outstanding issue, anybody who doesn't use a yarn lockfile or npm shrinkwrap or tries to update those will have issues with React Native minified bundles. It's unfortunate that this has changed in a patch version (although it would have impacted us the same in a minor version) and not been reverted :( Thank you for the quick responses though. |
repro: $ cat ric.js function f() {
var runInContext = function runInContext(context) {
function lodash(value) {}
lodash.runInContext = runInContext;
return lodash;
}
var _ = runInContext();
} correct: $ bin/uglifyjs ric.js -b -c reduce_vars=false function f() {
var runInContext = function runInContext(context) {
function lodash(value) {}
return lodash.runInContext = runInContext, lodash;
};
runInContext();
} incorrect: $ bin/uglifyjs ric.js -b -c reduce_vars=true function f() {
!function(context) {
function lodash(value) {}
lodash.runInContext = runInContext, lodash;
}();
}
correct: $ bin/uglifyjs ric.js -b -c reduce_vars=true,keep_fnames=true function f() {
!function runInContext(context) {
function lodash(value) {}
return lodash.runInContext = runInContext, lodash;
}();
} |
They should. Alternatively, disable |
Duplicate of #1575. Possible fix: #1575 (comment) |
The only problem is that this is difficult to communicate to many thousands of users :\ I'll test that fix by modifying uglify-js in-place in node_modules and let you know |
When you don't freeze your module versions you take your chances. Nothing new there. |
Even if you use a lockfile, people setting up new projects will get the latest version because they don't have a lockfile in their app yet. That's just how npm shrinkwrap and Yarn's lock work. Even if React Native (or any other library) were to forgo semver and specify precise versions in its package.json, it depends on other packages who use semver in their own package.json files and indirectly depend on Uglify ^2.x.x. So the only practical solutions I see are either to roll back the npm release -- the least disruptive way to everyone being |
Function expression can be assigned to a variable and be given a name. Ensure function name is the reduced variable before clearing it out. fixes mishoo#1573 fixes mishoo#1575
Fix is at #1576 |
Then those packages should be changed to lock down their version. Semver assumes there are no maintenance bugs. Even the act of fixing a bug can create others. The only stable software version is the one you tested with. |
@alexlamsl Thanks man |
Summary: As per uglify-js maintainer kzc's comment in mishoo/UglifyJS#1573 (comment) we should be locking our version to prevent issues like #12772 from happening again. No test plan needed, people are already using this version of uglify-js (it's the latest). Closes #12802 Differential Revision: D4749853 Pulled By: javache fbshipit-source-id: 866a19cb2c1add31b55e14d0f4dadb7f68fda64c
Summary: As per uglify-js maintainer kzc's comment in mishoo/UglifyJS#1573 (comment) we should be locking our version to prevent issues like #12772 from happening again. No test plan needed, people are already using this version of uglify-js (it's the latest). Closes facebook/react-native#12802 Differential Revision: D4749853 Pulled By: javache fbshipit-source-id: 866a19cb2c1add31b55e14d0f4dadb7f68fda64c
React Native depends on on
uglify-js@^2.6.2
and as per facebook/react-native#12772 we have run into this error:runInContext
is undefined in JSC, where react-native runs.I know very little about uglify-js but posting this here in hopes that you folks may have a better idea of what the problem is.
The text was updated successfully, but these errors were encountered: