Skip to content

Commit

Permalink
feat: Dead code elimination is disabled by default
Browse files Browse the repository at this point in the history
Added an opinionated config for performing dead code elimination, which could be enabled by setting
`DEAD_CODE_ELIMINATION` environment variable to `true`
  • Loading branch information
halfzebra committed Oct 28, 2017
1 parent 44f0177 commit d5fd36f
Showing 1 changed file with 33 additions and 24 deletions.
57 changes: 33 additions & 24 deletions config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,33 @@ const extractTextPluginOptions = shouldUseRelativeAssetPaths
{ publicPath: Array(cssFilename.split('/').length).join('../') }
: {};

// Enable users to turn off dead code elimination.
const deadCodeElimination =
process.env.DEAD_CODE_ELIMINATION !== 'true'
? {
dead_code: true,
pure_funcs: [
'_elm_lang$core$Native_Utils.update',
'A2',
'A3',
'A4',
'A5',
'A6',
'A7',
'A8',
'A9',
'F2',
'F3',
'F4',
'F5',
'F6',
'F7',
'F8',
'F9'
]
}
: {};

module.exports = {
// Don't attempt to continue if there are any errors.
bail: true,
Expand Down Expand Up @@ -185,30 +212,12 @@ module.exports = {

// Minify the compiled JavaScript.
new UglifyJsPlugin({
compress: {
warnings: false,
// Enable users to turn off dead code elimination.
dead_code: process.env.DEAD_CODE_ELIMINATION !== 'false',
pure_funcs: [
'_elm_lang$core$Native_Utils.update',
'A2',
'A3',
'A4',
'A5',
'A6',
'A7',
'A8',
'A9',
'F2',
'F3',
'F4',
'F5',
'F6',
'F7',
'F8',
'F9'
]
},
compress: Object.assign(
{
warnings: false
},
deadCodeElimination
),
output: {
comments: false
}
Expand Down

2 comments on commit d5fd36f

@marmutro
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you accidentally choose the wrong comparison operator '!==' instead of '==='.
Now you have to set DEAD_CODE_ELIMINATION=true to disable dead code elimination.

@halfzebra
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marmutro thanks for pointing out! The fix is coming right up!

Please sign in to comment.