fix: ensure that raw query of styles can be accurately matched#5540
Merged
chenjiahan merged 1 commit intomainfrom Jul 5, 2025
Merged
fix: ensure that raw query of styles can be accurately matched#5540chenjiahan merged 1 commit intomainfrom
chenjiahan merged 1 commit intomainfrom
Conversation
✅ Deploy Preview for rsbuild ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request tightens up how resource queries are matched by introducing strict regexes for ?raw and ?inline, updates loader configurations to use them, and refreshes tests and snapshots to validate the new behavior.
- Add
RAW_QUERY_REGEXandINLINE_QUERY_REGEXconstants for precise matching of?rawand?inline - Update Stylus, Sass, Less, SWC, and CSS plugins to use the new regex constants in their
resourceQueryrules - Refresh snapshots and E2E tests to cover strict matching and “not-raw”/“not-inline” fallback cases
Reviewed Changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/plugin-stylus/src/index.ts | Introduce strict raw/inline regex and update Stylus loader rules |
| packages/plugin-sass/src/index.ts | Introduce strict raw/inline regex and update Sass loader rules |
| packages/plugin-less/src/index.ts | Introduce strict raw/inline regex and update Less loader rules |
| packages/core/src/constants.ts | Export shared RAW_QUERY_REGEX and INLINE_QUERY_REGEX |
| packages/core/src/plugins/css.ts | Apply strict query regexes in CSS plugin |
| packages/core/src/plugins/swc.ts | Replace inline rawRegex with shared RAW_QUERY_REGEX |
| tests/snapshots/** | Update test snapshots for all plugins to match new regex arrays |
| e2e/cases/ | Extend/instrument E2E tests for non-raw/inline import scenarios |
Comments suppressed due to low confidence (2)
e2e/cases/assets/raw-query/src/index.js:4
- Consider adding an assertion for
normalJsin the corresponding test to verify that imports with?not-rawfall back to the default JS loader, ensuring correct behavior for non-raw queries.
import normalJs from './foo.js?not-raw';
packages/core/src/constants.ts:50
- [nitpick] Consider adding a brief comment above the
RAW_QUERY_REGEXandINLINE_QUERY_REGEXexports to explain their intended use for future maintainability.
export const RAW_QUERY_REGEX: RegExp = /^\?raw$/;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Enhance the handling of resource queries (
rawandinline). This ensures stricter validation for raw and inline imports.Related Links
Checklist