No description
- Rust 99.8%
- JavaScript 0.2%
| .cargo | ||
| .vscode | ||
| javascript | ||
| src | ||
| .gitignore | ||
| .rustfmt.toml | ||
| Cargo.lock | ||
| Cargo.toml | ||
| package.json | ||
| README.md | ||
Unminification
This is an SWC plugin which aims to reverse many of the effects of code minification.
Setup
- use Rust nightly:
rustup override set nightly - run:
rustup target add wasm32-wasi - build using:
cargo build-wasi --release
Changes
Restore Literals
- SWC and other transpilers transform literals into equivalent values to reduce the size of code generated
- The following are reverted back into their literal forms:
!0➞true!1➞falsevoid 0➞undefined1 / 0➞Infinity-1 / 0➞-Infinity0 / 0➞NaN
- Note that:
undefined,Infinity, andNaNcould be potentially inaccurate since they are not reserved words. However this is unlikely to be a concern in a minified context.
Desequencing
- Transpilers often convert a sequence of statements into a sequence expression to save space
- foo(), bar();
+ foo();
+ bar();
- foo = (baz(), bar);
+ baz();
+ foo = bar;
- return (foo(), bar)
+ foo();
+ return bar;
- throw (foo(), bar)
+ foo();
+ throw bar;
- if ((foo = bar, baz)) {}
+ foo = bar;
+ if (baz) {}
- switch (foo(), bar) {}
+ foo();
+ switch(bar) {}
# add normal for
- for (foo in (baz(), bar)) {}
+ baz();
+ for (foo in bar) {}
- for (foo of (baz(), bar)) {}
+ baz();
+ for (foo of bar) {}