diff --git a/packages/next/export/index.ts b/packages/next/export/index.ts index b1612ece4853294..375d4f915571145 100644 --- a/packages/next/export/index.ts +++ b/packages/next/export/index.ts @@ -640,13 +640,13 @@ export default async function exportApp( Object.keys(prerenderManifest.routes).map(async (route) => { const { srcRoute } = prerenderManifest!.routes[route] const pageName = srcRoute || route - route = normalizePagePath(route) // returning notFound: true from getStaticProps will not // output html/json files during the build if (prerenderManifest!.notFoundRoutes.includes(route)) { return } + route = normalizePagePath(route) const pagePath = getPagePath(pageName, distDir, isLikeServerless) const distPagesDir = join( diff --git a/test/integration/export-index-not-found-gsp/pages/index.js b/test/integration/export-index-not-found-gsp/pages/index.js new file mode 100644 index 000000000000000..f5ec69c7fffa704 --- /dev/null +++ b/test/integration/export-index-not-found-gsp/pages/index.js @@ -0,0 +1,7 @@ +export default function Page() { + return 'Hello world' +} + +export function getStaticProps() { + return { notFound: true } +} diff --git a/test/integration/export-index-not-found-gsp/test/index.test.ts b/test/integration/export-index-not-found-gsp/test/index.test.ts new file mode 100644 index 000000000000000..c915d7af1b8797e --- /dev/null +++ b/test/integration/export-index-not-found-gsp/test/index.test.ts @@ -0,0 +1,21 @@ +/* eslint-env jest */ + +import fs from 'fs-extra' +import { join } from 'path' +import { nextBuild, nextExport } from 'next-test-utils' + +const appDir = join(__dirname, '../') +const outdir = join(appDir, 'out') + +describe('Export index page with `notFound: true` in `getStaticProps`', () => { + it('should build successfully', async () => { + await fs.remove(join(appDir, '.next')) + const { code } = await nextBuild(appDir) + if (code !== 0) throw new Error(`build failed with status ${code}`) + }) + + it('should export successfully', async () => { + const { code } = await nextExport(appDir, { outdir }) + if (code !== 0) throw new Error(`export failed with status ${code}`) + }) +})