* Applies the plugin by registering its hooks on the compiler. * @param {Compiler} compiler the compiler instance * @returns {void}
(compiler)
| 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 | |
| 198 | module.exports = MangleExportsPlugin; |
nothing calls this directly
no test coverage detected