From 7def9157de6fecd147935bd0aa10444aca465b8c Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 24 Aug 2017 23:26:16 +0200 Subject: [PATCH 1/5] SWITCH UglifyJS for Babel-Minify UglifyJS does not support any ES6 whatsoever. We want to allow users to set their own target env. --- app/react-native/package.json | 1 + .../src/server/config/webpack.config.prod.js | 18 ++++++------------ app/react/package.json | 1 + .../src/server/config/webpack.config.prod.js | 16 ++++++---------- app/vue/package.json | 1 + .../src/server/config/webpack.config.prod.js | 16 ++++++---------- 6 files changed, 21 insertions(+), 32 deletions(-) diff --git a/app/react-native/package.json b/app/react-native/package.json index 087e5be2859b..02ef965a05e5 100644 --- a/app/react-native/package.json +++ b/app/react-native/package.json @@ -32,6 +32,7 @@ "autoprefixer": "^7.1.1", "babel-core": "^6.25.0", "babel-loader": "^7.0.0", + "babel-minify-webpack-plugin": "^0.2.0", "babel-plugin-syntax-async-functions": "^6.13.0", "babel-plugin-syntax-trailing-function-commas": "^6.22.0", "babel-plugin-transform-class-properties": "^6.24.1", diff --git a/app/react-native/src/server/config/webpack.config.prod.js b/app/react-native/src/server/config/webpack.config.prod.js index 841459f0c83f..a4ba2f053bb5 100644 --- a/app/react-native/src/server/config/webpack.config.prod.js +++ b/app/react-native/src/server/config/webpack.config.prod.js @@ -1,5 +1,6 @@ import path from 'path'; import webpack from 'webpack'; +import MinifyPlugin from 'babel-minify-webpack-plugin'; import { OccurenceOrderPlugin, includePaths, excludePaths } from './utils'; const config = { @@ -21,19 +22,12 @@ const config = { plugins: [ new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"production"' }), new webpack.optimize.DedupePlugin(), - new webpack.optimize.UglifyJsPlugin({ - compress: { - screw_ie8: true, - warnings: false, - }, - mangle: { - screw_ie8: true, - }, - output: { + new MinifyPlugin( + {}, + { comments: false, - screw_ie8: true, - }, - }), + } + ), ], module: { loaders: [ diff --git a/app/react/package.json b/app/react/package.json index 390ef2fef27d..417f515016cf 100644 --- a/app/react/package.json +++ b/app/react/package.json @@ -31,6 +31,7 @@ "autoprefixer": "^7.1.1", "babel-core": "^6.25.0", "babel-loader": "^7.0.0", + "babel-minify-webpack-plugin": "^0.2.0", "babel-plugin-react-docgen": "^1.6.0", "babel-preset-env": "^1.6.0", "babel-preset-minify": "^0.2.0", diff --git a/app/react/src/server/config/webpack.config.prod.js b/app/react/src/server/config/webpack.config.prod.js index 989b1adca7ad..953d25373b1d 100644 --- a/app/react/src/server/config/webpack.config.prod.js +++ b/app/react/src/server/config/webpack.config.prod.js @@ -1,5 +1,6 @@ import path from 'path'; import webpack from 'webpack'; +import MinifyPlugin from 'babel-minify-webpack-plugin'; import babelLoaderConfig from './babel.prod'; import { includePaths, excludePaths, loadEnv, nodePaths } from './utils'; @@ -24,17 +25,12 @@ export default function() { }, plugins: [ new webpack.DefinePlugin(loadEnv({ production: true })), - new webpack.optimize.UglifyJsPlugin({ - compress: { - screw_ie8: true, - warnings: false, - }, - mangle: false, - output: { + new MinifyPlugin( + {}, + { comments: false, - screw_ie8: true, - }, - }), + } + ), ], module: { rules: [ diff --git a/app/vue/package.json b/app/vue/package.json index 3bec1d4a754f..044c15f10a34 100644 --- a/app/vue/package.json +++ b/app/vue/package.json @@ -31,6 +31,7 @@ "autoprefixer": "^7.1.1", "babel-core": "^6.25.0", "babel-loader": "^7.0.0", + "babel-minify-webpack-plugin": "^0.2.0", "babel-plugin-react-docgen": "^1.6.0", "babel-preset-env": "^1.6.0", "babel-preset-minify": "^0.2.0", diff --git a/app/vue/src/server/config/webpack.config.prod.js b/app/vue/src/server/config/webpack.config.prod.js index 1260b9de6dc4..ae2323ca0d0f 100644 --- a/app/vue/src/server/config/webpack.config.prod.js +++ b/app/vue/src/server/config/webpack.config.prod.js @@ -1,5 +1,6 @@ import path from 'path'; import webpack from 'webpack'; +import MinifyPlugin from 'babel-minify-webpack-plugin'; import babelLoaderConfig from './babel.prod'; import { includePaths, excludePaths, loadEnv, nodePaths } from './utils'; @@ -24,17 +25,12 @@ export default function() { }, plugins: [ new webpack.DefinePlugin(loadEnv({ production: true })), - new webpack.optimize.UglifyJsPlugin({ - compress: { - screw_ie8: true, - warnings: false, - }, - mangle: false, - output: { + new MinifyPlugin( + {}, + { comments: false, - screw_ie8: true, - }, - }), + } + ), ], module: { rules: [ From 52e6d52e171ce0892f224ec8b720bab0f94174b7 Mon Sep 17 00:00:00 2001 From: hypnos Date: Fri, 29 Sep 2017 03:53:35 +0300 Subject: [PATCH 2/5] Don't minify built-ins, so that they can be shimmed properly --- app/react/src/server/config/webpack.config.prod.js | 4 +++- yarn.lock | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/react/src/server/config/webpack.config.prod.js b/app/react/src/server/config/webpack.config.prod.js index 70edae925fe2..e036f83600e6 100644 --- a/app/react/src/server/config/webpack.config.prod.js +++ b/app/react/src/server/config/webpack.config.prod.js @@ -48,7 +48,9 @@ export default function() { }), new webpack.DefinePlugin(loadEnv({ production: true })), new MinifyPlugin( - {}, + { + builtIns: false, + }, { comments: false, } diff --git a/yarn.lock b/yarn.lock index 052776a17777..a2e29f495d7c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -665,7 +665,7 @@ babel-core@^5: trim-right "^1.0.0" try-resolve "^1.0.0" -babel-core@^6.0.0, babel-core@^6.21.0, babel-core@^6.26.0, babel-core@^6.7.2: +babel-core@^6.0.0, babel-core@^6.21.0, babel-core@^6.24.1, babel-core@^6.26.0, babel-core@^6.7.2: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.26.0.tgz#af32f78b31a6fcef119c87b0fd8d9753f03a0bb8" dependencies: @@ -930,6 +930,14 @@ babel-messages@^6.23.0: dependencies: babel-runtime "^6.22.0" +babel-minify-webpack-plugin@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/babel-minify-webpack-plugin/-/babel-minify-webpack-plugin-0.2.0.tgz#ef9694d11a1b8ab8f3204d89f5c9278dd28fc2a9" + dependencies: + babel-core "^6.24.1" + babel-preset-minify "^0.2.0" + webpack-sources "^1.0.1" + babel-plugin-check-es2015-constants@^6.22.0, babel-plugin-check-es2015-constants@^6.5.0, babel-plugin-check-es2015-constants@^6.7.2, babel-plugin-check-es2015-constants@^6.8.0: version "6.22.0" resolved "https://registry.yarnpkg.com/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz#35157b101426fd2ffd3da3f75c7d1e91835bbf8a" From d3c1f0e1e29c4a0d2ec304f3c864e7d3861b75f4 Mon Sep 17 00:00:00 2001 From: hypnos Date: Fri, 29 Sep 2017 04:35:33 +0300 Subject: [PATCH 3/5] Disable `evaluate` and `propertyLiterals` transforms, as they break `he` library See https://github.com/babel/minify/pull/416#issuecomment-282955682 --- app/react/src/server/config/webpack.config.prod.js | 2 ++ app/vue/src/server/config/webpack.config.prod.js | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/react/src/server/config/webpack.config.prod.js b/app/react/src/server/config/webpack.config.prod.js index e036f83600e6..02ab60bb7227 100644 --- a/app/react/src/server/config/webpack.config.prod.js +++ b/app/react/src/server/config/webpack.config.prod.js @@ -50,6 +50,8 @@ export default function() { new MinifyPlugin( { builtIns: false, + evaluate: false, + propertyLiterals: false, }, { comments: false, diff --git a/app/vue/src/server/config/webpack.config.prod.js b/app/vue/src/server/config/webpack.config.prod.js index 63da0caf3a06..7cee27f07330 100644 --- a/app/vue/src/server/config/webpack.config.prod.js +++ b/app/vue/src/server/config/webpack.config.prod.js @@ -48,7 +48,11 @@ export default function() { }), new webpack.DefinePlugin(loadEnv({ production: true })), new MinifyPlugin( - {}, + { + builtIns: false, + evaluate: false, + propertyLiterals: false, + }, { comments: false, } From 231f0f22071bc17b635348e68f0f233153c52394 Mon Sep 17 00:00:00 2001 From: hypnos Date: Mon, 2 Oct 2017 00:28:47 +0300 Subject: [PATCH 4/5] Disable name mangling as it breaks addon-actions --- app/react-native/src/server/config/webpack.config.prod.js | 4 +++- app/react/src/server/config/webpack.config.prod.js | 1 + app/vue/src/server/config/webpack.config.prod.js | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/react-native/src/server/config/webpack.config.prod.js b/app/react-native/src/server/config/webpack.config.prod.js index d71217bdbe05..c9e6618bb607 100644 --- a/app/react-native/src/server/config/webpack.config.prod.js +++ b/app/react-native/src/server/config/webpack.config.prod.js @@ -33,7 +33,9 @@ const getConfig = options => { new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"production"' }), new webpack.optimize.DedupePlugin(), new MinifyPlugin( - {}, + { + mangle: false, + }, { comments: false, } diff --git a/app/react/src/server/config/webpack.config.prod.js b/app/react/src/server/config/webpack.config.prod.js index 02ab60bb7227..3196f91a3643 100644 --- a/app/react/src/server/config/webpack.config.prod.js +++ b/app/react/src/server/config/webpack.config.prod.js @@ -52,6 +52,7 @@ export default function() { builtIns: false, evaluate: false, propertyLiterals: false, + mangle: false, }, { comments: false, diff --git a/app/vue/src/server/config/webpack.config.prod.js b/app/vue/src/server/config/webpack.config.prod.js index 7cee27f07330..fe97f50b6ad7 100644 --- a/app/vue/src/server/config/webpack.config.prod.js +++ b/app/vue/src/server/config/webpack.config.prod.js @@ -52,6 +52,7 @@ export default function() { builtIns: false, evaluate: false, propertyLiterals: false, + mangle: false, }, { comments: false, From 4280d323d4666d3c545f1c49b90ad544c87b2b55 Mon Sep 17 00:00:00 2001 From: hypnos Date: Sat, 18 Nov 2017 02:30:50 +0300 Subject: [PATCH 5/5] Update lockfile --- yarn.lock | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/yarn.lock b/yarn.lock index 04f74970a627..841d082a1143 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3802,7 +3802,7 @@ debug@2.3.3: dependencies: ms "0.7.2" -debuglog@*, debuglog@^1.0.1: +debuglog@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" @@ -6455,7 +6455,7 @@ import-local@^0.1.1: pkg-dir "^2.0.0" resolve-cwd "^2.0.0" -imurmurhash@*, imurmurhash@^0.1.4: +imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" @@ -8155,10 +8155,6 @@ lodash._basecopy@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36" -lodash._baseindexof@*: - version "3.1.0" - resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c" - lodash._baseisequal@^3.0.0: version "3.0.7" resolved "https://registry.yarnpkg.com/lodash._baseisequal/-/lodash._baseisequal-3.0.7.tgz#d8025f76339d29342767dcc887ce5cb95a5b51f1" @@ -8182,14 +8178,10 @@ lodash._basevalues@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz#5b775762802bde3d3297503e26300820fdf661b7" -lodash._bindcallback@*, lodash._bindcallback@^3.0.0: +lodash._bindcallback@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e" -lodash._cacheindexof@*: - version "3.0.2" - resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92" - lodash._createassigner@^3.0.0: version "3.1.1" resolved "https://registry.yarnpkg.com/lodash._createassigner/-/lodash._createassigner-3.1.1.tgz#838a5bae2fdaca63ac22dee8e19fa4e6d6970b11" @@ -8198,17 +8190,11 @@ lodash._createassigner@^3.0.0: lodash._isiterateecall "^3.0.0" lodash.restparam "^3.0.0" -lodash._createcache@*: - version "3.1.2" - resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093" - dependencies: - lodash._getnative "^3.0.0" - lodash._createset@~4.0.0: version "4.0.3" resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26" -lodash._getnative@*, lodash._getnative@^3.0.0: +lodash._getnative@^3.0.0: version "3.9.1" resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" @@ -8358,7 +8344,7 @@ lodash.pick@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3" -lodash.restparam@*, lodash.restparam@^3.0.0: +lodash.restparam@^3.0.0: version "3.6.1" resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" @@ -11199,7 +11185,7 @@ readable-stream@~1.1.10, readable-stream@~1.1.8, readable-stream@~1.1.9: isarray "0.0.1" string_decoder "~0.10.x" -readdir-scoped-modules@*, readdir-scoped-modules@^1.0.0: +readdir-scoped-modules@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/readdir-scoped-modules/-/readdir-scoped-modules-1.0.2.tgz#9fafa37d286be5d92cbaebdee030dc9b5f406747" dependencies: @@ -13763,7 +13749,7 @@ v8flags@^3.0.0: dependencies: homedir-polyfill "^1.0.1" -validate-npm-package-license@*, validate-npm-package-license@^3.0.1: +validate-npm-package-license@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc" dependencies: @@ -13857,7 +13843,7 @@ vm-browserify@0.0.4: dependencies: indexof "0.0.1" -"vm2@github:patriksimek/vm2#custom_files": +vm2@patriksimek/vm2#custom_files: version "3.5.0" resolved "https://codeload.github.com/patriksimek/vm2/tar.gz/7e82f90ac705fc44fad044147cb0df09b4c79a57"