Load the Dawn binding lazily so the Chrome engine runs without it
1 changed file+3−2
src/cli/run.tsmodified+3−2View file
@@ -1,6 +1,5 @@
11 // Runs one simulation to completion in Node (Dawn WebGPU) and returns the pressure signal.
22
3-import { create, globals } from "webgpu";
43 import { defaultParams, type PhysParams } from "../params.ts";
54 import { Simulation } from "../sim/simulation.ts";
65
@@ -8,8 +7,10 @@ let devicePromise: Promise<GPUDevice> | null = null;
87
98 export function getDevice(): Promise<GPUDevice> {
109 if (!devicePromise) {
11- Object.assign(globalThis, globals);
1210 devicePromise = (async () => {
11+ // Loaded lazily: the prebuilt binding needs a recent glibc and is only used by --engine dawn.
12+ const { create, globals } = await import("webgpu");
13+ Object.assign(globalThis, globals);
1314 const gpu = create([]);
1415 const adapter = await gpu.requestAdapter();
1516 if (!adapter) throw new Error("No WebGPU adapter");