Files
bun.sh/test/regression/issue/24387/entry.js
Alistair Smith 995d988c73 Clear module cache when require'ing an es module with TLA throws (#24389)
### What does this PR do?

Fixes #24387

### How did you verify your code works?

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Marko Vejnovic <marko@bun.com>
2025-11-05 13:55:49 -08:00

13 lines
380 B
JavaScript

// @bun
var { require } = import.meta;
const entrypointPath = "./p.js";
let listener;
try {
listener = await require(entrypointPath);
} catch (e) {
console.log(e.message.replace(require.resolve(entrypointPath), "<the module>"));
listener = await import(entrypointPath);
}
for (let i = 0; i < 5; i++) if (listener.default) listener = listener.default;
console.log(listener);