preload-webpack-plugin
Advanced tools
Comparing version 2.1.1 to 2.1.2
22
index.js
@@ -26,9 +26,22 @@ /** | ||
const isChunkBelongToHtml = (chunk, roots) => { | ||
const doesChunkBelongToHTML = (chunk, roots, visitedChunks) => { | ||
// Prevent circular recursion. | ||
// See https://github.com/GoogleChromeLabs/preload-webpack-plugin/issues/49 | ||
if (visitedChunks[chunk.renderedHash]) { | ||
return false; | ||
} | ||
visitedChunks[chunk.renderedHash] = true; | ||
for (const root of roots) { | ||
if (root.hash === chunk.renderedHash) return true; | ||
if (root.hash === chunk.renderedHash) { | ||
return true; | ||
} | ||
} | ||
for (const parent of chunk.parents) { | ||
if (isChunkBelongToHtml(parent, roots)) return true; | ||
if (doesChunkBelongToHTML(parent, roots, visitedChunks)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
@@ -84,3 +97,4 @@ }; | ||
// Only handle the chunk import by the htmlWebpackPlugin | ||
extractedChunks = extractedChunks.filter(chunk => isChunkBelongToHtml(chunk, Object.values(htmlPluginData.assets.chunks))); | ||
extractedChunks = extractedChunks.filter(chunk => doesChunkBelongToHTML( | ||
chunk, Object.values(htmlPluginData.assets.chunks), {})); | ||
@@ -87,0 +101,0 @@ flatten(extractedChunks.map(chunk => chunk.files)).filter(entry => { |
{ | ||
"name": "preload-webpack-plugin", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "Enhances html-webpack-plugin with link rel=preload wiring capabilities for scripts", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27659
124