Skip to content

[POC] feat(core): support experimental Rspack builtin CSS - #8101

Draft
intellild wants to merge 1 commit into
mainfrom
codex/feat-rspack-builtin-css
Draft

[POC] feat(core): support experimental Rspack builtin CSS#8101
intellild wants to merge 1 commit into
mainfrom
codex/feat-rspack-builtin-css

Conversation

@intellild

@intellild intellild commented Jul 13, 2026

Copy link
Copy Markdown

Summary

This PR adds an experimental Rsbuild experiments.css option for using Rspack's built-in CSS module types. When enabled, CSS, CSS Modules, ?inline, Less, and Sass use the native css/* pipeline without css-loader, style-loader, or CssExtractRspackPlugin; native parser and generator options can be set through tools.css.

Rsbuild needs a dedicated option because tools.rspack can be a sync or async callback and runs after Rsbuild creates its CSS rules. Reading tools.rspack.experiments.css therefore cannot reliably select the internal CSS pipeline.

export default {
  experiments: {
    css: true,
  },
};

CSS ?url imports and Vue SFC CSS Modules are currently unsupported in this mode and emit warnings.


by OpenAI Codex

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds a top-level experiments.css configuration with built-in CSS parser and generator options. The CSS plugin configures Rspack built-in CSS rules and retains the css-loader pipeline when disabled. Less and Sass module rules mirror CSS branch metadata, Tailwind handles available CSS module branches, and Vue warns about unsupported SFC CSS Modules. Tests cover rule shapes, loaders, warnings, module modes, style exports, and end-to-end configuration.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely summarizes the main change: experimental built-in Rspack CSS support.
Description check ✅ Passed The description is directly related and accurately explains the experimental CSS feature and its limitations.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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

Comment @coderabbitai help to get the list of available commands.

@intellild

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@intellild

Copy link
Copy Markdown
Author

