@wordpress/dependency-extraction-webpack-plugin
Advanced tools
Comparing version 6.8.1 to 6.8.2
@@ -372,2 +372,5 @@ /** | ||
static #staticDepsCurrent = new WeakSet(); | ||
static #staticDepsCache = new WeakMap(); | ||
/** | ||
@@ -382,2 +385,16 @@ * Can we trace a line of static dependencies from an entry to a module | ||
static hasStaticDependencyPathToRoot( compilation, block ) { | ||
if ( DependencyExtractionWebpackPlugin.#staticDepsCache.has( block ) ) { | ||
return DependencyExtractionWebpackPlugin.#staticDepsCache.get( | ||
block | ||
); | ||
} | ||
if ( | ||
DependencyExtractionWebpackPlugin.#staticDepsCurrent.has( block ) | ||
) { | ||
return false; | ||
} | ||
DependencyExtractionWebpackPlugin.#staticDepsCurrent.add( block ); | ||
const incomingConnections = [ | ||
@@ -396,2 +413,9 @@ ...compilation.moduleGraph.getIncomingConnections( block ), | ||
if ( ! incomingConnections.length ) { | ||
DependencyExtractionWebpackPlugin.#staticDepsCache.set( | ||
block, | ||
true | ||
); | ||
DependencyExtractionWebpackPlugin.#staticDepsCurrent.delete( | ||
block | ||
); | ||
return true; | ||
@@ -415,2 +439,9 @@ } | ||
if ( ! staticDependentModules.length ) { | ||
DependencyExtractionWebpackPlugin.#staticDepsCache.set( | ||
block, | ||
false | ||
); | ||
DependencyExtractionWebpackPlugin.#staticDepsCurrent.delete( | ||
block | ||
); | ||
return false; | ||
@@ -420,8 +451,13 @@ } | ||
// Continue to explore any static dependencies | ||
return staticDependentModules.some( ( parentStaticDependentModule ) => | ||
DependencyExtractionWebpackPlugin.hasStaticDependencyPathToRoot( | ||
compilation, | ||
parentStaticDependentModule | ||
) | ||
const result = staticDependentModules.some( | ||
( parentStaticDependentModule ) => | ||
DependencyExtractionWebpackPlugin.hasStaticDependencyPathToRoot( | ||
compilation, | ||
parentStaticDependentModule | ||
) | ||
); | ||
DependencyExtractionWebpackPlugin.#staticDepsCache.set( block, result ); | ||
DependencyExtractionWebpackPlugin.#staticDepsCurrent.delete( block ); | ||
return result; | ||
} | ||
@@ -428,0 +464,0 @@ } |
{ | ||
"name": "@wordpress/dependency-extraction-webpack-plugin", | ||
"version": "6.8.1", | ||
"version": "6.8.2", | ||
"description": "Extract WordPress script dependencies from webpack bundles.", | ||
@@ -41,3 +41,3 @@ "author": "The WordPress Contributors", | ||
}, | ||
"gitHead": "cf707c1f25a2716e310cc8f9afcc8554405c79ac" | ||
"gitHead": "51204ac9382d0551d8fdebd3c8d4623dabfa9f3c" | ||
} |
69754
561