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
Lodash breaks when transpiled twice #1916
Comments
The That means it's failing
Is there a global it can attach to? |
Oh, I see. I tried these steps and, if I recall correctly, I used Or, to be more precise, it broke in Mocha tests with a normal UMD build because our Mocha configuration was transpiling it with Babel. That's how I discovered the issue in the first place. Please see https://github.com/jdalton/redux/pull/1 for steps to reproduce |
Interesting. Apparently module.exports = isPlainObject;
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) Could this be an attempt to polyfill a |
Yes, that's it. Ours, using Our |
in the Webpack config solved the issue. |
Without that though won't |
Oh right, it would in browser. |
I added this as the plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
{
'apply': function(compiler) {
compiler.parser.plugin('expression global', function() {
this.state.module.addVariable('global', "(function() { return this; }()) || Function('return this')()");
return true;
});
}
}
] |
Closing as I updated the "(function() { return this; }()) || Function('return this')()" so that under normal cases it avoids Related to webpack/webpack#1963 and reduxjs/redux#1339. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Original issue: reduxjs/redux#611 (comment)
Basically we started using Lodash as a dependency of Redux, and I noticed that UMD builds can no longer be tested from our Mocha tests. After more investigation I realized that they break if they are transpiled twice because Babel inserts
use strict
in the code, and then Lodashfunction () {return this;}
global detection returnsundefined
.I'm not sure whether this can be considered a Lodash issue. Definitely transpiling twice is wrong but some people do that due to bad configurations. We used to support transpiling twice, but now due to our new dependency on Lodash, transpiling twice is broken.
What do you think?
The text was updated successfully, but these errors were encountered: