|
| 1 | +import { FileRef, nextTestSetup } from 'e2e-utils' |
| 2 | +import path from 'path' |
| 3 | + |
| 4 | +describe('app-dir edge SSR invalid reexport', () => { |
| 5 | + const { next, isNextDev, skipped } = nextTestSetup({ |
| 6 | + files: { |
| 7 | + 'app/export': new FileRef(path.join(__dirname, 'app', 'export')), |
| 8 | + 'app/export/inherit/page.tsx': |
| 9 | + "export { default, runtime, preferredRegion } from '../basic/page'", |
| 10 | + }, |
| 11 | + skipStart: true, |
| 12 | + skipDeployment: true, |
| 13 | + }) |
| 14 | + |
| 15 | + if (skipped) { |
| 16 | + return |
| 17 | + } |
| 18 | + |
| 19 | + it('should warn or error about the re-export of a pages runtime/preferredRegion config', async () => { |
| 20 | + try { |
| 21 | + await next.start() |
| 22 | + } catch (_) { |
| 23 | + // We expect the build to fail |
| 24 | + } |
| 25 | + |
| 26 | + if (isNextDev) { |
| 27 | + const browser = await next.browser('/export/inherit') |
| 28 | + // Turbopack is stricter and disallows reexports completely |
| 29 | + // webpack merely warns in the CLI and still serves the page wuthout a redbox |
| 30 | + if (process.env.IS_TURBOPACK_TEST) { |
| 31 | + await expect(browser).toDisplayRedbox(` |
| 32 | + { |
| 33 | + "description": "Next.js can't recognize the exported \`preferredRegion\` field in route. It musn't be reexported.", |
| 34 | + "environmentLabel": null, |
| 35 | + "label": "Build Error", |
| 36 | + "source": "./app/export/inherit/page.tsx (1:28) |
| 37 | + Next.js can't recognize the exported \`preferredRegion\` field in route. It musn't be reexported. |
| 38 | + > 1 | export { default, runtime, preferredRegion } from '../basic/page' |
| 39 | + | ^^^^^^^^^^^^^^^", |
| 40 | + "stack": [], |
| 41 | + } |
| 42 | + `) |
| 43 | + } |
| 44 | + } |
| 45 | + |
| 46 | + expect(next.cliOutput).toInclude( |
| 47 | + `Next.js can't recognize the exported \`runtime\` field in` |
| 48 | + ) |
| 49 | + expect(next.cliOutput).toInclude( |
| 50 | + `Next.js can't recognize the exported \`preferredRegion\` field in` |
| 51 | + ) |
| 52 | + }) |
| 53 | +}) |
0 commit comments