question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

rollup: PARSE_ERROR when code contains "process.env ="

See original GitHub issue

Describe the bug

The error caused by phaser library . And then I found: if the code contains process.env=<any> and run vite build, it will raise a rollup parserError.

Reproduction

Write process.env={} any where and run vite build.

System Info

  • required vite version: 1.0.0-rc.4
  • required Operating System: MacOS 10.15.7
  • required Node version: 14.7.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
hyriouscommented, Jan 17, 2021

@hyrious I’d be interested on how to “apply the hack on every post install”. My machine I can open up the node_modules and remove the line, but the build machines won’t work that way. This webpack world is not something I am very knowledgeable on as far as my options.

This is quite easy, you can come up with a hack.ts: https://gist.github.com/hyrious/6817207816032d532a10e53e4c3daac8

Then in package.json:

"postinstall": "ts-node -O \"{\\\"module\\\":\\\"commonjs\\\"}\" hack.ts",

BTW, I’ve tried mermaid in vite2, it seems there’s no such issue at all.

1reaction
jbjorgecommented, Oct 21, 2020

It would be great if we could figure out a workaround together. It might seem like process.env = {} is a byproduct from webpack (or whichever bundler the library creators use) making builds runnable in the browser.

In my project

▶ grep -iRl "process.env = {}" ./node_modules | wc -l
17 (packages)

In the source of one of the dependencies that contain it

▶ grep -iRl "process.env = {}" ./node_modules | wc -l
35 (packages)

I suspect we would need to ask a lot of maintainers to change their builds if we want to get rid of this error without using a workaround.

Read more comments on GitHub >

github_iconTop Results From Across the Web

rollup-plugin-inject-process-env - npm
Inject environment variables in process.env with Rollup. ... TypeScript icon, indicating that this package has built-in type declarations.
Read more >
Build Setup Recipes
You can use an environment variable like process.env. ... Of course, make sure to have the relevant dependencies like `rollup-plugin-babel @babel/core` and ...
Read more >
Environment variables in svelte + rollup - Stack Overflow
You can inject build time constants in compiled code with @rollup/plugin-replace. Something like this: rollup.config.js
Read more >
VMware SD-WAN 4.3.1 Release Notes
Orchestrator rollup build R431-20220429-GA includes fixed issues #84152 ... includes this fix has enhanced path information processing code ...
Read more >
How to Set Up Environment Variables using JSON files with ...
Installing Rollup Plugins. Since the Single-page application considers Rollup.js as the module bundler, we'll need to install a couple of node ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found