@codex review

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/core/src/plugins/css.ts`:
- Around line 257-265: Update isBuiltinCssEnabled in the core CSS plugin and the
corresponding builtin-CSS checks in the Less and Sass plugins to inspect the
finalized Rspack configuration rather than config.tools.rspack directly. Resolve
array and callback-based ToolsRspackConfig forms before reading experiments.css,
and preserve native CSS handling so css-loader/extract loaders are not installed
when the final config enables builtin CSS.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6c3a5786-10f4-4ab2-8735-30b04db40c5c

📥 Commits

Reviewing files that changed from the base of the PR and between cd66e62 and c1bdea4.

📒 Files selected for processing (8)
  • packages/core/src/loader/cssUrlLoader.ts
  • packages/core/src/plugins/css.ts
  • packages/core/src/types/config.ts
  • packages/core/tests/css.test.ts
  • packages/plugin-less/src/index.ts
  • packages/plugin-less/tests/index.test.ts
  • packages/plugin-sass/src/index.ts
  • packages/plugin-sass/tests/index.test.ts

Comment thread packages/core/src/plugins/css.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c1bdea49e8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/core/src/loader/cssUrlLoader.ts Outdated
@intellild

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@intellild

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8bd1db7e25

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/core/src/loader/cssUrlLoader.ts Outdated
Comment thread packages/core/src/loader/cssUrlLoader.ts Outdated
@intellild intellild changed the title feat(core): support Rspack builtin CSS feat(core): support experimental Rspack builtin CSS Jul 13, 2026
@intellild

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7fd3536f87

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/core/src/plugins/css.ts
Comment thread packages/core/src/plugins/css.ts Outdated
@intellild

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7fd3536f87

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/core/src/plugins/css.ts
Comment thread packages/core/src/plugins/css.ts Outdated
Comment thread packages/core/src/plugins/css.ts Outdated
@intellild

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2c87092eb8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/core/src/plugins/css.ts Outdated
Comment thread packages/core/src/plugins/css.ts
@intellild

Copy link
Copy Markdown
Author

@codex review

1 similar comment
@intellild

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cb2a65a9db

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/core/src/plugins/css.ts Outdated
Comment thread packages/core/src/plugins/css.ts
@intellild

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ce4405c4e1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/core/src/plugins/css.ts
@intellild

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5982dcb06c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/core/src/plugins/css.ts
@intellild

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eb83dd426b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/core/src/plugins/css.ts
Comment thread packages/plugin-sass/src/index.ts
Comment thread packages/plugin-less/src/index.ts
@intellild

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9847eccc39

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/core/src/plugins/css.ts
@intellild
intellild force-pushed the codex/feat-rspack-builtin-css branch from e6316ae to a72a04b Compare July 15, 2026 07:11
@intellild
intellild force-pushed the codex/feat-rspack-builtin-css branch from a72a04b to 4020e3f Compare July 15, 2026 07:22
@intellild
intellild marked this pull request as ready for review July 15, 2026 08:19
@intellild
intellild requested a review from chenjiahan July 15, 2026 08:19

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4020e3f2eb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +477 to +480
.parser({
exportType: 'text',
namedExports: true,
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Merge native parser options into inline CSS rule

When experiments.css is enabled and a user configures native parser options via tools.css.parser (for example url: false, import: false, or resolveImport), this rule-level parser object overrides the module.parser['css/auto'] options that applyBuiltinCssConfig just merged. As a result, import './style.css?inline' still resolves url()/@import using Rspack defaults instead of the user's built-in CSS parser settings; merge config.tools.css?.parser into this inline parser and then force exportType: 'text'.

Useful? React with 👍 / 👎.

* Only takes effect when `experiments.css` is enabled.
* @experimental
*/
export interface ToolsCSSConfig {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rspack's builtin CSS support is not a "tool", we should avoid providing a tools.* config for builtin CSS

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d prefer to keep this PR focused on the core changes and exclude any plugin-related changes.

Comment on lines +166 to +196
expect(mainRule).toBeTruthy();
expect(cssModulesRule).toBeTruthy();
expect(urlRule).toBeUndefined();
expect(inlineRule).toMatchObject({
type: 'css/auto',
parser: {
exportType: 'text',
namedExports: true,
},
});
expect(inlineRule).not.toHaveProperty('generator');
expect(loaders.some((loader) => loader.includes('css-loader/index'))).toBe(false);
expect(loaders.some((loader) => loader.includes('style-loader/index'))).toBe(false);
expect(loaders.some((loader) => loader.includes('cssExtractLoader'))).toBe(false);
expect(loaders).toContain('builtin:lightningcss-loader');
expect(matchPlugin(rspackConfigs[0], 'CssExtractRspackPlugin')).toBeFalsy();
expect(rspackConfigs[0].experiments?.css).toBe(true);
expect(rspackConfigs[0].module?.parser).toMatchObject({
'css/auto': {
import: false,
namedExports: true,
},
});
expect(rspackConfigs[0].module?.parser?.['css/auto']).not.toHaveProperty('url');
expect(rspackConfigs[0].module?.generator).toMatchObject({
'css/auto': {
exportsConvention: 'dashes-only',
exportsOnly: false,
localIdentName: 'custom__[local]',
},
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use test snapshots


type BuiltinCssRuleType = 'css' | 'css/auto' | 'css/global' | 'css/module';

const CSS_MODULE_REGEX = /\.module(s)?\.css$/i;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can reuse the regex in packages/core/src/helpers/css.ts

'dashes-only',
] as const;

const builtinCssExportConventionMap = Object.fromEntries(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we avoid computing this at the top level? Since it’s only used under certain conditions, initializing it eagerly adds unnecessary overhead

@intellild
intellild marked this pull request as draft July 15, 2026 08:42

@chenjiahan chenjiahan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s avoid experiments.css: it conflicts with Rspack v1’s option and doesn’t clearly describe the Rsbuild behavior change.

@intellild intellild changed the title feat(core): support experimental Rspack builtin CSS [POC] feat(core): support experimental Rspack builtin CSS Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants