From aec4bf2055a9935ee6d67c6d93071d75a4260a94 Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 12 Aug 2019 08:57:44 -0700 Subject: [PATCH] Fix `uglify-js` special case (#41) * Fix uglify special case * Add uglify-js to devDependencies --- package.json | 1 + src/utils/special-cases.js | 13 ++----------- test/integration/uglify.js | 4 ++++ yarn.lock | 10 +++++++++- 4 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 test/integration/uglify.js diff --git a/package.json b/package.json index 283d4d2e..5a6705e4 100644 --- a/package.json +++ b/package.json @@ -95,6 +95,7 @@ "tiny-json-http": "^7.1.2", "twilio": "^3.33.0", "typescript": "^3.5.2", + "uglify-js": "^3.6.0", "vm2": "^3.8.2", "vue": "^2.6.10", "vue-server-renderer": "^2.6.10", diff --git a/src/utils/special-cases.js b/src/utils/special-cases.js index cafd070e..e1c8c6b7 100644 --- a/src/utils/special-cases.js +++ b/src/utils/special-cases.js @@ -149,18 +149,9 @@ const specialCases = { emitAsset(path.resolve(id, '../exports.js')); } }, - 'uglify-js' ({ id, emitAsset }) { + 'uglify-js' ({ id, emitAsset, emitAssetDirectory }) { if (id.endsWith('uglify-js/tools/node.js')) { - emitAsset(path.resolve(id, '../../lib/utils.js')); - emitAsset(path.resolve(id, '../../lib/ast.js')); - emitAsset(path.resolve(id, '../../lib/parse.js')); - emitAsset(path.resolve(id, '../../lib/transform.js')); - emitAsset(path.resolve(id, '../../lib/scope.js')); - emitAsset(path.resolve(id, '../../lib/output.js')); - emitAsset(path.resolve(id, '../../lib/compress.js')); - emitAsset(path.resolve(id, '../../lib/sourcemap.js')); - emitAsset(path.resolve(id, '../../lib/mozilla-ast.js')); - emitAsset(path.resolve(id, '../../lib/propmangle.js')); + emitAssetDirectory(path.resolve(id, '../../lib')); emitAsset(path.resolve(id, '../exports.js')); } } diff --git a/test/integration/uglify.js b/test/integration/uglify.js new file mode 100644 index 00000000..35f2487a --- /dev/null +++ b/test/integration/uglify.js @@ -0,0 +1,4 @@ +const UglifyJS = require('uglify-js') +const code = 'function add(first, second) { return first + second; }' +const result = UglifyJS.minify(code) +console.log(result) diff --git a/yarn.lock b/yarn.lock index 65299583..72c1610f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3330,7 +3330,7 @@ commander@2.15.1: resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f" integrity sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag== -commander@^2.12.2: +commander@^2.12.2, commander@~2.20.0: version "2.20.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422" integrity sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ== @@ -13010,6 +13010,14 @@ uglify-js@^3.1.4: commander "~2.19.0" source-map "~0.6.1" +uglify-js@^3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.6.0.tgz#704681345c53a8b2079fb6cec294b05ead242ff5" + integrity sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg== + dependencies: + commander "~2.20.0" + source-map "~0.6.1" + uglify-js@~2.4: version "2.4.24" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.4.24.tgz#fad5755c1e1577658bb06ff9ab6e548c95bebd6e"