Skip to content

Commit

Permalink
Upgrade the version of Terser to make reduce_funcs work well
Browse files Browse the repository at this point in the history
  • Loading branch information
kfule authored and dead-claudia committed Dec 26, 2024
1 parent 1a6847f commit 4ba76ac
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 34 deletions.
178 changes: 148 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
"npm-run-all": "^4.1.5",
"ospec": "4.2.1",
"rimraf": "^6.0.1",
"terser": "^4.3.4"
"terser": "^5.7.2"
}
}
4 changes: 2 additions & 2 deletions scripts/bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ async function build() {
return
}
console.log("minifying...")
// Terser's “compress” option seems to degrade performance. So, disable it.
const minified = Terser.minify(original, {compress: false, mangle: true})
// Terser's "reduce_funcs" option seems to degrade performance. So, disable it.
const minified = await Terser.minify(original, {compress: {reduce_funcs: false}, mangle: true})
if (minified.error) throw new Error(minified.error)
await writeFile(params.output, minified.code, "utf-8")
const originalSize = Buffer.byteLength(original, "utf-8")
Expand Down
2 changes: 1 addition & 1 deletion scripts/minify-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async function minify() {
const input = path.resolve(__dirname, "../stream/stream.js")
const output = path.resolve(__dirname, "../stream/stream.min.js")
const original = await fs.readFile(input, "utf-8")
const minified = Terser.minify(original)
const minified = await Terser.minify(original)
if (minified.error) throw new Error(minified.error)
await fs.writeFile(output, minified.code, "utf-8")
const originalSize = Buffer.byteLength(original, "utf-8")
Expand Down

0 comments on commit 4ba76ac

Please sign in to comment.