Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ensure ssr page conflict is caught also
  • Loading branch information
ijjk committed Jan 8, 2021
1 parent 859fdb7 commit 999a815
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
9 changes: 8 additions & 1 deletion packages/next/build/index.ts
Expand Up @@ -800,7 +800,14 @@ export default async function build(
if (staticPages.size > 0 || ssgPages.size > 0 || useStatic404) {
const combinedPages = [...staticPages, ...ssgPages]

detectConflictingPaths(combinedPages, ssgPages, additionalSsgPaths)
detectConflictingPaths(
[
...combinedPages,
...pageKeys.filter((page) => !combinedPages.includes(page)),
],
ssgPages,
additionalSsgPaths
)
const exportApp = require('../export').default
const exportOptions = {
silent: false,
Expand Down
55 changes: 54 additions & 1 deletion test/integration/conflicting-ssg-paths/test/index.test.js
Expand Up @@ -74,8 +74,9 @@ describe('Conflicting SSG paths', () => {
)
expect(output).toContain('err.sh/next.js/conflicting-ssg-paths')
expect(output).toContain(
`path: "/blog/conflicting" from page: "/blog/[slug]" conflicts with path: "/blog/conflicting" from page: "/[...catchAll]"`
`path: "/blog/conflicting" from page: "/[...catchAll]"`
)
expect(output).toContain(`conflicts with path: "/blog/conflicting"`)
})

it('should show proper error when a dynamic SSG route conflicts with normal route', async () => {
Expand Down Expand Up @@ -127,4 +128,56 @@ describe('Conflicting SSG paths', () => {
`path: "/hellO/world" from page: "/[...catchAll]" conflicts with path: "/hello/world"`
)
})

it('should show proper error when a dynamic SSG route conflicts with SSR route', async () => {
await fs.ensureDir(join(pagesDir, 'hello'))
await fs.writeFile(
join(pagesDir, 'hello/world.js'),
`
export const getServerSideProps = () => ({ props: {} })
export default function Page() {
return '/hello/world'
}
`
)

await fs.writeFile(
join(pagesDir, '[...catchAll].js'),
`
export const getStaticProps = () => {
return {
props: {}
}
}
export const getStaticPaths = () => {
return {
paths: [
'/hello',
'/hellO/world'
],
fallback: false
}
}
export default function Page() {
return '/[catchAll]'
}
`
)

const result = await nextBuild(appDir, undefined, {
stdout: true,
stderr: true,
})
const output = result.stdout + result.stderr
expect(output).toContain(
'Conflicting paths returned from getStaticPaths, paths must unique per page'
)
expect(output).toContain('err.sh/next.js/conflicting-ssg-paths')
expect(output).toContain(
`path: "/hellO/world" from page: "/[...catchAll]" conflicts with path: "/hello/world"`
)
})
})

0 comments on commit 999a815

Please sign in to comment.