@@ -2,13 +2,13 @@ import { existsSync, promises } from 'fs'
2
2
import path , { relative , join } from 'path'
3
3
4
4
import type { NetlifyConfig , NetlifyPluginUtils } from '@netlify/build'
5
- import { yellowBright , greenBright , blueBright , redBright , reset } from 'chalk'
5
+ import { yellowBright , greenBright , blueBright , reset } from 'chalk'
6
6
import { async as StreamZip } from 'node-stream-zip'
7
7
import { outdent } from 'outdent'
8
8
import prettyBytes from 'pretty-bytes'
9
9
import { satisfies } from 'semver'
10
10
11
- import { LAMBDA_MAX_SIZE } from '../constants'
11
+ import { LAMBDA_MAX_SIZE , LAMBDA_WARNING_SIZE } from '../constants'
12
12
13
13
import { isBundleSizeCheckDisabled } from './utils'
14
14
@@ -105,7 +105,11 @@ export const checkForRootPublish = ({
105
105
}
106
106
}
107
107
108
- export const checkZipSize = async ( file : string , maxSize : number = LAMBDA_MAX_SIZE ) : Promise < void > => {
108
+ export const checkZipSize = async (
109
+ file : string ,
110
+ maxSize : number = LAMBDA_MAX_SIZE ,
111
+ warningSize : number = LAMBDA_WARNING_SIZE ,
112
+ ) : Promise < void > => {
109
113
// Requires contacting the Netlify Support team to fully enable.
110
114
// Enabling this without contacting them can result in failed deploys.
111
115
if ( isBundleSizeCheckDisabled ( ) ) {
@@ -120,15 +124,16 @@ export const checkZipSize = async (file: string, maxSize: number = LAMBDA_MAX_SI
120
124
return
121
125
}
122
126
const fileSize = await promises . stat ( file ) . then ( ( { size } ) => size )
123
- if ( fileSize < maxSize ) {
127
+ if ( fileSize < warningSize ) {
124
128
return
125
129
}
126
130
// We don't fail the build, because the actual hard max size is larger so it might still succeed
127
131
console . log (
128
- redBright ( outdent `
129
- The function zip ${ yellowBright ( relative ( process . cwd ( ) , file ) ) } size is ${ prettyBytes (
132
+ yellowBright ( outdent `
133
+ The function zip ${ blueBright ( relative ( process . cwd ( ) , file ) ) } size is ${ prettyBytes (
130
134
fileSize ,
131
- ) } , which is larger than the maximum supported size of ${ prettyBytes ( maxSize ) } .
135
+ ) } , which is larger than the recommended maximum size of ${ prettyBytes ( warningSize ) } .
136
+ This will fail the build if the unzipped size is bigger than the maximum size of ${ prettyBytes ( maxSize ) } .
132
137
There are a few reasons this could happen. You may have accidentally bundled a large dependency, or you might have a
133
138
large number of pre-rendered pages included.
134
139
` ) ,
0 commit comments