You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A compiled (compilePackages) CommonJS module that exports a class via module.exports = SomeClass loses the class's entire method table — both static methods and prototype (instance) methods come back undefined. The class is importable and callable as a constructor, but it's effectively bare.
Concretely with stack-utils@2.x (a transitive dep of ink via <ErrorOverview>):
importStackUtilsfrom'stack-utils';console.log(typeofStackUtils);// 'function' ✓console.log(typeofStackUtils.nodeInternals);// 'undefined' ✗ (static method)console.log(typeofStackUtils.prototype?.clean);// 'undefined' ✗ (instance/prototype method)newStackUtils();// TypeError: undefined is not iterable
Node prints function / function / function, and new StackUtils() succeeds.
stack-utils/index.js is a textbook shape:
classStackUtils{constructor(opts){
...
if('internals'inopts===false){opts.internals=StackUtils.nodeInternals();// ← static call from ctor}
...
}staticnodeInternals(){return[...natives];}clean(stack,indent=0){ ... }// ...more instance methods...}module.exports=StackUtils;// line 344 — CJS default-export of the class
Because StackUtils.nodeInternals is undefined, the constructor's internal call collapses to spreading undefined, surfacing as TypeError: undefined is not iterable during new StackUtils().
This is the ink wall immediately after the react-reconciler SIGBUS fix (#4902). Module-init eval-order tracing through ink stops at ink/build/components/ErrorOverview.js, whose top level runs:
The breakage is method access on the class object (both Ctor.staticFn and Ctor.prototype.method read back undefined), not the constructor itself — new runs the ctor body. So the class's static + prototype method tables aren't attached to the object that module.exports = Ctor publishes.
Likely specific to the CJS module.exports = <class> export path (the class is defined at top level, exported at the bottom). Worth checking whether the exported binding is a re-wrapped/forwarded copy of the class that drops its method side-tables, vs. the original class identity.
Any compilePackages CJS module doing module.exports = class { … } and relying on its methods. stack-utils is the immediate one; the pattern is extremely common.
Summary
A compiled (
compilePackages) CommonJS module that exports a class viamodule.exports = SomeClassloses the class's entire method table — bothstaticmethods andprototype(instance) methods come backundefined. The class is importable and callable as a constructor, but it's effectively bare.Concretely with
stack-utils@2.x(a transitive dep of ink via<ErrorOverview>):Node prints
function / function / function, andnew StackUtils()succeeds.stack-utils/index.jsis a textbook shape:Because
StackUtils.nodeInternalsisundefined, the constructor's internal call collapses to spreadingundefined, surfacing asTypeError: undefined is not iterableduringnew StackUtils().How it surfaced (ink end-to-end, #348)
This is the ink wall immediately after the react-reconciler SIGBUS fix (#4902). Module-init eval-order tracing through ink stops at
ink/build/components/ErrorOverview.js, whose top level runs:→
undefined is not iterable, before any user code. So importinginkthrows at init.Minimal repro environment
stack-utils@2.x, incompilePackages+allow.compilePackages: ["*"],PERRY_TREE_SHAKE=1,perry.defineNODE_ENV=production. No correctness escape hatches.Scope / suggested triage
Ctor.staticFnandCtor.prototype.methodread backundefined), not the constructor itself —newruns the ctor body. So the class's static + prototype method tables aren't attached to the object thatmodule.exports = Ctorpublishes.module.exports = <class>export path (the class is defined at top level, exported at the bottom). Worth checking whether the exported binding is a re-wrapped/forwarded copy of the class that drops its method side-tables, vs. the original class identity.typeof … === 'undefined'), not merely non-dispatching, and statics are affected too.Impact
compilePackagesCJS module doingmodule.exports = class { … }and relying on its methods.stack-utilsis the immediate one; the pattern is extremely common.ink(React-based TUI framework) end-to-end viaperry.compilePackages#348): this blocksimport 'ink'at init via<ErrorOverview>. After it, ink's next gate is yoga-layout's WASM runtime (out-of-scope).Related
ink(React-based TUI framework) end-to-end viaperry.compilePackages#348 (ink end-to-end — where this surfaced)