From 35dffa0715cc54019ce928ee7f0c80f7d58f9e58 Mon Sep 17 00:00:00 2001 From: Bill Wallace Date: Wed, 26 Aug 2026 15:17:52 -0400 Subject: [PATCH] fix: load static-wado-util via createRequire so Bun can require() it static-wado-util resolves to lib/index.ts and is ESM, while 48 files in static-wado-creator reach it through a CommonJS require(). lib/index.mjs also imported it as ESM, which pulled it into that module's async graph; Bun 1.3 then rejects every one of those requires with TypeError: require() async module ".../static-wado-util/lib/index.ts" is unsupported. use "await import()" instead. which makes mkdicomweb fail at startup. Nothing in static-wado-util uses top-level await -- the async classification comes purely from the mixed ESM/CJS load order, and requiring the package from a plain CJS entry has always worked. Loading it through createRequire keeps it out of the ESM graph, so all 48 CJS requires resolve synchronously again. static-wado-creator is the only package in the monorepo with this mix. Co-Authored-By: Claude Opus 5 --- packages/static-wado-creator/lib/index.mjs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/static-wado-creator/lib/index.mjs b/packages/static-wado-creator/lib/index.mjs index db9dbe4..9c2de11 100644 --- a/packages/static-wado-creator/lib/index.mjs +++ b/packages/static-wado-creator/lib/index.mjs @@ -4,7 +4,14 @@ import programIndex from './program/index.js'; import createMain from './createMain.js'; import deleteMain from './deleteMain.js'; import adaptProgramOpts from './util/adaptProgramOpts.js'; -import { uids } from '@radicalimaging/static-wado-util'; +import { createRequire } from 'module'; + +// static-wado-util is ESM (lib/index.ts), while 23 files in this package reach it through a CJS +// require(). Importing it here as ESM too pulls it into this module's async graph, and Bun >= 1.3 +// then rejects every one of those requires with "require() async module ... is unsupported". Loading +// it through createRequire keeps it out of the ESM graph, so the CJS requires resolve synchronously. +const require = createRequire(import.meta.url); +const { uids } = require('@radicalimaging/static-wado-util'); const { configureProgram } = programIndex;