feat(swc-loader)!: move rspackExperiments.import to top-level transformImport#13345
feat(swc-loader)!: move rspackExperiments.import to top-level transformImport#13345
Conversation
…ransformImport` Promote the import transformation API from experimental to stable by moving it out of `rspackExperiments` to a top-level `transformImport` option. The old `rspackExperiments.import` is kept for backward compatibility but marked as deprecated.
Deploying rspack with
|
| Latest commit: |
aaf8c1e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0b905345.rspack-v2.pages.dev |
| Branch Preview URL: | https://refactor-swc-loader-transfor.rspack-v2.pages.dev |
There was a problem hiding this comment.
Pull request overview
This PR promotes the rspackExperiments.import option in builtin:swc-loader to a new top-level transformImport option, marking the old location as deprecated. The Rust transformer prefers the top-level option when both are present, and error messages are updated to reference the new option name.
Changes:
- Added top-level
transformImportfield to both JS types and Rust deserialization structs, with the Rust transformer preferring it over the deprecatedrspackExperiments.import - Updated all error messages in
swc_plugin_importand corresponding test expectations to referencetransformImport[*] - Updated English and Chinese documentation to document
transformImportas the primary API and add a deprecation warning forrspackExperiments.import
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/rspack/src/builtin-loader/swc/types.ts | Added transformImport field and @deprecated on old field |
| packages/rspack/src/builtin-loader/swc/index.ts | Added resolution of top-level transformImport option |
| crates/rspack_loader_swc/src/options.rs | Added transform_import field to deserialization structs |
| crates/rspack_loader_swc/src/transformer.rs | Updated transform to prefer transform_import over deprecated path |
| crates/rspack_loader_swc/src/lib.rs | Pass transform_import to transformer |
| crates/swc_plugin_import/src/lib.rs | Updated error messages to reference transformImport |
| tests/.../plugin-import/rspack.config.js | Migrated test config to transformImport |
| tests/.../issue-4597/rspack.config.js | Migrated test config to transformImport |
| tests/.../plugin-import-invalid-template/* | Migrated config and error expectation |
| tests/.../plugin-import-invalid-helper/* | Migrated config and error expectation |
| tests/.../plugin-import-incomplate-template/* | Migrated config and error expectation |
| website/docs/en/guide/features/builtin-swc-loader.mdx | Updated English docs with new API and deprecation warning |
| website/docs/zh/guide/features/builtin-swc-loader.mdx | Updated Chinese docs with new API and deprecation warning |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| HANDLER.with(|handler| { | ||
| handler.err(&format!( | ||
| "[builtin:swc-loader] Failed to parse option \"rspackExperiments.import[{}].customName\".\nReason: {}", | ||
| "[builtin:swc-loader] Failed to parse option \"transformImport[{}].customName\".\nReason: {}", |
Rsdoctor Bundle Diff AnalysisFound 5 projects in monorepo, 5 projects with changes. 📊 Quick Summary
📋 Detailed Reports (Click to expand)📁 react-10kPath:
📁 react-1kPath:
📁 romePath:
📁 react-5kPath:
📁 ui-componentsPath:
Generated by Rsdoctor GitHub Action |
📦 Binary Size-limit
❌ Size increased by 2.00KB from 49.04MB to 49.05MB (⬆️0.00%) |
Merging this PR will not alter performance
Comparing Footnotes
|
Summary
options.rspackExperiments.importto top-leveloptions.transformImportinbuiltin:swc-loaderrspackExperiments.importas deprecated backward-compatible aliasswc_plugin_importto referencetransformImport[*]transformImportsection and deprecation warningTest plan
cargo test -p rspack_loader_swc -p rspack_swc_plugin_import)plugin-import,issue-4597,plugin-import-invalid-template,plugin-import-invalid-helper,plugin-import-incomplate-template)