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(
70
70
externals : string [ ] ,
71
71
) {
72
72
const outputPath = path . join ( outputDir , "open-next.config.mjs" ) ;
73
+ logger . debug ( "Compiling open-next.config.ts for Node." , outputPath ) ;
73
74
74
75
//Check if open-next.config.ts exists
75
76
if ( ! fs . existsSync ( sourcePath ) ) {
@@ -105,8 +106,8 @@ export function compileOpenNextConfigEdge(
105
106
externals : string [ ] ,
106
107
) {
107
108
const outputPath = path . join ( outputDir , "open-next.config.edge.mjs" ) ;
109
+ logger . debug ( "Compiling open-next.config.ts for edge runtime." , outputPath ) ;
108
110
109
- logger . info ( "Compiling open-next.config.ts for edge runtime." , outputPath ) ;
110
111
buildSync ( {
111
112
entryPoints : [ sourcePath ] ,
112
113
outfile : outputPath ,
@@ -117,5 +118,4 @@ export function compileOpenNextConfigEdge(
117
118
platform : "browser" ,
118
119
external : externals ,
119
120
} ) ;
120
- logger . info ( "Compiled open-next.config.ts for edge runtime." ) ;
121
121
}
Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ export async function copyTracedFiles(
96
96
`
97
97
--------------------------------------------------------------------------------
98
98
${ 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.
100
100
See the docs for more information on how to bundle edge runtime functions.
101
101
--------------------------------------------------------------------------------
102
102
` ,
@@ -117,7 +117,7 @@ File ${fullFilePath} does not exist
117
117
filesToCopy . set ( f , f . replace ( standaloneDir , outputDir ) ) ;
118
118
} ) ;
119
119
120
- if ( ! existsSync ( path . join ( standaloneNextDir , ` ${ fullFilePath } ` ) ) ) {
120
+ if ( ! existsSync ( path . join ( standaloneNextDir , fullFilePath ) ) ) {
121
121
throw new Error (
122
122
`This error should only happen for static 404 and 500 page from page router. Report this if that's not the case.,
123
123
File ${ fullFilePath } does not exist` ,
Original file line number Diff line number Diff line change @@ -45,12 +45,12 @@ export async function createGenericHandler<
45
45
const override = config [ handler . type ]
46
46
?. override as any as DefaultOverrideOptions < E , R > ;
47
47
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 ) ;
50
50
51
51
// 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 ) ;
54
54
55
- return wrapper . wrapper ( handler . handler , adapter ) ;
55
+ return wrapper ( handler . handler , converter ) ;
56
56
}
Original file line number Diff line number Diff line change @@ -53,13 +53,15 @@ export async function createMainHandler() {
53
53
54
54
globalThis . lastModified = { } ;
55
55
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 ) ;
58
58
59
59
// Then we create the handler
60
- const wrapper = await resolveWrapper ( thisFunction . override ?. wrapper ) ;
60
+ const { wrapper, name } = await resolveWrapper (
61
+ thisFunction . override ?. wrapper ,
62
+ ) ;
61
63
62
- debug ( "Using wrapper" , wrapper . name ) ;
64
+ debug ( "Using wrapper" , name ) ;
63
65
64
- return wrapper . wrapper ( openNextHandler , adapter ) ;
66
+ return wrapper ( openNextHandler , converter ) ;
65
67
}
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ const handler: WrapperHandler<
15
15
globalThis . process = process ;
16
16
17
17
// 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
19
19
for ( const [ key , value ] of Object . entries ( env ) ) {
20
20
if ( typeof value === "string" ) {
21
21
process . env [ key ] = value ;
Original file line number Diff line number Diff line change @@ -25,7 +25,8 @@ export interface IPluginSettings {
25
25
/**
26
26
* @param opts.nextDir - The path to the .next directory
27
27
* @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
29
30
* @returns
30
31
*/
31
32
export function openNextEdgePlugins ( {
@@ -80,12 +81,10 @@ export function openNextEdgePlugins({
80
81
// they import from `export * from "node:*";`
81
82
build . onLoad (
82
83
{ 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
+ } ) ,
89
88
) ;
90
89
91
90
// We inject the entry files into the edgeFunctionHandler
@@ -190,11 +189,8 @@ ${contents}
190
189
export const MiddlewareManifest = ${ JSON . stringify ( MiddlewareManifest ) } ;
191
190
192
191
process.env.NEXT_BUILD_ID = BuildId;
193
-
194
- ` ;
195
- return {
196
- contents,
197
- } ;
192
+ ` ;
193
+ return { contents } ;
198
194
} ) ;
199
195
} ,
200
196
} ;
Original file line number Diff line number Diff line change @@ -72,9 +72,8 @@ export function openNextReplacementPlugin({
72
72
) ;
73
73
contents = contents . replace ( pattern , "" ) ;
74
74
} ) ,
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" ) ;
78
77
const matches = replacementFile . matchAll ( overridePattern ) ;
79
78
80
79
const importMatch = replacementFile . match ( importPattern ) ;
@@ -91,7 +90,7 @@ export function openNextReplacementPlugin({
91
90
) ;
92
91
logger . debug (
93
92
chalk . blue ( `Open-next replacement plugin ${ name } ` ) ,
94
- `-- Applying override for ${ id } from ${ fp } ` ,
93
+ `-- Applying override for ${ id } from ${ filename } ` ,
95
94
) ;
96
95
contents = contents . replace ( pattern , replacement ) ;
97
96
}
You can’t perform that action at this time.
0 commit comments