source: trip-planner-front/node_modules/webpack/lib/dependencies/HarmonyExportSpecifierDependency.js@ e29cc2e

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

initial commit

  • Property mode set to 100644
File size: 3.0 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 HarmonyExportInitFragment = require("./HarmonyExportInitFragment");
10const NullDependency = require("./NullDependency");
11
12/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
13/** @typedef {import("../Dependency")} Dependency */
14/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
15/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
16/** @typedef {import("../ModuleGraph")} ModuleGraph */
17/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
18
19class HarmonyExportSpecifierDependency extends NullDependency {
20 constructor(id, name) {
21 super();
22 this.id = id;
23 this.name = name;
24 }
25
26 get type() {
27 return "harmony export specifier";
28 }
29
30 /**
31 * Returns the exported names
32 * @param {ModuleGraph} moduleGraph module graph
33 * @returns {ExportsSpec | undefined} export names
34 */
35 getExports(moduleGraph) {
36 return {
37 exports: [this.name],
38 priority: 1,
39 terminalBinding: true,
40 dependencies: undefined
41 };
42 }
43
44 /**
45 * @param {ModuleGraph} moduleGraph the module graph
46 * @returns {ConnectionState} how this dependency connects the module to referencing modules
47 */
48 getModuleEvaluationSideEffectsState(moduleGraph) {
49 return false;
50 }
51
52 serialize(context) {
53 const { write } = context;
54 write(this.id);
55 write(this.name);
56 super.serialize(context);
57 }
58
59 deserialize(context) {
60 const { read } = context;
61 this.id = read();
62 this.name = read();
63 super.deserialize(context);
64 }
65}
66
67makeSerializable(
68 HarmonyExportSpecifierDependency,
69 "webpack/lib/dependencies/HarmonyExportSpecifierDependency"
70);
71
72HarmonyExportSpecifierDependency.Template = class HarmonyExportSpecifierDependencyTemplate extends (
73 NullDependency.Template
74) {
75 /**
76 * @param {Dependency} dependency the dependency for which the template should be applied
77 * @param {ReplaceSource} source the current replace source which can be modified
78 * @param {DependencyTemplateContext} templateContext the context object
79 * @returns {void}
80 */
81 apply(
82 dependency,
83 source,
84 { module, moduleGraph, initFragments, runtime, concatenationScope }
85 ) {
86 const dep = /** @type {HarmonyExportSpecifierDependency} */ (dependency);
87 if (concatenationScope) {
88 concatenationScope.registerExport(dep.name, dep.id);
89 return;
90 }
91 const used = moduleGraph
92 .getExportsInfo(module)
93 .getUsedName(dep.name, runtime);
94 if (!used) {
95 const set = new Set();
96 set.add(dep.name || "namespace");
97 initFragments.push(
98 new HarmonyExportInitFragment(module.exportsArgument, undefined, set)
99 );
100 return;
101 }
102
103 const map = new Map();
104 map.set(used, `/* binding */ ${dep.id}`);
105 initFragments.push(
106 new HarmonyExportInitFragment(module.exportsArgument, map, undefined)
107 );
108 }
109};
110
111module.exports = HarmonyExportSpecifierDependency;
Note: See TracBrowser for help on using the repository browser.