Astro Info
Astro v4.0.7
Node v18.18.0
System Linux (x64)
Package Manager npm
Output static
Adapter none
Integrations none
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
lazy loading styles using dynamic import() like this does not work:
async function loadCss() {
await import("../styles.css");
}
the styles will get loaded even before the function is called.
same scenario works correctly in vite: https://stackblitz.com/edit/vitejs-vite-u5qhnz?file=index.html,styles.css&terminal=dev
possibly related issue: #6328
What's the expected result?
styles should only be imported after the code is actually called.
one important detail: in my case, the import() is only used in a client-side script, so astro should never inline it, only bundle it.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/withastro-astro-xmc34j
Participation
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
lazy loading styles using dynamic
import()like this does not work:the styles will get loaded even before the function is called.
same scenario works correctly in vite: https://stackblitz.com/edit/vitejs-vite-u5qhnz?file=index.html,styles.css&terminal=dev
possibly related issue: #6328
What's the expected result?
styles should only be imported after the code is actually called.
one important detail: in my case, the
import()is only used in a client-side script, so astro should never inline it, only bundle it.Link to Minimal Reproducible Example
https://stackblitz.com/edit/withastro-astro-xmc34j
Participation