fix duplicated preload directive

pull/478/head
Evan You 4 years ago
parent 6774f8e988
commit 6ca3c97ab9

@ -46,12 +46,14 @@ export async function renderPage(
: [] : []
: result && appChunk : result && appChunk
? [ ? [
// resolve imports for index.js + page.md.js and inject script tags for ...new Set([
// them as well so we fetch everything as early as possible without having // resolve imports for index.js + page.md.js and inject script tags for
// to wait for entry chunks to parse // them as well so we fetch everything as early as possible without having
...resolvePageImports(config, page, result, appChunk), // to wait for entry chunks to parse
pageClientJsFileName, ...resolvePageImports(config, page, result, appChunk),
appChunk.fileName pageClientJsFileName,
appChunk.fileName
])
] ]
: [] : []
) )
@ -130,7 +132,7 @@ function resolvePageImports(
config: SiteConfig, config: SiteConfig,
page: string, page: string,
result: RollupOutput, result: RollupOutput,
indexChunk: OutputChunk appChunk: OutputChunk
) { ) {
// find the page's js chunk and inject script tags for its imports so that // find the page's js chunk and inject script tags for its imports so that
// they are start fetching as early as possible // they are start fetching as early as possible
@ -140,14 +142,12 @@ function resolvePageImports(
const pageChunk = result.output.find( const pageChunk = result.output.find(
(chunk) => chunk.type === 'chunk' && chunk.facadeModuleId === srcPath (chunk) => chunk.type === 'chunk' && chunk.facadeModuleId === srcPath
) as OutputChunk ) as OutputChunk
return Array.from( return [
new Set([ ...appChunk.imports,
...indexChunk.imports, ...appChunk.dynamicImports,
...indexChunk.dynamicImports, ...pageChunk.imports,
...pageChunk.imports, ...pageChunk.dynamicImports
...pageChunk.dynamicImports ]
])
)
} }
function renderHead(head: HeadConfig[]) { function renderHead(head: HeadConfig[]) {

Loading…
Cancel
Save