-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add warning when providing query values in exportPathMap for auto-exp…
…ort page
- Loading branch information
Showing
6 changed files
with
93 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
// target: 'serverless', | ||
exportPathMap() { | ||
return { | ||
'/': { page: '/hello', query: { first: 'second' } }, | ||
'/amp': { page: '/amp' }, | ||
'/ssr': { page: '/ssr' }, | ||
} | ||
}, | ||
} |
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 const config = { amp: 'hybrid' } | ||
|
||
export default () => 'hi from hybrid AMP' |
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 () => 'hi' |
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,5 @@ | ||
const Page = () => "I'm SSRed" | ||
|
||
Page.getInitialProps = () => ({ hello: 'world' }) | ||
|
||
export default Page |
59 changes: 59 additions & 0 deletions
59
test/integration/auto-export-query-warn/test/index.test.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,59 @@ | ||
/* eslint-env jest */ | ||
/* global jasmine */ | ||
import path from 'path' | ||
import fs from 'fs-extra' | ||
import { nextBuild, nextExport } from 'next-test-utils' | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 1 | ||
const appDir = path.join(__dirname, '..') | ||
const outdir = path.join(__dirname, 'out') | ||
const nextConfig = path.join(appDir, 'next.config.js') | ||
let stderr | ||
|
||
const runTests = () => { | ||
it('should show warning for query provided for auto exported page correctly', async () => { | ||
expect(stderr).toContain( | ||
'Warn: you provided query values for / which is an auto-exported page. These can not be applied since the page can no longer be re-rendered on the server. To disable auto-export for this page add `getInitialProps`' | ||
) | ||
|
||
expect(stderr).not.toContain('/amp') | ||
expect(stderr).not.toContain('/ssr') | ||
expect(stderr).not.toContain('/hello') | ||
}) | ||
} | ||
|
||
let origNextConfig | ||
|
||
describe('Auto Export', () => { | ||
describe('server mode', () => { | ||
beforeAll(async () => { | ||
await nextBuild(appDir) | ||
const { stderr: curStderr } = await nextExport( | ||
appDir, | ||
{ outdir }, | ||
{ stderr: true } | ||
) | ||
stderr = curStderr | ||
}) | ||
|
||
runTests() | ||
}) | ||
|
||
describe('serverless mode', () => { | ||
beforeAll(async () => { | ||
origNextConfig = await fs.readFile(nextConfig, 'utf8') | ||
await nextBuild(appDir) | ||
const { stderr: curStderr } = await nextExport( | ||
appDir, | ||
{ outdir }, | ||
{ stderr: true } | ||
) | ||
stderr = curStderr | ||
}) | ||
afterAll(async () => { | ||
await fs.writeFile(nextConfig, origNextConfig) | ||
}) | ||
|
||
runTests() | ||
}) | ||
}) |