Files
bun.sh/test/regression/issue/24387.test.ts
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

24 lines
694 B
TypeScript

import { bunEnv, bunExe } from "harness";
import { join } from "path";
test("regression: require()ing a module with TLA should error and then wipe the module cache, so that importing it again works", async () => {
const proc = Bun.spawn({
cmd: [bunExe(), "run", "--smol", join(import.meta.dir, "24387", "entry.js")],
env: bunEnv,
stdout: "pipe",
stderr: "pipe",
});
const { stdout, stderr } = proc;
expect(await stderr.text()).toBe("");
expect(await stdout.text()).toMatchInlineSnapshot(`
"require() async module "<the module>" is unsupported. use "await import()" instead.
Module {
foo: 67,
}
"
`);
expect(await proc.exited).toBe(0);
});