Fix build-manifest not removing _app files for modern (#8447)

This commit is contained in:
JJ Kasper 2019-08-20 14:32:03 -05:00 committed by Joe Haddad
parent 8bd2e433de
commit 9c8aaf9d4b
4 changed files with 42 additions and 1 deletions

View file

@ -25,8 +25,9 @@ const generateClientManifest = (
): string => {
const clientManifest: { [s: string]: string[] } = {}
const appDependencies = new Set(assetMap.pages['/_app'])
delete assetMap.pages['/_app']
Object.entries(assetMap.pages).forEach(([page, dependencies]) => {
if (page === '/_app') return
// Filter out dependencies in the _app entry, because those will have already
// been loaded by the client prior to a navigation event
const filteredDeps = dependencies.filter(

View file

@ -0,0 +1,6 @@
module.exports = {
experimental: {
modern: true,
granularChunks: true
}
}

View file

@ -0,0 +1 @@
export default () => <p>hi</p>

View file

@ -0,0 +1,33 @@
/* eslint-env jest */
/* global jasmine */
import { join } from 'path'
import { readFile } from 'fs-extra'
import { nextBuild } from 'next-test-utils'
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 1
const appDir = join(__dirname, '../')
let buildId
describe('Chunking (minimal)', () => {
beforeAll(async () => {
await nextBuild(appDir)
buildId = await readFile(join(appDir, '.next/BUILD_ID'), 'utf8')
})
it('should have an empty client-manifest', async () => {
const manifest = await readFile(
join(appDir, '.next/static', buildId, '_buildManifest.js'),
'utf8'
)
expect(manifest).not.toMatch(/\.js/)
})
it('should have an empty modern client-manifest', async () => {
const manifest = await readFile(
join(appDir, '.next/static', buildId, '_buildManifest.module.js'),
'utf8'
)
expect(manifest).not.toMatch(/\.js/)
})
})