source: trip-planner-front/node_modules/webpack/lib/dependencies/HarmonyImportSideEffectDependency.js@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const makeSerializable = require("../util/makeSerializable");
9const HarmonyImportDependency = require("./HarmonyImportDependency");
10
11/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
12/** @typedef {import("../Dependency")} Dependency */
13/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
14/** @typedef {import("../InitFragment")} InitFragment */
15/** @typedef {import("../Module")} Module */
16/** @typedef {import("../ModuleGraph")} ModuleGraph */
17/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
18/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
19/** @typedef {import("../util/Hash")} Hash */
20/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
21
22class HarmonyImportSideEffectDependency extends HarmonyImportDependency {
23 constructor(request, sourceOrder, assertions) {
24 super(request, sourceOrder, assertions);
25 }
26
27 get type() {
28 return "harmony side effect evaluation";
29 }
30
31 /**
32 * @param {ModuleGraph} moduleGraph module graph
33 * @returns {null | false | function(ModuleGraphConnection, RuntimeSpec): ConnectionState} function to determine if the connection is active
34 */
35 getCondition(moduleGraph) {
36 return connection => {
37 const refModule = connection.resolvedModule;
38 if (!refModule) return true;
39 return refModule.getSideEffectsConnectionState(moduleGraph);
40 };
41 }
42
43 /**
44 * @param {ModuleGraph} moduleGraph the module graph
45 * @returns {ConnectionState} how this dependency connects the module to referencing modules
46 */
47 getModuleEvaluationSideEffectsState(moduleGraph) {
48 const refModule = moduleGraph.getModule(this);
49 if (!refModule) return true;
50 return refModule.getSideEffectsConnectionState(moduleGraph);
51 }
52}
53
54makeSerializable(
55 HarmonyImportSideEffectDependency,
56 "webpack/lib/dependencies/HarmonyImportSideEffectDependency"
57);
58
59HarmonyImportSideEffectDependency.Template = class HarmonyImportSideEffectDependencyTemplate extends (
60 HarmonyImportDependency.Template
61) {
62 /**
63 * @param {Dependency} dependency the dependency for which the template should be applied
64 * @param {ReplaceSource} source the current replace source which can be modified
65 * @param {DependencyTemplateContext} templateContext the context object
66 * @returns {void}
67 */
68 apply(dependency, source, templateContext) {
69 const { moduleGraph, concatenationScope } = templateContext;
70 if (concatenationScope) {
71 const module = moduleGraph.getModule(dependency);
72 if (concatenationScope.isModuleInScope(module)) {
73 return;
74 }
75 }
76 super.apply(dependency, source, templateContext);
77 }
78};
79
80module.exports = HarmonyImportSideEffectDependency;
Note: See TracBrowser for help on using the repository browser.