Skip to content

Commit ee7fae6

Browse files
committed
Fix json manifest convention
1 parent 3d3a792 commit ee7fae6

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

packages/next/src/build/webpack/loaders/next-app-loader.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ async function createAppRouteCode({
124124

125125
resolvedPagePath = `next-metadata-route-loader?${stringify({
126126
page,
127+
filePath: resolvedPagePath,
127128
isDynamic: isDynamic ? '1' : '0',
128-
})}!${resolvedPagePath}${`?${WEBPACK_RESOURCE_QUERIES.metadataRoute}`}`
129+
})}!?${WEBPACK_RESOURCE_QUERIES.metadataRoute}`
129130
}
130131

131132
const pathname = new AppPathnameNormalizer().normalize(page)

packages/next/src/build/webpack/loaders/next-metadata-route-loader.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const cacheHeader = {
2222

2323
type MetadataRouteLoaderOptions = {
2424
page: string
25+
filePath: string
2526
isDynamic: '1' | '0'
2627
}
2728

@@ -46,7 +47,6 @@ function getContentType(resourcePath: string) {
4647
return 'text/plain'
4748
}
4849

49-
// Strip metadata resource query string from `import.meta.url` to make sure the fs.readFileSync get the right path.
5050
async function getStaticAssetRouteCode(
5151
resourcePath: string,
5252
fileBaseName: string
@@ -236,33 +236,25 @@ ${staticGenerationCode}
236236
`
237237
return code
238238
}
239-
// `import.meta.url` is the resource name of the current module.
239+
240240
// When it's static route, it could be favicon.ico, sitemap.xml, robots.txt etc.
241241
// TODO-METADATA: improve the cache control strategy
242242
const nextMetadataRouterLoader: webpack.LoaderDefinitionFunction<MetadataRouteLoaderOptions> =
243243
async function () {
244-
const { resourcePath } = this
245-
246-
const { page, isDynamic } = this.getOptions()
247-
const { name: fileBaseName } = getFilenameAndExtension(resourcePath)
244+
const { page, isDynamic, filePath } = this.getOptions()
245+
const { name: fileBaseName } = getFilenameAndExtension(filePath)
248246

249247
let code = ''
250248
if (isDynamic === '1') {
251249
if (fileBaseName === 'robots' || fileBaseName === 'manifest') {
252-
code = getDynamicTextRouteCode(resourcePath)
250+
code = getDynamicTextRouteCode(filePath)
253251
} else if (fileBaseName === 'sitemap') {
254-
code = await getDynamicSiteMapRouteCode(resourcePath, page, this)
252+
code = await getDynamicSiteMapRouteCode(filePath, page, this)
255253
} else {
256-
code = getDynamicImageRouteCode(resourcePath)
254+
code = getDynamicImageRouteCode(filePath)
257255
}
258256
} else {
259-
console.log(
260-
'getStaticAssetRouteCode page',
261-
page,
262-
'this.resourcePath',
263-
this.resourcePath
264-
)
265-
code = await getStaticAssetRouteCode(resourcePath, fileBaseName)
257+
code = await getStaticAssetRouteCode(filePath, fileBaseName)
266258
}
267259

268260
return code

0 commit comments

Comments
 (0)