Skip to content

fix: ensure that raw query of styles can be accurately matched#5540

Merged
chenjiahan merged 1 commit intomainfrom
css_query_0705
Jul 5, 2025
Merged

fix: ensure that raw query of styles can be accurately matched#5540
chenjiahan merged 1 commit intomainfrom
css_query_0705

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

Summary

Enhance the handling of resource queries (raw and inline). This ensures stricter validation for raw and inline imports.

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings July 5, 2025 01:42
@netlify
Copy link
Copy Markdown

netlify Bot commented Jul 5, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 7532b86
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/686883193a5cc00008679a1c
😎 Deploy Preview https://deploy-preview-5540--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 80 (🟢 up 8 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
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 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_REGEX and INLINE_QUERY_REGEX constants for precise matching of ?raw and ?inline
  • Update Stylus, Sass, Less, SWC, and CSS plugins to use the new regex constants in their resourceQuery rules
  • 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 normalJs in the corresponding test to verify that imports with ?not-raw fall 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_REGEX and INLINE_QUERY_REGEX exports to explain their intended use for future maintainability.
export const RAW_QUERY_REGEX: RegExp = /^\?raw$/;

Comment thread packages/plugin-stylus/src/index.ts
Comment thread packages/plugin-sass/src/index.ts
Comment thread packages/plugin-less/src/index.ts
Comment thread packages/core/src/plugins/css.ts
@chenjiahan chenjiahan merged commit 3605d90 into main Jul 5, 2025
13 checks passed
@chenjiahan chenjiahan deleted the css_query_0705 branch July 5, 2025 02:24
@chenjiahan chenjiahan mentioned this pull request Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants