feat(core): support importing files as raw text with import attributes (AI-assisted) - #12491
Merged
slorber merged 6 commits intoSep 24, 2026
Merged
Conversation
slorber
added this pull request to stack #12490
September 24, 2026 15:57
✅ [V2]
To edit notification comments on pull requests, go to your Netlify project configuration. |
slorber
force-pushed
the
slorber/import-text-attributes
branch
from
September 24, 2026 16:11
7a69f72 to
f13af2f
Compare
|
Size Change: -2.89 kB (-0.02%) Total Size: 12.4 MB 📦 View Changed
ℹ️ View Unchanged
|
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
⚡️ Lighthouse report for the deploy preview of this PR
|
|
Size Change: -2.91 kB (-0.02%) Total Size: 12.5 MB 📦 View Changed
ℹ️ View Unchanged
|
…s (AI-assisted)
`import text from './file.tsx' with {type: 'text'}` now returns the raw file
content, like the legacy `!!raw-loader!` syntax, for any file type, in both
MDX and JS/TS files.
- Exclude text import attributes from all module rules (including rules added
by plugins), so that no loader processes them
- Keep import attributes in SWC-transpiled code (`keepImportAttributes`)
- Add dogfooding tests for JS, TS, TSX, JSON, CSS, CSS modules, SVG, MD, MDX,
YAML and text files, in both MDX and TSX pages
- Replace raw-loader usages in docs by import attributes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…X page rendering JSX/TSX tests (AI-assisted) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
slorber
force-pushed
the
slorber/import-text-attributes
branch
from
September 24, 2026 16:15
7c4312c to
4028a9a
Compare
…usaurus rule instead of all rules (AI-assisted) Third-party plugin rules are no longer modified implicitly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
slorber
force-pushed
the
slorber/import-text-attributes
branch
from
September 24, 2026 16:38
7c4312c to
4028a9a
Compare
…variables (AI-assisted) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Pre-flight checklist
Motivation
You can now import any file as raw text with the standard import attributes syntax. It works in both MDX and JS/TS files, on both Rspack and webpack. This replaces the
!!raw-loader!pattern (AI-assisted).Two things prevented this from working:
{with: {type: 'text'}, type: 'asset/source'}rule, but every other matching rule still applied its loaders first. A.tsxfile imported as text came back transpiled, a.mdfile compiled, a.svgfile turned into an SVGR component, and so on. Every rule Docusaurus defines now has an explicitwith: {type: {not: 'text'}}condition (rules[].with): core JS/CSS/CSS modules, the asset rules in@docusaurus/utils(images, SVG, fonts, media, files),createMDXLoaderRule()(docs/blog/pages), the synthetic MDX fallback, ideal-image, and the SVGR wrapper rule. Third-party plugin rules are not modified. This behaves the same with the latest Rspack (2.2.7).jsc.experimental.keepImportAttributes, SWC silently removeswith {…}. On Docusaurus Faster, attributes in JS/TS files were ignored, includingwith {type: 'json'}. That flag is now enabled.Docs:
raw-loaderusages in the current docs and dogfooding pages are replaced.raw-loaderdependency for them.Test Plan
_dogfooding/_pages tests/import-attributes/, with a single MDX page. It imports 11 fixtures as text (JS, TS, TSX, JSON, CSS, CSS module, SVG, MD, MDX, YAML and TXT), then renders JSX and TSX components that do the same imports. Each result is checked for a raw-source snippet that a loader would transform. A failure throws, so a regression fails the website build.DOCUSAURUS_SLOWER=true), with clean caches: 33/33 pass (11 fixtures in MDX, JSX and TSX) with both bundlers. With the fix disabled, the build fails.raw-loaderrender identical content tomain. Only the documentation examples changed.Test links
Deploy preview: https://deploy-preview-12491--docusaurus-2.netlify.app/
Related issues/PRs
🤖 Generated with Claude Code