Closed learntheropes closed 6 months ago
Hey there, @learntheropes. π It looks like this is due to the global process
object being polyfilled. You can use the globals
config option to disable it, and that appears to fix the issue as far as I can tell. Here is what that looks like in your config.
import { nodePolyfills } from 'vite-plugin-node-polyfills'
export default defineNuxtConfig({
vite: {
plugins: [
nodePolyfills({
include: ['buffer', 'util', 'stream', 'crypto'],
globals: {
process: false,
},
}),
],
},
})
For what it's worth, this is likely something that should be handled automatically when the include
and exclude
options are used, but that is not how they are currently implemented. I'll leave this issue open to track that enhancement.
Thank you, @davidmyersdev ! I confirm that this fixed the issue on my project.
Thank you as well. Without this issue, what was going on would never have occurred to me. I would probably add a small note about this to README.md, so others know.
globals: { process: false, },
Doesn't seem like a solution. I am trying to polyfill process, any ideas?
@lokinz can you share an example with your use case?
This has been fixed by #63 and is available in v0.18.0
.
Hi @davidmyersdev
The new version v0.18.0
seems like a regression since now I cannot even run the nuxt dev server unless I disable the global process option.
globals: { process: false, },
Doesn't seem like a solution. I am trying to polyfill process, any ideas?
As pointed out by @lokinz, not polyfilling the process global in build mode did not seem right to me since that is exactly what I need the plugin to do and I was hoping that the new version fixed it.
My use case:
nuxt
+ web3auth/modal
library
This library needs pollyfils as explained here.
Version 0.17.0
of this plugin was allowing me to run at least the dev server but was failing in build mode as explained in this thread.
Latest version now breaks both dev and build modes throwing:
dev: Missing "./shims/process/" specifier in "vite-plugin-node-polyfills" package [plugin vite:dep-pre-bundle]
build: Nuxt Build Error: Missing "./shims/process/" specifier in "vite-plugin-node-polyfills" package
Here is a reproduction
Any help will be appreciated and thanks for the plugin!! π
I really appreciate the reproduction, @paro-paro! It looks like a dependency is trying to import process/
(with a trailing /
) rather than process
which leads to the error you're seeing. Would you mind opening another issue for this? I will get a fix together soon.
Thanks a lot for your quick response @davidmyersdev ! π
Opening a new issue for tracking...
Environment
Build Modules: -
Reproduction
https://github.com/learntheropes/github-anc6tm
https://stackblitz.com/edit/github-anc6tm But you need to build it.
Describe the bug
In a Nuxt 3 application,
vite.config.js
is replaced innuxt.config.js
as follows.However, the plguin breaks
nuxi build
as follows :Accordingly to Nuxt devs, is a plugin issue: https://github.com/nuxt/nuxt/issues/23091#issuecomment-1712098697