1
1
// @ts -check
2
2
3
- const { join } = require ( 'path' )
3
+ const { join, relative } = require ( 'path' )
4
4
5
5
const { copy, existsSync } = require ( 'fs-extra' )
6
6
7
- const { ODB_FUNCTION_NAME , HANDLER_FUNCTION_NAME } = require ( './constants' )
8
7
const { 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' )
11
10
const {
12
11
verifyNetlifyBuildVersion,
13
12
checkNextSiteHasBuilt,
@@ -44,13 +43,13 @@ module.exports = {
44
43
45
44
const { appDir, basePath, i18n, images, target } = await getNextConfig ( { publish, failBuild } )
46
45
47
- setBundler ( { netlifyConfig, target } )
48
-
49
46
verifyBuildTarget ( target )
50
47
51
- setIncludedFiles ( { netlifyConfig, publish } )
48
+ configureHandlerFunctions ( { netlifyConfig, publish : relative ( process . cwd ( ) , publish ) } )
52
49
53
50
await generateFunctions ( constants , appDir )
51
+ await generatePagesResolver ( { netlifyConfig, target, constants } )
52
+
54
53
const publicDir = join ( appDir , 'public' )
55
54
if ( existsSync ( publicDir ) ) {
56
55
await copy ( publicDir , `${ publish } /` )
@@ -64,14 +63,7 @@ module.exports = {
64
63
} )
65
64
} ,
66
65
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 } } ) {
75
67
return saveCache ( { cache, publish : netlifyConfig . build . publish } )
76
68
} ,
77
69
}
0 commit comments