@@ -7,33 +7,39 @@ import { async as StreamZip } from 'node-stream-zip'
7
7
import { relative } from 'pathe'
8
8
import prettyBytes from 'pretty-bytes'
9
9
10
- // 50MB, which is the documented max, though the hard max seems to be higher
10
+ // 50MB, which is the warning max
11
11
// eslint-disable-next-line no-magic-numbers
12
- export const LAMBDA_MAX_SIZE = 1024 * 1024 * 50
12
+ export const LAMBDA_WARNING_SIZE = 1024 * 1024 * 50
13
+
14
+ // 250MB, which is the hard max
15
+ // eslint-disable-next-line no-magic-numbers
16
+ export const LAMBDA_MAX_SIZE = 1024 * 1024 * 250
13
17
14
18
// eslint-disable-next-line max-statements
15
19
export const checkZipSize = async (
16
20
file : string ,
21
+ warningSize : number = LAMBDA_WARNING_SIZE ,
17
22
maxSize : number = LAMBDA_MAX_SIZE ,
18
23
) : Promise < void > => {
19
24
if ( ! existsSync ( file ) ) {
20
25
console . warn ( `Could not check zip size because ${ file } does not exist` )
21
26
return
22
27
}
23
28
const fileSize = await promises . stat ( file ) . then ( ( { size } ) => size )
24
- if ( fileSize < maxSize ) {
29
+ if ( fileSize < warningSize ) {
25
30
return
26
31
}
27
32
// We don't fail the build, because the actual hard max size is larger so it might still succeed
28
33
console . log (
29
- redBright ( stripIndent `
30
- The function zip ${ yellowBright (
34
+ yellowBright ( stripIndent `
35
+ The function zip ${ blueBright (
31
36
relative ( process . cwd ( ) , file ) ,
32
37
) } size is ${ prettyBytes (
33
38
fileSize ,
34
- ) } , which is larger than the maximum supported size of ${ prettyBytes (
35
- maxSize ,
36
- ) } .
39
+ ) } , which is larger than the recommended maximum size of ${ prettyBytes (
40
+ warningSize ,
41
+ ) } . This will fail the build if the unzipped size is bigger than the maximum size of ${ prettyBytes (
42
+ maxSize .
37
43
There are a few reasons this could happen , such as accidentally bundling a large dependency or adding lots of files to "included_files" .
38
44
`),
39
45
)
0 commit comments