mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
codegen: fix this ModuleLoader enum (#18769)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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 += `
|
||||
|
||||
Reference in New Issue
Block a user