Bug report
Describe the bug
When a CommonJS module synchronously require()s a pure-ESM module (either
a local .mjs file or a "type": "module" npm package), the user worker
crashes during resolution with:
Error: Expected to resolve main module, got Import instead.
at loadESMFromCJS (node:module:777)
To Reproduce
Drop a minimal CJS-requires-ESM function into examples/:
examples/commonjs-require-esm/
├── package.json { "type": "commonjs" }
├── index.js const esm = require("./message.mjs");
│ Deno.serve(() => new Response(esm.message));
└── message.mjs export const message = "cjs require esm ok";
Start the runtime and hit the function:
./scripts/run.sh # main worker on :9000
curl http://localhost:9000/commonjs-require-esm
Expected: cjs require esm ok.
Actual: the user worker fails to boot with the error above.
The same happens with any real pure-ESM npm dependency
(e.g. node-fetch@3, chalk@5).
Expected behavior
CJS → ESM require() should succeed, matching Node and Deno's
standalone runtime behavior. The function above should respond with
cjs require esm ok.
Bug report
Describe the bug
When a CommonJS module synchronously
require()s a pure-ESM module (eithera local
.mjsfile or a"type": "module"npm package), the user workercrashes during resolution with:
To Reproduce
Drop a minimal CJS-requires-ESM function into
examples/:Start the runtime and hit the function:
./scripts/run.sh # main worker on :9000 curl http://localhost:9000/commonjs-require-esmExpected:
cjs require esm ok.Actual: the user worker fails to boot with the error above.
The same happens with any real pure-ESM npm dependency
(e.g.
node-fetch@3,chalk@5).Expected behavior
CJS → ESM
require()should succeed, matching Node and Deno'sstandalone runtime behavior. The function above should respond with
cjs require esm ok.