Repository navigation
fix(css): keep Lightning CSS module names stable for ?inline imports (fix #23735) - #23736
everton-dgn wants to merge 9 commits into
Conversation
|
Could someone rerun the macOS job?
These failures already occurred on |
|
Could someone rerun the Ubuntu/Node 26 and macOS/Node 24 jobs in run 38320165323? Both fixtures use the default PostCSS transformer, so neither reaches the changed
Both spec files also pass locally on macOS, on head |
Update filesystem-routing to 0.4.1, which keeps the route scan order on watcher updates (solidjs/filesystem-routing#28) and removes watched routes by the file that added them, so its Bun patch is dropped. The generated route declarations now type each ref by its picked exports. The middleware comment no longer claims that the API handler only takes a Request. Update vite-plus and vite-plus-core to 1.4.0. The CSS Modules patch still applies unchanged, since vitejs/vite#23736 is not in this release, and moves to the new version key. The bundled oxlint now asks for String.raw in the relative import restriction regex. Update the Node runtime to the 24.22.1 security release and raise the engine floor to match.
|
Could someone rerun just the Windows / Node 26 job on The original Ubuntu / Node 26 failure was separate. The two CSS sourcemap builds shared an output directory, so one could remove the script referenced by the other's HTML. The variants now build in separate directories, and the Ubuntu job passed. |
Fixes #23735.
With
css.transformer: 'lightningcss', a CSS Module imported normally and with?inlinegets different class names.compileLightningCSSpassesremoveDirectQuery(id)as the filename, soinlinestays in the path Lightning CSS hashes, and the selectors in the?inlinestring don't match the module's exports.By default Lightning CSS prefixes names with a hash of the filename, and its docs describe
[hash]as "a hash of the full file path" (CSS modules docs). So whatever Vite passes as the filename is the hash input. Vite already removes?directfrom it for this reason (#19481), and this PR does the same forinline.inlineparameters are removed, with values and repeats, only when CSS Modules is enabled for the file. The path and the other parameters keep their bytes and order, sovue&type=style&index=0keeps its own names and?inline-cssis untouched. Plain CSS andcssModules: falsekeep the full query in the filename seen by Lightning CSS visitors.How this differs from #23371: that PR targeted #22957, changed both transformers, passed
cleanUrl(filename)to Lightning CSS and addedgeneric-names. It was closed with a link to this comment, which treats the PostCSS case as a postcss-modules bug. This PR leaves PostCSS alone and adds no dependency. I didn't usecleanUrlbecause it drops the whole query:App.vue?vue&type=style&index=0&lang.module.cssandindex=1would both hash/App.vueand get the same names.#22957 (PostCSS with a string
generateScopedName) is not fixed here. Nuxt's?inline&usedisn't covered either, sinceusedis kept.Framework-free repro: https://github.com/everton-dgn/vite-lightningcss-inline-repro.
pnpm install && pnpm checkfails on Vite 8.3.4 and passes against a local build with this patch.Validation:
pnpm run test-serve css: 147 passed, 42 skipped.pnpm run test-build css: 151 passed, 38 skipped.pnpm run test-serve-bundled css: 135 passed, 44 skipped, 10 todo.pnpm run typecheck, ESLint and Oxfmt passed. The full monorepo suite was not run locally.AI disclosure: AI tools were used to investigate the bug, write the patch and tests, and draft this description. I reviewed every change in the diff and ran the checks listed above.