From 980801c8a3daf9cb7f435156487ee733037efd9b Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 24 Oct 2018 10:50:37 -0400 Subject: [PATCH] build: use terser instead of uglify --- package.json | 2 +- scripts/build.js | 4 ++-- yarn.lock | 13 +++++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index aa72889a..028936ba 100644 --- a/package.json +++ b/package.json @@ -138,7 +138,7 @@ "serialize-javascript": "^1.3.0", "shelljs": "^0.8.1", "typescript": "^3.1.3", - "uglify-js": "^3.0.15", + "terser": "^3.10.2", "webpack": "^4.22.0", "weex-js-runtime": "^0.23.6", "weex-styler": "^0.3.0", diff --git a/scripts/build.js b/scripts/build.js index 82d4c52e..27147148 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -2,7 +2,7 @@ const fs = require('fs') const path = require('path') const zlib = require('zlib') const rollup = require('rollup') -const uglify = require('uglify-js') +const terser = require('terser') if (!fs.existsSync('dist')) { fs.mkdirSync('dist') @@ -48,7 +48,7 @@ function buildEntry (config) { .then(bundle => bundle.generate(output)) .then(({ code }) => { if (isProd) { - var minified = (banner ? banner + '\n' : '') + uglify.minify(code, { + var minified = (banner ? banner + '\n' : '') + terser.minify(code, { output: { ascii_only: true }, diff --git a/yarn.lock b/yarn.lock index 1dba1b63..6ff2cc13 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7562,7 +7562,7 @@ source-map-resolve@^0.5.0, source-map-resolve@^0.5.2: source-map-url "^0.4.0" urix "^0.1.0" -source-map-support@^0.5.9: +source-map-support@^0.5.9, source-map-support@~0.5.6: version "0.5.9" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.9.tgz#41bc953b2534267ea2d605bccfa7bfa3111ced5f" integrity sha512-gR6Rw4MvUlYy83vP0vxoVNzM6t8MUXqNuRsuBmBHQDu1Fh6X015FrLdgoDKcNdkwGubozq0P4N0Q37UyFVr1EA== @@ -7914,6 +7914,15 @@ tar@^4: safe-buffer "^5.1.2" yallist "^3.0.2" +terser@^3.10.2: + version "3.10.2" + resolved "https://registry.yarnpkg.com/terser/-/terser-3.10.2.tgz#a61d2c97065f9fdc8c49a18655e2a80ca7298a94" + integrity sha512-+QrFoqBImmsQGB4c/HvaqgZynmbNvNBwoBxuu7fYXtq5EEtlLUzph+WimDj+xMkuqawXPMl2lgCIz81CdXvt+w== + dependencies: + commander "~2.17.1" + source-map "~0.6.1" + source-map-support "~0.5.6" + test-exclude@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-5.0.0.tgz#cdce7cece785e0e829cd5c2b27baf18bc583cfb7" @@ -8123,7 +8132,7 @@ uglify-es@^3.3.4: commander "~2.13.0" source-map "~0.6.1" -uglify-js@^3.0.15, uglify-js@^3.1.4: +uglify-js@^3.1.4: version "3.4.9" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.9.tgz#af02f180c1207d76432e473ed24a28f4a782bae3" integrity sha512-8CJsbKOtEbnJsTyv6LE6m6ZKniqMiFWmm9sRbopbkGs3gMPPfd3Fh8iIA4Ykv5MgaTbqHr4BaoGLJLZNhsrW1Q==