-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Move babel-preset-env-standalone to the monorepo. #6438
Conversation
# Conflicts: # packages/babel-standalone/src/gulpTasks.js
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/5831/ |
Gulpfile.js
Outdated
libraryTarget: "umd", | ||
}, | ||
plugins: [ | ||
new webpack.DefinePlugin({ | ||
"process.env.NODE_ENV": '"production"', | ||
BABEL_VERSION: JSON.stringify(version), | ||
"process.env": JSON.stringify({ NODE_ENV: "production" }), |
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 this the same ^?
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.
Yeah why do you need this? NODE_ENV is already defined two lines above.
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.
It doesn't work for me with cases like var env = process.env
: https://github.com/ai/browserslist/blob/master/index.js#L35
Gulpfile.js
Outdated
@@ -82,7 +82,7 @@ gulp.task("build-babel-standalone", cb => { | |||
pump( | |||
[ | |||
gulp.src(__dirname + "/packages/babel-standalone/src/index.js"), | |||
webpackBuild(), | |||
webpackBuild({ filename: "babel.js", library: "Babel" }), |
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.
Rather than doing this, I'd prefer if this entire task was made reusable again. I'm not sure why it was changed to not be reusable. See my original implementation: https://github.com/Daniel15/babel/blob/5b9722c8255ce65584a31effe4518c0677176525/packages/babel-standalone/src/gulpTasks.js
function registerBabelStandaloneTask(gulp, name, exportName, path, version) {
gulp.task("build-" + name + "-standalone", cb => {
pump(
[
gulp.src(path + "/src/index.js"),
webpackBuild(
name + ".js",
exportName,
version
),
gulp.dest(path),
uglify(),
rename({ extname: ".min.js" }),
gulp.dest(path),
],
cb
);
});
}
Gulpfile.js
Outdated
gulp.dest(__dirname + "/experimental/babel-preset-env-standalone"), | ||
uglify(), | ||
rename({ extname: ".min.js" }), | ||
gulp.dest(__dirname + "/experimental/babel-preset-env-standalone"), |
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.
These steps are all identical to the regular babel-standalone build, except with a different path. Please remove the repetition :)
Gulpfile.js
Outdated
libraryTarget: "umd", | ||
}, | ||
plugins: [ | ||
new webpack.DefinePlugin({ | ||
"process.env.NODE_ENV": '"production"', | ||
BABEL_VERSION: JSON.stringify(version), | ||
"process.env": JSON.stringify({ NODE_ENV: "production" }), |
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.
Yeah why do you need this? NODE_ENV is already defined two lines above.
new webpack.optimize.ModuleConcatenationPlugin(), | ||
]; | ||
|
||
registerBabelStandaloneTask( |
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.
Why do you have this build defined in two separate Gulpfiles?
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.
Oops, just remained after the merge. Thanks!
# Conflicts: # Gulpfile.js
# Conflicts: # .eslintignore # Gulpfile.js # yarn.lock
# Conflicts: # Gulpfile.js
@@ -0,0 +1,8 @@ | |||
{ | |||
"env": { | |||
"mocha": true |
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.
Might be better to just add it to:
https://github.com/babel/babel/blob/master/.eslintrc#L26
# Conflicts: # .eslintrc # experimental/babel-preset-env/test/.eslintrc
nice work @yavorsky!! whoo that was a lot.. hopefully eventually we can simplify all these config+build steps.. and if we can make it small enough just merge it into babel-standalone |
I've modified Gulpfile a bit to be more flexible and allow building standalone packages besides Babel.
Currently, the size of babel-preset-env-standalone is 162 kb.
I've added tests which passed successfully with different targets/cases.
I don't know about the name in package.json, because we already have
babel-preset-env-standalone
, which represents https://github.com/yavorsky/babel-preset-env-standalone andbabel-env-standalone
from https://github.com/babel/babel-standalone/tree/v7/packages/babel-env-standalone.