mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Fix some issues related to rendering.
This commit is contained in:
parent
e3d68ff401
commit
03209d88fd
|
@ -31,13 +31,13 @@ const {
|
|||
location
|
||||
} = window
|
||||
|
||||
window.NEXT_PAGE_LOADER = new PageLoader(buildId)
|
||||
|
||||
const pageLoader = window.NEXT_PAGE_LOADER = new PageLoader(buildId)
|
||||
const Component = evalScript(component).default
|
||||
const ErrorComponent = evalScript(errorComponent).default
|
||||
let lastAppProps
|
||||
|
||||
export const router = createRouter(pathname, query, getURL(), {
|
||||
pageLoader,
|
||||
Component,
|
||||
ErrorComponent,
|
||||
err
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/* global NEXT_PAGE_LOADER */
|
||||
|
||||
import { parse, format } from 'url'
|
||||
import mitt from 'mitt'
|
||||
import shallowEquals from '../shallow-equals'
|
||||
|
@ -10,7 +8,7 @@ import { _notifyBuildIdMismatch } from './'
|
|||
const webpackModule = module
|
||||
|
||||
export default class Router {
|
||||
constructor (pathname, query, as, { Component, ErrorComponent, err } = {}) {
|
||||
constructor (pathname, query, as, { pageLoader, Component, ErrorComponent, err } = {}) {
|
||||
// represents the current component key
|
||||
this.route = toRoute(pathname)
|
||||
|
||||
|
@ -26,6 +24,7 @@ export default class Router {
|
|||
// Handling Router Events
|
||||
this.events = mitt()
|
||||
|
||||
this.pageLoader = pageLoader
|
||||
this.prefetchQueue = new PQueue({ concurrency: 2 })
|
||||
this.ErrorComponent = ErrorComponent
|
||||
this.pathname = pathname
|
||||
|
@ -80,7 +79,7 @@ export default class Router {
|
|||
|
||||
async reload (route) {
|
||||
delete this.components[route]
|
||||
NEXT_PAGE_LOADER.clearCache(route)
|
||||
this.pageLoader.clearCache(route)
|
||||
|
||||
if (route !== this.route) return
|
||||
|
||||
|
@ -335,7 +334,7 @@ export default class Router {
|
|||
})
|
||||
}
|
||||
|
||||
return await NEXT_PAGE_LOADER.loadPage(route)
|
||||
return await this.pageLoader.loadPage(route)
|
||||
}
|
||||
|
||||
abortComponentLoad (as) {
|
||||
|
|
|
@ -12,7 +12,7 @@ export default class PagesPlugin {
|
|||
pages.forEach((chunk) => {
|
||||
const page = compilation.assets[chunk.name]
|
||||
const pageName = matchRouteName.exec(chunk.name)[1]
|
||||
const routeName = `/${pageName.replace(/index$/, '')}`
|
||||
const routeName = `/${pageName.replace(/[/\\]index$/, '')}`
|
||||
|
||||
const content = page.source()
|
||||
const newContent = `
|
||||
|
|
Loading…
Reference in a new issue