@@ -6,12 +6,12 @@ import { fileURLToPath } from "node:url";
66import type { BuildOptions } from "@opennextjs/aws/build/helper.js" ;
77import { build , Plugin } from "esbuild" ;
88
9- import { Config } from "../config" ;
10- import * as patches from "./patches" ;
11- import { copyPrerenderedRoutes } from "./utils" ;
9+ import { Config } from "../config.js " ;
10+ import * as patches from "./patches/index.js " ;
11+ import { copyPrerenderedRoutes } from "./utils/index.js " ;
1212
1313/** The dist directory of the Cloudflare adapter package */
14- const packageDistDir = path . join ( path . dirname ( fileURLToPath ( import . meta. url ) ) , ".." ) ;
14+ const packageDistDir = path . join ( path . dirname ( fileURLToPath ( import . meta. url ) ) , "../.. " ) ;
1515
1616/**
1717 * Bundle the Open Next server.
@@ -51,15 +51,15 @@ export async function bundleServer(config: Config, openNextOptions: BuildOptions
5151 // Note: we apply an empty shim to next/dist/compiled/ws because it generates two `eval`s:
5252 // eval("require")("bufferutil");
5353 // eval("require")("utf-8-validate");
54- "next/dist/compiled/ws" : path . join ( config . paths . internal . templates , "shims" , "empty.ts " ) ,
54+ "next/dist/compiled/ws" : path . join ( config . paths . internal . templates , "shims" , "empty.js " ) ,
5555 // Note: we apply an empty shim to next/dist/compiled/edge-runtime since (amongst others) it generated the following `eval`:
5656 // eval(getModuleCode)(module, module.exports, throwingRequire, params.context, ...Object.values(params.scopedContext));
5757 // which comes from https://github.com/vercel/edge-runtime/blob/6e96b55f/packages/primitives/src/primitives/load.js#L57-L63
5858 // QUESTION: Why did I encountered this but mhart didn't?
59- "next/dist/compiled/edge-runtime" : path . join ( config . paths . internal . templates , "shims" , "empty.ts " ) ,
59+ "next/dist/compiled/edge-runtime" : path . join ( config . paths . internal . templates , "shims" , "empty.js " ) ,
6060 // `@next/env` is a library Next.js uses for loading dotenv files, for obvious reasons we need to stub it here
6161 // source: https://github.com/vercel/next.js/tree/0ac10d79720/packages/next-env
62- "@next/env" : path . join ( config . paths . internal . templates , "shims" , "env.ts " ) ,
62+ "@next/env" : path . join ( config . paths . internal . templates , "shims" , "env.js " ) ,
6363 } ,
6464 define : {
6565 // config file used by Next.js, see: https://github.com/vercel/next.js/blob/68a7128/packages/next/src/build/utils.ts#L2137-L2139
@@ -188,10 +188,7 @@ function createFixRequiresESBuildPlugin(config: Config): Plugin {
188188 setup ( build ) {
189189 // Note: we (empty) shim require-hook modules as they generate problematic code that uses requires
190190 build . onResolve ( { filter : / ^ \. \/ r e q u i r e - h o o k $ / } , ( ) => ( {
191- path : path . join ( config . paths . internal . templates , "shims" , "empty.ts" ) ,
192- } ) ) ;
193- build . onResolve ( { filter : / \. \/ l i b \/ n o d e - f s - m e t h o d s $ / } , ( ) => ( {
194- path : path . join ( config . paths . internal . templates , "shims" , "empty.ts" ) ,
191+ path : path . join ( config . paths . internal . templates , "shims" , "empty.js" ) ,
195192 } ) ) ;
196193 } ,
197194 } ;
0 commit comments