codegen: fix this ModuleLoader enum (#18769)

This commit is contained in:
Meghan Denny
2025-04-03 18:49:06 -08:00
committed by GitHub
parent 8414ef1562
commit 2bbdf4f950
2 changed files with 4 additions and 4 deletions

View File

@@ -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 += `