1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | "use strict";
|
7 |
|
8 | const util = require("util");
|
9 | const ChunkGraph = require("./ChunkGraph");
|
10 | const DependenciesBlock = require("./DependenciesBlock");
|
11 | const ModuleGraph = require("./ModuleGraph");
|
12 | const RuntimeGlobals = require("./RuntimeGlobals");
|
13 | const { first } = require("./util/SetHelpers");
|
14 | const { compareChunksById } = require("./util/comparators");
|
15 | const makeSerializable = require("./util/makeSerializable");
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 | const EMPTY_RESOLVE_OPTIONS = {};
|
103 |
|
104 | let debugId = 1000;
|
105 |
|
106 | const DEFAULT_TYPES_UNKNOWN = new Set(["unknown"]);
|
107 | const DEFAULT_TYPES_JS = new Set(["javascript"]);
|
108 |
|
109 | const deprecatedNeedRebuild = util.deprecate(
|
110 | (module, context) => {
|
111 | return module.needRebuild(
|
112 | context.fileSystemInfo.getDeprecatedFileTimestamps(),
|
113 | context.fileSystemInfo.getDeprecatedContextTimestamps()
|
114 | );
|
115 | },
|
116 | "Module.needRebuild is deprecated in favor of Module.needBuild",
|
117 | "DEP_WEBPACK_MODULE_NEED_REBUILD"
|
118 | );
|
119 |
|
120 |
|
121 |
|
122 | class Module extends DependenciesBlock {
|
123 | |
124 |
|
125 |
|
126 |
|
127 |
|
128 | constructor(type, context = null, layer = null) {
|
129 | super();
|
130 |
|
131 |
|
132 | this.type = type;
|
133 |
|
134 | this.context = context;
|
135 |
|
136 | this.layer = layer;
|
137 |
|
138 | this.needId = true;
|
139 |
|
140 |
|
141 |
|
142 | this.debugId = debugId++;
|
143 |
|
144 |
|
145 |
|
146 | this.resolveOptions = EMPTY_RESOLVE_OPTIONS;
|
147 |
|
148 | this.factoryMeta = undefined;
|
149 |
|
150 |
|
151 |
|
152 | this.useSourceMap = false;
|
153 |
|
154 | this.useSimpleSourceMap = false;
|
155 |
|
156 |
|
157 |
|
158 | this._warnings = undefined;
|
159 |
|
160 | this._errors = undefined;
|
161 |
|
162 | this.buildMeta = undefined;
|
163 |
|
164 | this.buildInfo = undefined;
|
165 |
|
166 | this.presentationalDependencies = undefined;
|
167 | }
|
168 |
|
169 |
|
170 |
|
171 | get id() {
|
172 | return ChunkGraph.getChunkGraphForModule(
|
173 | this,
|
174 | "Module.id",
|
175 | "DEP_WEBPACK_MODULE_ID"
|
176 | ).getModuleId(this);
|
177 | }
|
178 |
|
179 | set id(value) {
|
180 | if (value === "") {
|
181 | this.needId = false;
|
182 | return;
|
183 | }
|
184 | ChunkGraph.getChunkGraphForModule(
|
185 | this,
|
186 | "Module.id",
|
187 | "DEP_WEBPACK_MODULE_ID"
|
188 | ).setModuleId(this, value);
|
189 | }
|
190 |
|
191 | |
192 |
|
193 |
|
194 | get hash() {
|
195 | return ChunkGraph.getChunkGraphForModule(
|
196 | this,
|
197 | "Module.hash",
|
198 | "DEP_WEBPACK_MODULE_HASH"
|
199 | ).getModuleHash(this, undefined);
|
200 | }
|
201 |
|
202 | |
203 |
|
204 |
|
205 | get renderedHash() {
|
206 | return ChunkGraph.getChunkGraphForModule(
|
207 | this,
|
208 | "Module.renderedHash",
|
209 | "DEP_WEBPACK_MODULE_RENDERED_HASH"
|
210 | ).getRenderedModuleHash(this, undefined);
|
211 | }
|
212 |
|
213 | get profile() {
|
214 | return ModuleGraph.getModuleGraphForModule(
|
215 | this,
|
216 | "Module.profile",
|
217 | "DEP_WEBPACK_MODULE_PROFILE"
|
218 | ).getProfile(this);
|
219 | }
|
220 |
|
221 | set profile(value) {
|
222 | ModuleGraph.getModuleGraphForModule(
|
223 | this,
|
224 | "Module.profile",
|
225 | "DEP_WEBPACK_MODULE_PROFILE"
|
226 | ).setProfile(this, value);
|
227 | }
|
228 |
|
229 | get index() {
|
230 | return ModuleGraph.getModuleGraphForModule(
|
231 | this,
|
232 | "Module.index",
|
233 | "DEP_WEBPACK_MODULE_INDEX"
|
234 | ).getPreOrderIndex(this);
|
235 | }
|
236 |
|
237 | set index(value) {
|
238 | ModuleGraph.getModuleGraphForModule(
|
239 | this,
|
240 | "Module.index",
|
241 | "DEP_WEBPACK_MODULE_INDEX"
|
242 | ).setPreOrderIndex(this, value);
|
243 | }
|
244 |
|
245 | get index2() {
|
246 | return ModuleGraph.getModuleGraphForModule(
|
247 | this,
|
248 | "Module.index2",
|
249 | "DEP_WEBPACK_MODULE_INDEX2"
|
250 | ).getPostOrderIndex(this);
|
251 | }
|
252 |
|
253 | set index2(value) {
|
254 | ModuleGraph.getModuleGraphForModule(
|
255 | this,
|
256 | "Module.index2",
|
257 | "DEP_WEBPACK_MODULE_INDEX2"
|
258 | ).setPostOrderIndex(this, value);
|
259 | }
|
260 |
|
261 | get depth() {
|
262 | return ModuleGraph.getModuleGraphForModule(
|
263 | this,
|
264 | "Module.depth",
|
265 | "DEP_WEBPACK_MODULE_DEPTH"
|
266 | ).getDepth(this);
|
267 | }
|
268 |
|
269 | set depth(value) {
|
270 | ModuleGraph.getModuleGraphForModule(
|
271 | this,
|
272 | "Module.depth",
|
273 | "DEP_WEBPACK_MODULE_DEPTH"
|
274 | ).setDepth(this, value);
|
275 | }
|
276 |
|
277 | get issuer() {
|
278 | return ModuleGraph.getModuleGraphForModule(
|
279 | this,
|
280 | "Module.issuer",
|
281 | "DEP_WEBPACK_MODULE_ISSUER"
|
282 | ).getIssuer(this);
|
283 | }
|
284 |
|
285 | set issuer(value) {
|
286 | ModuleGraph.getModuleGraphForModule(
|
287 | this,
|
288 | "Module.issuer",
|
289 | "DEP_WEBPACK_MODULE_ISSUER"
|
290 | ).setIssuer(this, value);
|
291 | }
|
292 |
|
293 | get usedExports() {
|
294 | return ModuleGraph.getModuleGraphForModule(
|
295 | this,
|
296 | "Module.usedExports",
|
297 | "DEP_WEBPACK_MODULE_USED_EXPORTS"
|
298 | ).getUsedExports(this, undefined);
|
299 | }
|
300 |
|
301 | |
302 |
|
303 |
|
304 |
|
305 | get optimizationBailout() {
|
306 | return ModuleGraph.getModuleGraphForModule(
|
307 | this,
|
308 | "Module.optimizationBailout",
|
309 | "DEP_WEBPACK_MODULE_OPTIMIZATION_BAILOUT"
|
310 | ).getOptimizationBailout(this);
|
311 | }
|
312 |
|
313 | get optional() {
|
314 | return this.isOptional(
|
315 | ModuleGraph.getModuleGraphForModule(
|
316 | this,
|
317 | "Module.optional",
|
318 | "DEP_WEBPACK_MODULE_OPTIONAL"
|
319 | )
|
320 | );
|
321 | }
|
322 |
|
323 | addChunk(chunk) {
|
324 | const chunkGraph = ChunkGraph.getChunkGraphForModule(
|
325 | this,
|
326 | "Module.addChunk",
|
327 | "DEP_WEBPACK_MODULE_ADD_CHUNK"
|
328 | );
|
329 | if (chunkGraph.isModuleInChunk(this, chunk)) return false;
|
330 | chunkGraph.connectChunkAndModule(chunk, this);
|
331 | return true;
|
332 | }
|
333 |
|
334 | removeChunk(chunk) {
|
335 | return ChunkGraph.getChunkGraphForModule(
|
336 | this,
|
337 | "Module.removeChunk",
|
338 | "DEP_WEBPACK_MODULE_REMOVE_CHUNK"
|
339 | ).disconnectChunkAndModule(chunk, this);
|
340 | }
|
341 |
|
342 | isInChunk(chunk) {
|
343 | return ChunkGraph.getChunkGraphForModule(
|
344 | this,
|
345 | "Module.isInChunk",
|
346 | "DEP_WEBPACK_MODULE_IS_IN_CHUNK"
|
347 | ).isModuleInChunk(this, chunk);
|
348 | }
|
349 |
|
350 | isEntryModule() {
|
351 | return ChunkGraph.getChunkGraphForModule(
|
352 | this,
|
353 | "Module.isEntryModule",
|
354 | "DEP_WEBPACK_MODULE_IS_ENTRY_MODULE"
|
355 | ).isEntryModule(this);
|
356 | }
|
357 |
|
358 | getChunks() {
|
359 | return ChunkGraph.getChunkGraphForModule(
|
360 | this,
|
361 | "Module.getChunks",
|
362 | "DEP_WEBPACK_MODULE_GET_CHUNKS"
|
363 | ).getModuleChunks(this);
|
364 | }
|
365 |
|
366 | getNumberOfChunks() {
|
367 | return ChunkGraph.getChunkGraphForModule(
|
368 | this,
|
369 | "Module.getNumberOfChunks",
|
370 | "DEP_WEBPACK_MODULE_GET_NUMBER_OF_CHUNKS"
|
371 | ).getNumberOfModuleChunks(this);
|
372 | }
|
373 |
|
374 | get chunksIterable() {
|
375 | return ChunkGraph.getChunkGraphForModule(
|
376 | this,
|
377 | "Module.chunksIterable",
|
378 | "DEP_WEBPACK_MODULE_CHUNKS_ITERABLE"
|
379 | ).getOrderedModuleChunksIterable(this, compareChunksById);
|
380 | }
|
381 |
|
382 | |
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 | isProvided(exportName) {
|
389 | return ModuleGraph.getModuleGraphForModule(
|
390 | this,
|
391 | "Module.usedExports",
|
392 | "DEP_WEBPACK_MODULE_USED_EXPORTS"
|
393 | ).isExportProvided(this, exportName);
|
394 | }
|
395 |
|
396 |
|
397 | |
398 |
|
399 |
|
400 |
|
401 | get exportsArgument() {
|
402 | return (this.buildInfo && this.buildInfo.exportsArgument) || "exports";
|
403 | }
|
404 |
|
405 | |
406 |
|
407 |
|
408 |
|
409 | get moduleArgument() {
|
410 | return (this.buildInfo && this.buildInfo.moduleArgument) || "module";
|
411 | }
|
412 |
|
413 | |
414 |
|
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 | getExportsType(moduleGraph, strict) {
|
423 | switch (this.buildMeta && this.buildMeta.exportsType) {
|
424 | case "flagged":
|
425 | return strict ? "default-with-named" : "namespace";
|
426 | case "namespace":
|
427 | return "namespace";
|
428 | case "default":
|
429 | switch (this.buildMeta.defaultObject) {
|
430 | case "redirect":
|
431 | return "default-with-named";
|
432 | case "redirect-warn":
|
433 | return strict ? "default-only" : "default-with-named";
|
434 | default:
|
435 | return "default-only";
|
436 | }
|
437 | case "dynamic": {
|
438 | if (strict) return "default-with-named";
|
439 |
|
440 | const handleDefault = () => {
|
441 | switch (this.buildMeta.defaultObject) {
|
442 | case "redirect":
|
443 | case "redirect-warn":
|
444 | return "default-with-named";
|
445 | default:
|
446 | return "default-only";
|
447 | }
|
448 | };
|
449 | const exportInfo = moduleGraph.getReadOnlyExportInfo(
|
450 | this,
|
451 | "__esModule"
|
452 | );
|
453 | if (exportInfo.provided === false) {
|
454 | return handleDefault();
|
455 | }
|
456 | const target = exportInfo.getTarget(moduleGraph);
|
457 | if (
|
458 | !target ||
|
459 | !target.export ||
|
460 | target.export.length !== 1 ||
|
461 | target.export[0] !== "__esModule"
|
462 | ) {
|
463 | return "dynamic";
|
464 | }
|
465 | switch (
|
466 | target.module.buildMeta &&
|
467 | target.module.buildMeta.exportsType
|
468 | ) {
|
469 | case "flagged":
|
470 | case "namespace":
|
471 | return "namespace";
|
472 | case "default":
|
473 | return handleDefault();
|
474 | default:
|
475 | return "dynamic";
|
476 | }
|
477 | }
|
478 | default:
|
479 | return strict ? "default-with-named" : "dynamic";
|
480 | }
|
481 | }
|
482 |
|
483 | |
484 |
|
485 |
|
486 |
|
487 |
|
488 | addPresentationalDependency(presentationalDependency) {
|
489 | if (this.presentationalDependencies === undefined) {
|
490 | this.presentationalDependencies = [];
|
491 | }
|
492 | this.presentationalDependencies.push(presentationalDependency);
|
493 | }
|
494 |
|
495 | |
496 |
|
497 |
|
498 |
|
499 | clearDependenciesAndBlocks() {
|
500 | if (this.presentationalDependencies !== undefined) {
|
501 | this.presentationalDependencies.length = 0;
|
502 | }
|
503 | super.clearDependenciesAndBlocks();
|
504 | }
|
505 |
|
506 | |
507 |
|
508 |
|
509 |
|
510 | addWarning(warning) {
|
511 | if (this._warnings === undefined) {
|
512 | this._warnings = [];
|
513 | }
|
514 | this._warnings.push(warning);
|
515 | }
|
516 |
|
517 | |
518 |
|
519 |
|
520 | getWarnings() {
|
521 | return this._warnings;
|
522 | }
|
523 |
|
524 | |
525 |
|
526 |
|
527 | getNumberOfWarnings() {
|
528 | return this._warnings !== undefined ? this._warnings.length : 0;
|
529 | }
|
530 |
|
531 | |
532 |
|
533 |
|
534 |
|
535 | addError(error) {
|
536 | if (this._errors === undefined) {
|
537 | this._errors = [];
|
538 | }
|
539 | this._errors.push(error);
|
540 | }
|
541 |
|
542 | |
543 |
|
544 |
|
545 | getErrors() {
|
546 | return this._errors;
|
547 | }
|
548 |
|
549 | |
550 |
|
551 |
|
552 | getNumberOfErrors() {
|
553 | return this._errors !== undefined ? this._errors.length : 0;
|
554 | }
|
555 |
|
556 | |
557 |
|
558 |
|
559 |
|
560 | clearWarningsAndErrors() {
|
561 | if (this._warnings !== undefined) {
|
562 | this._warnings.length = 0;
|
563 | }
|
564 | if (this._errors !== undefined) {
|
565 | this._errors.length = 0;
|
566 | }
|
567 | }
|
568 |
|
569 | |
570 |
|
571 |
|
572 |
|
573 | isOptional(moduleGraph) {
|
574 | let hasConnections = false;
|
575 | for (const r of moduleGraph.getIncomingConnections(this)) {
|
576 | if (
|
577 | !r.dependency ||
|
578 | !r.dependency.optional ||
|
579 | !r.isTargetActive(undefined)
|
580 | ) {
|
581 | return false;
|
582 | }
|
583 | hasConnections = true;
|
584 | }
|
585 | return hasConnections;
|
586 | }
|
587 |
|
588 | |
589 |
|
590 |
|
591 |
|
592 |
|
593 |
|
594 | isAccessibleInChunk(chunkGraph, chunk, ignoreChunk) {
|
595 |
|
596 | for (const chunkGroup of chunk.groupsIterable) {
|
597 | if (!this.isAccessibleInChunkGroup(chunkGraph, chunkGroup)) return false;
|
598 | }
|
599 | return true;
|
600 | }
|
601 |
|
602 | |
603 |
|
604 |
|
605 |
|
606 |
|
607 |
|
608 | isAccessibleInChunkGroup(chunkGraph, chunkGroup, ignoreChunk) {
|
609 | const queue = new Set([chunkGroup]);
|
610 |
|
611 |
|
612 | queueFor: for (const cg of queue) {
|
613 |
|
614 |
|
615 | for (const chunk of cg.chunks) {
|
616 | if (chunk !== ignoreChunk && chunkGraph.isModuleInChunk(this, chunk))
|
617 | continue queueFor;
|
618 | }
|
619 |
|
620 | if (chunkGroup.isInitial()) return false;
|
621 |
|
622 | for (const parent of chunkGroup.parentsIterable) queue.add(parent);
|
623 | }
|
624 |
|
625 | return true;
|
626 | }
|
627 |
|
628 | |
629 |
|
630 |
|
631 |
|
632 |
|
633 |
|
634 | hasReasonForChunk(chunk, moduleGraph, chunkGraph) {
|
635 |
|
636 | for (const [
|
637 | fromModule,
|
638 | connections
|
639 | ] of moduleGraph.getIncomingConnectionsByOriginModule(this)) {
|
640 | if (!connections.some(c => c.isTargetActive(chunk.runtime))) continue;
|
641 | for (const originChunk of chunkGraph.getModuleChunksIterable(
|
642 | fromModule
|
643 | )) {
|
644 |
|
645 | if (!this.isAccessibleInChunk(chunkGraph, originChunk, chunk))
|
646 | return true;
|
647 | }
|
648 | }
|
649 | return false;
|
650 | }
|
651 |
|
652 | |
653 |
|
654 |
|
655 |
|
656 |
|
657 | hasReasons(moduleGraph, runtime) {
|
658 | for (const c of moduleGraph.getIncomingConnections(this)) {
|
659 | if (c.isTargetActive(runtime)) return true;
|
660 | }
|
661 | return false;
|
662 | }
|
663 |
|
664 | |
665 |
|
666 |
|
667 | toString() {
|
668 | return `Module[${this.debugId}: ${this.identifier()}]`;
|
669 | }
|
670 |
|
671 | |
672 |
|
673 |
|
674 |
|
675 |
|
676 | needBuild(context, callback) {
|
677 | callback(
|
678 | null,
|
679 | !this.buildMeta ||
|
680 | this.needRebuild === Module.prototype.needRebuild ||
|
681 | deprecatedNeedRebuild(this, context)
|
682 | );
|
683 | }
|
684 |
|
685 | |
686 |
|
687 |
|
688 |
|
689 |
|
690 |
|
691 | needRebuild(fileTimestamps, contextTimestamps) {
|
692 | return true;
|
693 | }
|
694 |
|
695 | |
696 |
|
697 |
|
698 |
|
699 |
|
700 | updateHash(
|
701 | hash,
|
702 | context = {
|
703 | chunkGraph: ChunkGraph.getChunkGraphForModule(
|
704 | this,
|
705 | "Module.updateHash",
|
706 | "DEP_WEBPACK_MODULE_UPDATE_HASH"
|
707 | ),
|
708 | runtime: undefined
|
709 | }
|
710 | ) {
|
711 | const { chunkGraph, runtime } = context;
|
712 | hash.update(chunkGraph.getModuleGraphHash(this, runtime));
|
713 | if (this.presentationalDependencies !== undefined) {
|
714 | for (const dep of this.presentationalDependencies) {
|
715 | dep.updateHash(hash, context);
|
716 | }
|
717 | }
|
718 | super.updateHash(hash, context);
|
719 | }
|
720 |
|
721 | |
722 |
|
723 |
|
724 | invalidateBuild() {
|
725 |
|
726 | }
|
727 |
|
728 |
|
729 | |
730 |
|
731 |
|
732 |
|
733 | identifier() {
|
734 | const AbstractMethodError = require("./AbstractMethodError");
|
735 | throw new AbstractMethodError();
|
736 | }
|
737 |
|
738 |
|
739 | |
740 |
|
741 |
|
742 |
|
743 |
|
744 | readableIdentifier(requestShortener) {
|
745 | const AbstractMethodError = require("./AbstractMethodError");
|
746 | throw new AbstractMethodError();
|
747 | }
|
748 |
|
749 |
|
750 | |
751 |
|
752 |
|
753 |
|
754 |
|
755 |
|
756 |
|
757 |
|
758 |
|
759 | build(options, compilation, resolver, fs, callback) {
|
760 | const AbstractMethodError = require("./AbstractMethodError");
|
761 | throw new AbstractMethodError();
|
762 | }
|
763 |
|
764 | |
765 |
|
766 |
|
767 |
|
768 | getSourceTypes() {
|
769 |
|
770 | if (this.source === Module.prototype.source) {
|
771 | return DEFAULT_TYPES_UNKNOWN;
|
772 | } else {
|
773 | return DEFAULT_TYPES_JS;
|
774 | }
|
775 | }
|
776 |
|
777 | |
778 |
|
779 |
|
780 |
|
781 |
|
782 |
|
783 |
|
784 |
|
785 | source(dependencyTemplates, runtimeTemplate, type = "javascript") {
|
786 | if (this.codeGeneration === Module.prototype.codeGeneration) {
|
787 | const AbstractMethodError = require("./AbstractMethodError");
|
788 | throw new AbstractMethodError();
|
789 | }
|
790 | const chunkGraph = ChunkGraph.getChunkGraphForModule(
|
791 | this,
|
792 | "Module.source() is deprecated. Use Compilation.codeGenerationResults.getSource(module, runtime, type) instead",
|
793 | "DEP_WEBPACK_MODULE_SOURCE"
|
794 | );
|
795 |
|
796 | const codeGenContext = {
|
797 | dependencyTemplates,
|
798 | runtimeTemplate,
|
799 | moduleGraph: chunkGraph.moduleGraph,
|
800 | chunkGraph,
|
801 | runtime: undefined
|
802 | };
|
803 | const sources = this.codeGeneration(codeGenContext).sources;
|
804 | return type ? sources.get(type) : sources.get(first(this.getSourceTypes()));
|
805 | }
|
806 |
|
807 |
|
808 | |
809 |
|
810 |
|
811 |
|
812 |
|
813 | size(type) {
|
814 | const AbstractMethodError = require("./AbstractMethodError");
|
815 | throw new AbstractMethodError();
|
816 | }
|
817 |
|
818 | |
819 |
|
820 |
|
821 |
|
822 | libIdent(options) {
|
823 | return null;
|
824 | }
|
825 |
|
826 | |
827 |
|
828 |
|
829 | nameForCondition() {
|
830 | return null;
|
831 | }
|
832 |
|
833 | |
834 |
|
835 |
|
836 |
|
837 | getConcatenationBailoutReason(context) {
|
838 | return `Module Concatenation is not implemented for ${this.constructor.name}`;
|
839 | }
|
840 |
|
841 | |
842 |
|
843 |
|
844 |
|
845 | getSideEffectsConnectionState(moduleGraph) {
|
846 | return true;
|
847 | }
|
848 |
|
849 | |
850 |
|
851 |
|
852 |
|
853 | codeGeneration(context) {
|
854 |
|
855 | const sources = new Map();
|
856 | for (const type of this.getSourceTypes()) {
|
857 | if (type !== "unknown") {
|
858 | sources.set(
|
859 | type,
|
860 | this.source(
|
861 | context.dependencyTemplates,
|
862 | context.runtimeTemplate,
|
863 | type
|
864 | )
|
865 | );
|
866 | }
|
867 | }
|
868 | return {
|
869 | sources,
|
870 | runtimeRequirements: new Set([
|
871 | RuntimeGlobals.module,
|
872 | RuntimeGlobals.exports,
|
873 | RuntimeGlobals.require
|
874 | ])
|
875 | };
|
876 | }
|
877 |
|
878 | |
879 |
|
880 |
|
881 |
|
882 |
|
883 | chunkCondition(chunk, compilation) {
|
884 | return true;
|
885 | }
|
886 |
|
887 | |
888 |
|
889 |
|
890 |
|
891 |
|
892 |
|
893 |
|
894 | updateCacheModule(module) {
|
895 | this.type = module.type;
|
896 | this.layer = module.layer;
|
897 | this.context = module.context;
|
898 | this.factoryMeta = module.factoryMeta;
|
899 | this.resolveOptions = module.resolveOptions;
|
900 | }
|
901 |
|
902 | |
903 |
|
904 |
|
905 |
|
906 |
|
907 | getUnsafeCacheData() {
|
908 | return {
|
909 | factoryMeta: this.factoryMeta,
|
910 | resolveOptions: this.resolveOptions
|
911 | };
|
912 | }
|
913 |
|
914 | |
915 |
|
916 |
|
917 |
|
918 |
|
919 | _restoreFromUnsafeCache(unsafeCacheData, normalModuleFactory) {
|
920 | this.factoryMeta = unsafeCacheData.factoryMeta;
|
921 | this.resolveOptions = unsafeCacheData.resolveOptions;
|
922 | }
|
923 |
|
924 | |
925 |
|
926 |
|
927 | cleanupForCache() {
|
928 | this.factoryMeta = undefined;
|
929 | this.resolveOptions = undefined;
|
930 | }
|
931 |
|
932 | |
933 |
|
934 |
|
935 | originalSource() {
|
936 | return null;
|
937 | }
|
938 |
|
939 | |
940 |
|
941 |
|
942 |
|
943 |
|
944 |
|
945 | addCacheDependencies(
|
946 | fileDependencies,
|
947 | contextDependencies,
|
948 | missingDependencies,
|
949 | buildDependencies
|
950 | ) {}
|
951 |
|
952 | serialize(context) {
|
953 | const { write } = context;
|
954 | write(this.type);
|
955 | write(this.layer);
|
956 | write(this.context);
|
957 | write(this.resolveOptions);
|
958 | write(this.factoryMeta);
|
959 | write(this.useSourceMap);
|
960 | write(this.useSimpleSourceMap);
|
961 | write(
|
962 | this._warnings !== undefined && this._warnings.length === 0
|
963 | ? undefined
|
964 | : this._warnings
|
965 | );
|
966 | write(
|
967 | this._errors !== undefined && this._errors.length === 0
|
968 | ? undefined
|
969 | : this._errors
|
970 | );
|
971 | write(this.buildMeta);
|
972 | write(this.buildInfo);
|
973 | write(this.presentationalDependencies);
|
974 | super.serialize(context);
|
975 | }
|
976 |
|
977 | deserialize(context) {
|
978 | const { read } = context;
|
979 | this.type = read();
|
980 | this.layer = read();
|
981 | this.context = read();
|
982 | this.resolveOptions = read();
|
983 | this.factoryMeta = read();
|
984 | this.useSourceMap = read();
|
985 | this.useSimpleSourceMap = read();
|
986 | this._warnings = read();
|
987 | this._errors = read();
|
988 | this.buildMeta = read();
|
989 | this.buildInfo = read();
|
990 | this.presentationalDependencies = read();
|
991 | super.deserialize(context);
|
992 | }
|
993 | }
|
994 |
|
995 | makeSerializable(Module, "webpack/lib/Module");
|
996 |
|
997 |
|
998 | Object.defineProperty(Module.prototype, "hasEqualsChunks", {
|
999 | get() {
|
1000 | throw new Error(
|
1001 | "Module.hasEqualsChunks was renamed (use hasEqualChunks instead)"
|
1002 | );
|
1003 | }
|
1004 | });
|
1005 |
|
1006 |
|
1007 | Object.defineProperty(Module.prototype, "isUsed", {
|
1008 | get() {
|
1009 | throw new Error(
|
1010 | "Module.isUsed was renamed (use getUsedName, isExportUsed or isModuleUsed instead)"
|
1011 | );
|
1012 | }
|
1013 | });
|
1014 |
|
1015 |
|
1016 | Object.defineProperty(Module.prototype, "errors", {
|
1017 | get: util.deprecate(
|
1018 | /**
|
1019 | * @this {Module}
|
1020 | * @returns {WebpackError[]} array
|
1021 | */
|
1022 | function () {
|
1023 | if (this._errors === undefined) {
|
1024 | this._errors = [];
|
1025 | }
|
1026 | return this._errors;
|
1027 | },
|
1028 | "Module.errors was removed (use getErrors instead)",
|
1029 | "DEP_WEBPACK_MODULE_ERRORS"
|
1030 | )
|
1031 | });
|
1032 |
|
1033 |
|
1034 | Object.defineProperty(Module.prototype, "warnings", {
|
1035 | get: util.deprecate(
|
1036 | /**
|
1037 | * @this {Module}
|
1038 | * @returns {WebpackError[]} array
|
1039 | */
|
1040 | function () {
|
1041 | if (this._warnings === undefined) {
|
1042 | this._warnings = [];
|
1043 | }
|
1044 | return this._warnings;
|
1045 | },
|
1046 | "Module.warnings was removed (use getWarnings instead)",
|
1047 | "DEP_WEBPACK_MODULE_WARNINGS"
|
1048 | )
|
1049 | });
|
1050 |
|
1051 |
|
1052 | Object.defineProperty(Module.prototype, "used", {
|
1053 | get() {
|
1054 | throw new Error(
|
1055 | "Module.used was refactored (use ModuleGraph.getUsedExports instead)"
|
1056 | );
|
1057 | },
|
1058 | set(value) {
|
1059 | throw new Error(
|
1060 | "Module.used was refactored (use ModuleGraph.setUsedExports instead)"
|
1061 | );
|
1062 | }
|
1063 | });
|
1064 |
|
1065 | module.exports = Module;
|