Skip to content

feat(swc-loader)!: move rspackExperiments.import to top-level transformImport#13345

Open
JSerFeng wants to merge 1 commit intomainfrom
refactor/swc-loader-transform-import
Open

feat(swc-loader)!: move rspackExperiments.import to top-level transformImport#13345
JSerFeng wants to merge 1 commit intomainfrom
refactor/swc-loader-transform-import

Conversation

@JSerFeng
Copy link
Contributor

Summary

  • Promote options.rspackExperiments.import to top-level options.transformImport in builtin:swc-loader
  • Keep rspackExperiments.import as deprecated backward-compatible alias
  • Update error messages in swc_plugin_import to reference transformImport[*]
  • Update all test configs and error expectations to use the new API
  • Update English and Chinese documentation with new transformImport section and deprecation warning

Test plan

  • Rust unit tests pass (cargo test -p rspack_loader_swc -p rspack_swc_plugin_import)
  • Integration tests pass (plugin-import, issue-4597, plugin-import-invalid-template, plugin-import-invalid-helper, plugin-import-incomplate-template)
  • All linters pass (rustfmt, prettier, eslint, spellcheck)

…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.
@JSerFeng JSerFeng requested a review from hardfist as a code owner March 13, 2026 10:24
Copilot AI review requested due to automatic review settings March 13, 2026 10:24
@github-actions github-actions bot added release: refactor team The issue/pr is created by the member of Rspack. labels Mar 13, 2026
@cloudflare-workers-and-pages
Copy link

Deploying rspack with  Cloudflare Pages  Cloudflare Pages

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

View logs

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 transformImport field to both JS types and Rust deserialization structs, with the Rust transformer preferring it over the deprecated rspackExperiments.import
  • Updated all error messages in swc_plugin_import and corresponding test expectations to reference transformImport[*]
  • Updated English and Chinese documentation to document transformImport as the primary API and add a deprecation warning for rspackExperiments.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: {}",
@github-actions
Copy link
Contributor

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 5 projects with changes.

📊 Quick Summary
Project Total Size Change
react-10k 5.7 MB -
react-1k 826.2 KB -
rome 984.2 KB -
react-5k 2.7 MB -
ui-components 2.3 MB -
📋 Detailed Reports (Click to expand)

📁 react-10k

Path: ../build-tools-performance/cases/react-10k/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 5.7 MB - -
📄 JavaScript 5.7 MB - -
🎨 CSS 21.0 B - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

📁 react-1k

Path: ../build-tools-performance/cases/react-1k/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 826.2 KB - -
📄 JavaScript 826.2 KB - -
🎨 CSS 0 B - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

📁 rome

Path: ../build-tools-performance/cases/rome/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 984.2 KB - -
📄 JavaScript 984.2 KB - -
🎨 CSS 0 B - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

📁 react-5k

Path: ../build-tools-performance/cases/react-5k/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 2.7 MB - -
📄 JavaScript 2.7 MB - -
🎨 CSS 21.0 B - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

📁 ui-components

Path: ../build-tools-performance/cases/ui-components/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 2.3 MB - -
📄 JavaScript 2.0 MB - -
🎨 CSS 271.4 KB - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Contributor

📦 Binary Size-limit

Comparing aaf8c1e to refactor: remove Ukey DataBase abstraction (#13339) by hardfist

❌ Size increased by 2.00KB from 49.04MB to 49.05MB (⬆️0.00%)

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 13, 2026

Merging this PR will not alter performance

✅ 16 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing refactor/swc-loader-transform-import (aaf8c1e) with main (cf2c8bc)2

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (3e83955) during the generation of this report, so cf2c8bc was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@chenjiahan chenjiahan changed the title refactor(swc-loader): move rspackExperiments.import to top-level transformImport feat(swc-loader)!: move rspackExperiments.import to top-level transformImport Mar 14, 2026
@github-actions github-actions bot added release: feature release: feature related release(mr only) and removed release: refactor labels Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants