-
Notifications
You must be signed in to change notification settings - Fork 2.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
Exclude core-js and babel-runtime from babel transformations #1039
Conversation
@@ -33,6 +33,10 @@ module.exports = { | |||
{ | |||
test: /\.js$/, | |||
loaders: ["babel"], | |||
exclude: [ | |||
path.join(__dirname, "node_modules", "core-js"), | |||
path.join(__dirname, "node_modules", "babel-runtime"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might work without this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(eg delete line 38, you only need line 37)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I removed the babel-runtime
element of the list, I got the same results as before (described in the PR notes as 29
including 30
including 31
including 32
including 29
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ok, that's odd. LGTM otherwise
@glasserc it might be a good idea to release a .pre version to npm then test it out in a website via |
Good idea, thanks! I'll try that. |
I tried one of the tips-and-tricks ones (specifically, https://jsfiddle.net/hdp1kgn6/1/), and it failed before I published -pre.1 and it seems to work now. I'll cut a real release.. |
had a bit of a think about this - it might be better to use the regex form and exclude anywhere where '/node_module/core-js/' or '/node_modules/babel-runtime/' exists in the module path. That way it can cover nested deps with different babel-runtime or core-js versions |
Thanks for the suggestion. I opened #1040 as you can see to try to get webpack into modern shape. I'm not sure whether the changes are even still necessary -- looking at the output, it doesn't seem like anything is including itself any more, even without the change. Are you familiar with any change that would make webpack smarter in this regard? Think it's worth cutting another prerelease release without the exclude clause and see what happens? |
Reasons for making this change
Discussion with @graingert suggests that issues #994, #991, and #1022 might be caused by a strange recursive webpack-babel-corejs configuration. Specifically, babel-runtime normally injects certain utility functions, or uses those of core-js, when it sees JS code that needs them. Our webpack configuration causes babel to be used on all our dependencies, including babel-runtime and core-js. Babel then injects the utility methods into the babel-runtime and core-js files that define the utility methods, leading to a circular dependency.
This fix excludes just babel-runtime and core-js from the
dist
Webpack configuration.I'm not really sure how to test this without cutting a release. What I did to verify it at least a little bit:
--optimize-minimize
frombuild:dist
inpackage.json
npm run dist
dist/react-jsonschema-form.js
.defineProperty
seems to be defined in29
, which requires30
, which requires31
, which requires32
, which requires29
npm run dist
dist/react-jsonschema-form.js
.29
requires30
, which requires31
, which does not require anything.There may be more clever ways to tell Webpack not to do anything silly, but we're running Webpack v1.13.3 (current is v4.20.2).
See also the discussion at the end of #982.
Checklist
npm run cs-format
on my branch to conform my code to prettier coding style