Support for Vite 4
Closed this issue · 5 comments
Now that Vite Version 4 was release (and is used by sveltekit and others), this plugin doesn't work anymore as it requires vite 2 or 3. Are there plans on upgrading support here?
➕1 on this question. Would love to use with Vite 4+.
adding this from pnpm install
command with vite 4
pnpm install
WARN Issues with peer dependencies found
.
└─┬ vite-plugin-node-stdlib-browser 0.1.1
├── ✕ unmet peer vite@"^2.0.0 || ^3.0.0": found 4.0.3
└─┬ @rollup/plugin-inject 4.0.4
├── ✕ missing peer rollup@"^1.20.0 || ^2.0.0"
└─┬ @rollup/pluginutils 3.1.0
└── ✕ missing peer rollup@^1.20.0||^2.0.0
Peer dependencies that should be installed:
rollup@">=1.20.0 <2.0.0 || >=2.0.0 <3.0.0"
pnpm run dev
VITE v4.0.3 ready in 320 ms
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h to show help
✘ [ERROR] The injected path "/Users/xxx/development/xxx/xxx-frontend/node_modules/.pnpm/node-stdlib-browser@1.2.0/node_modules/node-stdlib-browser/helpers/esbuild/shim.js" cannot be marked as external
Build failed with 1 error:
error: The injected path "/Users/xxx/development/xxx/xxx-frontend/node_modules/.pnpm/node-stdlib-browser@1.2.0/node_modules/node-stdlib-browser/helpers/esbuild/shim.js" cannot be marked as external
I have tried to look at this, but I don't understand how Vite passes option to EsBuild well enough to understand what exactly is going wrong here.
The error message is triggered by the 'inject' option:
esbuildOptions: {
inject: [require.resolve('node-stdlib-browser/helpers/esbuild/shim')],
Somehow, it seems like this library is being passed to, or interpreted by EsBuild in the 'external' option. I've tried explicitly setting the 'external' option explicitily empty. That did not seem to have any effect.
Digging a bit deeper, I notice that Vite's 'EsBuildOptions' is actually derived from 'TransformOptions' in ESBuild, not 'BuildOptions'. The 'inject' property only exists in 'BuildOptions' and not 'TransformOptions'
https://github.com/vitejs/vite/blob/4f7a48fc15086b97ea99668c9bfeece14b439eba/packages/vite/src/node/plugins/esbuild.ts#L36
+1
You can use this package instead: