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