Unverified Commit c56e9629 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Add lambda version of shared chunks (#6924)

* Add lambda version of shared chunks

* Fix test on Windows
parent 31dc4549
......@@ -160,19 +160,21 @@ export class ChunkGraphPlugin implements Plugin {
}
})
const getLambdaChunk = (name: string) =>
name.includes(this.buildId)
? name
.replace(new RegExp(`${this.buildId}[\\/\\\\]`), '')
.replace(/[.]js$/, `.${this.buildId}.js`)
: name
for (const page in pages) {
manifest.pages[page] = [...pages[page], ...sharedFiles]
manifest.pageChunks[page] = [
...new Set([
...pageChunks[page],
...pageChunks[page].map(name =>
name.includes(this.buildId)
? name
.replace(new RegExp(`${this.buildId}[\\/\\\\]`), '')
.replace(/[.]js$/, `.${this.buildId}.js`)
: name
),
...pageChunks[page].map(getLambdaChunk),
...sharedChunks,
...sharedChunks.map(getLambdaChunk),
]),
].sort()
}
......
/* eslint-env jest */
import { getSpecifiedPages } from 'next/dist/build'
import { getSpecifiedPages as _getSpecifiedPages } from 'next/dist/build'
const getSpecifiedPages = async (...args) =>
(await _getSpecifiedPages(...args)).map(pg => pg.replace(/\\+/g, '/'))
describe('getSpecifiedPages', () => {
it('should only choose selected', async () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment