-
Notifications
You must be signed in to change notification settings - Fork 137
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
Unable to "un-extern" native node modules from renderer #61
Comments
By default,
I don't know if these can help. |
About It would be nice to be able to disable the default externing of node builtins in renderer. Currently I solved it by applying a patch as part of yarn install: package.json "resolutions": {
"electron-vite": "patch:electron-vite@1.0.14#.yarn/patches/electron-vite-1.0.14.patch"
}, .yarn/patches/electron-vite-1.0.14.patch diff --git a/dist/chunks/lib-d0e65f8e.js b/dist/chunks/lib-d0e65f8e.js
index e0211a8ce..f2bdc0c14 100644
--- a/dist/chunks/lib-d0e65f8e.js
+++ b/dist/chunks/lib-d0e65f8e.js
@@ -361,1 +361,1 @@
- external: [...node_module.builtinModules.flatMap(m => [m, `node:${m}`])]
+ // external: [...node_module.builtinModules.flatMap(m => [m, `node:${m}`])]
|
@ykrasik Thanks. I didn't understand your idea correctly. This requirement seems reasonable, I will fix it. |
new ver 1.0.15 is out! |
Describe the bug
I'm porting a project from webpack to
electron-vite
. Webpack was previously bundling this as an IIFE.I ran into a case where one of my dependencies used in the renderer, not sure which one, was using the "utils" nodejs module transitively. I think it was pulling "utils" in through make-error-cause.
This would result in the following error from renderer, even though
nodeIntegration: true
andcontextIsolation: false
:index.html:1 Uncaught TypeError: Failed to resolve module specifier "util". Relative references must start with either "/", "./", or "../".
I don't understand why this was happening, as from what I understand, turning on
nodeIntegration: true
should've given renderer access to "utils". Or was webpack bundling "utils" in the renderer before? Anyway, as I couldn't find a solution, I decided to polyfill it instead. What I found out is - you can't polyfill any node native modules, because they are marked as externals.I was trying to polyfill them through an alias:
Also, the following had no effect - I was unable to override the default
extern
config for rollup:I think that having an ability to un-extern node native modules, or replace the extern block with a function, is useful and currently missing.
P.S. If you could explain why this error appears with
vite-electron
but not withwebpack
, that would help a lot.Electron-Vite Version
1.0.14
Electron Version
21.2.2
Vite Version
3.2.4
Validations
The text was updated successfully, but these errors were encountered: