Files
cloudflare__vinext/pnpm-workspace.yaml
T
James Anderson ce29f9c6aa fix(scss): preprocess SCSS CSS-module composes deps via SassAwareFileSystemLoader (#1882)
* fix(scss): preprocess SCSS CSS-module composes deps via SassAwareFileSystemLoader

postcss-modules' built-in FileSystemLoader reads files referenced by
`composes: className from './other.module.scss'` as raw text — without
Sass preprocessing.  For .scss files this leaves SCSS variables and bare
@import directives in the CSS output, causing LightningCSS to crash with
"Invalid empty selector" during production builds.

Fix: introduce SassAwareFileSystemLoader that delegates to Vite's
`preprocessCSS` API for every `composes:` dependency, so Sass compilation
runs before CSS-module scoping.  Register it via `css.modules.Loader` in
vinext's Vite config hook and thread the resolved config through via a new
`setSassLoaderResolvedConfig` call in the `configResolved` hook.

Fixes the following deploy-suite tests (both sass and sass-embedded variants):
- test/e2e/app-dir/scss/nm-module/nm-module.test.ts
- test/e2e/app-dir/scss/nm-module-nested/nm-module-nested.test.ts
- test/e2e/app-dir/scss/composes-external/composes-external.test.ts

Part of #1825 (non-tilde CSS-module/composes cases; complements #1881)

* fix(scss): address review feedback on SassAwareFileSystemLoader

- Guard the css.modules.Loader injection: respect a user's explicit
  css.modules: false (mergeConfigRecursively would otherwise re-enable
  CSS Modules with an object override) and never clobber a
  user-provided custom Loader. The override is precomputed as a typed
  const so the conditional spread doesn't disturb the config literal's
  contextual typing.
- Surface composes preprocessing failures via config.logger.warn
  instead of a bare catch {}, so missing composed classes are
  observable; a missing/unreadable dependency file now rejects like
  postcss-modules' FileSystemLoader did.
- Use Vite's exported preprocessCSS + PreprocessCSSResult type via a
  top-level import instead of the lazy dynamic import and stringly
  typed casts.
- Preserve parity for composes from non-*.module.* files: hand
  preprocessCSS a virtual *.module.* filename so plain '.css' deps are
  still scoped and export tokens extracted, matching the built-in
  FileSystemLoader.
- Port the three failing Next.js fixtures (composes-external,
  nm-module, nm-module-nested) as production-build regression tests in
  tests/scss-composes.test.ts, plus a plain .module.css / non-module
  .css parity test. All three SCSS tests reproduce the original
  "[lightningcss minify] Invalid empty selector" crash when the
  Loader injection is disabled.
- Add sass as a root devDependency so the SCSS tests (including the
  previously always-skipped tests/scss.test.ts) actually run in CI;
  drop the now-redundant knip ignore entry. Installing sass makes
  Vite's SassPreprocessorOptions resolve to the concrete sass types
  (previously any), so the tilde-importer's importers array now
  carries an explicit SassPreprocessorOptions["importers"] cast.

* fix(scss): bind composes-loader config per plugin instance; scope extensionless deps

- Replace the module-level resolved-config singleton with a per-vinext-
  instance binding (createSassAwareFileSystemLoader), so multiple builds in
  one process never preprocess composes deps with another build's config.
- Cover extensionless composes deps in the virtual *.module.* rename
  (append .module.css) so their tokens are scoped instead of silently
  dropped; add a parity test case.
- Pin url() pass-through behaviour for composed deps in the parity test
  (verbatim, never mangled into placeholders — matches the built-in
  FileSystemLoader, verified against a vanilla Vite build).

* docs(scss): document the per-subtree recursion boundary of the composes loader

Notes the two structural consequences of delegating nested composes
recursion to preprocessCSS (per-subtree duplicate inlining collapsed by
LightningCSS, and no cross-boundary cycle short-circuit for invalid
circular composes), per review.

* fix(scss): fail the build on composed-dep preprocessing errors

Only a missing Sass implementation is downgraded to a logged warning;
any other preprocessCSS error (e.g. a Sass syntax error in the composed
dependency) now propagates and fails the build, matching postcss-modules'
built-in FileSystemLoader instead of shipping a green build with
silently-missing classes. Docstrings updated to accurately describe the
silent empty-token path when no resolved config is bound. Adds a
regression test for the fail-loudly path.

* chore(deps): move sass to the workspace catalog; drop the now-dead dynamic skip in scss.test.ts

Review feedback on #1882: sass belongs in the pnpm workspace catalog
rather than pinned inline in the root package.json. With sass now a
guaranteed root devDependency, the runtime describeIfSass skip in
tests/scss.test.ts is dead code — the suite always runs — so make the
unskip explicit by removing the conditional machinery.

* rebuild lockfile
2026-06-11 00:29:51 +00:00

135 lines
3.4 KiB
YAML

autoInstallPeers: false
frozenLockfile: true
preferFrozenLockfile: true
saveExact: true
blockExoticSubdeps: true
minimumReleaseAge: 1440
packages:
- apps/*
- packages/*
- examples/*
- tests/fixtures/*
- tests/fixtures/ecosystem/*
- benchmarks/vinext
catalog:
"@cloudflare/kumo": ^2.2.0
"@cloudflare/vite-plugin": ^1.31.0
"@cloudflare/workers-types": ^4.0.0
"@heroicons/react": 2.2.0
"@mdx-js/loader": 3.1.0
"@mdx-js/react": ^3.1.1
"@mdx-js/rollup": ^3.1.1
"@phosphor-icons/react": ^2.1.10
"@playwright/test": ^1.60.0
"@radix-ui/react-dialog": ^1.1.14
"@radix-ui/react-dropdown-menu": ^2.1.15
"@radix-ui/react-slot": ^1.2.3
"@tailwindcss/forms": 0.5.10
"@tailwindcss/postcss": 4.1.4
"@tailwindcss/typography": 0.5.16
"@tailwindcss/vite": ^4.1.0
"@takumi-rs/image-response": ^0.72.0
"@types/mdx": 2.0.13
"@types/ms": 2.1.0
"@types/node": ^25.9.2
"@types/react": ^19.2.16
"@types/react-dom": ^19.2.3
"@typescript/native-preview": ^7.0.0-dev.20260213.1
"@unpic/react": ^1.0.2
"@vercel/og": ^0.8.6
"@vitejs/plugin-react": ^6.0.1
"@next/mdx": 16.2.7
recma-codehike: 0.0.1
remark-codehike: 0.0.1
"@vitejs/plugin-rsc": ^0.5.27
"@vitest/coverage-istanbul": 4.1.6
better-auth: ^1.5.6
better-sqlite3: ^12.0.0
class-variance-authority: ^0.7.1
clsx: ^2.1.1
codehike: 1.0.7
date-fns: 4.1.0
drizzle-kit: ^0.31.10
drizzle-orm: ^0.45.2
sanitize-html: ^2.17.3
fumadocs-core: 16.7.9
fumadocs-mdx: 14.2.10
fumadocs-ui: 16.7.9
image-size: 2.0.2
ipaddr.js: ^2.1.0
lucide-react: ^0.577.0
magic-string: ^0.30.21
"@mswjs/interceptors": ^0.41.3
msw: ^2.14.6
ms: 3.0.0-canary.1
next: 16.2.7
next-intl: ^4.9.2
next-themes: ^0.4.6
next-view-transitions: ^0.3.5
nitro: npm:nitro-nightly@latest
nuqs: ^2.8.8
playwright: ^1.60.0
postcss: 8.5.10
react: ^19.2.7
react-dom: ^19.2.7
react-server-dom-webpack: ^19.2.7
sass: 1.100.0
server-only: ^0.0.1
swr: ^2.0.0
tailwind-merge: ^3.3.0
tailwindcss: 4.1.4
typescript: ^5.7.0
use-count-up: 3.0.1
validator: ^13.15.26
vite: npm:@voidzero-dev/vite-plus-core@0.1.24
vite-plugin-commonjs: ^0.10.4
vite-plus: 0.1.24
vite-tsconfig-paths: ^6.1.1
vitest: npm:@voidzero-dev/vite-plus-test@0.1.24
web-vitals: ^4.2.4
wrangler: ^4.80.0
zod: 3.24.3
knip: ^6.16.0
overrides:
vite: "catalog:"
vitest: "catalog:"
picomatch: ">=2.3.2"
srvx: ">=0.11.13"
peerDependencyRules:
allowAny:
- vite
- vitest
allowedVersions:
vite: "*"
vitest: "*"
ignoreMissing:
- next
- webpack
- rollup
packageExtensions:
# codehike@1.0.7 lists zod only as a devDependency, so pnpm doesn't nest zod
# next to it. TS then resolves `zod` from inside codehike's .d.ts files to
# whichever zod happens to be hoisted (zod@4.3.6 in this monorepo, pulled in
# by better-auth/fumadocs), which is incompatible with codehike's zod v3
# types. Declare zod as a peerDependency on codehike so pnpm pulls the
# correct version (zod@3.24.3 from the catalog) into codehike's scope.
codehike@1.0.7:
peerDependencies:
zod: 3.24.3
allowBuilds:
better-sqlite3: true
esbuild: true
sharp: true
workerd: true
"@parcel/watcher": true
"@swc/core": true
unrs-resolver: false
# MSW's postinstall only copies a service worker into ./public for browser
# mocking. We exclusively use msw/node, so the postinstall is unnecessary.
msw: false