This repository was archived by the owner on Jan 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -124,15 +124,15 @@ class Builder {
124124 join ( this . nextConfigDir , ".next/serverless/pages" ) ,
125125 join ( this . outputDir , DEFAULT_LAMBDA_CODE_DIR , "pages" ) ,
126126 {
127- // skip api pages from default lambda code
128- filter : file => {
129- const isHTML = path . extname ( file ) === ".html " ;
130- const isJSON = path . extname ( file ) === ".json" ;
127+ filter : ( file : string ) => {
128+ const isNotPrerenderedHTMLPage = path . extname ( file ) !== ".html" ;
129+ const isNotStaticPropsJSONFile = path . extname ( file ) !== ".json " ;
130+ const isNotApiPage = pathToPosix ( file ) . indexOf ( "pages/api" ) === - 1 ;
131131
132132 return (
133- pathToPosix ( file ) . indexOf ( "pages/api" ) === - 1 &&
134- ! isHTML &&
135- ! isJSON
133+ isNotApiPage &&
134+ isNotPrerenderedHTMLPage &&
135+ isNotStaticPropsJSONFile
136136 ) ;
137137 }
138138 }
Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ describe("Builder Tests", () => {
152152
153153 describe ( "Default Handler Artefact Files" , ( ) => {
154154 it ( "copies build files" , async ( ) => {
155- expect . assertions ( 5 ) ;
155+ expect . assertions ( 7 ) ;
156156
157157 const files = await fse . readdir (
158158 join ( outputDir , `${ DEFAULT_LAMBDA_CODE_DIR } ` )
@@ -185,7 +185,11 @@ describe("Builder Tests", () => {
185185 // api pages should not be included in the default lambda
186186 expect ( apiDirExists ) . toEqual ( false ) ;
187187
188- // html pages should not be included in the default lambda
188+ // HTML Prerendered pages or JSON static props files
189+ // should not be included in the default lambda
190+ expect ( pages ) . not . toContain ( [ "blog.json" ] ) ;
191+ expect ( pages ) . not . toContain ( [ "about.html" , "terms.html" ] ) ;
192+
189193 expect ( pages ) . toEqual ( [ "_error.js" , "blog.js" , "customers" ] ) ;
190194 expect ( customerPages ) . toEqual ( [ "[...catchAll].js" , "[post].js" ] ) ;
191195 } ) ;
You can’t perform that action at this time.
0 commit comments