-
Notifications
You must be signed in to change notification settings - Fork 26.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix metadata routes prerender cache for standalone mode (#49208)
Fixes #48962 Fixes #49009 Fixes #49107 ### Why For standalone mode the `fs.readFile` is executed for `route.js` when the module is loaded, then the fs operation aginst the wrong file path will break the proper module loading, then it fallbacks to `/_error` module. ### What We move the fs read operation to the first get then cache the buffer in the module level variable, so that `fs.readFile` won't be executed. As we already have prerender cache, the meta/body fs cache will be HIT and served
- Loading branch information
Showing
7 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default function Root({ children }) { | ||
return ( | ||
<html> | ||
<head></head> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function page() { | ||
return 'page' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { createNextDescribe } from 'e2e-utils' | ||
|
||
createNextDescribe( | ||
'standalone mode - metadata routes', | ||
{ | ||
files: __dirname, | ||
}, | ||
({ next }) => { | ||
beforeAll(async () => { | ||
// Hide source files to make sure route.js can read files from source | ||
// in order to hit the prerender cache | ||
await next.renameFolder('app', 'app_hidden') | ||
}) | ||
|
||
it('should work', async () => { | ||
const faviconRes = await next.fetch('/favicon.ico') | ||
const iconRes = await next.fetch('/icon.svg') | ||
expect(faviconRes.status).toBe(200) | ||
expect(iconRes.status).toBe(200) | ||
}) | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
output: 'standalone', | ||
experimental: { | ||
appDir: true, | ||
}, | ||
} |
77ea7c0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stats from current release
Default Build (Increase detected⚠️ )
General Overall increase⚠️
Client Bundles (main, webpack) Overall increase⚠️
Legacy Client Bundles (polyfills)
Client Pages Overall decrease ✓
Client Build Manifests
Rendered Page Sizes Overall decrease ✓
Edge SSR bundle Size Overall increase⚠️
Middleware size Overall increase⚠️
Diffs
Diff for page.js
Diff too large to display
Diff for middleware-b..-manifest.js
Diff for middleware-r..-manifest.js
Diff for middleware.js
Diff for edge-ssr.js
Diff too large to display
Diff for _buildManifest.js
Diff for _app-HASH.js
Diff for _error-HASH.js
Diff for amp-HASH.js
Diff for css-HASH.js
Diff for dynamic-HASH.js
Diff for edge-ssr-HASH.js
Diff for head-HASH.js
Diff for hooks-HASH.js
Diff for image-HASH.js
Diff for index-HASH.js
Diff for link-HASH.js
Diff for routerDirect-HASH.js
Diff for script-HASH.js
Diff for withRouter-HASH.js
Diff for 846-HASH.js
Diff too large to display
Diff for 869.HASH.js
Diff for 974ec2d0-HASH.js
Diff too large to display
Diff for page-0f3d25a7c0ecb2fe.js
Diff for page-12bf7c84b5879789.js
Diff for layout-ccf26..8433d050e.js
Diff for main-HASH.js
Diff too large to display
Diff for main-app-HASH.js
Diff for webpack-HASH.js
Diff for index.html
Diff for link.html
Diff for withRouter.html