Skip to content

Commit 98057a7

Browse files
committed
fix: esm runtime evaluation
1 parent 2ec327b commit 98057a7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/core/next.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ async function safeEval(code: string, routePath: string) {
3434
}
3535

3636
async function getModuleTranspiler() {
37-
if (typeof require === "undefined") {
38-
const { transpileModule } = await import(/* webpackIgnore: true */ "typescript");
39-
return transpileModule;
37+
if (typeof require !== "undefined" && typeof exports !== "undefined") {
38+
// eslint-disable-next-line @typescript-eslint/no-require-imports
39+
return require(/* webpackIgnore: true */ "typescript").transpileModule;
4040
}
41-
// eslint-disable-next-line @typescript-eslint/no-require-imports
42-
return require(/* webpackIgnore: true */ "typescript").transpileModule;
41+
const { transpileModule } = await import(/* webpackIgnore: true */ "typescript");
42+
return transpileModule;
4343
}
4444

4545
export async function getRouteExports(routePath: string, routeDefinerName: string, schemas: Record<string, unknown>) {

0 commit comments

Comments
 (0)