fix(css): rewrite root-relative dev CSS sourcemap sources (fixes #23195) - #23205
Open
santhiprakash wants to merge 1 commit into
Open
fix(css): rewrite root-relative dev CSS sourcemap sources (fixes #23195)#23205santhiprakash wants to merge 1 commit into
santhiprakash wants to merge 1 commit into
Conversation
- Problem: lightningcss URL-served CSS maps kept project-root-relative `sources` entries; transformRequest only rebased absolute paths. - Fix: resolve non-absolute sources against the module dir or project root, then emit paths relative to the served CSS file URL. - Verification: pnpm run test-serve sources-resolution.spec (2 passed).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With
css.devSourcemap: trueandcss.transformer: 'lightningcss', URL-served CSS sourcemaps keepsourcesentries relative to the project root (e.g.nested/dir/dep.css). The map is resolved against the CSS file URL, so those names double the path (/nested/dir/nested/dir/dep.css). Postcss URL-served maps were already correct because absolute sources get rebased intransformRequest.Fixes #23195 (Shape 3).
Triage / Root cause
transformRequestrebases sourcemapsourcesto paths relative to the served module file, but only whenpath.isAbsolute(sourcePath). Lightningcss emits root-relative names that slip through unchanged.Fix
sourcesagainst the module directory or project root (whichever yields a valid relative path), then emit paths relative to the served file URL.Verification
pnpm run test-serve sources-resolution.spec— 2 passedpnpm exec vitest run src/node/server/__tests__/transformRequest.spec.ts— 4 passedNotes / Risks
sourcesare written against the wrong base #23195) still need separate work in the CSS plugin path.