-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove buildId from server-side files (#14413)
Gets rid of the custom function for naming files by removing buildId from the file paths.
- Loading branch information
1 parent
a7af013
commit 6c2ce70
Showing
30 changed files
with
269 additions
and
388 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {} |
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 = (props) => { | ||
return <h1 id="404-title">{props.extraProp}</h1> | ||
} | ||
|
||
export default page |
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,18 @@ | ||
import App from 'next/app' | ||
|
||
function MyApp({ Component, pageProps, extraProp }) { | ||
return <Component {...pageProps} extraProp={extraProp} /> | ||
} | ||
|
||
// Only uncomment this method if you have blocking data requirements for | ||
// every single page in your application. This disables the ability to | ||
// perform automatic static optimization, causing every page in your app to | ||
// be server-side rendered. | ||
MyApp.getInitialProps = async (appContext) => { | ||
// calls page's `getInitialProps` and fills `appProps.pageProps` | ||
const appProps = await App.getInitialProps(appContext) | ||
|
||
return { ...appProps, extraProp: 'Hi There' } | ||
} | ||
|
||
export default MyApp |
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 = () => 'custom 404 page' | ||
page.getInitialProps = () => { | ||
throw new Error('oops') | ||
} | ||
export default page |
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 () => 'hello from index' |
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,89 @@ | ||
/* eslint-env jest */ | ||
|
||
import fs from 'fs-extra' | ||
import { join } from 'path' | ||
import { | ||
killApp, | ||
findPort, | ||
launchApp, | ||
nextStart, | ||
nextBuild, | ||
fetchViaHTTP, | ||
} from 'next-test-utils' | ||
import webdriver from 'next-webdriver' | ||
import cheerio from 'cheerio' | ||
|
||
jest.setTimeout(1000 * 60 * 2) | ||
|
||
const appDir = join(__dirname, '../') | ||
const gip404Err = /`pages\/404` can not have getInitialProps\/getServerSideProps/ | ||
|
||
let appPort | ||
let app | ||
|
||
describe('404 Page Support with _app', () => { | ||
describe('production mode', () => { | ||
afterAll(() => killApp(app)) | ||
|
||
it('should build successfully', async () => { | ||
const { code, stderr, stdout } = await nextBuild(appDir, [], { | ||
stderr: true, | ||
stdout: true, | ||
}) | ||
|
||
expect(code).toBe(0) | ||
expect(stderr).not.toMatch(gip404Err) | ||
expect(stdout).not.toMatch(gip404Err) | ||
|
||
appPort = await findPort() | ||
app = await nextStart(appDir, appPort) | ||
}) | ||
|
||
it('should not output static 404 if _app has getInitialProps', async () => { | ||
const browser = await webdriver(appPort, '/404') | ||
const isAutoExported = await browser.eval('__NEXT_DATA__.autoExport') | ||
expect(isAutoExported).toBe(null) | ||
}) | ||
|
||
it('specify to use the 404 page still in the routes-manifest', async () => { | ||
const manifest = await fs.readJSON( | ||
join(appDir, '.next/routes-manifest.json') | ||
) | ||
expect(manifest.pages404).toBe(true) | ||
}) | ||
|
||
it('should still use 404 page', async () => { | ||
const res = await fetchViaHTTP(appPort, '/abc') | ||
expect(res.status).toBe(404) | ||
const $ = cheerio.load(await res.text()) | ||
expect($('#404-title').text()).toBe('Hi There') | ||
}) | ||
}) | ||
|
||
describe('dev mode', () => { | ||
let stderr = '' | ||
let stdout = '' | ||
|
||
beforeAll(async () => { | ||
appPort = await findPort() | ||
app = await launchApp(appDir, appPort, { | ||
onStderr(msg) { | ||
stderr += msg | ||
}, | ||
onStdout(msg) { | ||
stdout += msg | ||
}, | ||
}) | ||
}) | ||
afterAll(() => killApp(app)) | ||
|
||
it('should not show pages/404 GIP error if _app has GIP', async () => { | ||
const res = await fetchViaHTTP(appPort, '/abc') | ||
expect(res.status).toBe(404) | ||
const $ = cheerio.load(await res.text()) | ||
expect($('#404-title').text()).toBe('Hi There') | ||
expect(stderr).not.toMatch(gip404Err) | ||
expect(stdout).not.toMatch(gip404Err) | ||
}) | ||
}) | ||
}) |
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
Oops, something went wrong.