-
Notifications
You must be signed in to change notification settings - Fork 114
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
Adding Babel to frontend workflow; Upgrading Webpack to version 2. #2736
Conversation
@@ -0,0 +1,9 @@ | |||
{ | |||
"presets": ["es2015", "stage-2"], |
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.
Just curious: Why'd you choose stage 2? Have you looked at babel-preset-env that lets you target the browsers your project supports? (Although now that I think about it, because we support old versions of IE it probably would end up applying every plugin and transform imaginable).
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'd you choose stage 2?
It was just and arbitrary starting point. We can adjust if we find language features we want to use but find missing. The process is quite interesting, as it appears features are moving in / out of stages based on the TC39 process. https://github.com/tc39/proposals.
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.
Works for me. 👍
@sebworks along with this PR, we should add ES6 guidelines to our JS standards |
package.json
Outdated
@@ -69,6 +71,7 @@ | |||
"psi": "2.0.4", | |||
"selenium-webdriver": "2.53.3", | |||
"sinon": "1.17.3", | |||
"snyk": "1.25", |
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.
1.25
-> 1.25.0
Will try to review this today! |
filename: '[name]' | ||
}, | ||
plugins: [ | ||
new webpack.optimize.CommonsChunkPlugin( COMMON_BUNDLE_NAME ), | ||
new webpack.optimize.CommonsChunkPlugin( COMMON_BUNDLE_NAME, | ||
[ COMMON_BUNDLE_NAME ] ), |
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.
IIRC the redundant commons chunk calls here were for the scenario where all included scripts included a reference to a module EXCEPT common.js. In that case, since all scripts reference a module, the module's declaration should be moved to common.js automatically by webpack, instead of leaving them redundantly in each script. I tested this behavior in the old setup and the new setup and it still works as expected 👍
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.
You are correct but in order for that to work you need to set the minChunks
property. The default is infinity. You can test this by setting minChunks: 3
and running gulp build
. It should increase the size of common.js
and decrease the size of each of individual modules. That decrease is due to the standardType
being added to common.js
as it's required by atleast 3 modules. Do you think we should set the minChunks property?
LGTM 👍 nice work |
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.
👍 from me as well.
929e18e
to
424160c
Compare
Adding babel to frontend workflow; Upgrading Webpack to version 2.
Additions
.babelrc
as a babel Configuration file. Using thees2015
andstage-2
presets. Presets are just sets of transformations.Changes
Modified
config/webpack-config.js
to do the following:Modified
gulp/tasks/scripts.js
to passwebpack-stream
a Webpack param.Updated
package.json
to do the following:slick-carousel
as it's no longer needed.snyk
as it's not necessary to run on Jenkins.Testing
rm -rf node_modules
frontend.sh
.rm -rf node_modules
frontend.sh production
.Screenshots
Before:
After:
Notes
webpack.optimize.UglifyJsPlugin
. There are alternatives which uglify in parallel, we should investigate if they are worth using.Todos
Checklist