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

Commit

Permalink
Ensure that chunks are unique and filter out duplicate preload chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinGrandon authored and fusion-bot[bot] committed Sep 8, 2018
1 parent c802d47 commit 97aa51d
Showing 1 changed file with 5 additions and 2 deletions.
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

0 comments on commit 97aa51d

Please sign in to comment.