ensureDisposeSymbols
Makes Symbol.dispose and Symbol.asyncDispose exist, falling back to the registry symbols esbuild’s using helpers look up.
Serialized into the emitted banner. A disposable declares its method under the LITERAL key
[Symbol.dispose], while esbuild lowers everyusingto a lookup through__knownSymbol('dispose'), which falls back toSymbol.for('Symbol.dispose')when the engine has no well-known symbol. On such an engine the literal key evaluates toundefined, the method lands under the string"undefined", and everyusingof it throwsObject not disposable. Filling the well-known slot with that same registry symbol makes both sides name one key on every engine. A host that already has the symbol is left untouched:??=never reaches the assignment, which the host’s non-writable property would refuse.The default names
Symbolbare on purpose: it exists on every engine this runs on, and a bare reference resolves against whatever scope the banner is evaluated in, exactly as the bundle’s own[Symbol.dispose]keys do.
Import:
import { ensureDisposeSymbols } from 'obsidian-dev-utils/script-utils/bundlers/esbuild-impl/preprocess-plugin';Signature:
function ensureDisposeSymbols(symbolConstructor: DisposeSymbolHost): voidParameters:
| Parameter | Type | Description |
|---|---|---|
symbolConstructor |
DisposeSymbolHost | The Symbol constructor to patch. Defaults to the ambient one; the parameter exists so a test can hand in an engine that lacks the well-known symbols. |
Returns: void