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

Compiling MDsveX file with the content "import.meta.env" in SvelteKit fails the build #413

Closed
danawoodman opened this issue Jan 31, 2022 · 2 comments

Comments

@danawoodman
Copy link

danawoodman commented Jan 31, 2022

I've come across a strange bug with MDsveX (0.10.5) and SvelteKit (1.0.0-next.249).

If you create a MDsveX file with the string import.meta.env, then the command npm run build fails with:

[rollup-plugin-dynamic-import-variables] Unexpected token (37:15)
file: /Users/danawoodman/code/danawoodman.com/src/routes/using-environment-variables-in-sveltekit-and-vite.svx:37:15

import.meta.env is a global in Vite that you can use to grab out environment variables and I happened to write a blog post on that subject but if the content mentions import.meta.env anywhere the build fails. If I remove it, it works fine.

For example, try to compile this file with the latest version of SvelteKit and MDsveX (use npm init svelte@next then npx svelte-add mdsvex):

---
title: Foo
---

Let's talk about `import.meta.env` in Vite!

Then try to build with npm run build.

I'm reporting here but let me know if this makes more sense in one of the other repos instead.

@dimfeld
Copy link

dimfeld commented Feb 3, 2022

Looks like this is a Vite issue: vitejs/vite#3304

@danawoodman
Copy link
Author

You're totally right. Closing

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

No branches or pull requests

2 participants