1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | "use strict";
|
7 |
|
8 | const makeSerializable = require("../util/makeSerializable");
|
9 | const HarmonyExportInitFragment = require("./HarmonyExportInitFragment");
|
10 | const NullDependency = require("./NullDependency");
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | class 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 |
|
32 |
|
33 |
|
34 |
|
35 | getExports(moduleGraph) {
|
36 | return {
|
37 | exports: [this.name],
|
38 | priority: 1,
|
39 | terminalBinding: true,
|
40 | dependencies: undefined
|
41 | };
|
42 | }
|
43 |
|
44 | |
45 |
|
46 |
|
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 |
|
67 | makeSerializable(
|
68 | HarmonyExportSpecifierDependency,
|
69 | "webpack/lib/dependencies/HarmonyExportSpecifierDependency"
|
70 | );
|
71 |
|
72 | HarmonyExportSpecifierDependency.Template = class HarmonyExportSpecifierDependencyTemplate extends (
|
73 | NullDependency.Template
|
74 | ) {
|
75 | |
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 | apply(
|
82 | dependency,
|
83 | source,
|
84 | { module, moduleGraph, initFragments, runtime, concatenationScope }
|
85 | ) {
|
86 | const dep = (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 |
|
111 | module.exports = HarmonyExportSpecifierDependency;
|
112 |
|
\ | No newline at end of file |