(module, runtime, forceSideEffects)
| 223 | * @returns {void} |
| 224 | */ |
| 225 | const processModule = (module, runtime, forceSideEffects) => { |
| 226 | /** @typedef {Map<string, string[] | ReferencedExport>} ExportMaps */ |
| 227 | /** @type {Map<Module, ReferencedExports | ExportMaps>} */ |
| 228 | const map = new Map(); |
| 229 | // Modules whose whole namespace object escapes in a mangleable way. |
| 230 | // Tracked separately so specific member references are still merged |
| 231 | // (and marked used) instead of being dropped by the escape marker. |
| 232 | /** @type {Set<Module>} */ |
| 233 | const mangleableEscapeModules = new Set(); |
| 234 | |
| 235 | /** @type {ArrayQueue<DependenciesBlock>} */ |
| 236 | const queue = new ArrayQueue(); |
| 237 | queue.enqueue(module); |
| 238 | for (;;) { |
| 239 | const block = queue.dequeue(); |
| 240 | if (block === undefined) break; |
| 241 | for (const b of block.blocks) { |
| 242 | if (b.groupOptions && b.groupOptions.entryOptions) { |
| 243 | processModule( |
| 244 | b, |
| 245 | this.global |
| 246 | ? undefined |
| 247 | : b.groupOptions.entryOptions.runtime || undefined, |
| 248 | true |
| 249 | ); |
| 250 | } else { |
| 251 | queue.enqueue(b); |
| 252 | } |
| 253 | } |
| 254 | for (const dep of block.dependencies) { |
| 255 | const connection = moduleGraph.getConnection(dep); |
| 256 | if (!connection || !connection.module) { |
| 257 | continue; |
| 258 | } |
| 259 | const activeState = connection.getActiveState(runtime); |
| 260 | if (activeState === false) continue; |
| 261 | const { module } = connection; |
| 262 | if (activeState === ModuleGraphConnection.TRANSITIVE_ONLY) { |
| 263 | processModule(module, runtime, false); |
| 264 | continue; |
| 265 | } |
| 266 | const oldReferencedExports = map.get(module); |
| 267 | if (oldReferencedExports === EXPORTS_OBJECT_REFERENCED) { |
| 268 | continue; |
| 269 | } |
| 270 | const referencedExports = |
| 271 | compilation.getDependencyReferencedExports(dep, runtime); |
| 272 | // The non-mangleable whole-object reference is the most |
| 273 | // conservative result and always wins. |
| 274 | if (referencedExports === EXPORTS_OBJECT_REFERENCED) { |
| 275 | map.set(module, EXPORTS_OBJECT_REFERENCED); |
| 276 | mangleableEscapeModules.delete(module); |
| 277 | continue; |
| 278 | } |
| 279 | // A mangleable whole-object escape keeps the module's exports |
| 280 | // mangleable (applied after the merge). Unlike the conservative |
| 281 | // marker it must not drop specific member references: those still |
| 282 | // need their own (possibly non-existent) export marked used so |
nothing calls this directly
no test coverage detected