1
0
Fork 0
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:
Arunoda Susiripala 2017-04-06 10:33:11 +05:30
parent 76bfc38a09
commit 5aa02d0727
6 changed files with 7 additions and 36 deletions

View file

@ -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()
})
}
}

View file

@ -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
}

View file

@ -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()
]

View file

@ -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)
},

View file

@ -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) {

View file

@ -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