2.0.0-beta.42 - npm Install Hotfix
v2.0.0-beta.42 is a one-fix hotfix for a crash that only
reproduced when alchemy was installed from npm:
ReferenceError: Cannot access 'bindWorkerAsyncBindings' before initialization at node_modules/alchemy/src/Cloudflare/Workers/Worker.ts:684:13Worker.ts forms import cycles with WorkerAsyncBindings.ts and
WorkerRuntimeContext.ts, and it passed their exports directly
into Platform(...) — reading them at module-load time. When Bun
enters the cycle from the other side (which happens with the npm
package layout, but not in the local workspace), those references
are still in their temporal dead zone and the import crashes.
beta.42 wraps both hook arguments in arrows so they resolve at call time instead of module-load time (#378):
} = Platform(WorkerTypeId, { onCreate: bindWorkerAsyncBindings, createRuntimeContext: makeWorkerRuntimeContext, onCreate: (resource, props) => bindWorkerAsyncBindings(resource as Worker, props), createRuntimeContext: (id) => makeWorkerRuntimeContext(id),});