From 2bbdf4f95088e08d20018210972327b8bfc4f2ff Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Thu, 3 Apr 2025 18:49:06 -0800 Subject: [PATCH] codegen: fix this ModuleLoader enum (#18769) --- src/bun.js/module_loader.zig | 2 +- src/codegen/bundle-modules.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig index e0cc50662a..1681d068ca 100644 --- a/src/bun.js/module_loader.zig +++ b/src/bun.js/module_loader.zig @@ -2521,7 +2521,7 @@ pub const ModuleLoader = struct { if (!is_allowed_to_use_internal_testing_apis) return null; } - return jsSyntheticModule(.InternalForTesting, specifier); + return jsSyntheticModule(.@"bun:internal-for-testing", specifier); }, .@"bun:wrap" => .{ .allocator = null, diff --git a/src/codegen/bundle-modules.ts b/src/codegen/bundle-modules.ts index 4e954e76bd..037087bf15 100644 --- a/src/codegen/bundle-modules.ts +++ b/src/codegen/bundle-modules.ts @@ -273,6 +273,7 @@ function idToEnumName(id: string) { } function idToPublicSpecifierOrEnumName(id: string) { + if (id === "internal-for-testing.ts") return "bun:internal-for-testing"; // not in the `bun/` folder because it's added conditionally id = id.replace(/\.[mc]?[tj]s$/, ""); if (id.startsWith("node/")) { return "node:" + id.slice(5).replaceAll(".", "/"); @@ -490,7 +491,7 @@ declare module "module" { namespace NodeJS { interface Require { - + `; for (let i = 0; i < nativeStartIndex; i++) { @@ -502,8 +503,7 @@ declare module "module" { let internalName = idToPublicSpecifierOrEnumName(id); if (internalName.startsWith("internal:")) internalName = internalName.replace(":", "/"); - dts += ` (id: "${internalName}"): typeof import("${path.join(BASE, id)}").default; -`; + dts += ` (id: "${internalName}"): typeof import("${path.join(BASE, id)}").default;\n`; } dts += `