swc/ecmascript/minifier
Donny/강동윤 b8933e3db9
fix(swc): Fix bugs (#2538)
swc_ecma_transforms_base:
 - `unique_scopes`: Handle method properties.
 - `hygiene`: Fix handling of method properties. (#2539)

swc_ecma_transforms_compat:
  - Fold children of for-of/in statements. (#2531)

swc_ecma_minifier:
 - `name_mangler`: Fix handling of method properties.
2021-10-26 07:43:32 +00:00
..
examples perf(es/minifier): Make name mangler parallel (#2527) 2021-10-25 07:09:00 +00:00
scripts perf(es/minifier): Make name mangler parallel (#2527) 2021-10-25 07:09:00 +00:00
src fix(swc): Fix bugs (#2538) 2021-10-26 07:43:32 +00:00
tests fix(swc): Fix bugs (#2538) 2021-10-26 07:43:32 +00:00
.eslintrc feat(es/minifier): Implement more rules (#1871) 2021-07-30 10:11:27 +09:00
.gitignore fix(es/minifier): Fix minification of react hooks (#2450) 2021-10-17 15:24:17 +09:00
Cargo.toml fix(swc): Fix bugs (#2538) 2021-10-26 07:43:32 +00:00
package.json feat(es/minifer): Improve minifier (#2229) 2021-09-16 04:23:33 +00:00
README.md feat(es/minifier): Implement more rules (#1871) 2021-07-30 10:11:27 +09:00
yarn.lock feat(es/minifer): Improve minifier (#2229) 2021-09-16 04:23:33 +00: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