@@ -13,10 +13,10 @@ const pkg = readJsonSync(`${PLUGIN_DIR}/package.json`)
1313 * @param config Netlify config
1414 */
1515export const createServerHandler = async ( ) => {
16- // clear the server handler directory
16+ // clear the handler directory
1717 emptyDirSync ( SERVER_HANDLER_DIR )
1818
19- // trace the server handler dependencies
19+ // trace the handler dependencies
2020 const { fileList } = await nodeFileTrace (
2121 [ `${ PLUGIN_DIR } /dist/templates/server-handler.js` , `${ PLUGIN_DIR } /dist/templates/cache-handler.cjs` ] ,
2222 { base : PLUGIN_DIR , ignore : [ 'package.json' , 'node_modules/next/**' ] } ,
@@ -27,11 +27,11 @@ export const createServerHandler = async () => {
2727 copySync ( `${ PLUGIN_DIR } /${ path } ` , `${ SERVER_HANDLER_DIR } /${ path } ` )
2828 } )
2929
30- // copy the next.js standalone build output to the server handler directory
30+ // copy the next.js standalone build output to the handler directory
3131 copySync ( `${ NEXT_BUILD_DIR } /standalone/.next` , `${ SERVER_HANDLER_DIR } /.next` )
3232 copySync ( `${ NEXT_BUILD_DIR } /standalone/node_modules` , `${ SERVER_HANDLER_DIR } /node_modules` )
3333
34- // create the server handler metadata file
34+ // create the handler metadata file
3535 writeJSONSync ( `${ SERVER_HANDLER_DIR } /${ SERVER_HANDLER_NAME } .json` , {
3636 config : {
3737 name : 'Next.js Server Handler' ,
@@ -43,8 +43,10 @@ export const createServerHandler = async () => {
4343 version : 1 ,
4444 } )
4545
46+ // config ESM
4647 writeFileSync ( `${ SERVER_HANDLER_DIR } /package.json` , JSON . stringify ( { type : 'module' } ) )
4748
49+ // write the root handler file
4850 writeFileSync (
4951 `${ SERVER_HANDLER_DIR } /${ SERVER_HANDLER_NAME } .js` ,
5052 `import handler from './dist/templates/server-handler.js';export default handler;export const config = { path: '/*' }` ,
0 commit comments