diff --git a/packages/dependency-extraction-webpack-plugin/lib/index.js b/packages/dependency-extraction-webpack-plugin/lib/index.js index 7fb904427b9ae..0e6f8a5fbc6cc 100644 --- a/packages/dependency-extraction-webpack-plugin/lib/index.js +++ b/packages/dependency-extraction-webpack-plugin/lib/index.js @@ -349,9 +349,6 @@ class DependencyExtractionWebpackPlugin { } } - static #staticDepsCurrent = new WeakSet(); - static #staticDepsCache = new WeakMap(); - /** * Can we trace a line of static dependencies from an entry to a module * @@ -361,20 +358,6 @@ class DependencyExtractionWebpackPlugin { * @return {boolean} True if there is a static import path to the root */ 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 = [ ...compilation.moduleGraph.getIncomingConnections( block ), ].filter( @@ -388,13 +371,6 @@ class DependencyExtractionWebpackPlugin { // If we don't have non-entry, non-library incoming connections, // we've reached a root of if ( ! incomingConnections.length ) { - DependencyExtractionWebpackPlugin.#staticDepsCache.set( - block, - true - ); - DependencyExtractionWebpackPlugin.#staticDepsCurrent.delete( - block - ); return true; } @@ -413,28 +389,16 @@ class DependencyExtractionWebpackPlugin { // All the dependencies were Async, the module was reached via a dynamic import if ( ! staticDependentModules.length ) { - DependencyExtractionWebpackPlugin.#staticDepsCache.set( - block, - false - ); - DependencyExtractionWebpackPlugin.#staticDepsCurrent.delete( - block - ); return false; } // Continue to explore any static dependencies - const result = staticDependentModules.some( - ( parentStaticDependentModule ) => - DependencyExtractionWebpackPlugin.hasStaticDependencyPathToRoot( - compilation, - parentStaticDependentModule - ) + return staticDependentModules.some( ( parentStaticDependentModule ) => + DependencyExtractionWebpackPlugin.hasStaticDependencyPathToRoot( + compilation, + parentStaticDependentModule + ) ); - - DependencyExtractionWebpackPlugin.#staticDepsCache.set( block, result ); - DependencyExtractionWebpackPlugin.#staticDepsCurrent.delete( block ); - return result; } } diff --git a/packages/dependency-extraction-webpack-plugin/test/fixtures/cyclic-external-deps/webpack.config.js b/packages/dependency-extraction-webpack-plugin/test/fixtures/cyclic-external-deps/webpack.config.js index 59d4c5d2ead3a..bfffff3ae7831 100644 --- a/packages/dependency-extraction-webpack-plugin/test/fixtures/cyclic-external-deps/webpack.config.js +++ b/packages/dependency-extraction-webpack-plugin/test/fixtures/cyclic-external-deps/webpack.config.js @@ -4,11 +4,5 @@ const DependencyExtractionWebpackPlugin = require( '../../..' ); module.exports = { - plugins: [ - new DependencyExtractionWebpackPlugin( { - requestToExternalModule( request ) { - return request.startsWith( '@wordpress/' ); - }, - } ), - ], + plugins: [ new DependencyExtractionWebpackPlugin() ], };