Skip to content

Commit

Permalink
perf: generate preload directives for dynamicImport chunks too
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 12, 2021
1 parent 12b1625 commit b9fc0cb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/node/build/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,18 @@ function resolvePageImports(
) {
// find the page's js chunk and inject script tags for its imports so that
// they are start fetching as early as possible

const srcPath = normalizePath(path.resolve(config.root, page))
const pageChunk = result.output.find(
(chunk) => chunk.type === 'chunk' && chunk.facadeModuleId === srcPath
) as OutputChunk
return Array.from(new Set([...indexChunk.imports, ...pageChunk.imports]))
return Array.from(
new Set([
...indexChunk.imports,
...indexChunk.dynamicImports,
...pageChunk.imports,
...pageChunk.dynamicImports
])
)
}

function renderHead(head: HeadConfig[]) {
Expand Down

0 comments on commit b9fc0cb

Please sign in to comment.