mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 20:28:58 +00:00
docs(minifier): clarify assumptions for compressor (#8404)
Listed the assumptions that the compressor probably makes.
This commit is contained in:
parent
8d2176e2e1
commit
aaa009dd4d
1 changed files with 12 additions and 0 deletions
|
|
@ -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…
Reference in a new issue