Skip to content

Commit

Permalink
Remove redundant plugin config in test
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed Sep 16, 2024
1 parent 3f8f2f4 commit b5e33db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 48 deletions.
46 changes: 5 additions & 41 deletions packages/dependency-extraction-webpack-plugin/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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(
Expand All @@ -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;
}

Expand All @@ -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;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,5 @@
const DependencyExtractionWebpackPlugin = require( '../../..' );

module.exports = {
plugins: [
new DependencyExtractionWebpackPlugin( {
requestToExternalModule( request ) {
return request.startsWith( '@wordpress/' );
},
} ),
],
plugins: [ new DependencyExtractionWebpackPlugin() ],
};

0 comments on commit b5e33db

Please sign in to comment.