Skip to content

fix(packages/sui-bundler): keep plainCssPackages rules out of the link sass loader - #1994

Merged
tomasmax merged 1 commit into
masterfrom
fix/link-loader-skip-plain-css-rules
Aug 18, 2026
Merged

fix(packages/sui-bundler): keep plainCssPackages rules out of the link sass loader#1994
tomasmax merged 1 commit into
masterfrom
fix/link-loader-skip-plain-css-rules

Conversation

@tomasmax

Copy link
Copy Markdown
Collaborator

Problem

plainCssPackages (added in #1988, released in v9.79.0) has no effect when the bundler runs with link flags (-l / -L).

loaders/linkLoaderConfigBuilder.js rewrote every rule whose test matched .css, swapping its last loader for @s-ui/sass-loader with the link importer. That also hit the plainCssPackages passthrough rule ([style-loader, css-loader]), turning it into [style-loader, @s-ui/sass-loader]. Plain CSS then went through Sass and the build died:

ERROR in node_modules/@adv-mt/ui/dist/basic/button/styles.css
Module build failed (from node_modules/@s-ui/sass-loader/src/index.js):
Error: Expected digit.
2 │ @layer properties{@supports (((-webkit-hyphens:none)) and ...

Reproduced in frontend-mt--web-app, whose dev_coches target passes -l ../packages/domain … -L ../packages/ui and declares plainCssPackages: ["@adv-mt/ui", "@adv-mt/theme"] (Tailwind v4 output — not valid SCSS).

Fix

Only replace the sass importer on rules that already pipe through @s-ui/sass-loader. Any other rule is returned untouched, so the plainCssPackages passthrough survives link mode. Also bails out when use isn't an array.

Verification

Ran the builder over a config mirroring webpack.config.dev.js (sass rule + plainCssPackages passthrough + a JS rule) with packagesToLink set:

  • sass rule → last loader still swapped for the importer-aware @s-ui/sass-loader
  • plainCssPackages rule → [style-loader, css-loader], unchanged ✅
  • JS rule → unchanged ✅

Before the fix the second rule became [style-loader, @s-ui/sass-loader]. sui-lint js reports 0 errors on the touched file (only pre-existing sui/commonjs warnings).

🤖 Generated with Claude Code

…k sass loader

When linking packages (-l / -L) the link config builder rewrote every rule
whose test matched .css, replacing its last loader with @s-ui/sass-loader.
That also hit the plainCssPackages passthrough rule, so plain CSS shipped by
packages such as Tailwind v4 output was parsed as SCSS and the build failed
with "Error: Expected digit".

Now only rules that already pipe through @s-ui/sass-loader get its importer
replaced; every other rule is left untouched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tomasmax
tomasmax merged commit eb4c889 into master Aug 18, 2026
2 checks passed
@tomasmax
tomasmax deleted the fix/link-loader-skip-plain-css-rules branch August 18, 2026 12:37
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.

3 participants