-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Use babel-polyfill and babel-preset-env #3790
Conversation
For some reasons, in node4 with babel-polyfill the errors behave differently and put some additional slashes:
|
That looks great. 👍 A few questions:
|
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.
Awesome, thanks for working on this! As we discussed, the one downside is that packages that depend on yarn may now end up including babel-polyfill
twice. But yarn mainly being a cli tool, getting dev convenience of using the latest features, and mitigating all of it with useBuiltins, I think the change is worth it! 😄
@@ -6,6 +6,7 @@ | |||
"preferGlobal": true, | |||
"description": "📦🐈 Fast, reliable, and secure dependency management.", | |||
"dependencies": { | |||
"babel-polyfill": "^6.23.0", | |||
"babel-runtime": "^6.0.0", |
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.
babel-runtime
can probably be removed now.
.babelrc
Outdated
["transform-object-rest-spread"], | ||
["transform-class-properties"], | ||
["transform-inline-imports-commonjs"] | ||
], |
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.
nit, they don't have to be nested arrays.
@@ -58,7 +59,7 @@ const compilerLegacy = webpack({ | |||
test: /\.js$/, | |||
exclude: /node_modules/, | |||
loader: 'babel-loader', | |||
query: babelRc.env['pre-node5'], | |||
query: babelRc.env.node4, |
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.
This can also be done by defining process.env.BABEL_ENV
in https://webpack.js.org/plugins/environment-plugin/ so we don't have to parse the babelrc manually in the file, esp. since query
field has been replaced with options w/ webpack2. Gulp probably has something similar as well.
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.
Is it ok if we open another issue/pull request on that? This pr is becoming too big imho.
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.
yup, thanks!
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.
@kaylieEB can you open the issue? Because I don't fully understand your comment, I am afraid to write something wrong
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.
np :) #3809
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.
thanks :D
"useBuiltIns": true | ||
}]] | ||
}, | ||
"node6": { |
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.
to what @Volune said, maybe this can be "development", which babel uses as default.
@Volune some answers:
The file src/cli/index.js is always required one time, I included in that file because otherwise babel-preset-env does not do its magic (I mean replacing the require('babel-polyfill') with all require that really needs in base on the platform).
Yes, we can, I will do asap I did it
I think we should ask this question to @bestander or maybe @kittens, I can always revert and use the stage-0 preset, It's not a problem at all :D |
Looping in @BYK. |
One thing to test - what is the impact on the bundle size? |
That's a good answer, I will check it O.o @bestander do you think we can integrate https://github.com/siddharthkp/bundlesize in yarn? |
That looks cool and useful. I would separate Yarn as a project into two areas
The latter is non homogenous and split across domains and tools. |
@voxsim - The effect of this pull request on the bundle size looks way too big, unfortunately. Comparing the yarn-legacy JS file, it's 4.23 MB for this build (https://4316-49970642-gh.circle-artifacts.com/0/home/ubuntu/yarn/artifacts/yarn-legacy-0.27.0.js) vs 3.58 MB for the latest build of master (https://nightly.yarnpkg.com/yarn-legacy-0.27.0-20170703.1704.js). |
@@ -145,7 +145,7 @@ export async function executeLifecycleScript( | |||
// Add global bin folder if it is not present already, as some packages depend | |||
// on a globally-installed version of node-gyp. | |||
const globalBin = getGlobalBinFolder(config, {}); | |||
if (pathParts.indexOf(globalBin) === -1) { | |||
if (!pathParts.includes(globalBin)) { |
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.
What's the advantage of this change?
I've tried using Please perform a build with the old Babel config, and then another build with the new Babel config, and diff the files to see what the differences are. It's likely to be fine, but it's worth thoroughly inspecting the output. |
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.
Hey there, thanks for the PR and all the effort you've put into it. That said it looks like you've put a bit too much effort and the PR does many things at once.
I'd love to get more atomic changes so how about we split it into multiple pieces:
- Upgrade
babel-jest
- babel-preset related changes
- Rename babel env 'pre-node5' in 'node4'
And finally, not add babel-polyfill
into the mix since it adds quite a bit of cruft for very small gains. We've now fixed our CI and upgraded Jest to not include polyfills in tests by default so we catch .includes()
related failures on Node 4 builds.
We can probably just polyfill if (!String.prototype.includes) {
String.prototype.includes = function(str, start) {
return this.indexOf(str, start) > -1;
}
} |
@bestander I totally agree with you, btw I was talking on integrate bundle size in our travis/circleci build to check on every pr the bundlesize of yarn node6/node4 build (i don't like call it normal or legacy because with node8 it does not make sense). I can open a pr but I don't have the permissions to do anything on Travis or CircleCI. @Daniel15 thanks for your feedbacks and I agree with you about the polyfill, I think you should comment on #3693 and decide with us which are our next steps :) @BYK thanks for your review, I agree with you that this PR is too big. Do you prefer one pr for each commit or can i open a pull request with:
|
We can sort out the permission issue. |
One PR per commit please 😃 |
Summary
In this pull request:
Test plan
Tests in place
I am a babel newbie, if anyone found something erronous please let me know :D it took me many days to understand each part and how it works ;)