Skip to content
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

Update terser to fix problems using latest ECMAScript features #55

Merged
merged 1 commit into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions lib/summarize.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@ const Terser = require('terser');
const zlib = require('zlib');
const pify = require('pify');

function uglify(content) {
return new Promise((resolve, reject) => {
let uglified = Terser.minify(content);
if (uglified.error) {
reject(uglified.error);
} else {
resolve(uglified.code);
}
});
async function uglify(content) {
const { code } = await Terser.minify(content);
return code;
}

function compress(content) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"fs-extra": "^9.0.1",
"ora": "^5.1.0",
"pify": "^5.0.0",
"terser": "^3.10.11",
"terser": "^5.3.7",
"walk-sync": "^2.2.0",
"workerpool": "^6.0.1",
"workerpool": "^6.0.2",
"zlib": "^1.0.5"
},
"devDependencies": {
Expand Down
28 changes: 14 additions & 14 deletions test/acceptance/__snapshots__/cli.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,56 +8,56 @@ exports[`CLI generates expected output 1`] = `
\\"relativePath\\": \\"test-app/app.js\\",
\\"sizes\\": {
\\"raw\\": 606,
\\"uglified\\": 375,
\\"compressed\\": 119.82860520094562
\\"uglified\\": 377,
\\"compressed\\": 120.451057165231
}
},
{
\\"relativePath\\": \\"test-app/initializers/app-version.js\\",
\\"sizes\\": {
\\"raw\\": 510,
\\"uglified\\": 311,
\\"compressed\\": 99.37785657998424
\\"uglified\\": 313,
\\"compressed\\": 100.00313234142521
}
},
{
\\"relativePath\\": \\"test-app/initializers/container-debug-adapter.js\\",
\\"sizes\\": {
\\"raw\\": 590,
\\"uglified\\": 428,
\\"compressed\\": 136.76438140267928
\\"uglified\\": 430,
\\"compressed\\": 137.38449490994518
}
},
{
\\"relativePath\\": \\"test-app/initializers/export-application-global.js\\",
\\"sizes\\": {
\\"raw\\": 1377,
\\"uglified\\": 684,
\\"compressed\\": 218.56737588652481
\\"uglified\\": 686,
\\"compressed\\": 219.17619420516837
}
},
{
\\"relativePath\\": \\"test-app/resolver.js\\",
\\"sizes\\": {
\\"raw\\": 231,
\\"uglified\\": 154,
\\"compressed\\": 49.20961386918834
\\"uglified\\": 156,
\\"compressed\\": 49.841816758026624
}
},
{
\\"relativePath\\": \\"test-app/router.js\\",
\\"sizes\\": {
\\"raw\\": 425,
\\"uglified\\": 264,
\\"compressed\\": 84.35933806146572
\\"uglified\\": 268,
\\"compressed\\": 85.62568519968676
}
},
{
\\"relativePath\\": \\"test-app/templates/application.js\\",
\\"sizes\\": {
\\"raw\\": 399,
\\"uglified\\": 322,
\\"compressed\\": 102.89282899921197
\\"uglified\\": 324,
\\"compressed\\": 103.51761942051684
}
}
]
Expand Down
84 changes: 42 additions & 42 deletions test/integration/__snapshots__/summarize.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,56 +8,56 @@ exports[`summarize summarize calculates sizes 1`] = `
\\"relativePath\\": \\"test-app/app.js\\",
\\"sizes\\": {
\\"raw\\": 606,
\\"uglified\\": 375,
\\"compressed\\": 119.82860520094562
\\"uglified\\": 377,
\\"compressed\\": 120.451057165231
}
},
{
\\"relativePath\\": \\"test-app/initializers/app-version.js\\",
\\"sizes\\": {
\\"raw\\": 510,
\\"uglified\\": 311,
\\"compressed\\": 99.37785657998424
\\"uglified\\": 313,
\\"compressed\\": 100.00313234142521
}
},
{
\\"relativePath\\": \\"test-app/initializers/container-debug-adapter.js\\",
\\"sizes\\": {
\\"raw\\": 590,
\\"uglified\\": 428,
\\"compressed\\": 136.76438140267928
\\"uglified\\": 430,
\\"compressed\\": 137.38449490994518
}
},
{
\\"relativePath\\": \\"test-app/initializers/export-application-global.js\\",
\\"sizes\\": {
\\"raw\\": 1377,
\\"uglified\\": 684,
\\"compressed\\": 218.56737588652481
\\"uglified\\": 686,
\\"compressed\\": 219.17619420516837
}
},
{
\\"relativePath\\": \\"test-app/resolver.js\\",
\\"sizes\\": {
\\"raw\\": 231,
\\"uglified\\": 154,
\\"compressed\\": 49.20961386918834
\\"uglified\\": 156,
\\"compressed\\": 49.841816758026624
}
},
{
\\"relativePath\\": \\"test-app/router.js\\",
\\"sizes\\": {
\\"raw\\": 425,
\\"uglified\\": 264,
\\"compressed\\": 84.35933806146572
\\"uglified\\": 268,
\\"compressed\\": 85.62568519968676
}
},
{
\\"relativePath\\": \\"test-app/templates/application.js\\",
\\"sizes\\": {
\\"raw\\": 399,
\\"uglified\\": 322,
\\"compressed\\": 102.89282899921197
\\"uglified\\": 324,
\\"compressed\\": 103.51761942051684
}
}
]
Expand All @@ -72,56 +72,56 @@ exports[`summarize summarize-all calculates sizes of all files 1`] = `
\\"relativePath\\": \\"test-app/app.js\\",
\\"sizes\\": {
\\"raw\\": 606,
\\"uglified\\": 375,
\\"compressed\\": 119.82860520094562
\\"uglified\\": 377,
\\"compressed\\": 120.451057165231
}
},
{
\\"relativePath\\": \\"test-app/initializers/app-version.js\\",
\\"sizes\\": {
\\"raw\\": 510,
\\"uglified\\": 311,
\\"compressed\\": 99.37785657998424
\\"uglified\\": 313,
\\"compressed\\": 100.00313234142521
}
},
{
\\"relativePath\\": \\"test-app/initializers/container-debug-adapter.js\\",
\\"sizes\\": {
\\"raw\\": 590,
\\"uglified\\": 428,
\\"compressed\\": 136.76438140267928
\\"uglified\\": 430,
\\"compressed\\": 137.38449490994518
}
},
{
\\"relativePath\\": \\"test-app/initializers/export-application-global.js\\",
\\"sizes\\": {
\\"raw\\": 1377,
\\"uglified\\": 684,
\\"compressed\\": 218.56737588652481
\\"uglified\\": 686,
\\"compressed\\": 219.17619420516837
}
},
{
\\"relativePath\\": \\"test-app/resolver.js\\",
\\"sizes\\": {
\\"raw\\": 231,
\\"uglified\\": 154,
\\"compressed\\": 49.20961386918834
\\"uglified\\": 156,
\\"compressed\\": 49.841816758026624
}
},
{
\\"relativePath\\": \\"test-app/router.js\\",
\\"sizes\\": {
\\"raw\\": 425,
\\"uglified\\": 264,
\\"compressed\\": 84.35933806146572
\\"uglified\\": 268,
\\"compressed\\": 85.62568519968676
}
},
{
\\"relativePath\\": \\"test-app/templates/application.js\\",
\\"sizes\\": {
\\"raw\\": 399,
\\"uglified\\": 322,
\\"compressed\\": 102.89282899921197
\\"uglified\\": 324,
\\"compressed\\": 103.51761942051684
}
}
]
Expand Down Expand Up @@ -165,56 +165,56 @@ exports[`summarize summarize-all can ignore files 1`] = `
\\"relativePath\\": \\"test-app/app.js\\",
\\"sizes\\": {
\\"raw\\": 606,
\\"uglified\\": 375,
\\"compressed\\": 119.82860520094562
\\"uglified\\": 377,
\\"compressed\\": 120.451057165231
}
},
{
\\"relativePath\\": \\"test-app/initializers/app-version.js\\",
\\"sizes\\": {
\\"raw\\": 510,
\\"uglified\\": 311,
\\"compressed\\": 99.37785657998424
\\"uglified\\": 313,
\\"compressed\\": 100.00313234142521
}
},
{
\\"relativePath\\": \\"test-app/initializers/container-debug-adapter.js\\",
\\"sizes\\": {
\\"raw\\": 590,
\\"uglified\\": 428,
\\"compressed\\": 136.76438140267928
\\"uglified\\": 430,
\\"compressed\\": 137.38449490994518
}
},
{
\\"relativePath\\": \\"test-app/initializers/export-application-global.js\\",
\\"sizes\\": {
\\"raw\\": 1377,
\\"uglified\\": 684,
\\"compressed\\": 218.56737588652481
\\"uglified\\": 686,
\\"compressed\\": 219.17619420516837
}
},
{
\\"relativePath\\": \\"test-app/resolver.js\\",
\\"sizes\\": {
\\"raw\\": 231,
\\"uglified\\": 154,
\\"compressed\\": 49.20961386918834
\\"uglified\\": 156,
\\"compressed\\": 49.841816758026624
}
},
{
\\"relativePath\\": \\"test-app/router.js\\",
\\"sizes\\": {
\\"raw\\": 425,
\\"uglified\\": 264,
\\"compressed\\": 84.35933806146572
\\"uglified\\": 268,
\\"compressed\\": 85.62568519968676
}
},
{
\\"relativePath\\": \\"test-app/templates/application.js\\",
\\"sizes\\": {
\\"raw\\": 399,
\\"uglified\\": 322,
\\"compressed\\": 102.89282899921197
\\"uglified\\": 324,
\\"compressed\\": 103.51761942051684
}
}
]
Expand Down
28 changes: 14 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ combined-stream@^1.0.6, combined-stream@~1.0.6:
dependencies:
delayed-stream "~1.0.0"

