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

Vercel Edge adapter: "process.env.NODE_ENV" in markdown files breaks build #7149

Closed
1 task
pilcrowOnPaper opened this issue May 20, 2023 · 2 comments · Fixed by #7257
Closed
1 task

Vercel Edge adapter: "process.env.NODE_ENV" in markdown files breaks build #7149

pilcrowOnPaper opened this issue May 20, 2023 · 2 comments · Fixed by #7257
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)

Comments

@pilcrowOnPaper
Copy link
Contributor

pilcrowOnPaper commented May 20, 2023

What version of astro are you using?

2.5.0

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

Vercel (Edge)

What package manager are you using?

pnpm

What operating system are you using?

Mac

What browser are you using?

N/A

Describe the Bug

Astros + Vercel Edge adapter fails to build when a markdown includes "process.env.NODE_ENV", but only if it's mid-string. It's specific to "process.env.NODE_ENV"; "process.env" or "process.env.ANY_OTHER_STRING" doesn't have any issues. No issues with the severless adapter as well.

Breaks:

// process.env.NODE_ENV
fn(process.env.NODE_ENV)
`process.env.NODE_ENV`

Doesn't break:

process.env.NODE_ENV
process.env.FOO

Link to Minimal Reproducible Example

https://github.com/pilcrowOnPaper/astro-markdown-edge

Participation

  • I am willing to submit a pull request for this issue.
@bluwy
Copy link
Member

bluwy commented May 23, 2023

We could probably do something like this to fix it, currently we're only handling import.meta.env.*.

const code = escapeViteEnvReferences(`

It also a Vite issue though because it only replaces things statically: vitejs/vite#9829

@bluwy bluwy added the - P3: minor bug An edge case that only affects very specific usage (priority) label May 23, 2023
@mrthiti
Copy link
Contributor

mrthiti commented May 31, 2023

I'm facing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants