fix(plugin-babel): skip text import attributes in standalone rule - #8039
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (4)
📝 WalkthroughWalkthroughChangesThis change updates the Babel plugin's include/exclude rule to exclude modules with type 'text' from processing by adding a Related PRs: None specified. Suggested labels: plugin-babel, e2e-test Suggested reviewers: None specified. 🐰 A whisper of text, untouched by the loom, 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes an interaction between @rsbuild/plugin-babel’s include/exclude mode and Rsbuild’s “text import attributes” feature by ensuring the standalone Babel rule does not apply to import ... with { type: 'text' } requests, preserving the original source text.
Changes:
- Update the plugin-babel standalone script rule (include/exclude mode) to skip
with { type: 'text' }imports. - Update plugin-babel snapshot output to reflect the new rule condition.
- Add an e2e case verifying TS text-imports remain untransformed while normal named imports still work with Babel include mode.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/plugin-babel/src/plugin.ts | Excludes type: 'text' import attributes from the standalone Babel rule. |
| packages/plugin-babel/tests/snapshots/index.test.ts.snap | Updates expected rule serialization to include the new with.type.not condition. |
| e2e/cases/plugin-babel/import-attributes-text-script/src/text.ts | Adds a TS fixture used for both normal and text-attribute imports. |
| e2e/cases/plugin-babel/import-attributes-text-script/src/index.js | Imports the TS fixture normally and via with { type: 'text' } and exposes results on window. |
| e2e/cases/plugin-babel/import-attributes-text-script/index.test.ts | Verifies the text import equals the raw source file content and the named import still evaluates correctly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const loader = rule | ||
| .test(SCRIPT_REGEX) | ||
| .with({ type: { not: 'text' } }) | ||
| .use(CHAIN_ID.USE.BABEL) | ||
| .loader(BABEL_LOADER_PATH) |
Summary
This PR fixes a
@rsbuild/plugin-babelinclude/exclude mode compatibility issue where its standalone script rule could still transform script imports usingwith { type: 'text' }, causing the text import to export Babel-processed content instead of the original source text. The standalone Babel rule now skipstype: 'text'import attributes, and a focused e2e case covers the.tstext-import path while keeping normal named imports working.Related Links