Skip to content

feat(core): prototype the Rspack rule as option to skip loaders for text imports - #13056

Draft
slorber wants to merge 1 commit into
mainfrom
claude/rspack-loader-as-attribute-159b99
Draft

slorber wants to merge 1 commit into
mainfrom
claude/rspack-loader-as-attribute-159b99

Conversation

@slorber

@slorber slorber commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Prototype of the new experimental Rspack rules[].as option (Rspack 2.3.2), suggested by the Rspack team to simplify matching rules for import attributes.

Text imports (import x from './file.js' with {type: 'text'}) get the asset/source type from a default rule, but the loaders of all the other matching rules still apply. Today each Docusaurus rule excludes them with with: {type: {not: 'text'}} (core JS/CSS/assets rules, MDX loader, SVGR, ideal-image, synthetic MDX fallback). Third-party plugin rules must do the same.

With as, a single rule placed first does it for all subsequent rules, including the ones added by plugins:

{
  with: {type: 'text'},
  as: '[resource-path].text',
}

The subsequent rules match file.js.text instead of file.js, so none of them apply. Loaders and file reading still use the original resource.

⚠️ Draft, Rspack only: webpack doesn't support as. This prototype removes the per-rule exclusions, so webpack text imports are broken here: the webpack (DOCUSAURUS_SLOWER) website build is expected to fail on the import attributes dogfood page. Landing it would require keeping the exclusions for webpack, or dropping webpack support.

Test Plan

  • Upgrade @rspack/core to 2.3.2, the first version supporting as
  • Unit test asserting the Rspack text import rule comes first
  • The existing import attributes dogfood page throws during the build if any loader processes a text import (JS, TS, TSX, JSON, CSS, CSS modules, SVG, MD, MDX, YAML, TXT):
    • Rspack website build, persistent cache disabled: ✅
    • Same build with the as rule removed: ❌ Text import attribute test failed for JS, proving the page exercises the rule

Test links

Deploy preview: https://deploy-preview-13056--docusaurus-2.netlify.app/tests/pages/import-attributes

Related issues/PRs

🤖 Generated with Claude Code

… text imports

Replace the `with: {type: {not: 'text'}}` exclusions of every Docusaurus rule
by a single Rspack rule matching the subsequent rules against
`[resource-path].text`. Webpack doesn't support `as`: its text imports are
processed by loaders again in this prototype.

Upgrade @rspack/core to 2.3.2, the first version with `rules[].as`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@slorber slorber added the pr: new feature This PR adds a new API or behavior. label Nov 15, 2026
@meta-cla meta-cla Bot added the CLA Signed Signed Facebook CLA label Nov 15, 2026
@coderabbitai

coderabbitai Bot commented Nov 15, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​rspack/​core@​2.3.21001008196100

View full report

@netlify

netlify Bot commented Nov 15, 2026

Copy link
Copy Markdown

✅ [V2]

Name Link
🔨 Latest commit eafca5f
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/6af9b72cb958571b3bb8e8ef
😎 Deploy Preview https://deploy-preview-13056--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@github-actions

Copy link
Copy Markdown

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO Report
/ 🟠 78 🟢 98 🟢 100 🟢 100 Report
/docs/installation 🟠 78 🟢 97 🟢 100 🟢 100 Report
/docs/category/getting-started 🟠 74 🟢 100 🟢 100 🟠 86 Report
/blog 🟠 71 🟢 96 🟢 100 🟠 86 Report
/blog/preparing-your-site-for-docusaurus-v3 🟠 71 🟢 92 🟢 100 🟢 100 Report
/blog/tags/release 🟠 71 🟢 96 🟢 100 🟠 86 Report
/blog/tags 🟠 73 🟢 100 🟢 100 🟠 86 Report

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant