Giter VIP home page Giter VIP logo

Comments (14)

davidmyersdev avatar davidmyersdev commented on June 4, 2024 1

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.

davidmyersdev avatar davidmyersdev commented on June 4, 2024 1

@aryzing would you mind opening a new issue for this?

from vite-plugin-node-polyfills.

davidmyersdev avatar davidmyersdev commented on June 4, 2024

@navan101 this is fixed in v0.11.0.

from vite-plugin-node-polyfills.

rfe-sdev avatar rfe-sdev commented on June 4, 2024

Hi @davidmyersdev,

I seem to have the same kind of problem, even with version 0.11.0.

Capture d’écran 2023-08-08 à 16 55 58

Capture d’écran 2023-08-08 à 16 56 40

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.

VysockyStan avatar VysockyStan commented on June 4, 2024

Hi @davidmyersdev,

I seem to have the same kind of problem, even with version 0.11.0.

Capture d’écran 2023-08-08 à 16 55 58

Capture d’écran 2023-08-08 à 16 56 40

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?

I have the same issue

from vite-plugin-node-polyfills.

davidmyersdev avatar davidmyersdev commented on June 4, 2024

@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.

JounQin avatar JounQin commented on June 4, 2024
image image

Same issue here with "vite-plugin-node-polyfills": "^0.11.1"

from vite-plugin-node-polyfills.

VysockyStan avatar VysockyStan commented on June 4, 2024

@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.

VysockyStan avatar VysockyStan commented on June 4, 2024

But the difference that in my case Buffer is not undefined, however kMaxLength is

from vite-plugin-node-polyfills.

aryzing avatar aryzing commented on June 4, 2024

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.

VysockyStan avatar VysockyStan commented on June 4, 2024

I'm using https://www.npmjs.com/package/@ringcentral/sdk in React, which produces the error

from vite-plugin-node-polyfills.

aryzing avatar aryzing commented on June 4, 2024

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.

davidmyersdev avatar davidmyersdev commented on June 4, 2024

@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.

aryzing avatar aryzing commented on June 4, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.