-
Notifications
You must be signed in to change notification settings - Fork 113
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"presets": ["es2015", "stage-2"], | ||
"env": { | ||
// only happens if NODE_ENV is undefined or set to 'development' | ||
"development": { | ||
// ignored when NODE_ENV is production! | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,17 +19,26 @@ var modernConf = { | |
// so it needs to be defined here as an external script to ignore for | ||
// unmet dependency references. | ||
externals: { jquery: 'jQuery' }, | ||
context: path.join( __dirname, '/../', paths.unprocessed, JS_ROUTES_PATH ), | ||
entry: scriptsManifest.getDirectoryMap( paths.unprocessed + | ||
JS_ROUTES_PATH ), | ||
cache: true, | ||
context: path.join( __dirname, '/../', paths.unprocessed, JS_ROUTES_PATH ), | ||
entry: scriptsManifest.getDirectoryMap( paths.unprocessed + JS_ROUTES_PATH ), | ||
module: { | ||
rules: [ { | ||
test: /\.js$/, | ||
use: [ { | ||
loader: 'babel-loader?cacheDirectory=true' | ||
} ], | ||
exclude: /node_modules/ | ||
} ] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 |
||
}, | ||
output: { | ||
path: path.join( __dirname, 'js' ), | ||
path: path.join( __dirname, 'js' ), | ||
filename: '[name]' | ||
}, | ||
plugins: [ | ||
new webpack.optimize.CommonsChunkPlugin( COMMON_BUNDLE_NAME ), | ||
new webpack.optimize.CommonsChunkPlugin( COMMON_BUNDLE_NAME, | ||
[ COMMON_BUNDLE_NAME ] ), | ||
new webpack.optimize.CommonsChunkPlugin( { | ||
name: COMMON_BUNDLE_NAME | ||
} ), | ||
// Change `warnings` flag to true to view linter-style warnings at runtime. | ||
new webpack.optimize.UglifyJsPlugin( { | ||
compress: { warnings: false } | ||
|
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.
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. 👍