Closed navan101 closed 1 year ago
@navan101 this is fixed in v0.11.0
.
Hi @davidmyersdev,
I seem to have the same kind of problem, even with version 0.11.0.
require('buffer')
gives undefined so kMaxLength.toString(16)
is impossible.
I'm in the same situation as @navan101, I have the default configuration and the build passes but the dev environment gives me this error.
Is this something you can fix on your end?
Hi @davidmyersdev,
I seem to have the same kind of problem, even with version 0.11.0.
require('buffer')
gives undefined sokMaxLength.toString(16)
is impossible.I'm in the same situation as @navan101, I have the default configuration and the build passes but the dev environment gives me this error.
Is this something you can fix on your end?
I have the same issue
@rfe-sdev @VysockyStan @navan101 can any of you confirm whether this is working properly in v0.11.1
? Also, are you all using require
rather than import
? This could be an issue with the CommonJS build if so.
Same issue here with "vite-plugin-node-polyfills": "^0.11.1"
@davidmyersdev I've tried 0.11.1. The issue persists. It occurs in 3rd-party lib which which uses browserify-zlib as on the screen that @rfe-sdev posted above. As you may see it uses require. So there is no chance to make it work with CommonJS ?
But the difference that in my case Buffer is not undefined, however kMaxLength is
I may have opened a dupe of this issue, https://github.com/davidmyersdev/vite-plugin-node-polyfills/issues/34. I also created a reproduction repo to help with debugging.
I'm using https://www.npmjs.com/package/@ringcentral/sdk in React, which produces the error
I've noticed that when removing the import that needs Buffer
, the app does run fine, and Buffer
is defined in the browser's console. This leads me to believe that perhaps there's something about the plugin that causes the polyfills to be loaded too late?
@aryzing that does appear to be the case. I think the code that is erroring is actually a side effect that runs during the import process (before the polyfill code gets a chance to run). I'm trying to figure out a way to get this working though.
I was able to verify that both reproductions (thank you to @navan101 and @aryzing for providing them) have been fixed in v0.11.2
.
So some good news, and some bad news. Good news: for smaller projects, v0.11.2
does work. The bad news is that for a larger project I'm working on, this plugin is causing the build to fail with a heap limit error,
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
Possibly useful info:
vite-plugin-web-extension
.I've created a new reproduction repo using this plugin on a large codebase which displays the error above during the build.
@aryzing would you mind opening a new issue for this?
Hi @davidmyersdev,
link: [https://codesandbox.io/p/github/navan101/vite-buffer/master?file=/src/App.vue:1,1&workspaceId=89d4ce07-40e9-48ee-965a-5e9183e6320b]
Thank you!