MCPcopy
hub / github.com/webpack/webpack / apply

Method apply

lib/optimize/MangleExportsPlugin.js:177–195  ·  view source on GitHub ↗

* Applies the plugin by registering its hooks on the compiler. * @param {Compiler} compiler the compiler instance * @returns {void}

(compiler)

Source from the content-addressed store, hash-verified

175 * @returns {void}
176 */
177 apply(compiler) {
178 const { _deterministic: deterministic } = this;
179 compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
180 const moduleGraph = compilation.moduleGraph;
181 compilation.hooks.optimizeCodeGeneration.tap(PLUGIN_NAME, (modules) => {
182 if (compilation.moduleMemCaches) {
183 throw new Error(
184 "optimization.mangleExports can't be used with cacheUnaffected as export mangling is a global effect"
185 );
186 }
187 for (const module of modules) {
188 const isNamespace =
189 module.buildMeta && module.buildMeta.exportsType === "namespace";
190 const exportsInfo = moduleGraph.getExportsInfo(module);
191 mangleExportsInfo(deterministic, exportsInfo, isNamespace);
192 }
193 });
194 });
195 }
196}
197
198module.exports = MangleExportsPlugin;

Callers

nothing calls this directly

Calls 3

mangleExportsInfoFunction · 0.85
tapMethod · 0.80
getExportsInfoMethod · 0.80

Tested by

no test coverage detected