Commit Graph

256 Commits

Author SHA1 Message Date
oxc-bot 61dfcfdfd8 release(crates): v0.68.0 (#10777) 2025-05-04 09:06:24 +08:00
Boshen b01cb45578 feat(codegen): a way to keep legal comments after minification (#10689)
fixes https://github.com/rolldown/rolldown/issues/4118
fixes #10626

At present, there is no option to keep legal comments when minification is turn on.

This PR allows Codegen to set legal comments with minfication turned on, with the following behavior:

* Inline: only if the attached code is not removed
* Eof: move all legal comments to the end of file, regardless of where they appear
* Linked and External: saved into `CodegenReturn::legal_comments` for the caller to use, regardless of where they appear

Code gets moved around or removed if minifier is turned on, so some legal comments may disappear from the final output.

The recommended legal comment option is Eof.

---

For Rolldown to keep legal comments, it should set `LegalComment::Inline` for chunk codegen and `LegalComment::Eof` for minification codegen.
2025-05-01 06:31:34 +00:00
oxc-bot 7cf80ef7fd release(crates): v0.67.0 (#10637) 2025-04-27 22:30:07 +08:00
oxc-bot ff67f13f99 release(crates): v0.66.0 (#10565)
## [0.66.0] - 2025-04-23

### Features

- 7d5ad7d parser: Report error when `import type { type }` is used
(#10528) (camc314)
- 6e40fac parser: Report error when `export type { type }` is used
(#10524) (camc314)

### Bug Fixes

- 43ad4e9 ast: Box `this_param` in `TSCallSignatureDeclaration` (#10558)
(Yuji Sugiura)
- 8eb3c0a ast/estree: Fix raw deser for `FormalParameter` (#10548)
(overlookmotel)
- 3ebf220 codegen: Generate missing `type` in `export type {} from
'mod'` (#10539) (Boshen)
- f19b287 estree: Add `TSParameterProperty` (#10534) (Yuji Sugiura)
- 7284f16 isolated-declarations: Leading comments of
`ExportDefaultDeclaration` and `TSExportAssignment` appear in incorrect
places (#10559) (Dunqing)
- 4c316a5 isolated_declarations: Fix broken snapshot files (#10561)
(Boshen)
- 84742d8 transformer/module_runner: Fix export default live binding
(#10560) (hi-ogawa)
- 6c115c7 transformer/module_runner: Fix execution order of re-export
(#10362) (hi-ogawa)
- b9d84b0 transformer/typescript: Remove `StringLiteral::raw` when
rewriting extensions (#10554) (overlookmotel)

### Performance

- 6a045c8 codegen: Speed up printing `Directive`s (#10551)
(overlookmotel)
- 3418ae5 transformer/class-properties: Re-use
`InstanceInitializerVisitor` (#10543) (overlookmotel)
- 7fcf0ac transformer/typescript: Reduce allocations renaming extensions
(#10555) (overlookmotel)

### Documentation

- 1a9530c transformer/class-properties: Fix typo (#10542)
(overlookmotel)

### Refactor

- 7e71282 transformer/class-properties: Correct outdated comment
(#10546) (overlookmotel)
- 596978b transformer/class-properties: Simplify to get `constructor`
method only once (#10493) (Dunqing)
- f13fe0a transformer/class-properties: Defer re-parenting initializers
scopes until all instance properties are transformed (#10495) (Dunqing)
- c83dad6 transformer/class-properties: Streamline handling scope of
instance property initializer (#10492) (Dunqing)

### Styling

- e10dfc8 traverse: Remove excess whitespace (#10544) (overlookmotel)

### Testing

- 227febf allocator: Ignore a slow doc test (#10521) (Dunqing)
- 14bb2be codegen: Add more tests for strings (#10552) (overlookmotel)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-04-23 22:42:12 +08:00
oxc-bot 0ab2cb4a22 release(crates): v0.65.0 (#10522) 2025-04-21 18:03:15 +08:00
oxc-bot 619488a05a release(crates): v0.64.0 (#10459) 2025-04-17 10:09:07 +08:00
oxc-bot eba5fcf33b release(crates): v0.63.0 (#10309) 2025-04-08 13:52:15 +08:00
renovate[bot] e34967eb20 chore(deps): lock file maintenance npm packages (#10273) 2025-04-07 16:43:16 +08:00
oxc-bot 3b72e5b151 release(crates): v0.62.0 (#10158) 2025-04-02 09:48:40 +08:00
oxc-bot 76b245dafc release(crates): v0.61.2 (#9983) 2025-03-23 19:42:43 +08:00
sapphi-red ea3de06327 feat(mangler): support keep_names option (#9898)
Same with #9873, but built on top of #9897.

close #9873
close #9711
2025-03-23 09:17:42 +00:00
oxc-bot 9a36e677b2 release(crates): v0.61.1 (#9936)
## [0.61.1] - 2025-03-21

### Features

- 8e3b20d napi/parser: Add portable wasm browser build (#9901) (Hiroshi
Ogawa)
- bc0670c tasks,oxc_allocator: Add new method clone_in_with_semantic_ids
for `CloneIn` trait (#9894) (IWANABETHATGUY)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-03-21 12:46:52 +08:00
oxc-bot 33c1c76955 release(crates): v0.61.0 (#9923)
## [0.61.0] - 2025-03-20

- c631291 parser: [**BREAKING**] Parse `TSImportAttributes` as
`ObjectExpression` (#9902) (Boshen)

- eef7eb6 minifier: [**BREAKING**] Rename
`CompressOptions::all_true`/`all_false` to `smallest`/`safest` (#9866)
(sapphi-red)

### Features

- 38ad787 data_structures: Add `assert_unchecked!` macro (#9885)
(overlookmotel)
- dcd356e minifier: Support `keep_names` option (#9867) (sapphi-red)
- 6565fc4 napi: Feature gate allocator (#9921) (Boshen)
- 2cedfe4 napi: Add codeframe to napi error (#9893) (Boshen)
- a9a47a6 parser: Add regex cargo feature to oxc_parser (#9879) (Toshit)
- d4a83ba parser: Report duplicate modifier `Accessibility modifier
already seen.` (#9890) (Boshen)
- 59c8f71 parser,codegen: Handle lone surrogate in string literal
(#9918) (Boshen)

### Bug Fixes

- 28a2ed3 estree/ast: Fix `IdentifierName` and `IdentifierReference`
(#9863) (hi-ogawa)
- 3d4c5f3 semantic: Correctly visit `IfStmt` `test` when building cfg
(#9864) (camc314)
- 1774225 transformer/using: Incorrect scope ids for bindings (#9871)
(camc314)- 68018e1 Ast changes (Boshen)

### Performance

- 5f97f28 ast/estree: Speed up raw deser for `JSXElement` (#9895)
(overlookmotel)
- b272893 mangler, minifier: Initialize a Vec with a specific value
using `Vec::from_iter_in` combined with `repeat_with` (#9908) (Dunqing)
- f7d078c semantic: Use `reserve_exact` instead of `reserve` to save
memory in pre-reserve (#9910) (Dunqing)

### Documentation

- 590a258 napi/parser: Add stackblitz link for wasm build (Boshen)

### Refactor

- 62e2859 ast/ast_builder: Use `self.vec_from_iter` instead of
`Vec::from_iter_in` for consistency (#9909) (Dunqing)
- b2f3d23 isolated_declarations: Remove unused `self` params (#9868)
(overlookmotel)
- 961b95d napi: Move common code to `oxc_napi` (#9875) (Boshen)
- 233c1fc napi/playground: Add JSON.parse wrapper (#9880) (Hiroshi
Ogawa)
- dbe61c5 transformer/module-runner-transform: Remove redundant
converison (#9912) (Dunqing)
- ecdfe2e transformer/using: Move work to `exit_static_block` (#9713)
(camc314)

### Testing

- 9314147 data_structures: Enable doc tests for `oxc_data_structures`
crate (#9884) (overlookmotel)
- 040e993 napi: Refactor NAPI parser benchmarks (#9911) (overlookmotel)
- e637e2e napi/parser: Tweak vitest config (#9878) (Hiroshi Ogawa)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-03-20 20:06:21 +08:00
Boshen 6565fc4261 feat(napi): feature gate allocator (#9921)
Rolldown already has allocator enabled, double allocator is a compile error.
2025-03-20 11:40:08 +00:00
Hiroshi Ogawa e637e2edcf test(napi/parser): tweak vitest config (#9878)
- fixed `@vitest/browser` version mismatch
- removed `--typecheck` since `tsc` catches same errors (and honestly
vitest typecheck mode is not so intuitive 🙃)
- added `diff.expand: false` since raw transfer mismatch is huge (we
might change the default on Vitest side
https://github.com/vitest-dev/vitest/pull/7697)
2025-03-19 09:28:45 +08:00
sapphi-red dcd356ee32 feat(minifier): support keep_names option (#9867)
Added support for `keep_names: { function: true, class: true }`.
Setting `.name` is makes it difficult to treeshake later on (https://github.com/evanw/esbuild/issues/3965), so it is better to avoid if possible.

This PR only adds support for the compressor. I'll add support for the mangler later on (probably first add required information to the semantics).

refs #9711
2025-03-18 11:24:04 +00:00
oxc-bot 9baa7568f8 release(crates): v0.60.0 (#9861) 2025-03-18 17:01:17 +08:00
Boshen aa3dff887a feat(napi): add mimalloc to parser and transformr (#9859) 2025-03-18 16:51:37 +08:00
hi-ogawa 7106e5dc0f refactor(napi): disable unused browser fs (#9848)
I don't think file access is needed for napi packages. I've already disabled this on napi/playground.
2025-03-18 05:53:21 +00:00
oxc-bot 7cfe1a5e01 release(crates): v0.59.0 (#9850) 2025-03-18 13:50:33 +08:00
LongYinan 84fa5389a3 perf(minify): use mimalloc-safe to replace mimalloc (#9810)
This is maintained by us, and it's upgraded to mimalloc 2.2.2. This pr
also adds mimalloc to `oxc-minify`
2025-03-17 12:38:01 +08:00
oxc-bot 7856a0b091 release(crates): v0.58.1 (#9754)
## [0.58.1] - 2025-03-13

### Features

- a8331f7 transformer: Turn off explicit resource management by default
(#9749) (Boshen)

### Bug Fixes

- cd3f2fb ast/estree: Fix `JSXOpeningFragment` (#9747) (Hiroshi Ogawa)
- fecec56 ast/estree: Fix `JSXOpeningElement` field order (#9746)
(hi-ogawa)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-03-13 20:34:27 +08:00
oxc-bot 38d1302267 release(crates): v0.58.0 (#9740) 2025-03-13 16:58:56 +08:00
Boshen a6c9b0949c docs(napi/minifier): improve documentation (#9736) 2025-03-13 06:28:23 +00:00
oxc-bot 8d18dc4207 release(crates): v0.57.0 (#9668)
## [0.57.0] - 2025-03-11

- 510446a parser: [**BREAKING**] Align JSXNamespacedName with ESTree
(#9648) (Arnaud Barré)

- b0d979d semantic: [**BREAKING**] Make `Scoping::references` private
(#9629) (Boshen)

- 3c6f140 semantic: [**BREAKING**] Make `Scoping` methods consistent
(#9628) (Boshen)

- ef6e0cc semantic: [**BREAKING**] Combine `SymbolTable` and `ScopeTree`
into `Scoping` (#9615) (Boshen)

- 7331656 semantic: [**BREAKING**] Rename `SymbolTable` and `ScopeTree`
methods (#9613) (Boshen)

- 23738bf semantic: [**BREAKING**] Introduce `Scoping` (#9611) (Boshen)

### Features

- b6deff8 ecmascript: Support integer index access for array and string
in `may_have_side_effects` (#9603) (sapphi-red)
- 047fb01 minifier: Place `void 0` on right hand side if possible
(#9606) (sapphi-red)
- 36f8703 minifier: Compress `[] + string` to `string` (#9602)
(sapphi-red)
- 554c4ce minifier: Compress constant integer index access (#9604)
(sapphi-red)
- e3c2015 minifier: Allow compressing computed __proto__ more precisely
(#9595) (sapphi-red)
- 6a57198 minifier: Allow compressing computed constructor/prototype
keys precisely (#9594) (sapphi-red)
- 638007b parser: Apply `preserveParens` to `TSParenthesizedType`
(#9653) (Boshen)

### Bug Fixes

- eae1a41 ast: Align `TSImportType` field names with ts-eslint (#9664)
(Boshen)
- 96eef8b ecmascript: `(foo() + "").length` may have a side effect
(#9605) (sapphi-red)
- 24d9261 minifier: Remove names from functions / classes in normal pass
to make the minifier idempotent (#9608) (sapphi-red)
- 6ac3635 napi/parser: Disable raw transfer on unsupported platforms
(#9651) (overlookmotel)
- cfdcfdb parser: Fix end span for optional binding pattern without type
annotation (#9652) (Boshen)
- 26da65d parser: Parse asi after class accessor property (#9623)
(Boshen)
- 87462fd parser: Fix end span for `using` declaration (#9622) (Boshen)
- 29edb51 transformer: Fix module runner transform of export default
expression (#9661) (hi-ogawa)

### Documentation

- 31a2618 allocator: Add safety constraint for
`String::from_raw_parts_in` (#9640) (overlookmotel)

### Refactor

- 44101bd allocator: Refactor and improve safty comments of
`String::from_strs_array_in` (#9639) (overlookmotel)
- c6edafe napi: Remove `npm/oxc-*/` npm packages (#9631) (Boshen)
- a43c341 semantic: Add `Scoping` to `Semantic` (#9614) (Boshen)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-03-11 12:05:56 +08:00
Boshen c6edafe08d refactor(napi): remove npm/oxc-*/ npm packages (#9631)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-03-09 22:43:06 +08:00
Boshen ef6e0cca39 refactor(semantic)!: combine SymbolTable and ScopeTree into Scoping (#9615)
closes #9607
2025-03-09 10:28:12 +00:00
Boshen c08b7fc0ce fix(napi): commit wasi files 2025-03-07 19:53:33 +08:00
Boshen 0bbb197c87 ci(npm): rework release pipeline (#9581) 2025-03-07 11:49:50 +08:00
Boshen d129055dc6 test(napi): add tests for worker threads (#9408)
There are user code which may crash under some random circumstances
that we don't understand. Prevent these crashes with a test.
2025-02-27 07:19:11 +00:00
oxc-bot ba8dcfd6aa release(crates): v0.52.0 (#9276) 2025-02-21 23:51:58 +08:00
Boshen c2ee8060dc chore: include build.rs in napi crates 2025-02-21 23:37:03 +08:00
Boshen c933c6d67a chore(deps): bump napi (#9274) 2025-02-21 23:33:21 +08:00
Arnaud Barré 8d7ceeeed4 ci(napi/transform): validate napi dts files (#9183)
---------

Co-authored-by: Dunqing <dengqing0821@gmail.com>
2025-02-18 17:14:22 +08:00
renovate[bot] 5681e414bc chore(deps): lock file maintenance rust crates (#9167) 2025-02-17 16:01:35 +08:00
Boshen df3eef81e6 chore(napi/parser): use vitest bench instead of tinybench (#9134)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-02-15 14:42:48 +08:00
overlookmotel a4a8e7deda style(all): replace #[allow] with #[expect] (#8930)
Replace `#[allow]` with `#[expect]` through the whole codebase.

This also surfaced many places where the `#[allow]` attributes were outdated/pointless and could be removed entirely.

Only places `#[allow]` remains are:

1. In generated code and macros, where lint errors may or may not be triggered depending on the generated code.
2. A few places where clippy malfunctions. These use e.g. `#[allow(unused, clippy::allow_attributes)]`.
2025-02-07 14:50:02 +00:00
Daniel Bulant 6aa2ddeb85 refactor(codegen): accept SymbolTable instead of Mangler (#8829)
It seems to be that the easiest way to rename variables is to use
rename_symbol from SymbolTable and to let it be applied during codegen -
this is what Mangler does.

This PR changes Codegen to accept (any) SymbolTable instead of just
Mangler itself, and for Mangler build output to be a new SymbolTable,
after consuming itself (which makes it clear at the type level if a
Mangler has been built or not).

This also moves the few symbol table helper methods from Mangler to
SymbolTable itself, and adds an example of Mangler use to it's
documentation.

Codegen dependencies now include semantic (which was transient by
mangler before). It's dependency on Mangler could be removed, though
I've left it to allow easy linking of docs (with_symbol_table points
users to Mangler, hopefully helps with migration?)
2025-02-02 17:13:09 +08:00
sapphi-red 86b6219d26 feat(mangler): use characters in the order of their likely frequency (#8771)
Just noticed that we can use a static list here. I think this has no downsides. To have better compression, we can actually count the characters, but I guess there won't be much difference normally.
2025-01-29 02:20:44 +00:00
翠 / green 6589c3bbb3 feat(mangler): reuse variable names (#8562)
Changed the mangler to reuse variable names where possible.

This will reduce the code size as shorter variable names can be used in
more places. But requires global information and limits parallelism in a
single file and requires more memory.

---------

Co-authored-by: Boshen <boshenc@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-25 14:00:24 +08:00
Boshen 9ec4e24eb7 test(napi/minify): fix more broken tests 2025-01-16 16:09:23 +08:00
Boshen 0acbef356a test(napi/minify): fix matching of arrays 2025-01-16 15:34:20 +08:00
Boshen 855c8395cf fix(codegen): shorthand assignment target identifier consider mangled names (#8536) 2025-01-16 07:26:07 +00:00
Boshen c63c8b924d test(napi/minify): add runtime test (#8501) 2025-01-15 21:13:00 +08:00
Boshen aa9d7e47ea build(napi): napi build --no-dts-cache (#8499) 2025-01-15 07:02:29 +00:00
Boshen 4ad695dcfb feat(napi/minify): implement napi (#8478) 2025-01-14 08:55:55 +00:00
翠 / green db9e93b554 feat(mangler): mangle top level variables (#7907)
Adds `top_level` option which is similar to [terser's `toplevel`
option](https://terser.org/docs/cli-usage/#cli-mangle-options).

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-15 21:31:41 +08:00
overlookmotel 3858221f45 refactor(global): sort imports (#7883)
Pure refactor. Re-order imports for clarity:

1. `std`
2. External crates
3. `oxc_*` crates
4. Current crate `use crate::...`
5. Super `use super::...`
6. Local modules

This order is from "furthest away" to "closest". This makes it clearer to see what is coming from where.

`cargo +nightly fmt` (#7877) did a lot of the work, but unfortunately `rustfmt` does not have an option to (a) put workspace crates in a separate block from external crates and (b) move `mod` statements to after `use` statements.
2024-12-14 15:07:21 +00:00
Boshen 7fb9d47460 style(rust): cargo +nightly fmt (#7877) 2024-12-14 06:03:31 +00:00
Boshen 771c698a81 feat(oxc): remove oxc_napi crate (#7634)
napi has a limitation, it cannot feature gate type exposure.

closes #7623
2024-12-04 10:07:32 +08:00