Comments (14)
I was able to verify that both reproductions (thank you to @navan101 and @aryzing for providing them) have been fixed in v0.11.2
.
from vite-plugin-node-polyfills.
@aryzing would you mind opening a new issue for this?
from vite-plugin-node-polyfills.
@navan101 this is fixed in v0.11.0
.
from vite-plugin-node-polyfills.
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?
from vite-plugin-node-polyfills.
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
from vite-plugin-node-polyfills.
@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.
from vite-plugin-node-polyfills.
Same issue here with "vite-plugin-node-polyfills": "^0.11.1"
from vite-plugin-node-polyfills.
@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 ?
from vite-plugin-node-polyfills.
But the difference that in my case Buffer is not undefined, however kMaxLength is
from vite-plugin-node-polyfills.
I may have opened a dupe of this issue, #34. I also created a reproduction repo to help with debugging.
from vite-plugin-node-polyfills.
I'm using https://www.npmjs.com/package/@ringcentral/sdk in React, which produces the error
from vite-plugin-node-polyfills.
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?
from vite-plugin-node-polyfills.
@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.
from vite-plugin-node-polyfills.
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
Stack trace
1: 0xc98550 node::Abort() [/home/user/.nvm/versions/node/v20.5.1/bin/node]
2: 0xb700a7 [/home/user/.nvm/versions/node/v20.5.1/bin/node]
3: 0xebae80 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/home/user/.nvm/versions/node/v20.5.1/bin/node]
4: 0xebb167 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/home/user/.nvm/versions/node/v20.5.1/bin/node]
5: 0x10cc7d5 [/home/user/.nvm/versions/node/v20.5.1/bin/node]
6: 0x10e4658 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/home/user/.nvm/versions/node/v20.5.1/bin/node]
7: 0x10ba771 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/home/user/.nvm/versions/node/v20.5.1/bin/node]
8: 0x10bb905 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/home/user/.nvm/versions/node/v20.5.1/bin/node]
9: 0x1098e76 v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/home/user/.nvm/versions/node/v20.5.1/bin/node]
10: 0x14f3ca6 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/home/user/.nvm/versions/node/v20.5.1/bin/node]
11: 0x7f93f7ed9ef6
Aborted (core dumped)
Possibly useful info:
- As modules get processed, the speed at which they get processed decreases.
- With Node v18 Vite processes ~750 modules before crashing, with Node v20 closer to ~1100
- I'm developing a web extension, which requires assets to be written to disk even in dev mode. This is done via
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.
from vite-plugin-node-polyfills.
Related Issues (20)
- Missing "./shims/global" specifier HOT 4
- TypeError: net.createConnection is not a function HOT 7
- When vite define contains process.env: xx, process polyfill will fail HOT 1
- Migrate to `unenv`
- Release `v1.0.0`
- Cannot find module 'vite-plugin-node-polyfills/shims/buffer' HOT 9
- Missing kMaxLength and SlowBuffer exposure HOT 1
- toString error with zlib starting with 0.18.0 HOT 2
- Failed to resolve module specifier "vite-plugin-node-polyfills/shims/global". Relative references must start with either "/", "./", or "../". HOT 3
- Failed to resolve import "vite-plugin-node-polyfills/shims/buffer" HOT 6
- Error when having type: module in package.json HOT 1
- `process` is not polyfilled if `viteConfig.define` is used to define, for example, a static environment variable in the form of `process.env.var_name` HOT 2
- Cannot access "fs/promises.readFile" in client code.
- bug: config `include: [],` treated as `no option is passed`
- Globals are always defined HOT 1
- Bug: conflict with another middleware plugin HOT 3
- Bug: PassThrough is not exported by "__vite-browser-external" during build HOT 1
- Bug: exports is not defined HOT 2
- Bug: importing 'crypto' polyfill leads to error `exports is not defined` with yarn build && yarn preview in nuxt HOT 2
- Bug: `node:assert/strict` is not polyfilled
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vite-plugin-node-polyfills.