Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(minifier): clarify assumptions for compressor #8404

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions crates/oxc_minifier/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ The printer is also responsible for printing out the shortened variable names.
The compressor is responsible for rewriting statements and expressions for minimal text output.
[Terser](https://github.com/terser/terser) is a good place to start for learning the fundamentals.

### Assumptions

- [Properties of the global object defined in the ECMAScript spec](https://tc39.es/ecma262/multipage/global-object.html#sec-global-object) behaves the same as in the spec
- Examples of properties: `Infinity`, `parseInt`, `Object`, `Promise.resolve`
- Examples that breaks this assumption: `globalThis.Object = class MyObject {}`
- [`document.all`](https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-IsHTMLDDA-internal-slot) is not used or behaves as a normal object
- Examples that breaks this assumption: `console.log(typeof document.all === 'undefined')`
- TDZ violation does not happen
- Examples that breaks this assumption: `(() => { console.log(v); let v; })()`
- `with` statement is not used
- Examples that breaks this assumption: `with (Math) { console.log(PI); }`

## Terser Tests

The fixtures are copied from https://github.com/terser/terser/tree/v5.9.0/test/compress
Loading