Files
tinycast/Scripts
Federico Zivolo 9c4755f2c2 Keep node shim exports alive through esbuild's __toESM (#1038)
The lazy-stub Proxy behind every resolve-but-refuse module has a `get` trap
and nothing else. esbuild's `__toESM` never gets a property: it snapshots
`Object.getOwnPropertyNames(mod)` and copies those, so with no `ownKeys` trap
the own keys fall through to the literal target and every manufactured member
is dropped. That is what every namespace or named import compiles to, so the
intended "… is not supported in Tinycast extensions" refusal never fires.
What the extension sees instead is `undefined`, and a `class X extends
<undefined>` turns that into `TypeError: The superclass is not a constructor`
at import time, in a stack that is all `__commonJS` frames and names nothing.

Give the Proxy `ownKeys` and `getOwnPropertyDescriptor`, backed by Node's own
function-valued export names per module. Constants stay out: a member made
here is always a throwing callable, which is the wrong value for one. `http`,
`https` and `stream` stay out too — they are partially supported, their real
classes are already own properties, and phantom keys would flip a working
`typeof stream.isReadable === "function"` fallback into a throw.

`async_hooks` was a plain object literal rather than one of these proxies, so
`AsyncResource` was undefined outright and undici's `class … extends
AsyncResource` produced the same error with no message at all. It gets a real
one — a single synchronous context means the scope is just the call.

Closes #852
2026-09-23 03:22:41 +06:00
..
2026-08-14 20:35:26 +06:00
2026-09-23 02:39:54 +06:00
2026-08-09 00:38:33 +06:00