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
rollup: PARSE_ERROR when code contains "process.env =" #930
Comments
I'm not sure why you give a value to |
I didn't intend to do this but some libraries like |
It is very wirely for library if it change |
It would be great if we could figure out a workaround together. In my project
In the source of one of the dependencies that contain it
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. |
how about downloading from CDN and using it from a script tag... |
That's my current solution, but it can only be imported from a remote CDN. Vite will bundle all the js files, even if that's not the entry file. |
you can download from CDN and place it in the public folder... I think the bundler does not touch the things in there... |
Same problem when importing In the end I did a hack on node_modules/that_module and apply the hack on every "postinstall":
I don't think this issue could be resolved by vite -- it should be resolved by library authors :/ |
Probably caused by this process shim, which is used in webpack bundling: https://github.com/defunctzombie/node-process/blob/master/browser.js#L157 |
Same problem with using mermaid node_modules/mermaid/dist/mermaid.core.js
@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 Then in "postinstall": "ts-node -O \"{\\\"module\\\":\\\"commonjs\\\"}\" hack.ts", BTW, I've tried mermaid in vite2, it seems there's no such issue at all. |
Describe the bug
The error caused by
phaser
library . And then I found: if the code containsprocess.env=<any>
and runvite build
, it will raise a rollup parserError.Reproduction
Write
process.env={}
any where and runvite build
.System Info
vite
version: 1.0.0-rc.4The text was updated successfully, but these errors were encountered: