Skip to content

fix(sui-bundler): don't force sass-loader on plainCssPackages when linking - #1993

Open
tomasmax wants to merge 1 commit into
masterfrom
fix/link-loader-config-builder-plain-css
Open

fix(sui-bundler): don't force sass-loader on plainCssPackages when linking#1993
tomasmax wants to merge 1 commit into
masterfrom
fix/link-loader-config-builder-plain-css

Conversation

@tomasmax

@tomasmax tomasmax commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • linkLoaderConfigBuilder (used by sui-bundler dev -l/-L and sui-bundler build -l/-L for local package linking) rewrites the last loader of every module rule whose test matches .css, injecting @s-ui/sass-loader with the link importer.
  • This unconditionally includes the plainCssPackages passthrough rule added in feat(sui-bundler): add plainCssPackages config to bypass sass-loader #1988, which exists specifically to make webpack treat certain packages' .css as plain CSS and skip sass-loader entirely.
  • Net effect: any consumer linking local packages (a standard monorepo dev workflow) while also using plainCssPackages for a dependency shipping modern CSS (e.g. Tailwind v4's @layer/@supports syntax) gets that CSS silently routed through sass-loader anyway, which can't parse it → Module parse failed at dev-server startup.
  • Fix: only rewrite rules whose use chain already includes @s-ui/sass-loader, compared by require.resolved path (not a package-name substring — needed so this still works when @s-ui/sass-loader itself is linked, where its resolved path is packages/sui-sass-loader/src/index.js and doesn't contain the package name).

Test plan

  • Added packages/sui-bundler/test/server/linkLoaderConfigBuilderSpec.js: asserts the sass-loader rule still gets the link importer injected, the plainCssPackages passthrough rule is left untouched, and the no-op case (nothing to link) returns config unchanged.
  • npx @s-ui/test server -P 'packages/sui-bundler/test/server/*Spec.js' — 15 passing (includes pre-existing linkLoaderSpec, plainCssSplitChunksSpec, integration specs).
  • sui-lint js --fix — 0 errors (pre-existing sui/commonjs warnings elsewhere in the package, not introduced by this change).
  • Full pre-push suite (npm run test && npm run types:check) passed: 595 client tests, 18 server tests, typecheck clean.
  • Reproduced against a real consumer (frontend-mt--web-app, running dev:coches with -l ../packages/domain -l ../packages/literals -l ../packages/segment-wrapper -l ../packages/theme -L ../packages/ui and plainCssPackages: ["@adv-mt/ui", "@adv-mt/theme"]): before the fix, dev server failed to compile with Module parse failed: Unexpected token on @adv-mt/theme/dist/tokens.css and @adv-mt/ui/dist/basic/button/styles.css; after patching locally, dev server compiled and served correctly.

🤖 Generated with Claude Code

…s when linking

linkLoaderConfigBuilder rewrote the last loader of every module rule
whose test matched .css to inject @s-ui/sass-loader with the link
importer — including the plainCssPackages passthrough rule (added in
#1988), which is meant to skip sass-loader entirely for packages that
ship pre-built plain CSS. This broke consumers linking local packages
via -l/-L (a standard dev workflow in monorepos) whenever any
plainCssPackages dependency shipped modern CSS syntax (e.g. Tailwind
v4's @layer/@supports), since sass-loader can't parse it.

Only rewrite rules that already use @s-ui/sass-loader, compared by
resolved path so this also holds when @s-ui/sass-loader itself is
linked (its resolved path won't contain the package name substring).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.

1 participant