When AMP first pages are accessed, the following error statement outputs.
Could not find files for /xxx in .next/build-manifest.json.
These AMP pages can be viewed.
> next start
ready - started server on http://localhost:3000
Could not find files for / in .next/build-manifest.json
No error outputs.
None.
This error will be called in getPageFiles here.
getPageFiles will be called in getDocumentFiles here.
getDocumentFiles is called when rendering all pages that use _document.
So all pages might pass this function.
But I found that AMP First Pages was not included in build-manifest.json's pages (PR).
And, when AMPState ampFirst is true, the amp page files were excluded by render.tsx.
However, This PR seems to be removed that feature and caused the error.
It may be roughly solved the following way in _document.tsx.
before:
const files: DocumentFiles = getDocumentFiles(
this.context.buildManifest,
this.context.__NEXT_DATA__.page
)
after:
const files: DocumentFiles = inAmpMode ? {
sharedFiles: [],
pageFiles: [],
allFiles: [],
} : getDocumentFiles(
this.context.buildManifest,
this.context.__NEXT_DATA__.page
)
Does anyone review it?
Most helpful comment
Does anyone review it?