-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix metadata json manifest convention (#62615)
### What Change from processing the file with `next-metatdata-route-loader` directly into passing the file as loader query, and leave an empty resource file for it. This will resolve the error that users were seeing with `manifest.json` convention. ``` Import trace for requested module: ../../../../packages/next/dist/build/webpack/loaders/next-metadata-route-loader.js?page=%2Fmanifest.jso n%2Froute&isDynamic=0!./app/manifest.json?__next_metadata_route__ getStaticAssetRouteCode page /manifest.json/route this.resourcePath /Users/huozhi/workspace/next.js/tes t/e2e/app-dir/metadata-json-manifest/app/manifest.json ``` ### Why I looked at the loader process that the final resource processed by webpack is `json!next-metadata-route-loader...`, which means the builtin json loader processing json file after the metadata route loader. I didn't get chance to solve the ordering issue, so I changed the resourcePath to empty "", and pass the file path as query into the loader to avoid json-loader processing it after transpilation. Fixes #59923 Closes NEXT-2630 Closes NEXT-2439
- Loading branch information
Showing
6 changed files
with
57 additions
and
10 deletions.
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
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
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,12 @@ | ||
export const metadata = { | ||
title: 'Next.js', | ||
description: 'Generated by Next.js', | ||
} | ||
|
||
export default function RootLayout({ children }) { | ||
return ( | ||
<html lang="en"> | ||
<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,6 @@ | ||
{ | ||
"name": "My Next.js Application", | ||
"short_name": "Next.js App", | ||
"description": "An application built with Next.js", | ||
"start_url": "/" | ||
} |
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.js' | ||
} |
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( | ||
'app-dir metadata-json-manifest', | ||
{ | ||
files: __dirname, | ||
skipDeployment: true, | ||
}, | ||
({ next }) => { | ||
it('should support metadata.json manifest', async () => { | ||
const response = await next.fetch('/manifest.json') | ||
expect(response.status).toBe(200) | ||
const json = await response.json() | ||
expect(json).toEqual({ | ||
name: 'My Next.js Application', | ||
short_name: 'Next.js App', | ||
description: 'An application built with Next.js', | ||
start_url: '/', | ||
}) | ||
}) | ||
} | ||
) |