swc/crates/swc_ecma_minifier
Donny/강동윤 fd0e952aec
perf(es/minifier): Fix performance bug of the mangler (#3633)
swc_ecma_minifier:
 - Use a bi-directional hashmap instead of iterating all keys.
2022-02-19 10:31:54 +00:00
..
examples perf(es/minifier): Fix performance bug of the mangler (#3633) 2022-02-19 10:31:54 +00:00
inputs fix(es/minifier): Fix bugs (#2955) 2022-01-05 05:12:52 +09:00
scripts fix(es/minifier): Fix analyzer (#3557) 2022-02-14 15:47:16 +09:00
src perf(es/minifier): Fix performance bug of the mangler (#3633) 2022-02-19 10:31:54 +00:00
tests feat(es/minifier): Treat !0 as a literal while inlining (#3631) 2022-02-19 17:33:36 +09:00
.eslintrc refactor: Flatten ecmascript (#2708) 2021-11-10 19:00:54 +09:00
.gitignore chore(es/minifier): Add scripts to extract tests automatically (#3212) 2022-01-10 16:59:21 +09:00
Cargo.toml chore: Publish crates 2022-02-19 08:42:02 +00:00
package.json fix(es/minifier): Fix optimization of assignment expressions (#3231) 2022-01-12 08:26:56 +09:00
README.md chore: Update markdown files to use "SWC" instead of "swc" (#2744) 2021-11-15 04:26:04 +00:00
yarn.lock fix(es/minifier): Fix optimization of assignment expressions (#3231) 2022-01-12 08:26:56 +09:00

Minifier

EcmaScript minifier for the SWC project. This is basically a port of terser.

Note

Currently name mangler is very simple. To focus on creating a MVP, I (kdy1) will use simple logic for name mangler and implement the content-aware name mangler after publishing first non-beta version.

Testing

Real-library tests

You can use vscode to see diffs. Select a file from tests/projects/output and select the corresponding file from tests/projects/refs. Then you can right click to see an option to open diff.

Splitting a library test

Extracting only subset from a library test makes development much easier.

Split status:

  • angular-1.2.5
  • backbone-1.1.0
  • jquery-1.9.1
  • jquery.mobile-1.4.2
  • mootools-1.4.5
  • underscore-1.5.2
  • yui-3.12.0

Tests from terser

Tests ported from terser has

  • input.js
  • config.json
  • mangle.json (if name mangling is enabled)
  • output.js (if exists and can be modified if our one is better or due to lack of frequency-aware base54)
  • output.terser.js (if exists)

Copying tests

Replace the content of terser/test/compress.js with it of scripts/compress.js and run npm run test:compress