Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Ensure that chunks are unique and filter out duplicate preload chunks #287

Merged
merged 1 commit into from
Sep 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/plugins/ssr.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function getCoreGlobals(ctx) {
}

function getUrls({chunkUrlMap, webpackPublicPath}, chunks) {
return chunks.map(id => {
return [...new Set(chunks)].map(id => {
let url = chunkUrlMap.get(id).get('es5');
if (webpackPublicPath.endsWith('/')) {
url = webpackPublicPath + url;
Expand All @@ -134,7 +134,10 @@ function getChunkScripts(ctx) {
ctx.nonce
}" defer${crossOrigin} src="${url}"></script>`;
});
const preloaded = getUrls(ctx, ctx.preloadChunks).map(({id, url}) => {
const preloaded = getUrls(
ctx,
ctx.preloadChunks.filter(item => !ctx.syncChunks.includes(item))
).map(({id, url}) => {
return `<script nonce="${
ctx.nonce
}" defer${crossOrigin} src="${url}"></script>`;
Expand Down