-
-
Notifications
You must be signed in to change notification settings - Fork 249
feat: allow to get raw JS content with ?raw
#5353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for rsbuild ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this 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 introduces support for importing the raw content of JavaScript, TypeScript, JSX, and TSX files via the “?raw” query parameter.
- Updated various module rules across plugins (svelte, react, babel, swc, and webpack) to conditionally handle raw imports.
- Added a new rule in the SWC plugin to treat “?raw” imports as asset/source.
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/plugin-svelte/tests/snapshots/index.test.ts.snap | Added "resourceQuery" rule for non‐raw/inline JS/TS files. |
| packages/plugin-react/tests/snapshots/index.test.ts.snap | Updated snapshot to exclude raw files from standard JS processing. |
| packages/plugin-babel/tests/snapshots/index.test.ts.snap | Included "resourceQuery" checks to filter raw imports. |
| packages/core/tests/snapshots/swc.test.ts.snap | Added raw asset rule snapshots for SWC plugin. |
| packages/core/src/plugins/swc.ts | Introduced a new rule for handling “?raw” imports using asset/source type. |
| packages/core/src/configChain.ts | Added a new constant for the raw JS rule. |
| packages/compat/webpack/tests/snapshots/default.test.ts.snap | Updated webpack snapshots with raw content handling. |
| e2e/cases/assets/raw-query/* | Added tests and sample files to verify raw asset loading functionality. |
|
Why not make the distinction directly through oneOf but add an independent rule instead? I think it should be consistent with the scope of the default rules, for example, also affected by Are there any other reasons? |
|
Switch to |
|
I'm considering using oneOf in Rsbuild v2. Thank you for your feedback! |
hah, I was just about to ask if I was considering applying it in 2.0 |
|
Updated in: #7032 |

Summary
Add support for importing the raw content of JavaScript, TypeScript, and JSX files through the
?rawquery parameter. This makes the?rawquery more general and intuitive.Related Links
#2665
Checklist