Skip to content

Commit 1445775

Browse files
authored
fix(runtime): exclude unevaluated module in require.cache (#5903)
Close: #5898
1 parent feefaf0 commit 1445775

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/js/builtins/ImportMetaObject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export function createRequireCache() {
165165
},
166166

167167
has(target, key: string) {
168-
return $requireMap.$has(key) || Loader.registry.$has(key);
168+
return $requireMap.$has(key) || Boolean(Loader.registry.$get(key)?.evaluated);
169169
},
170170

171171
deleteProperty(target, key: string) {

src/js/out/WebCoreJSBuiltins.cpp

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/cli/run/require-cache-bug-5188.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ok(!Object.getOwnPropertyNames(require.cache).includes("bad"));
99
require("msgpackr-extract");
1010

1111
strictEqual(require.cache["extract"], undefined);
12+
ok(!("extract" in require.cache)); // https://github.com/oven-sh/bun/issues/5898
1213
ok(!Object.hasOwnProperty.call(require.cache, "extract"));
1314
ok(!Object.getOwnPropertyNames(require.cache).includes("extract"));
1415

0 commit comments

Comments
 (0)