feat: add SWC transform and minify support#10201
Conversation
- Updated `exports.ts` to include SWC options in the experiments interface.
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces support for SWC-based transformation and minification to provide a compiler API for transforming and minifying JavaScript. Key changes include:
- Adding asynchronous functions (transform and minify) in packages/rspack/src/swc.ts.
- Exposing SWC functionality via experiments in packages/rspack/src/exports.ts.
- Implementing the corresponding native bindings and tasks in the Rust node binding (crates/node_binding).
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/rspack/src/swc.ts | Introduces async transform and minify functions |
| packages/rspack/src/exports.ts | Exposes SWC transform and minify in the experiments |
| crates/node_binding/src/swc.rs | Implements async SWC tasks for transformation/minification |
| crates/node_binding/src/lib.rs | Re-exports SWC functions |
| crates/node_binding/rspack.wasi.cjs & browser.js | Exports SWC functions for WASI and browser targets |
| crates/node_binding/Cargo.toml | Adds dependency on rspack_javascript_compiler |
Comments suppressed due to low confidence (1)
packages/rspack/src/exports.ts:349
- Please add tests covering the new SWC transform and minify functionality to ensure the experimental API behaves as expected.
swc: {
✅ Deploy Preview for rspack canceled.
|
CodSpeed Performance ReportMerging #10201 will not alter performanceComparing 🎉 Hooray!
|
Summary
Consider upper layer (rslib, rsbuild or rspress) and js plugin need parse [t|j]s file or minify js. We should provide a compiler api to transform js & minify it.
So we reuse swc transform and minify feature.
exports.tsto include SWC options in the experiments interface.Related issue (if exists):
#8998
Checklist