Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 740761a

Browse files
committed
fix(vite): fallback resolver for built-in deps for prod build
1 parent 70cd825 commit 740761a

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/build/vite/plugin.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { getViteRollupConfig } from "./rollup";
88
import { buildProduction, prodEntry } from "./prod";
99
import { createNitroEnvironment, createServiceEnvironments } from "./env";
1010
import { configureViteDevServer } from "./dev";
11-
import { runtimeDir } from "nitro/runtime/meta";
11+
import { runtimeDependencies, runtimeDir } from "nitro/runtime/meta";
1212

1313
import * as rou3 from "rou3";
1414
import * as rou3Compiler from "rou3/compiler";
@@ -168,6 +168,26 @@ export async function nitro(
168168
return resolved;
169169
}
170170
}
171+
172+
// Resolve built-in deps
173+
if (
174+
runtimeDependencies.some(
175+
(dep) => id === dep || id.startsWith(`${dep}/`)
176+
)
177+
) {
178+
const resolved = await this.resolve(id, importer, {
179+
...options,
180+
skipSelf: true,
181+
});
182+
return (
183+
resolved ||
184+
resolveModulePath(id, {
185+
from: ctx.nitro!.options.nodeModulesDirs,
186+
conditions: ctx.nitro!.options.exportConditions,
187+
try: true,
188+
})
189+
);
190+
}
171191
},
172192

173193
async load(id) {

0 commit comments

Comments
 (0)