Repository navigation
Conversation
…der and CssExtractRspackPlugin Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
✅ [V2]
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Size Change: +6.85 kB (+0.06%) Total Size: 12.1 MB 📦 View Changed
ℹ️ View Unchanged
|
✅ [V2]
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Size Change: 0 B Total Size: 12.1 MB ℹ️ View Unchanged
|
|
The latest updates on your projects. Learn more about Argos notifications ↗︎ Awaiting the start of a new Argos build… |
⚡️ Lighthouse report for the deploy preview of this PR
|
This branch has not been deployed
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.
Motivation
Use the native CSS support of Rspack (
type: 'css'andtype: 'css/module') instead ofcss-loader+CssExtractRspackPlugin. Rspack parses, bundles and emits CSS in Rust, so there is less JS work per CSS file.Draft to evaluate the approach: Rspack only. Webpack (deprecated) keeps the current pipeline unchanged.
Blocker: the CSS order changes, and
pnpm --filter website test:css-orderfails. See below.What changes with Rspack
cssandcss/moduletypes.postcss-loaderstays, soconfigurePostCss(), the cascade layers plugin and RTL keep working.[local]_[hash]with a 4-charbase64urldigest.[contenthash]gives different class names in the client and server compilers (hydration mismatch).@keyframes, like css-loader. Native CSS modules also rename custom properties, grid names, container names… by default, which breaks CSS variables like--docusaurus-highlighted-code-line-bg.namedExports: false, because Docusaurus imports CSS modules with a default import.exportsOnly) and run no loaders. Global CSS still goes through the null loader.ignoreWarnings: [/Conflicting order/]replaces theignoreOrder: trueofCssExtractRspackPlugin, which native CSS doesn't have.stylescache group matches the native CSS module types too. The JS part of CSS modules (class name maps) now lands in a newassets/js/styles.[hash].js.:global().@layer a, b, c;order declaration to each file it wraps. Layer order is the order of first appearance, and native CSS putsplugin-debugandtheme-classicbefore Infima: without this, Infima would win over the theme. The minifier removes the redundant declarations.Blocker: CSS order
Rspack orders native CSS modules of a shared chunk differently from
CssExtractRspackPlugin. With the conflicts Docusaurus always has (lazy routes import CSS in different orders), it looks like modules are picked by chunk groups sorted by module identifier, instead of starting from the entry chunk group.Thanks to the layer declaration, layered CSS is fine. But the order of unlayered CSS, and within a layer, differs. For example, the homepage CSS module now comes before the site
custom.cssand client modules:So a site page CSS module can lose against
custom.csswith equal specificity. I triedexperiments.CssChunkingPlugin, with no effect: the enforcedstylescache group wins. It would also go against the single CSS file of meta/docusaurus#2006.We probably need an upstream option in Rspack: an
ignoreOrder-like behavior matchingCssExtractRspackPluginfor native CSS.Other open questions
getStyleLoaders()(public API, used bydocusaurus-plugin-sass) still returnscss-loader+CssExtractRspackPlugin.loader, and the plugin stays registered. Rspack documents that it can't be combined with the native CSS types: a site with both would likely emit 2 CSS files with the same name. Not tested yet.Benchmark
Website
build:fast(--locale en),DOCUSAURUS_NO_PERSISTENT_CACHE=true, one run each on a laptop, so only indicative:mainassets/cssassets/jsstyles.js: 9.7 KB)Test Plan
DOCUSAURUS_SLOWER=true): unchanged, CSS order test passes.Test links
Deploy preview: https://deploy-preview-13032--docusaurus-2.netlify.app/
all: revert-layer): https://deploy-preview-13032--docusaurus-2.netlify.app/tests/pages/style-isolationRelated issues/PRs
🤖 Generated with Claude Code