Closed Kida007 closed 2 years ago
Hi, I would need a reproduction repo to debug this, but one guess i have is that the alias plugin wants the actual file as input, not the directory.
i see. thanks for the quickest reply possible. is there any other/better way to polyfill libraries ?
Try adding index.js
or whatever is relevant to the end. Think this is the way to go in general 👍
Tried adding the relevant entrypoints for each lib. unfortunately same error. even removing the alias completely . it gives me 2 error warnings ( could not resolve crypto, stream ....) , takes some time and then crash with same error. initially i thought it might be due to node 16 + m1 combination, but example app builds just fine.
Thanks for your help though mate, will try reproducing on new project.
Tried reproducing this on example project. added all the crytpo libs . but it bundles perfectly for me on example project. btw our project is part of big monorepo architecture, can this be related ?
Here are my new findings
a) I was able to successfully bundle when i took the application out of monorepo. hence it looks like a monorepo issue. not sure how to solve it
b) after installing react-native-quick-crypto a JSI based library . their is a runtime error maybe related to bundle. reproducible on example app as well.
E0829 17:50:10.347693 175337472 NativeToJsBridge.cpp:188] Attempting to call JS function on a bad application bundle: RCTDeviceEventEmitter.emit()
so found out because of the huge monorepo packages/deps, esbuild build step was kind of going OOM. hence i deleted some packages ( not related to the app ) and build the monorepo again. and then it bundled fine. will change the Issue Title for future reference and close it.
issue i still face
E0829 17:50:10.347693 175337472 NativeToJsBridge.cpp:188] Attempting to call JS function on a bad application bundle: RCTDeviceEventEmitter.emit()
setted up react-native-esbuild on our app and after proper configuration . it crashes with a fatal error while bundling or starting a dev server.
Here is the configuration:
Unfortunately i cannot create repro repo since this belong to an org. would really appreciate some pointers. here is The Error StackTrace:
Error / Crash Report
``` <--- Last few GCs ---> [54594:0x148008000] 25224 ms: Scavenge 4052.5 (4133.7) -> 4044.9 (4133.5) MB, 4.3 / 0.0 ms (average mu = 0.302, current mu = 0.256) allocation failure [54594:0x148008000] 25231 ms: Scavenge 4053.3 (4134.5) -> 4046.8 (4134.5) MB, 4.5 / 0.0 ms (average mu = 0.302, current mu = 0.256) allocation failure [54594:0x148008000] 26898 ms: Mark-sweep 4055.7 (4136.9) -> 4045.0 (4135.2) MB, 1662.1 / 0.0 ms (average mu = 0.213, current mu = 0.123) allocation failure scavenge might not succeed <--- JS stacktrace ---> FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 0x104d782dc node::Abort() [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 2: 0x104d78464 node::errors::TryCatchScope::~TryCatchScope() [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 3: 0x104ec7b90 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 4: 0x104ec7b24 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 5: 0x10504b23c v8::internal::Heap::GarbageCollectionReasonToString(v8::internal::GarbageCollectionReason) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 6: 0x10504e84c v8::internal::Heap::CollectSharedGarbage(v8::internal::GarbageCollectionReason) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 7: 0x10504ba04 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 8: 0x10504932c v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 9: 0x1050550a4 v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 10: 0x105055138 v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 11: 0x105027fcc v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 12: 0x1053600d0 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 13: 0x10567474c Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 14: 0x10a18905c 15: 0x10a18b2e0 16: 0x1056874c8 Builtins_ArrayForEach [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 17: 0x1056083d8 Builtins_InterpreterEntryTrampoline [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 18: 0x1056083d8 Builtins_InterpreterEntryTrampoline [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 19: 0x10a109698 20: 0x10a013164 21: 0x10a079464 22: 0x105639bac Builtins_GeneratorPrototypeNext [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 23: 0x109ed4acc 24: 0x105639bac Builtins_GeneratorPrototypeNext [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 25: 0x109e98294 26: 0x109ea0b7c 27: 0x109e99dd8 28: 0x109ea8f08 29: 0x109eb13ec 30: 0x109ea8228 31: 0x109e9861c 32: 0x109ea0b7c 33: 0x109e99dd8 34: 0x109ef40bc 35: 0x1056bc878 Builtins_PromiseFulfillReactionJob [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 36: 0x105629db4 Builtins_RunMicrotasks [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 37: 0x1056060a4 Builtins_JSRunMicrotasksEntry [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 38: 0x104fd79ec v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 39: 0x104fd7e20 v8::internal::(anonymous namespace)::InvokeWithTryCatch(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 40: 0x104fd7f0c v8::internal::Execution::TryRunMicrotasks(v8::internal::Isolate*, v8::internal::MicrotaskQueue*, v8::internal::MaybeHandle