commander@^2.19.0:
commander@^2.20.0:
version "2.20.3"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
Expand Down Expand Up @@ -3973,7 +3973,7 @@ source-map-resolve@^0.5.0:
source-map-url "^0.4.0"
urix "^0.1.0"

source-map-support@^0.5.6, source-map-support@~0.5.10:
source-map-support@^0.5.6, source-map-support@~0.5.19:
version "0.5.19"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61"
integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==
Expand All @@ -3996,7 +3996,7 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1:
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==

source-map@^0.7.3:
source-map@^0.7.3, source-map@~0.7.2:
version "0.7.3"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"
integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==
Expand Down Expand Up @@ -4195,14 +4195,14 @@ terminal-link@^2.0.0:
ansi-escapes "^4.2.1"
supports-hyperlinks "^2.0.0"

terser@^3.10.11:
version "3.17.0"
resolved "https://registry.yarnpkg.com/terser/-/terser-3.17.0.tgz#f88ffbeda0deb5637f9d24b0da66f4e15ab10cb2"
integrity sha512-/FQzzPJmCpjAH9Xvk2paiWrFq+5M6aVOf+2KRbwhByISDX/EujxsK+BAvrhb6H+2rtrLCHK9N01wO014vrIwVQ==
terser@^5.3.7:
version "5.3.7"
resolved "https://registry.yarnpkg.com/terser/-/terser-5.3.7.tgz#798a4ae2e7ff67050c3e99fcc4e00725827d97e2"
integrity sha512-lJbKdfxWvjpV330U4PBZStCT9h3N9A4zZVA5Y4k9sCWXknrpdyxi1oMsRKLmQ/YDMDxSBKIh88v0SkdhdqX06w==
dependencies:
commander "^2.19.0"
source-map "~0.6.1"
source-map-support "~0.5.10"
commander "^2.20.0"
source-map "~0.7.2"
source-map-support "~0.5.19"

test-exclude@^6.0.0:
version "6.0.0"
Expand Down Expand Up @@ -4585,10 +4585,10 @@ word-wrap@^1.2.3, word-wrap@~1.2.3:
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"
integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==

workerpool@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.0.1.tgz#9e661102e074138125cb12197a7867547f2558d4"
integrity sha512-4I1YJngJuIAsJHOOJNPHQUjoA/Kr1QNtdRoPX8w92BtNy2pIo7zr6hQHDqm3d0CWnxmfcWsqxcFWN1Ni3w4C+g==
workerpool@^6.0.2:
version "6.0.2"
resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.0.2.tgz#e241b43d8d033f1beb52c7851069456039d1d438"
integrity sha512-DSNyvOpFKrNusaaUwk+ej6cBj1bmhLcBfj80elGk+ZIo5JSkq+unB1dLKEOcNfJDZgjGICfhQ0Q5TbP0PvF4+Q==

wrap-ansi@^6.2.0:
version "6.2.0"
Expand Down