mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Remove the json-pages plugin.
This commit is contained in:
parent
76bfc38a09
commit
5aa02d0727
|
@ -1,24 +0,0 @@
|
|||
export default class JsonPagesPlugin {
|
||||
apply (compiler) {
|
||||
compiler.plugin('after-compile', (compilation, callback) => {
|
||||
const pages = Object
|
||||
.keys(compilation.assets)
|
||||
.filter((filename) => /^bundles[/\\]pages.*\.js$/.test(filename))
|
||||
|
||||
pages.forEach((pageName) => {
|
||||
const page = compilation.assets[pageName]
|
||||
// delete compilation.assets[pageName]
|
||||
|
||||
const content = page.source()
|
||||
const newContent = JSON.stringify({ component: content })
|
||||
|
||||
compilation.assets[`${pageName}on`] = {
|
||||
source: () => newContent,
|
||||
size: () => newContent.length
|
||||
}
|
||||
})
|
||||
|
||||
callback()
|
||||
})
|
||||
}
|
||||
}
|
|
@ -28,11 +28,8 @@ export default class PagesPlugin {
|
|||
window.NEXT_LOADED_PAGES.push(loadPage)
|
||||
}
|
||||
`
|
||||
// Replace the current asset
|
||||
// TODO: We need to move "client-bundles" back to "bundles" once we remove
|
||||
// all the JSON eval stuff
|
||||
delete compilation.assets[chunk.name]
|
||||
compilation.assets[`client-bundles/pages/${pageName}.js`] = {
|
||||
// Replace the exisiting chunk with the new content
|
||||
compilation.assets[chunk.name] = {
|
||||
source: () => newContent,
|
||||
size: () => newContent.length
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import WriteFilePlugin from 'write-file-webpack-plugin'
|
|||
import FriendlyErrorsWebpackPlugin from 'friendly-errors-webpack-plugin'
|
||||
import CaseSensitivePathPlugin from 'case-sensitive-paths-webpack-plugin'
|
||||
import UnlinkFilePlugin from './plugins/unlink-file-plugin'
|
||||
import JsonPagesPlugin from './plugins/json-pages-plugin'
|
||||
import PagesPlugin from './plugins/pages-plugin'
|
||||
import CombineAssetsPlugin from './plugins/combine-assets-plugin'
|
||||
import getConfig from '../config'
|
||||
|
@ -117,7 +116,6 @@ export default async function createCompiler (dir, { dev = false, quiet = false,
|
|||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': JSON.stringify(dev ? 'development' : 'production')
|
||||
}),
|
||||
new JsonPagesPlugin(),
|
||||
new PagesPlugin(),
|
||||
new CaseSensitivePathPlugin()
|
||||
]
|
||||
|
|
|
@ -122,7 +122,7 @@ export default class Server {
|
|||
return await renderScriptError(req, res, '/_error', error, customFields, this.renderOpts)
|
||||
}
|
||||
|
||||
const p = join(this.dir, '.next/client-bundles/pages/_error.js')
|
||||
const p = join(this.dir, '.next/bundles/pages/_error.js')
|
||||
await this.serveStatic(req, res, p)
|
||||
},
|
||||
|
||||
|
|
|
@ -57,8 +57,8 @@ async function doRender (req, res, pathname, query, {
|
|||
errorComponent
|
||||
] = await Promise.all([
|
||||
loadGetInitialProps(Component, ctx),
|
||||
readPage(join(dir, '.next', 'client-bundles', 'pages', page)),
|
||||
readPage(join(dir, '.next', 'client-bundles', 'pages', '_error'))
|
||||
readPage(join(dir, '.next', 'bundles', 'pages', page)),
|
||||
readPage(join(dir, '.next', 'bundles', 'pages', '_error'))
|
||||
])
|
||||
|
||||
// the response might be finshed on the getinitialprops call
|
||||
|
@ -114,7 +114,7 @@ async function doRender (req, res, pathname, query, {
|
|||
|
||||
export async function renderScript (req, res, page, opts) {
|
||||
try {
|
||||
const path = join(opts.dir, '.next', 'client-bundles', 'pages', page)
|
||||
const path = join(opts.dir, '.next', 'bundles', 'pages', page)
|
||||
const realPath = await resolvePath(path)
|
||||
await serveStatic(req, res, realPath)
|
||||
} catch (err) {
|
||||
|
|
|
@ -37,7 +37,7 @@ describe('On Demand Entries', () => {
|
|||
|
||||
it('should dispose inactive pages', async () => {
|
||||
await renderViaHTTP(context.appPort, '/_next/-/pages/about')
|
||||
const aboutPagePath = resolve(__dirname, '../.next/client-bundles/pages/about.js')
|
||||
const aboutPagePath = resolve(__dirname, '../.next/bundles/pages/about.js')
|
||||
expect(existsSync(aboutPagePath)).toBeTruthy()
|
||||
|
||||
// Wait maximum of jasmine.DEFAULT_TIMEOUT_INTERVAL checking
|
||||
|
|
Loading…
Reference in a new issue