Document minification backends
Document here what minification backends are used since minification breaks things. I would like to know what software to avoid.
https://trunkrs.dev/assets/#minification
It's basically:
- HTML: https://github.com/trunk-rs/trunk/blob/c160ed3ff7c98a94ab00f14acbbd198268a92525/Cargo.toml#L45
- JS: https://github.com/trunk-rs/trunk/blob/c160ed3ff7c98a94ab00f14acbbd198268a92525/Cargo.toml#L46
- CSS: https://github.com/trunk-rs/trunk/blob/c160ed3ff7c98a94ab00f14acbbd198268a92525/Cargo.toml#L78
HTML is based on lighteningcss and and minify-js.
I believe lightningcss is solid because its used by parcel. Probably minify-js is to blame for failed minification.
That might be the case. I noticed that minify-js version 0.6.0 did break stuff. That's why we (like others) stick to 0.5. Maybe there's a better alternative.
rust based turbopack, rspack and parcel are using swc as backend. deno is using spack from swc. https://swc.rs sems to be standard for rust based JS build tools.
processing JS have several stages such as: transpiling, bundling, tree shaking, minimize, polyfill.
Usually classic minimizing is safe operation - remove whitespace and comments, rename local variables to shorter names.
JS Minimizers often do also tree shaking and its risky operation - even tools years in production like google closure compiler - https://mvnrepository.com/artifact/com.google.javascript/closure-compiler are generating wrong code sometimes. Some build tools like esbuild can disable tree shaking separately from minimization.
In reality you can never be sure that these tools will deliver working JS code, its too complex operation combined with bugs in browsers. You can only test final result on few browsers. JS developers simply trust their tool brand: "for example babel for transpiling/polyfiling".
You seem to be the expert :) … any chance you can help out. IIRC the locations where minification is triggered should be pretty central/focused.
I decided to go with wasm-pack + standard proven JS toolchain. wasm-opt doesn't do enough to justify risking another tool which can have bugs and generate wrong code.
I believe its ideal approach. wasm-pack plugin for JS tool and you are done.