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).
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>
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.
`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.
#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.
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.
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.