compiler
compiler copied to clipboard
🐛 BUG: astro complains about missing import on start
What version of @astrojs/compiler
are you using?
2.7.0
What package manager are you using?
npm
What operating system are you using?
mac
Describe the Bug
If I use astro's <Code>
component in a page for vue code, and the vue code contains an import
statement, astro thinks it's an actual import statement.
<Code
lang="vue"
code={`
<script setup>
import 'something';
</script>
<template>
<calendar-range :months="2">
<calendar-month />
<calendar-month :offset="1" />
</calendar-range>
</template>
`.trim()}
/>
i get the following error in the console on start:
16:59:37 [ERROR] [vite] Error: The following dependencies are imported but could not be resolved:
something (imported by /home/projects/astro-import-inside-code-string-repro/src/pages/index.astro?id=0)
Are they installed?
at eval (/home/projects/astro-import-inside-code-string-repro/node_modules/vite/dist/node/chunks/dep-BBHrJRja.js:52555:23)
at async eval (/home/projects/astro-import-inside-code-string-repro/node_modules/vite/dist/node/chunks/dep-BBHrJRja.js:52021:38)
I suspect this is caused by the <script>
tag in the code
string, more than the lang being vue. but of course in vue components, script tags are common
Link to Minimal Reproducible Example
https://stackblitz.com/edit/astro-import-inside-code-string-repro?file=src%2Fpages%2Findex.astro%3AL16