-
Notifications
You must be signed in to change notification settings - Fork 27.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
error when output: export is used with intercepting routes (#75058)
Intercepting routes are built on top of [rewrites](https://nextjs.org/docs/app/api-reference/config/next-config-js/rewrites) which is one of the listed [unsupported features](https://nextjs.org/docs/app/building-your-application/deploying/static-exports#unsupported-features) of `output: "export"`. However, because the Next.js server injects the interception routes, it's not caught by existing validation logic in the export flow. This properly documents that intercepting routes are not currently supported by `output: "export"` and hard errors in next dev/build if detected. Previously route interception would just not have worked, instead serving the non-intercepted page when built, leading to a confusing experience. We eventually want to support this with improved SPA/export features, however that's out of scope for this PR: the goal here is to ensure we're providing more immediate feedback about the fact that this is unsupported.
- Loading branch information
Showing
13 changed files
with
101 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test/e2e/app-dir/interception-routes-output-export/app/@modal/(.)page/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page() { | ||
return 'intercepted' | ||
} |
1 change: 1 addition & 0 deletions
1
test/e2e/app-dir/interception-routes-output-export/app/@modal/default.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default () => null |
3 changes: 3 additions & 0 deletions
3
test/e2e/app-dir/interception-routes-output-export/app/default.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Default() { | ||
return null | ||
} |
13 changes: 13 additions & 0 deletions
13
test/e2e/app-dir/interception-routes-output-export/app/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export default function Layout(props: { | ||
children: React.ReactNode | ||
modal: React.ReactNode | ||
}) { | ||
return ( | ||
<html> | ||
<body> | ||
<div id="children">{props.children}</div> | ||
<div id="modal">{props.modal}</div> | ||
</body> | ||
</html> | ||
) | ||
} |
9 changes: 9 additions & 0 deletions
9
test/e2e/app-dir/interception-routes-output-export/app/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Link from 'next/link' | ||
|
||
export default function Page() { | ||
return ( | ||
<div> | ||
<Link href="/page">To /page</Link> | ||
</div> | ||
) | ||
} |
3 changes: 3 additions & 0 deletions
3
test/e2e/app-dir/interception-routes-output-export/app/page/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page() { | ||
return <p>hello world</p> | ||
} |
30 changes: 30 additions & 0 deletions
30
test/e2e/app-dir/interception-routes-output-export/interception-routes-output-export.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { isNextDev, isNextStart } from 'e2e-utils' | ||
import { findPort, killApp, launchApp, nextBuild, retry } from 'next-test-utils' | ||
|
||
describe('interception-routes-output-export', () => { | ||
it('should error when using interception routes with static export', async () => { | ||
if (isNextStart) { | ||
const { code, stderr } = await nextBuild(__dirname, [], { stderr: true }) | ||
expect(stderr).toContain( | ||
'Intercepting routes are not supported with static export.' | ||
) | ||
expect(code).toBe(1) | ||
} else if (isNextDev) { | ||
let stderr = '' | ||
const port = await findPort() | ||
const app = await launchApp(__dirname, port, { | ||
onStderr(msg) { | ||
stderr += msg || '' | ||
}, | ||
}) | ||
|
||
await retry(async () => { | ||
expect(stderr).toContain( | ||
'Intercepting routes are not supported with static export.' | ||
) | ||
}) | ||
|
||
await killApp(app) | ||
} | ||
}) | ||
}) |
6 changes: 6 additions & 0 deletions
6
test/e2e/app-dir/interception-routes-output-export/next.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* @type {import('next').NextConfig} | ||
*/ | ||
const nextConfig = { output: 'export' } | ||
|
||
module.exports = nextConfig |