You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature]: Add as to raw import rules to reduce plugin exclusions #8870
Rsbuild handles ?raw imports through dedicated oneOf branches in its JavaScript, CSS, asset, and preprocessor rules. Selecting a raw branch prevents other branches in the same oneOf from running, but the resource can still match subsequent independent compilation rules.
Using Rspack's as option in raw branches could let subsequent extension-based compilation rules skip these resources automatically, reducing duplicated exclusions.
What does the proposed API look like?
Add as to existing raw branches, retaining their current query conditions and position within oneOf:
The suffix above is illustrative. For example, example.ts?raw would use example.ts.rsbuild-raw for subsequent path matching. A later rule matching TypeScript extensions would no longer select it, while the original file would still be read and exported as text.
Start with existing raw branches rather than introducing a global first-match raw rule. This preserves the current selection order and avoids unintentionally extending raw support to additional file types.
Compatibility and validation
Preserve each branch's existing query semantics and precedence relative to ?url, ?inline, ?worker, and import attributes.
Verify JavaScript/TypeScript, CSS, Sass/Less, JSON, and SVG raw imports in build and development, including Babel and refresh plugins.
Remove duplicated plugin exclusions only after confirming those rules run after the raw branch and are skipped by the rewritten path.
Check custom rules that intentionally process raw imports, since they may stop matching after the suffix is added.
as only changes nested and subsequent rule matching. It does not undo previously matched loaders, and rules based only on MIME types, query parameters, or other metadata can still match. The goal is to remove redundant exclusions where path matching provides equivalent behavior, not to guarantee that every plugin skips raw imports.
Related: #8869 evaluates the corresponding text/bytes import-attribute handling.
Activity