withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
46.83k stars 2.49k forks source link

v5 beta `render()` leaks imported CSS files #12062

Closed OverflowCat closed 1 month ago

OverflowCat commented 1 month ago

Astro Info

Astro                    v5.0.0-beta.1
Node                     v18.20.3
System                   Linux (x64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             @astrojs/mdx

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

  1. Use Content Layer and render in 'astro:content' to render page
  2. Visit any page, looks good
  3. Write a CSS file xxx.css (In the MRE we write * { color: red})
  4. import 'xxx.css' in an MDX file, or its layout. In the MRE I put import '../styles/test.css'; in using-mdx.mdx
  5. Visit the page, here blog/using-mdx
  6. Visit another page, found CSS leaking

https://github.com/user-attachments/assets/f5d04521-be22-4ec1-8f65-f5fccfd12794

What's the expected result?

Imported CSS not leaking into other pages

Link to Minimal Reproducible Example

https://stackblitz.com/edit/astro-leaky-css?file=src%2Fblog%2Fusing-mdx.mdx

Participation

matthewp commented 1 month ago

Thanks, this is known and will be fixed by https://github.com/withastro/astro/pull/11976

ascorbic commented 1 month ago

This should actually fixed by #12014, which is in beta-2. Could you upgrade and see if it's working?

OverflowCat commented 1 month ago

@ascorbic Just upgraded and looks like the CSS leak is sorted now 🚀 Thanks for the fix.

I'm going to stick with collections for now, though, as I found layout support in Markdown still isn’t there yet 😅