File tree Expand file tree Collapse file tree 7 files changed +28
-31
lines changed Expand file tree Collapse file tree 7 files changed +28
-31
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ export function compileOpenNextConfigNode(
7070 externals : string [ ] ,
7171) {
7272 const outputPath = path . join ( outputDir , "open-next.config.mjs" ) ;
73+ logger . debug ( "Compiling open-next.config.ts for Node." , outputPath ) ;
7374
7475 //Check if open-next.config.ts exists
7576 if ( ! fs . existsSync ( sourcePath ) ) {
@@ -105,8 +106,8 @@ export function compileOpenNextConfigEdge(
105106 externals : string [ ] ,
106107) {
107108 const outputPath = path . join ( outputDir , "open-next.config.edge.mjs" ) ;
109+ logger . debug ( "Compiling open-next.config.ts for edge runtime." , outputPath ) ;
108110
109- logger . info ( "Compiling open-next.config.ts for edge runtime." , outputPath ) ;
110111 buildSync ( {
111112 entryPoints : [ sourcePath ] ,
112113 outfile : outputPath ,
@@ -117,5 +118,4 @@ export function compileOpenNextConfigEdge(
117118 platform : "browser" ,
118119 external : externals ,
119120 } ) ;
120- logger . info ( "Compiled open-next.config.ts for edge runtime." ) ;
121121}
Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ export async function copyTracedFiles(
9696 `
9797--------------------------------------------------------------------------------
9898${ pagePath } cannot use the edge runtime.
99- OpenNext requires edge runtime function to be defined in a separate function.
99+ OpenNext requires edge runtime function to be defined in a separate function.
100100See the docs for more information on how to bundle edge runtime functions.
101101--------------------------------------------------------------------------------
102102 ` ,
@@ -117,7 +117,7 @@ File ${fullFilePath} does not exist
117117 filesToCopy . set ( f , f . replace ( standaloneDir , outputDir ) ) ;
118118 } ) ;
119119
120- if ( ! existsSync ( path . join ( standaloneNextDir , ` ${ fullFilePath } ` ) ) ) {
120+ if ( ! existsSync ( path . join ( standaloneNextDir , fullFilePath ) ) ) {
121121 throw new Error (
122122 `This error should only happen for static 404 and 500 page from page router. Report this if that's not the case.,
123123 File ${ fullFilePath } does not exist` ,
Original file line number Diff line number Diff line change @@ -45,12 +45,12 @@ export async function createGenericHandler<
4545 const override = config [ handler . type ]
4646 ?. override as any as DefaultOverrideOptions < E , R > ;
4747
48- // From the config, we create the adapter
49- const adapter = await resolveConverter < E , R > ( override ?. converter ) ;
48+ // From the config, we create the converter
49+ const converter = await resolveConverter < E , R > ( override ?. converter ) ;
5050
5151 // Then we create the handler
52- const wrapper = await resolveWrapper < E , R > ( override ?. wrapper ) ;
53- debug ( "Using wrapper" , wrapper . name ) ;
52+ const { name , wrapper } = await resolveWrapper < E , R > ( override ?. wrapper ) ;
53+ debug ( "Using wrapper" , name ) ;
5454
55- return wrapper . wrapper ( handler . handler , adapter ) ;
55+ return wrapper ( handler . handler , converter ) ;
5656}
Original file line number Diff line number Diff line change @@ -53,13 +53,15 @@ export async function createMainHandler() {
5353
5454 globalThis . lastModified = { } ;
5555
56- // From the config, we create the adapter
57- const adapter = await resolveConverter ( thisFunction . override ?. converter ) ;
56+ // From the config, we create the converter
57+ const converter = await resolveConverter ( thisFunction . override ?. converter ) ;
5858
5959 // Then we create the handler
60- const wrapper = await resolveWrapper ( thisFunction . override ?. wrapper ) ;
60+ const { wrapper, name } = await resolveWrapper (
61+ thisFunction . override ?. wrapper ,
62+ ) ;
6163
62- debug ( "Using wrapper" , wrapper . name ) ;
64+ debug ( "Using wrapper" , name ) ;
6365
64- return wrapper . wrapper ( openNextHandler , adapter ) ;
66+ return wrapper ( openNextHandler , converter ) ;
6567}
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ const handler: WrapperHandler<
1515 globalThis . process = process ;
1616
1717 // Set the environment variables
18- // Cloudlare suggests to not override the process.env object but instead apply the values to it
18+ // Cloudflare suggests to not override the process.env object but instead apply the values to it
1919 for ( const [ key , value ] of Object . entries ( env ) ) {
2020 if ( typeof value === "string" ) {
2121 process . env [ key ] = value ;
Original file line number Diff line number Diff line change @@ -25,7 +25,8 @@ export interface IPluginSettings {
2525/**
2626 * @param opts.nextDir - The path to the .next directory
2727 * @param opts.edgeFunctionHandlerPath - The path to the edgeFunctionHandler.js file that we'll use to bundle the routing
28- * @param opts.middlewareInfo - The entry files that we'll inject into the edgeFunctionHandler.js file
28+ * @param opts.middlewareInfo - Information about the middleware
29+ * @param opts.isInCloudfare - Whether the code runs on the cloudflare runtime
2930 * @returns
3031 */
3132export function openNextEdgePlugins ( {
@@ -80,12 +81,10 @@ export function openNextEdgePlugins({
8081 // they import from `export * from "node:*";`
8182 build . onLoad (
8283 { filter : / .* / , namespace : "node-built-in-modules" } ,
83- ( { path } ) => {
84- return {
85- contents : `export * from '${ path } '` ,
86- loader : "js" ,
87- } ;
88- } ,
84+ ( { path } ) => ( {
85+ contents : `export * from '${ path } '` ,
86+ loader : "js" ,
87+ } ) ,
8988 ) ;
9089
9190 // We inject the entry files into the edgeFunctionHandler
@@ -190,11 +189,8 @@ ${contents}
190189 export const MiddlewareManifest = ${ JSON . stringify ( MiddlewareManifest ) } ;
191190
192191 process.env.NEXT_BUILD_ID = BuildId;
193-
194- ` ;
195- return {
196- contents,
197- } ;
192+ ` ;
193+ return { contents } ;
198194 } ) ;
199195 } ,
200196 } ;
Original file line number Diff line number Diff line change @@ -72,9 +72,8 @@ export function openNextReplacementPlugin({
7272 ) ;
7373 contents = contents . replace ( pattern , "" ) ;
7474 } ) ,
75- ...( replacements ?? [ ] ) . map ( async ( fp ) => {
76- const p = fp ;
77- const replacementFile = await readFile ( p , "utf-8" ) ;
75+ ...( replacements ?? [ ] ) . map ( async ( filename ) => {
76+ const replacementFile = await readFile ( filename , "utf-8" ) ;
7877 const matches = replacementFile . matchAll ( overridePattern ) ;
7978
8079 const importMatch = replacementFile . match ( importPattern ) ;
@@ -91,7 +90,7 @@ export function openNextReplacementPlugin({
9190 ) ;
9291 logger . debug (
9392 chalk . blue ( `Open-next replacement plugin ${ name } ` ) ,
94- `-- Applying override for ${ id } from ${ fp } ` ,
93+ `-- Applying override for ${ id } from ${ filename } ` ,
9594 ) ;
9695 contents = contents . replace ( pattern , replacement ) ;
9796 }
You can’t perform that action at this time.
0 commit comments