Commit Graph

256 Commits

Author SHA1 Message Date
sapphi-red 3dc24b5cf5 docs(linter,minifier): always refer as "ES Modules" instead of "ES6 Modules" (#15409)
Nowadays, we normally call them "ES Modules" instead of "ES6 Modules". I made that consistent through the docs.
2025-11-07 10:13:26 +00:00
copilot-swe-agent 1c31cb1a08 feat(napi/minify): expose treeshake options (#15109)
feat(napi/minify): expose `treeshake` options

## Completed:
- [x] Understand the problem: Need to expose TreeShakeOptions to JavaScript users
- [x] Explore existing code structure and TreeShakeOptions in oxc_minifier
- [x] Build the project to ensure clean state
- [x] Add TreeShakeOptions struct with all fields
- [x] Update CompressOptions to accept optional treeshake field
- [x] Implement conversion from NAPI TreeShakeOptions to oxc_minifier::TreeShakeOptions
- [x] Build and verify TypeScript definitions are generated correctly
- [x] Add tests for treeshake options
- [x] Run all tests successfully
- [x] Format code with just fmt
- [x] Address all review feedback:
  - Renamed TreeShakeOptionsNapi to TreeShakeOptions
  - Changed property_read_side_effects to accept boolean | 'always'
  - Changed @default from true to 'always' for property_read_side_effects
  - Reverted From implementation back to use reference (From<&TreeShakeOptions>)
  - Changed to TryFrom to properly handle validation errors
  - Added validation for propertyReadSideEffects string values
  - Fixed clippy lint for inline format args

## Changes Made:
1. Added `TreeShakeOptions` struct with fields:
   - `annotations`: Whether to respect pure annotations (@__PURE__, #__NO_SIDE_EFFECTS__)
   - `manual_pure_functions`: List of function names to treat as pure
   - `property_read_side_effects`: Whether property reads have side effects (boolean | 'always', default: 'always')
   - `unknown_global_side_effects`: Whether accessing global variables has side effects
2. Updated `CompressOptions` to include optional `treeshake` field
3. Implemented `TryFrom<&TreeShakeOptions>` trait with proper error handling for invalid values
4. Added validation that rejects invalid string values for propertyReadSideEffects
5. Added tests covering treeshake functionality including error cases
6. Fixed all lint issues

All tests pass successfully!

<!-- START COPILOT CODING AGENT SUFFIX -->

<details>

<summary>Original prompt</summary>

> Add bindings for treeshake option here:
> https://github.com/oxc-project/oxc/blob/3fbb307367a31817a297dee299fec580912675db/napi/minify/src/options.rs#L90

</details>

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
2025-10-30 08:46:30 +00:00
Boshen 14fe64a935 release(crates): v0.96.0 (#15115) 2025-10-30 15:43:06 +08:00
leaysgur a8e5181ab7 chore(infra): dogfooding oxfmt (#14979)
Fixes #14803

- Added `oxfmt` and `oxfmtrc.jsonc`
- Remove `dprint` plugin and useless ignore paths
- Apply `dprint` again
- Apply `oxfmt`
2025-10-28 01:16:46 +00:00
camc314 ada9989c17 chore(deps): update vitest to v4 (#14919) 2025-10-24 14:09:11 +00:00
Brooooooklyn f472631b73 chore(napi): update cli and js bindings (#14917)
Ref: https://github.com/oxc-project/oxc/issues/14732#issuecomment-3431289160
2025-10-23 09:47:23 +00:00
sapphi-red 9e36186e4c feat(napi/minify): expose drop_labels option (#14635)
Exposed the `drop_labels` option from JS API.
2025-10-16 06:07:18 +00:00
sapphi-red d09c7ee8c3 feat(minifier): add drop_labels feature (#14634)
Implemented `drop_labels` feature, which is implemented in [esbuild](https://esbuild.github.io/api/#drop-labels) and [rolldown](https://rolldown.rs/apis/config-options#droplabels).
The plan is to use this in Rolldown.
2025-10-16 06:07:18 +00:00
Boshen 454ee94ff3 release(crates): v0.95.0 (#14619) 2025-10-15 15:06:05 +08:00
Boshen 32a41cfab5 fix(napi/minify): s/passes/max_iterations to avoid confusion (#14608)
`max_iterations` does not behave like `passes`, and may change in the future.

It should only be used for debugging purposes, as said on the
comment.
2025-10-15 02:31:18 +00:00
Kentaro Suzuki 14686a43d1 fix(napi/minify): handle boolean values for compress.unused option (#14513)
fixes https://github.com/oxc-project/oxc/issues/14512

Fixes the `compress.unused` option implemented in PR #11796 to properly
accept boolean values from the napi binding.
2025-10-15 09:25:22 +08:00
IWANABETHATGUY c19c9ec4af feat(napi/minify): expose join_vars, sequences, and max_iterations options (#14545)
related to https://github.com/rolldown/rolldown/issues/6477

I use `passes` instead of `max_iterations` since `passes` is commonly used in the Javascript community,
see
- terser: https://github.com/terser/terser#:~:text=passes%20(default%3A%201)%20%2D%2D%20The%20maximum%20number%20of%20times%20to%20run%20compress.%20In%20some%20cases%20more%20than%20one%20pass%20leads%20to%20further%20compressed%20code.%20Keep%20in%20mind%20more%20passes%20will%20take%20more%20time.
- swc:
<img width="626" height="828" alt="image" src="https://github.com/user-attachments/assets/aabc2e10-59a1-43ab-b9e0-52ab35522f85" />
2025-10-14 08:09:57 +00:00
renovate[bot] 502a2f8df2 chore(deps): lock file maintenance npm packages (#14363) 2025-10-06 21:45:39 +08:00
Boshen f88f5f4593 release(crates): v0.94.0 (#14377) 2025-10-06 20:48:05 +08:00
Boshen aa0689fe38 release(crates): v0.93.0 (#14194) 2025-09-28 14:13:41 +08:00
Masanori Tani 06b16a9a18 chore(infra): add publint (#13937)
close #13768 

Setup [publint](https://publint.dev/) and fix warnings.
target directory: `napi/` and `editor/vscode`. (I couldn’t determine
whether I should include the `npm/` directory or not.)

Co-authored-by: Boshen <boshenc@gmail.com>
2025-09-27 17:47:15 +08:00
Boshen 1b3f437468 release(crates): v0.92.0 (#14067) 2025-09-24 12:18:07 +08:00
overlookmotel cc0019fb0a refactor(napi): move scripts into scripts directory (#14048)
Move all build scripts in `napi` packages into a `scripts` dir. These packages don't have root directories with tons of files like `napi/parser` and `apps/oxlint` do, but IMO it's preferable to have a consistent directory structure in all NAPI packages.

Also, rename these scripts from `.mjs` to `.js`, since these packages are ESM.
2025-09-23 14:47:41 +00:00
overlookmotel 2f9e16da2e fix(napi/minifier, napi/transformer): rename CommonJS file to .cjs (#14047)
`webcontainer-fallback.js` in `napi/minify` and `napi/transform` are CommonJS files, but these packages are ESM. Rename them to `webcontainer-fallback.cjs` to avoid module resolution errors/fallbacks.
2025-09-23 14:47:40 +00:00
Boshen cb55daa1c5 release(crates): v0.91.0 (#14000) 2025-09-22 19:24:10 +08:00
Boshen fb347da614 release(crates): v0.91.0 (#13961) 2025-09-21 13:23:09 +08:00
sapphi-red 6fcb0d05c6 fix(minifier)!: receive supported engines instead of ecmascript versions (#13933)
fixes https://github.com/oxc-project/oxc/issues/8905
2025-09-20 14:41:56 +00:00
overlookmotel 21bbf959b8 fix(napi): rebuild bindings file for NAPI packages (#13889)
#13888 broke CI because it didn't run `pnpm build` to update version number in NAPI bindings files.

I don't think the published packages are broken, because it only matters if `NAPI_RS_ENFORCE_VERSION_CHECK` env is set.
2025-09-18 14:37:42 +00:00
Boshen d116504831 release(crates): v0.90.0 (#13888) 2025-09-18 22:07:37 +08:00
Copilot b52389a569 feat(node): Bump engines field to require Node.js 20.19.0+ for ESM support (#13879)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-09-18 20:10:11 +08:00
Boshen 9796ec12d7 fix(napi): fix binding files 2025-09-15 14:55:01 +08:00
Boshen de40f0bee0 release(crates): v0.89.0 (#13774) 2025-09-15 14:33:03 +08:00
renovate[bot] b4e9d2c379 chore(deps): lock file maintenance npm packages (#13758)
Co-authored-by: Boshen <boshenc@gmail.com>
2025-09-15 13:15:05 +08:00
Boshen 369287abac release(crates): v0.88.0 (#13765)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-09-15 11:01:32 +08:00
oxc-bot 7128fb57dd release(crates): v0.87.0 (#13587)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-09-08 11:35:41 +08:00
oxc-bot 7652c8d6ab release(crates): v0.86.0 (#13464)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-08-31 18:46:10 +08:00
oxc-bot 42ebd43ba0 release(crates): v0.85.0 (#13413)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-08-30 15:44:00 +08:00
oxc-bot d6a8aa1ce0 release(crates): v0.84.0 (#13412)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-08-30 13:15:55 +08:00
oxc-bot 732c57e55e release(crates): v0.83.0 (#13387)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-08-29 14:49:51 +08:00
Boshen 34d0a014f6 feat(napi/minify,transform)!: change module type to ESM (#13349)
part of #13329
2025-08-28 12:47:24 +00:00
sapphi-red 593f54ccb6 feat(minifier): add --max-iterations for debugging (#13291)
Added `--max-iterations` to make it easier to debug what has changed in each iteration.
2025-08-25 14:47:06 +00:00
sapphi-red a0e0a91688 feat(oxc_minify_napi): expose CodeGenOptions (#13288)
Follow up to #13239
2025-08-25 07:56:31 +00:00
oxc-bot 8b1e022f7f release(crates): v0.82.3 (#13230) 2025-08-20 23:19:06 +08:00
IWANABETHATGUY d86f732836 chore(oxc_minify_napi): expose more options struct (#13239)
Allow the downstream user to construct a napi options on their own, a
use case in rolldown
https://github.com/rolldown/rolldown/pull/5804/files#diff-56038ed67657ce910f150123cdc2d8ab42bd9bcd9745192c3127f2d837c78865R248,
we need to convert options back to `oxc_minify_napi`, since
`oxc::minify::options` did not implement `toNapi` trait.
2025-08-20 23:18:20 +08:00
Boshen f10ac33979 fix(codegen): remove end sourcemaps for }, ], ) (#13180)
closes #13174

This should reduce sourcemap memory usage by a huge amount.

These tokens were added in esbuild for code coverage: https://github.com/evanw/esbuild/commit/c4d45e6b5766b1a1b56bf24b7dadb240de91332b

But esbuild has an optimization to not generate these tokens when `}` is not on the same line

```
if class.CloseBraceLoc.Start > class.BodyLoc.Start {
    p.addSourceMapping(class.CloseBraceLoc)
}
```

We should revisit these tokens later in the future.
2025-08-18 11:45:14 +00:00
oxc-bot 4d0a05e1e7 release(crates): v0.82.2 (#13158) 2025-08-17 23:31:38 +08:00
Kevin Deng d5431999d0 chore(napi): fix publint issues (#13107)
See https://publint.dev/oxc-parser
2025-08-15 22:25:18 +08:00
Boshen 522356201b refactor(codegen): adjust some source mappings (#13084)
closes #12395
2025-08-14 09:54:29 +00:00
oxc-bot 92a3550c40 release(crates): v0.82.1 (#13049) 2025-08-13 12:24:37 +08:00
Boshen 993db8915c feat(minifier): .minify and .dce methods; run dce in loop (#13026) 2025-08-12 14:58:41 +00:00
oxc-bot c58a699e19 release(crates): v0.82.0 (#13014) 2025-08-12 13:53:10 +08:00
oxc-bot c245d9bf78 release(crates): v0.81.0 (#12850) 2025-08-06 23:05:58 +08:00
oxc-bot 9671def11f release(crates): v0.80.0 (#12777) 2025-08-03 16:38:23 +08:00
Boshen 2093f65e7f feat(napi/minify): make MinifyOptions pub (#12753) 2025-08-02 12:27:12 +00:00
overlookmotel 0ec214b4aa test(napi): compile tests in debug mode (#12750)
Compile NAPI tests in debug mode (not release mode), to speed up build in CI.

Only exception is `napi/parser` which is compiled with `--profile coverage`. The tests for this package are quite slow, so they'd take too long if package was compiled with no optimizations. `coverage` profile is closer to `--release`, but enables debug assertions, and has somewhat faster compilation (`-O 2` not `-O 3` etc).

In CI:

* Build time reduced by 1m30s.
* Test run time increased by 30s.
* Total reduction in CI time: 1 minute.

NAPI tests are still the slowest task in CI by a long margin. Trimming a minute off the time is something, but this task is still too slow.
2025-08-02 12:18:41 +00:00