-
-
Notifications
You must be signed in to change notification settings - Fork 780
Closed
Description
What problem does this feature solve?
While the optimizeModules hook was added in #2758 to support circular-dependency-plugin. The Module interface does not include the dependencies property the plugin uses to iterate through the dependencies of the module. Additionally the Compilation interface does not include the moduleGraph property the plugin uses.
What does the proposed API of configuration look like?
compilation.hooks.optimizeModules.tap('PluginName', (modules) => {
const seenModules = {};
for (const module of modules) {
seenModules[module.debugId] = true;
for (const dependency of module.dependencies) {
if (
dependency.constructor &&
dependency.constructor.name === 'CommonJsSelfReferenceDependency'
) {
continue;
}
const depModule = compilation.moduleGraph.getModule(dependency);
// Check things on depModule
}
}
});The plugin uses the following properties:
Module.dependencies: in Webpack this is an array ofHarmonyImportSideEffectDependencyModule.debugId: a numberCompilation.moduleGraph.getModule(dependency: HarmonyImportSideEffectDependency): Module: a method on the module graph that resolves a dependency to itsModule
Reactions are currently unavailable