11// @ts -check
22
3- const { join } = require ( 'path' )
3+ const { join, relative } = require ( 'path' )
44
55const { copy, existsSync } = require ( 'fs-extra' )
66
7- const { ODB_FUNCTION_NAME , HANDLER_FUNCTION_NAME } = require ( './constants' )
87const { restoreCache, saveCache } = require ( './helpers/cache' )
9- const { getNextConfig, setIncludedFiles , generateRedirects, setBundler } = require ( './helpers/config' )
10- const { generateFunctions, setupImageFunction } = require ( './helpers/functions' )
8+ const { getNextConfig, configureHandlerFunctions , generateRedirects } = require ( './helpers/config' )
9+ const { generateFunctions, setupImageFunction, generatePagesResolver } = require ( './helpers/functions' )
1110const {
1211 verifyNetlifyBuildVersion,
1312 checkNextSiteHasBuilt,
@@ -44,13 +43,13 @@ module.exports = {
4443
4544 const { appDir, basePath, i18n, images, target } = await getNextConfig ( { publish, failBuild } )
4645
47- setBundler ( { netlifyConfig, target } )
48-
4946 verifyBuildTarget ( target )
5047
51- setIncludedFiles ( { netlifyConfig, publish } )
48+ configureHandlerFunctions ( { netlifyConfig, publish : relative ( process . cwd ( ) , publish ) } )
5249
5350 await generateFunctions ( constants , appDir )
51+ await generatePagesResolver ( { netlifyConfig, target, constants } )
52+
5453 const publicDir = join ( appDir , 'public' )
5554 if ( existsSync ( publicDir ) ) {
5655 await copy ( publicDir , `${ publish } /` )
@@ -64,14 +63,7 @@ module.exports = {
6463 } )
6564 } ,
6665
67- async onPostBuild ( { netlifyConfig, constants : { FUNCTIONS_DIST = '.netlify/functions' } , utils : { run, cache } } ) {
68- // Remove swc binaries from the zipfile if present. Yes, it's a hack, but it drops >10MB from the zipfile when bundling with zip-it-and-ship-it
69- for ( const func of [ ODB_FUNCTION_NAME , HANDLER_FUNCTION_NAME ] ) {
70- await run ( `zip` , [ `-d` , join ( FUNCTIONS_DIST , `${ func } .zip` ) , '*node_modules/@next/swc-*' ] ) . catch ( ( ) => {
71- // This throws if there's none of these in the zipfile, so ignore it
72- } )
73- }
74-
66+ async onPostBuild ( { netlifyConfig, utils : { cache } } ) {
7567 return saveCache ( { cache, publish : netlifyConfig . build . publish } )
7668 } ,
7769}
0 commit comments