mirror of
https://github.com/abue-ammar/tinycast.git
synced 2026-10-02 08:14:38 +08:00
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