1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Make sure next export doesn't break other modes.

This commit is contained in:
Arunoda Susiripala 2017-05-09 00:42:48 -07:00
parent 147a5ce641
commit 450277f294
3 changed files with 9 additions and 1 deletions

View file

@ -105,5 +105,10 @@ export default class PageLoader {
route = this.normalizeRoute(route) route = this.normalizeRoute(route)
delete this.pageCache[route] delete this.pageCache[route]
delete this.loadingRoutes[route] delete this.loadingRoutes[route]
const script = document.getElementById(`__NEXT_PAGE__${route}`)
if (script) {
script.parentNode.removeChild(script)
}
} }
} }

View file

@ -123,7 +123,7 @@ export default class Server {
await this.serveStatic(req, res, p) await this.serveStatic(req, res, p)
}, },
'/_next/:buildId/page/_error': async (req, res, params) => { '/_next/:buildId/page/_error*': async (req, res, params) => {
if (!this.handleBuildId(params.buildId, res)) { if (!this.handleBuildId(params.buildId, res)) {
const error = new Error('INVALID_BUILD_ID') const error = new Error('INVALID_BUILD_ID')
const customFields = { buildIdMismatched: true } const customFields = { buildIdMismatched: true }

View file

@ -20,6 +20,7 @@ describe('Router', () => {
const request = { clone: () => null } const request = { clone: () => null }
describe('.prefetch()', () => { describe('.prefetch()', () => {
it('should prefetch a given page', async () => { it('should prefetch a given page', async () => {
global.__NEXT_DATA__ = {}
const pageLoader = new PageLoader() const pageLoader = new PageLoader()
const router = new Router('/', {}, '/', { pageLoader }) const router = new Router('/', {}, '/', { pageLoader })
const route = '/routex' const route = '/routex'
@ -29,6 +30,7 @@ describe('Router', () => {
}) })
it('should only run two jobs at a time', async () => { it('should only run two jobs at a time', async () => {
global.__NEXT_DATA__ = {}
// delay loading pages for an hour // delay loading pages for an hour
const pageLoader = new PageLoader({ delay: 1000 * 3600 }) const pageLoader = new PageLoader({ delay: 1000 * 3600 })
const router = new Router('/', {}, '/', { pageLoader }) const router = new Router('/', {}, '/', { pageLoader })
@ -46,6 +48,7 @@ describe('Router', () => {
}) })
it('should run all the jobs', async () => { it('should run all the jobs', async () => {
global.__NEXT_DATA__ = {}
const pageLoader = new PageLoader() const pageLoader = new PageLoader()
const router = new Router('/', {}, '/', { pageLoader }) const router = new Router('/', {}, '/', { pageLoader })
const routes = ['route1', 'route2', 'route3', 'route4'] const routes = ['route1', 'route2', 'route3', 'route4']