UNPKG

22.6 kBJavaScriptView Raw
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const util = require("util");
9const ExportsInfo = require("./ExportsInfo");
10const ModuleGraphConnection = require("./ModuleGraphConnection");
11const SortableSet = require("./util/SortableSet");
12const WeakTupleMap = require("./util/WeakTupleMap");
13
14/** @typedef {import("./DependenciesBlock")} DependenciesBlock */
15/** @typedef {import("./Dependency")} Dependency */
16/** @typedef {import("./ExportsInfo").ExportInfo} ExportInfo */
17/** @typedef {import("./Module")} Module */
18/** @typedef {import("./ModuleProfile")} ModuleProfile */
19/** @typedef {import("./RequestShortener")} RequestShortener */
20/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
21
22/**
23 * @callback OptimizationBailoutFunction
24 * @param {RequestShortener} requestShortener
25 * @returns {string}
26 */
27
28const EMPTY_ARRAY = [];
29
30/**
31 * @param {SortableSet<ModuleGraphConnection>} set input
32 * @returns {readonly Map<Module, readonly ModuleGraphConnection[]>} mapped by origin module
33 */
34const getConnectionsByOriginModule = set => {
35 const map = new Map();
36 /** @type {Module | 0} */
37 let lastModule = 0;
38 /** @type {ModuleGraphConnection[]} */
39 let lastList = undefined;
40 for (const connection of set) {
41 const { originModule } = connection;
42 if (lastModule === originModule) {
43 lastList.push(connection);
44 } else {
45 lastModule = originModule;
46 const list = map.get(originModule);
47 if (list !== undefined) {
48 lastList = list;
49 list.push(connection);
50 } else {
51 const list = [connection];
52 lastList = list;
53 map.set(originModule, list);
54 }
55 }
56 }
57 return map;
58};
59
60class ModuleGraphModule {
61 constructor() {
62 /** @type {SortableSet<ModuleGraphConnection>} */
63 this.incomingConnections = new SortableSet();
64 /** @type {Set<ModuleGraphConnection> | undefined} */
65 this.outgoingConnections = undefined;
66 /** @type {Module | null} */
67 this.issuer = undefined;
68 /** @type {(string | OptimizationBailoutFunction)[]} */
69 this.optimizationBailout = [];
70 /** @type {ExportsInfo} */
71 this.exports = new ExportsInfo();
72 /** @type {number} */
73 this.preOrderIndex = null;
74 /** @type {number} */
75 this.postOrderIndex = null;
76 /** @type {number} */
77 this.depth = null;
78 /** @type {ModuleProfile} */
79 this.profile = undefined;
80 /** @type {boolean} */
81 this.async = false;
82 }
83}
84
85class ModuleGraphDependency {
86 constructor() {
87 /** @type {ModuleGraphConnection} */
88 this.connection = undefined;
89 /** @type {Module} */
90 this.parentModule = undefined;
91 /** @type {DependenciesBlock} */
92 this.parentBlock = undefined;
93 }
94}
95
96class ModuleGraph {
97 constructor() {
98 /** @type {Map<Dependency, ModuleGraphDependency>} */
99 this._dependencyMap = new Map();
100 /** @type {Map<Module, ModuleGraphModule>} */
101 this._moduleMap = new Map();
102 /** @type {Map<Module, Set<ModuleGraphConnection>>} */
103 this._originMap = new Map();
104 /** @type {Map<any, Object>} */
105 this._metaMap = new Map();
106
107 // Caching
108 this._cacheModuleGraphModuleKey1 = undefined;
109 this._cacheModuleGraphModuleValue1 = undefined;
110 this._cacheModuleGraphModuleKey2 = undefined;
111 this._cacheModuleGraphModuleValue2 = undefined;
112 this._cacheModuleGraphDependencyKey = undefined;
113 this._cacheModuleGraphDependencyValue = undefined;
114
115 /** @type {WeakTupleMap<any[], any>} */
116 this._cache = undefined;
117 }
118
119 /**
120 * @param {Module} module the module
121 * @returns {ModuleGraphModule} the internal module
122 */
123 _getModuleGraphModule(module) {
124 if (this._cacheModuleGraphModuleKey1 === module)
125 return this._cacheModuleGraphModuleValue1;
126 if (this._cacheModuleGraphModuleKey2 === module)
127 return this._cacheModuleGraphModuleValue2;
128 let mgm = this._moduleMap.get(module);
129 if (mgm === undefined) {
130 mgm = new ModuleGraphModule();
131 this._moduleMap.set(module, mgm);
132 }
133 this._cacheModuleGraphModuleKey2 = this._cacheModuleGraphModuleKey1;
134 this._cacheModuleGraphModuleValue2 = this._cacheModuleGraphModuleValue1;
135 this._cacheModuleGraphModuleKey1 = module;
136 this._cacheModuleGraphModuleValue1 = mgm;
137 return mgm;
138 }
139
140 /**
141 * @param {Dependency} dependency the dependency
142 * @returns {ModuleGraphDependency} the internal dependency
143 */
144 _getModuleGraphDependency(dependency) {
145 if (this._cacheModuleGraphDependencyKey === dependency)
146 return this._cacheModuleGraphDependencyValue;
147 let mgd = this._dependencyMap.get(dependency);
148 if (mgd === undefined) {
149 mgd = new ModuleGraphDependency();
150 this._dependencyMap.set(dependency, mgd);
151 }
152 this._cacheModuleGraphDependencyKey = dependency;
153 this._cacheModuleGraphDependencyValue = mgd;
154 return mgd;
155 }
156
157 /**
158 * @param {Dependency} dependency the dependency
159 * @param {DependenciesBlock} block parent block
160 * @param {Module} module parent module
161 * @returns {void}
162 */
163 setParents(dependency, block, module) {
164 const mgd = this._getModuleGraphDependency(dependency);
165 mgd.parentBlock = block;
166 mgd.parentModule = module;
167 }
168
169 /**
170 * @param {Dependency} dependency the dependency
171 * @returns {Module} parent module
172 */
173 getParentModule(dependency) {
174 const mgd = this._getModuleGraphDependency(dependency);
175 return mgd.parentModule;
176 }
177
178 /**
179 * @param {Dependency} dependency the dependency
180 * @returns {DependenciesBlock} parent block
181 */
182 getParentBlock(dependency) {
183 const mgd = this._getModuleGraphDependency(dependency);
184 return mgd.parentBlock;
185 }
186
187 /**
188 * @param {Module} originModule the referencing module
189 * @param {Dependency} dependency the referencing dependency
190 * @param {Module} module the referenced module
191 * @returns {void}
192 */
193 setResolvedModule(originModule, dependency, module) {
194 const connection = new ModuleGraphConnection(
195 originModule,
196 dependency,
197 module,
198 undefined,
199 dependency.weak,
200 dependency.getCondition(this)
201 );
202 const mgd = this._getModuleGraphDependency(dependency);
203 mgd.connection = connection;
204 const connections = this._getModuleGraphModule(module).incomingConnections;
205 connections.add(connection);
206 const mgm = this._getModuleGraphModule(originModule);
207 if (mgm.outgoingConnections === undefined) {
208 mgm.outgoingConnections = new Set();
209 }
210 mgm.outgoingConnections.add(connection);
211 }
212
213 /**
214 * @param {Dependency} dependency the referencing dependency
215 * @param {Module} module the referenced module
216 * @returns {void}
217 */
218 updateModule(dependency, module) {
219 const mgd = this._getModuleGraphDependency(dependency);
220 if (mgd.connection.module === module) return;
221 const { connection } = mgd;
222 const newConnection = connection.clone();
223 newConnection.module = module;
224 mgd.connection = newConnection;
225 connection.setActive(false);
226 const originMgm = this._getModuleGraphModule(connection.originModule);
227 originMgm.outgoingConnections.add(newConnection);
228 const targetMgm = this._getModuleGraphModule(module);
229 targetMgm.incomingConnections.add(newConnection);
230 }
231
232 /**
233 * @param {Dependency} dependency the referencing dependency
234 * @returns {void}
235 */
236 removeConnection(dependency) {
237 const mgd = this._getModuleGraphDependency(dependency);
238 const { connection } = mgd;
239 const targetMgm = this._getModuleGraphModule(connection.module);
240 targetMgm.incomingConnections.delete(connection);
241 const originMgm = this._getModuleGraphModule(connection.originModule);
242 originMgm.outgoingConnections.delete(connection);
243 mgd.connection = undefined;
244 }
245
246 /**
247 * @param {Dependency} dependency the referencing dependency
248 * @param {string} explanation an explanation
249 * @returns {void}
250 */
251 addExplanation(dependency, explanation) {
252 const { connection } = this._getModuleGraphDependency(dependency);
253 connection.addExplanation(explanation);
254 }
255
256 /**
257 * @param {Module} sourceModule the source module
258 * @param {Module} targetModule the target module
259 * @returns {void}
260 */
261 cloneModuleAttributes(sourceModule, targetModule) {
262 const oldMgm = this._getModuleGraphModule(sourceModule);
263 const newMgm = this._getModuleGraphModule(targetModule);
264 newMgm.postOrderIndex = oldMgm.postOrderIndex;
265 newMgm.preOrderIndex = oldMgm.preOrderIndex;
266 newMgm.depth = oldMgm.depth;
267 newMgm.exports = oldMgm.exports;
268 newMgm.async = oldMgm.async;
269 }
270
271 /**
272 * @param {Module} module the module
273 * @returns {void}
274 */
275 removeModuleAttributes(module) {
276 const mgm = this._getModuleGraphModule(module);
277 mgm.postOrderIndex = null;
278 mgm.preOrderIndex = null;
279 mgm.depth = null;
280 mgm.async = false;
281 }
282
283 /**
284 * @returns {void}
285 */
286 removeAllModuleAttributes() {
287 for (const mgm of this._moduleMap.values()) {
288 mgm.postOrderIndex = null;
289 mgm.preOrderIndex = null;
290 mgm.depth = null;
291 mgm.async = false;
292 }
293 }
294
295 /**
296 * @param {Module} oldModule the old referencing module
297 * @param {Module} newModule the new referencing module
298 * @param {function(ModuleGraphConnection): boolean} filterConnection filter predicate for replacement
299 * @returns {void}
300 */
301 moveModuleConnections(oldModule, newModule, filterConnection) {
302 if (oldModule === newModule) return;
303 const oldMgm = this._getModuleGraphModule(oldModule);
304 const newMgm = this._getModuleGraphModule(newModule);
305 // Outgoing connections
306 const oldConnections = oldMgm.outgoingConnections;
307 if (oldConnections !== undefined) {
308 if (newMgm.outgoingConnections === undefined) {
309 newMgm.outgoingConnections = new Set();
310 }
311 const newConnections = newMgm.outgoingConnections;
312 for (const connection of oldConnections) {
313 if (filterConnection(connection)) {
314 connection.originModule = newModule;
315 newConnections.add(connection);
316 oldConnections.delete(connection);
317 }
318 }
319 }
320 // Incoming connections
321 const oldConnections2 = oldMgm.incomingConnections;
322 const newConnections2 = newMgm.incomingConnections;
323 for (const connection of oldConnections2) {
324 if (filterConnection(connection)) {
325 connection.module = newModule;
326 newConnections2.add(connection);
327 oldConnections2.delete(connection);
328 }
329 }
330 }
331
332 /**
333 * @param {Module} oldModule the old referencing module
334 * @param {Module} newModule the new referencing module
335 * @param {function(ModuleGraphConnection): boolean} filterConnection filter predicate for replacement
336 * @returns {void}
337 */
338 copyOutgoingModuleConnections(oldModule, newModule, filterConnection) {
339 if (oldModule === newModule) return;
340 const oldMgm = this._getModuleGraphModule(oldModule);
341 const newMgm = this._getModuleGraphModule(newModule);
342 // Outgoing connections
343 const oldConnections = oldMgm.outgoingConnections;
344 if (oldConnections !== undefined) {
345 if (newMgm.outgoingConnections === undefined) {
346 newMgm.outgoingConnections = new Set();
347 }
348 const newConnections = newMgm.outgoingConnections;
349 for (const connection of oldConnections) {
350 if (filterConnection(connection)) {
351 const newConnection = connection.clone();
352 newConnection.originModule = newModule;
353 newConnections.add(newConnection);
354 if (newConnection.module !== undefined) {
355 const otherMgm = this._getModuleGraphModule(newConnection.module);
356 otherMgm.incomingConnections.add(newConnection);
357 }
358 }
359 }
360 }
361 }
362
363 /**
364 * @param {Module} module the referenced module
365 * @param {string} explanation an explanation why it's referenced
366 * @returns {void}
367 */
368 addExtraReason(module, explanation) {
369 const connections = this._getModuleGraphModule(module).incomingConnections;
370 connections.add(new ModuleGraphConnection(null, null, module, explanation));
371 }
372
373 /**
374 * @param {Dependency} dependency the dependency to look for a referenced module
375 * @returns {Module} the referenced module
376 */
377 getResolvedModule(dependency) {
378 const { connection } = this._getModuleGraphDependency(dependency);
379 return connection !== undefined ? connection.resolvedModule : null;
380 }
381
382 /**
383 * @param {Dependency} dependency the dependency to look for a referenced module
384 * @returns {ModuleGraphConnection | undefined} the connection
385 */
386 getConnection(dependency) {
387 const { connection } = this._getModuleGraphDependency(dependency);
388 return connection;
389 }
390
391 /**
392 * @param {Dependency} dependency the dependency to look for a referenced module
393 * @returns {Module} the referenced module
394 */
395 getModule(dependency) {
396 const { connection } = this._getModuleGraphDependency(dependency);
397 return connection !== undefined ? connection.module : null;
398 }
399
400 /**
401 * @param {Dependency} dependency the dependency to look for a referencing module
402 * @returns {Module} the referencing module
403 */
404 getOrigin(dependency) {
405 const { connection } = this._getModuleGraphDependency(dependency);
406 return connection !== undefined ? connection.originModule : null;
407 }
408
409 /**
410 * @param {Dependency} dependency the dependency to look for a referencing module
411 * @returns {Module} the original referencing module
412 */
413 getResolvedOrigin(dependency) {
414 const { connection } = this._getModuleGraphDependency(dependency);
415 return connection !== undefined ? connection.resolvedOriginModule : null;
416 }
417
418 /**
419 * @param {Module} module the module
420 * @returns {Iterable<ModuleGraphConnection>} reasons why a module is included
421 */
422 getIncomingConnections(module) {
423 const connections = this._getModuleGraphModule(module).incomingConnections;
424 return connections;
425 }
426
427 /**
428 * @param {Module} module the module
429 * @returns {Iterable<ModuleGraphConnection>} list of outgoing connections
430 */
431 getOutgoingConnections(module) {
432 const connections = this._getModuleGraphModule(module).outgoingConnections;
433 return connections === undefined ? EMPTY_ARRAY : connections;
434 }
435
436 /**
437 * @param {Module} module the module
438 * @returns {readonly Map<Module, readonly ModuleGraphConnection[]>} reasons why a module is included, in a map by source module
439 */
440 getIncomingConnectionsByOriginModule(module) {
441 const connections = this._getModuleGraphModule(module).incomingConnections;
442 return connections.getFromUnorderedCache(getConnectionsByOriginModule);
443 }
444
445 /**
446 * @param {Module} module the module
447 * @returns {ModuleProfile | null} the module profile
448 */
449 getProfile(module) {
450 const mgm = this._getModuleGraphModule(module);
451 return mgm.profile;
452 }
453
454 /**
455 * @param {Module} module the module
456 * @param {ModuleProfile | null} profile the module profile
457 * @returns {void}
458 */
459 setProfile(module, profile) {
460 const mgm = this._getModuleGraphModule(module);
461 mgm.profile = profile;
462 }
463
464 /**
465 * @param {Module} module the module
466 * @returns {Module | null} the issuer module
467 */
468 getIssuer(module) {
469 const mgm = this._getModuleGraphModule(module);
470 return mgm.issuer;
471 }
472
473 /**
474 * @param {Module} module the module
475 * @param {Module | null} issuer the issuer module
476 * @returns {void}
477 */
478 setIssuer(module, issuer) {
479 const mgm = this._getModuleGraphModule(module);
480 mgm.issuer = issuer;
481 }
482
483 /**
484 * @param {Module} module the module
485 * @param {Module | null} issuer the issuer module
486 * @returns {void}
487 */
488 setIssuerIfUnset(module, issuer) {
489 const mgm = this._getModuleGraphModule(module);
490 if (mgm.issuer === undefined) mgm.issuer = issuer;
491 }
492
493 /**
494 * @param {Module} module the module
495 * @returns {(string | OptimizationBailoutFunction)[]} optimization bailouts
496 */
497 getOptimizationBailout(module) {
498 const mgm = this._getModuleGraphModule(module);
499 return mgm.optimizationBailout;
500 }
501
502 /**
503 * @param {Module} module the module
504 * @returns {true | string[] | null} the provided exports
505 */
506 getProvidedExports(module) {
507 const mgm = this._getModuleGraphModule(module);
508 return mgm.exports.getProvidedExports();
509 }
510
511 /**
512 * @param {Module} module the module
513 * @param {string | string[]} exportName a name of an export
514 * @returns {boolean | null} true, if the export is provided by the module.
515 * null, if it's unknown.
516 * false, if it's not provided.
517 */
518 isExportProvided(module, exportName) {
519 const mgm = this._getModuleGraphModule(module);
520 const result = mgm.exports.isExportProvided(exportName);
521 return result === undefined ? null : result;
522 }
523
524 /**
525 * @param {Module} module the module
526 * @returns {ExportsInfo} info about the exports
527 */
528 getExportsInfo(module) {
529 const mgm = this._getModuleGraphModule(module);
530 return mgm.exports;
531 }
532
533 /**
534 * @param {Module} module the module
535 * @param {string} exportName the export
536 * @returns {ExportInfo} info about the export
537 */
538 getExportInfo(module, exportName) {
539 const mgm = this._getModuleGraphModule(module);
540 return mgm.exports.getExportInfo(exportName);
541 }
542
543 /**
544 * @param {Module} module the module
545 * @param {string} exportName the export
546 * @returns {ExportInfo} info about the export (do not modify)
547 */
548 getReadOnlyExportInfo(module, exportName) {
549 const mgm = this._getModuleGraphModule(module);
550 return mgm.exports.getReadOnlyExportInfo(exportName);
551 }
552
553 /**
554 * @param {Module} module the module
555 * @param {RuntimeSpec} runtime the runtime
556 * @returns {false | true | SortableSet<string> | null} the used exports
557 * false: module is not used at all.
558 * true: the module namespace/object export is used.
559 * SortableSet<string>: these export names are used.
560 * empty SortableSet<string>: module is used but no export.
561 * null: unknown, worst case should be assumed.
562 */
563 getUsedExports(module, runtime) {
564 const mgm = this._getModuleGraphModule(module);
565 return mgm.exports.getUsedExports(runtime);
566 }
567
568 /**
569 * @param {Module} module the module
570 * @returns {number} the index of the module
571 */
572 getPreOrderIndex(module) {
573 const mgm = this._getModuleGraphModule(module);
574 return mgm.preOrderIndex;
575 }
576
577 /**
578 * @param {Module} module the module
579 * @returns {number} the index of the module
580 */
581 getPostOrderIndex(module) {
582 const mgm = this._getModuleGraphModule(module);
583 return mgm.postOrderIndex;
584 }
585
586 /**
587 * @param {Module} module the module
588 * @param {number} index the index of the module
589 * @returns {void}
590 */
591 setPreOrderIndex(module, index) {
592 const mgm = this._getModuleGraphModule(module);
593 mgm.preOrderIndex = index;
594 }
595
596 /**
597 * @param {Module} module the module
598 * @param {number} index the index of the module
599 * @returns {boolean} true, if the index was set
600 */
601 setPreOrderIndexIfUnset(module, index) {
602 const mgm = this._getModuleGraphModule(module);
603 if (mgm.preOrderIndex === null) {
604 mgm.preOrderIndex = index;
605 return true;
606 }
607 return false;
608 }
609
610 /**
611 * @param {Module} module the module
612 * @param {number} index the index of the module
613 * @returns {void}
614 */
615 setPostOrderIndex(module, index) {
616 const mgm = this._getModuleGraphModule(module);
617 mgm.postOrderIndex = index;
618 }
619
620 /**
621 * @param {Module} module the module
622 * @param {number} index the index of the module
623 * @returns {boolean} true, if the index was set
624 */
625 setPostOrderIndexIfUnset(module, index) {
626 const mgm = this._getModuleGraphModule(module);
627 if (mgm.postOrderIndex === null) {
628 mgm.postOrderIndex = index;
629 return true;
630 }
631 return false;
632 }
633
634 /**
635 * @param {Module} module the module
636 * @returns {number} the depth of the module
637 */
638 getDepth(module) {
639 const mgm = this._getModuleGraphModule(module);
640 return mgm.depth;
641 }
642
643 /**
644 * @param {Module} module the module
645 * @param {number} depth the depth of the module
646 * @returns {void}
647 */
648 setDepth(module, depth) {
649 const mgm = this._getModuleGraphModule(module);
650 mgm.depth = depth;
651 }
652
653 /**
654 * @param {Module} module the module
655 * @param {number} depth the depth of the module
656 * @returns {boolean} true, if the depth was set
657 */
658 setDepthIfLower(module, depth) {
659 const mgm = this._getModuleGraphModule(module);
660 if (mgm.depth === null || mgm.depth > depth) {
661 mgm.depth = depth;
662 return true;
663 }
664 return false;
665 }
666
667 /**
668 * @param {Module} module the module
669 * @returns {boolean} true, if the module is async
670 */
671 isAsync(module) {
672 const mgm = this._getModuleGraphModule(module);
673 return mgm.async;
674 }
675
676 /**
677 * @param {Module} module the module
678 * @returns {void}
679 */
680 setAsync(module) {
681 const mgm = this._getModuleGraphModule(module);
682 mgm.async = true;
683 }
684
685 /**
686 * @param {any} thing any thing
687 * @returns {Object} metadata
688 */
689 getMeta(thing) {
690 let meta = this._metaMap.get(thing);
691 if (meta === undefined) {
692 meta = Object.create(null);
693 this._metaMap.set(thing, meta);
694 }
695 return meta;
696 }
697
698 /**
699 * @param {any} thing any thing
700 * @returns {Object} metadata
701 */
702 getMetaIfExisting(thing) {
703 return this._metaMap.get(thing);
704 }
705
706 freeze() {
707 this._cache = new WeakTupleMap();
708 }
709
710 unfreeze() {
711 this._cache = undefined;
712 }
713
714 /**
715 * @template {any[]} T
716 * @template V
717 * @param {(moduleGraph: ModuleGraph, ...args: T) => V} fn computer
718 * @param {T} args arguments
719 * @returns {V} computed value or cached
720 */
721 cached(fn, ...args) {
722 if (this._cache === undefined) return fn(this, ...args);
723 return this._cache.provide(fn, ...args, () => fn(this, ...args));
724 }
725
726 // TODO remove in webpack 6
727 /**
728 * @param {Module} module the module
729 * @param {string} deprecateMessage message for the deprecation message
730 * @param {string} deprecationCode code for the deprecation
731 * @returns {ModuleGraph} the module graph
732 */
733 static getModuleGraphForModule(module, deprecateMessage, deprecationCode) {
734 const fn = deprecateMap.get(deprecateMessage);
735 if (fn) return fn(module);
736 const newFn = util.deprecate(
737 /**
738 * @param {Module} module the module
739 * @returns {ModuleGraph} the module graph
740 */
741 module => {
742 const moduleGraph = moduleGraphForModuleMap.get(module);
743 if (!moduleGraph)
744 throw new Error(
745 deprecateMessage +
746 "There was no ModuleGraph assigned to the Module for backward-compat (Use the new API)"
747 );
748 return moduleGraph;
749 },
750 deprecateMessage + ": Use new ModuleGraph API",
751 deprecationCode
752 );
753 deprecateMap.set(deprecateMessage, newFn);
754 return newFn(module);
755 }
756
757 // TODO remove in webpack 6
758 /**
759 * @param {Module} module the module
760 * @param {ModuleGraph} moduleGraph the module graph
761 * @returns {void}
762 */
763 static setModuleGraphForModule(module, moduleGraph) {
764 moduleGraphForModuleMap.set(module, moduleGraph);
765 }
766
767 // TODO remove in webpack 6
768 /**
769 * @param {Module} module the module
770 * @returns {void}
771 */
772 static clearModuleGraphForModule(module) {
773 moduleGraphForModuleMap.delete(module);
774 }
775}
776
777// TODO remove in webpack 6
778/** @type {WeakMap<Module, ModuleGraph>} */
779const moduleGraphForModuleMap = new WeakMap();
780
781// TODO remove in webpack 6
782/** @type {Map<string, (module: Module) => ModuleGraph>} */
783const deprecateMap = new Map();
784
785module.exports = ModuleGraph;
786module.exports.ModuleGraphConnection = ModuleGraphConnection;