Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 BUG: astro complains about missing import on start #989

Open
WickyNilliams opened this issue Mar 27, 2024 · 0 comments
Open

馃悰 BUG: astro complains about missing import on start #989

WickyNilliams opened this issue Mar 27, 2024 · 0 comments
Labels
needs triage Issue needs to be triaged

Comments

@WickyNilliams
Copy link

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

@github-actions github-actions bot added the needs triage Issue needs to be triaged label Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant