Problem
@cldmv/uuid@1.2.4 cannot be loaded from CommonJS. index.cjs loads ./index.mjs via require(), and index.mjs uses top-level await:
try { await import("./devcheck.mjs"); } catch {}
const { UUID, ISSUER_CATEGORIES } = await import("@cldmv/uuid/main");
Node's synchronous require(esm) refuses any ESM graph that contains top-level await:
Error [ERR_REQUIRE_ASYNC_MODULE]: require() cannot be used on an ESM graph with top-level await. Use import() instead.
Reproduced on Node 26.4.0 with node -e 'require("@cldmv/uuid")'. On Node versions without require(esm), the CJS entry fails with ERR_REQUIRE_ESM instead, so the require export has never worked.
Impact
Every CommonJS consumer is blocked, which prevents replacing npm uuid with @cldmv/uuid in CJS projects. For example, CLDMV/cldmv-node-chat#13 had to stay on uuid@^11 for this reason.
Fix
Replace the top-level awaits in index.mjs with static imports, so the ESM entry graph is synchronous. Static imports evaluate in source order, so devcheck.mjs still runs before the library module. devcheck.mjs must then ship in the package (it is already a no-op when installed under node_modules or when src/ is absent). index.cjs becomes a plain require("./index.mjs") re-export. Add a test that loads the package through require().
Problem
@cldmv/uuid@1.2.4cannot be loaded from CommonJS.index.cjsloads./index.mjsviarequire(), andindex.mjsuses top-levelawait:Node's synchronous
require(esm)refuses any ESM graph that contains top-level await:Reproduced on Node 26.4.0 with
node -e 'require("@cldmv/uuid")'. On Node versions withoutrequire(esm), the CJS entry fails withERR_REQUIRE_ESMinstead, so therequireexport has never worked.Impact
Every CommonJS consumer is blocked, which prevents replacing npm
uuidwith@cldmv/uuidin CJS projects. For example, CLDMV/cldmv-node-chat#13 had to stay onuuid@^11for this reason.Fix
Replace the top-level awaits in
index.mjswith static imports, so the ESM entry graph is synchronous. Static imports evaluate in source order, sodevcheck.mjsstill runs before the library module.devcheck.mjsmust then ship in the package (it is already a no-op when installed undernode_modulesor whensrc/is absent).index.cjsbecomes a plainrequire("./index.mjs")re-export. Add a test that loads the package throughrequire().