-
-
Notifications
You must be signed in to change notification settings - Fork 228
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
vite-plugin-node-polyfills breaks the compilation #931
Comments
In v0.19.1, I polyfilled browser globals when loading entrypoints in Node to get their options.
Specifically, setting a global Commenting out the I could use I tried messing around and doing things like setting a custom For now, while I figure out a solution I'd recommend patching WXT (pnpm or return {
...global,
window,
- document,
+ // This document is not compatible with vite-plugin-node-polyfill. Removing this means we can't use document outside the main function of entrypoints
+ // See https://github.com/wxt-dev/wxt/issues/931
+ // document,
self: global
}; |
@aklinker1 I guess this error is reading the cjs file and hitting the polyfill in |
@1natsu172 No, this error is caused by As for why it's resolving to CJS... Because we're using |
Yes, that understood, I was just saying that if I had loaded the ESM, it would not be an error only for this plugin. (Of course, that's still not the fundamental solution.)
OK, let's have a conversation about ESM load in #297 😃 |
I think this is the reason why #533 fails. I wonder if happy-dom would work. |
Another issue caused by this... #1227. I need to refactor when the browser environment is polyfilled so loading config like this isn't effected. |
I re-tested the reproduction with #1207, which fixes it. Will merge and release soon. |
Released in |
Describe the bug
I'm importing the
vite-plugin-node-polyfills
plugin in my project because I need some polyfills (Buffer, ...).Starting from
[email protected]
, adding the plugin breaks the compilation (both usingdev
andbuild
commands) with a unclear error:Reverting back to the
0.19.0
version removes the issue.Reproduction
This repo highlight the issue : https://github.com/stevebeauge/error-polyfill
Steps to reproduce
System Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: