Skip to content

fix: don't inject CSS sourcemap for direct requests#13115

Merged
patak-cat merged 4 commits intomainfrom
fix-css-sourcemap-linked
May 15, 2023
Merged

fix: don't inject CSS sourcemap for direct requests#13115
patak-cat merged 4 commits intomainfrom
fix-css-sourcemap-linked

Conversation

@ArnaudBarre
Copy link
Copy Markdown
Member

@ArnaudBarre ArnaudBarre commented May 7, 2023

Introduced in #8094

You can this this kind of output in the css-sourcemap playground
Screenshot 2023-05-07 at 21 54 38

The default linked.css should not have sourcemap because there is no transformation happening, but the one with import gets correct source map

I don't know exactly why, but the plugin container will inject sourcemap in the case of direct request but not proxy request.

@ArnaudBarre ArnaudBarre added the p3-minor-bug An edge case that only affects very specific usage (priority) label May 7, 2023
@ArnaudBarre ArnaudBarre requested a review from sapphi-red May 7, 2023 19:57
@ArnaudBarre ArnaudBarre self-assigned this May 7, 2023
@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Comment thread playground/css-sourcemap/__tests__/css-sourcemap.spec.ts Outdated
Comment thread packages/vite/src/node/plugins/css.ts Outdated

if (isDirectCSSRequest(id)) {
return await getContentWithSourcemap(css)
return htmlProxyRE.test(id) ? await getContentWithSourcemap(css) : css
Copy link
Copy Markdown
Member

@sapphi-red sapphi-red May 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should generate the sourcemap in the htmlInlineProxyPlugin.


Then, we can just run return null in this line I guess. (The plugin container will add the sourcemap if needed)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to understand. I've read part of the code of the plugin and I don't understand where is the pipeline called. I've the impression that the cache map is set with the tag content directly without transformation and then on this line we return this content

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, my bad. I was misunderstanding the code. I pushed the code I had in my mind.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok I didn't saw that call to the pluginContainer and just saw the load part.
I have no opinion on where this code 🤷‍♂️

@sapphi-red
Copy link
Copy Markdown
Member

/ecosystem-ci run

@vite-ecosystem-ci
Copy link
Copy Markdown

vite-ecosystem-ci bot commented May 13, 2023

📝 Ran ecosystem CI: Open

suite result
astro ✅ success
histoire ✅ success
iles ✅ success
ladle ✅ success
laravel ✅ success
marko ✅ success
nuxt ❌ failure
previewjs ✅ success
qwik ✅ success
rakkas ✅ success
sveltekit ✅ success
unocss ✅ success
vite-plugin-ssr ✅ success
vite-plugin-react ✅ success
vite-plugin-react-pages ✅ success
vite-plugin-react-swc ✅ success
vite-plugin-svelte ✅ success
vite-plugin-vue ✅ success
vite-setup-catalogue ✅ success
vitepress ✅ success
vitest ✅ success

@sapphi-red
Copy link
Copy Markdown
Member

nuxt is failing with main branch too 👍

@patak-cat
Copy link
Copy Markdown
Member

For reference, @danielroe said the issue in Nuxt is happening due to a new test they updated. We already did a Vite patch with this issue present. Let's merge this PR too for the next patch.

@patak-cat patak-cat merged commit 7d80a47 into main May 15, 2023
@patak-cat patak-cat deleted the fix-css-sourcemap-linked branch May 15, 2023 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: css p3-minor-bug An edge case that only affects very specific usage (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants