mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
Fixes failing assertion with turbopack Verified against turbopack + adapter deploy test locally <img width="2076" height="1336" alt="CleanShot 2026-02-26 at 13 25 30@2x" src="https://github.com/user-attachments/assets/a8c66314-8163-4371-b02a-dc7146989425" /> x-ref: https://github.com/vercel/next.js/pull/90600#issuecomment-3968044160
41 lines
1.4 KiB
JavaScript
41 lines
1.4 KiB
JavaScript
module.exports = {
|
|
onBuildComplete({ outputs }) {
|
|
const pagesDataPathnames = outputs.pages
|
|
.map((item) => item.pathname)
|
|
.filter((item) => item.startsWith('/_next/data/'))
|
|
const appPagesDataPathnames = outputs.appPages
|
|
.map((item) => item.pathname)
|
|
.filter((item) => item.startsWith('/_next/data/'))
|
|
|
|
const hasIndexData = pagesDataPathnames.some((item) =>
|
|
/^\/_next\/data\/[^/]+\/index\.json$/.test(item)
|
|
)
|
|
const hasDynamicData = pagesDataPathnames.some((item) =>
|
|
/^\/_next\/data\/[^/]+\/\[id\]\.json$/.test(item)
|
|
)
|
|
const hasDoubleIndexData = [
|
|
...pagesDataPathnames,
|
|
...appPagesDataPathnames,
|
|
].some((item) => /^\/_next\/data\/[^/]+\/index\/index\.json$/.test(item))
|
|
|
|
if (!hasIndexData || !hasDynamicData || hasDoubleIndexData) {
|
|
throw new Error(
|
|
[
|
|
'Unexpected edge pages data output from adapter build:',
|
|
`pagesDataPathnames=${JSON.stringify(pagesDataPathnames)}`,
|
|
`appPagesDataPathnames=${JSON.stringify(appPagesDataPathnames)}`,
|
|
`hasIndexData=${hasIndexData}`,
|
|
`hasDynamicData=${hasDynamicData}`,
|
|
`hasDoubleIndexData=${hasDoubleIndexData}`,
|
|
].join('\n')
|
|
)
|
|
}
|
|
|
|
if (appPagesDataPathnames.length > 0) {
|
|
throw new Error(
|
|
`Expected no pages-router data outputs in appPages: ${JSON.stringify(appPagesDataPathnames)}`
|
|
)
|
|
}
|
|
},
|
|
}
|