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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG: @astrojs/compiler panic when import.meta.env is called before other imports #508

Closed
1 task
sanskar-mk2 opened this issue Aug 31, 2022 · 1 comment · Fixed by #527
Closed
1 task

Comments

@sanskar-mk2
Copy link

sanskar-mk2 commented Aug 31, 2022

What version of astro are you using?

latest stable

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Windows

Describe the Bug

@astrojs/compiler encountered an unrecoverable error when compiling the following file.

C:/Users/sohma_w4/bug-reproduce/src/pages/index.astro

---
console.log(import.meta.env.FOO);
import Test from "../components/Test.astro";
---

<html lang="en">
    <head>
        <meta charset="utf-8" />
        <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
        <meta name="viewport" content="width=device-width" />
        <meta name="generator" content={Astro.generator} />
        <title>Astro</title>
    </head>
    <body>
        <Test />
        <h1>Astro</h1>
    </body>
</html>

When using import.meta.env. It must always be the last import, otherwise the compiler panics.

Link to Minimal Reproducible Example

https://github.com/sanskar-mk2/bug-reproduce

Participation

  • I am willing to submit a pull request for this issue.
@sanskar-mk2 sanskar-mk2 changed the title 🐛 BUG: @astrojs/compiler panic when import.meta.env is imported before other import 🐛 BUG: @astrojs/compiler panic when import.meta.env is called before other imports Sep 1, 2022
@matthewp matthewp transferred this issue from withastro/astro Sep 1, 2022
natemoo-re added a commit that referenced this issue Sep 28, 2022
natemoo-re added a commit that referenced this issue Sep 28, 2022
* fix(#508): handle import.meta

* chore: add changeset

Co-authored-by: Nate Moore <[email protected]>
@sanskar-mk2
Copy link
Author

🚮 Deleted the MRE repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant