Skip to content

Commit 6ca3c97

Browse files
committed
fix duplicated preload directive
1 parent 6774f8e commit 6ca3c97

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/node/build/render.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ export async function renderPage(
4646
: []
4747
: result && appChunk
4848
? [
49-
// resolve imports for index.js + page.md.js and inject script tags for
50-
// them as well so we fetch everything as early as possible without having
51-
// to wait for entry chunks to parse
52-
...resolvePageImports(config, page, result, appChunk),
53-
pageClientJsFileName,
54-
appChunk.fileName
49+
...new Set([
50+
// resolve imports for index.js + page.md.js and inject script tags for
51+
// them as well so we fetch everything as early as possible without having
52+
// to wait for entry chunks to parse
53+
...resolvePageImports(config, page, result, appChunk),
54+
pageClientJsFileName,
55+
appChunk.fileName
56+
])
5557
]
5658
: []
5759
)
@@ -130,7 +132,7 @@ function resolvePageImports(
130132
config: SiteConfig,
131133
page: string,
132134
result: RollupOutput,
133-
indexChunk: OutputChunk
135+
appChunk: OutputChunk
134136
) {
135137
// find the page's js chunk and inject script tags for its imports so that
136138
// they are start fetching as early as possible
@@ -140,14 +142,12 @@ function resolvePageImports(
140142
const pageChunk = result.output.find(
141143
(chunk) => chunk.type === 'chunk' && chunk.facadeModuleId === srcPath
142144
) as OutputChunk
143-
return Array.from(
144-
new Set([
145-
...indexChunk.imports,
146-
...indexChunk.dynamicImports,
147-
...pageChunk.imports,
148-
...pageChunk.dynamicImports
149-
])
150-
)
145+
return [
146+
...appChunk.imports,
147+
...appChunk.dynamicImports,
148+
...pageChunk.imports,
149+
...pageChunk.dynamicImports
150+
]
151151
}
152152

153153
function renderHead(head: HeadConfig[]) {

0 commit comments

Comments
 (0)