webpack 3.5.6 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +716 -567
- package/bin/convert-argv.js +1 -1
- package/lib/CachePlugin.js +25 -9
- package/lib/Compiler.js +3 -9
- package/lib/HotModuleReplacement.runtime.js +602 -602
- package/lib/Module.js +250 -250
- package/lib/NormalModule.js +556 -556
- package/lib/OptionsDefaulter.js +73 -73
- package/lib/SourceMapDevToolPlugin.js +209 -209
- package/lib/Template.js +176 -176
- package/lib/WebpackOptionsDefaulter.js +129 -129
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +285 -285
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +124 -124
- package/lib/dependencies/HarmonyModulesHelpers.js +85 -85
- package/lib/optimize/ConcatenatedModule.js +814 -814
- package/lib/webpack.js +119 -119
- package/package.json +2 -2
@@ -1,285 +1,285 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
"use strict";
|
6
|
-
const NullDependency = require("./NullDependency");
|
7
|
-
const HarmonyModulesHelpers = require("./HarmonyModulesHelpers");
|
8
|
-
|
9
|
-
class HarmonyExportImportedSpecifierDependency extends NullDependency {
|
10
|
-
constructor(originModule, importDependency, importedVar, id, name) {
|
11
|
-
super();
|
12
|
-
this.originModule = originModule;
|
13
|
-
this.importDependency = importDependency;
|
14
|
-
this.importedVar = importedVar;
|
15
|
-
this.id = id;
|
16
|
-
this.name = name;
|
17
|
-
}
|
18
|
-
|
19
|
-
get type() {
|
20
|
-
return "harmony export imported specifier";
|
21
|
-
}
|
22
|
-
|
23
|
-
getReference() {
|
24
|
-
const name = this.name;
|
25
|
-
const used = this.originModule.isUsed(name);
|
26
|
-
const active = HarmonyModulesHelpers.isActive(this.originModule, this);
|
27
|
-
const importedModule = this.importDependency.module;
|
28
|
-
|
29
|
-
if(!importedModule || !used || !active || !this.originModule.usedExports) return null;
|
30
|
-
|
31
|
-
const hasUsedExports = Array.isArray(this.originModule.usedExports);
|
32
|
-
|
33
|
-
if(name) {
|
34
|
-
const nameIsNotInUsedExports = hasUsedExports && this.originModule.usedExports.indexOf(name) < 0;
|
35
|
-
if(nameIsNotInUsedExports) return null;
|
36
|
-
|
37
|
-
// export { name as name }
|
38
|
-
if(this.id) {
|
39
|
-
return {
|
40
|
-
module: importedModule,
|
41
|
-
importedNames: [this.id]
|
42
|
-
};
|
43
|
-
}
|
44
|
-
|
45
|
-
// export { * as name }
|
46
|
-
return {
|
47
|
-
module: importedModule,
|
48
|
-
importedNames: true
|
49
|
-
};
|
50
|
-
}
|
51
|
-
|
52
|
-
const hasProvidedExports = Array.isArray(importedModule.providedExports);
|
53
|
-
|
54
|
-
// export *
|
55
|
-
if(hasUsedExports) {
|
56
|
-
// reexport * with known used exports
|
57
|
-
const activeExports = HarmonyModulesHelpers.getActiveExports(this.originModule, this);
|
58
|
-
const importedNames = this.originModule.usedExports.filter(id => {
|
59
|
-
const notInActiveExports = activeExports.indexOf(id) < 0;
|
60
|
-
const notDefault = id !== "default";
|
61
|
-
|
62
|
-
if(hasProvidedExports) {
|
63
|
-
const inProvidedExports = importedModule.providedExports.indexOf(id) >= 0;
|
64
|
-
return notInActiveExports && notDefault && inProvidedExports;
|
65
|
-
} else {
|
66
|
-
return notInActiveExports && notDefault;
|
67
|
-
}
|
68
|
-
});
|
69
|
-
|
70
|
-
return {
|
71
|
-
module: importedModule,
|
72
|
-
importedNames
|
73
|
-
};
|
74
|
-
}
|
75
|
-
|
76
|
-
if(hasProvidedExports) {
|
77
|
-
return {
|
78
|
-
module: importedModule,
|
79
|
-
importedNames: importedModule.providedExports.filter(id => id !== "default"),
|
80
|
-
};
|
81
|
-
}
|
82
|
-
|
83
|
-
return {
|
84
|
-
module: importedModule,
|
85
|
-
importedNames: true,
|
86
|
-
};
|
87
|
-
}
|
88
|
-
|
89
|
-
getExports() {
|
90
|
-
if(this.name) {
|
91
|
-
return {
|
92
|
-
exports: [this.name]
|
93
|
-
};
|
94
|
-
}
|
95
|
-
|
96
|
-
const importedModule = this.importDependency.module;
|
97
|
-
|
98
|
-
if(!importedModule) {
|
99
|
-
// no imported module available
|
100
|
-
return {
|
101
|
-
exports: null
|
102
|
-
};
|
103
|
-
}
|
104
|
-
|
105
|
-
if(Array.isArray(importedModule.providedExports)) {
|
106
|
-
return {
|
107
|
-
exports: importedModule.providedExports.filter(id => id !== "default"),
|
108
|
-
dependencies: [importedModule]
|
109
|
-
};
|
110
|
-
}
|
111
|
-
|
112
|
-
if(importedModule.providedExports) {
|
113
|
-
return {
|
114
|
-
exports: true
|
115
|
-
};
|
116
|
-
}
|
117
|
-
|
118
|
-
return {
|
119
|
-
exports: null,
|
120
|
-
dependencies: [importedModule]
|
121
|
-
};
|
122
|
-
}
|
123
|
-
|
124
|
-
describeHarmonyExport() {
|
125
|
-
const importedModule = this.importDependency.module;
|
126
|
-
if(!this.name && importedModule && Array.isArray(importedModule.providedExports)) {
|
127
|
-
// for a star export and when we know which exports are provided, we can tell so
|
128
|
-
return {
|
129
|
-
exportedName: importedModule.providedExports,
|
130
|
-
precedence: 3
|
131
|
-
};
|
132
|
-
}
|
133
|
-
|
134
|
-
return {
|
135
|
-
exportedName: this.name,
|
136
|
-
precedence: this.name ? 2 : 3
|
137
|
-
};
|
138
|
-
}
|
139
|
-
|
140
|
-
updateHash(hash) {
|
141
|
-
super.updateHash(hash);
|
142
|
-
const hashValue = this.getHashValue(this.importDependency.module);
|
143
|
-
hash.update(hashValue);
|
144
|
-
}
|
145
|
-
|
146
|
-
getHashValue(importedModule) {
|
147
|
-
if(!importedModule) {
|
148
|
-
return "";
|
149
|
-
}
|
150
|
-
|
151
|
-
const stringifiedUsedExport = JSON.stringify(importedModule.usedExports);
|
152
|
-
const stringifiedProvidedExport = JSON.stringify(importedModule.providedExports);
|
153
|
-
return importedModule.used + stringifiedUsedExport + stringifiedProvidedExport;
|
154
|
-
}
|
155
|
-
}
|
156
|
-
|
157
|
-
module.exports = HarmonyExportImportedSpecifierDependency;
|
158
|
-
|
159
|
-
HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedSpecifierDependencyTemplate {
|
160
|
-
apply(dep, source, outputOptions, requestShortener) {
|
161
|
-
const content = this.getContent(dep);
|
162
|
-
source.insert(-1, content);
|
163
|
-
}
|
164
|
-
|
165
|
-
getContent(dep) {
|
166
|
-
const name = dep.importedVar;
|
167
|
-
const used = dep.originModule.isUsed(dep.name);
|
168
|
-
const importedModule = dep.importDependency.module;
|
169
|
-
const active = HarmonyModulesHelpers.isActive(dep.originModule, dep);
|
170
|
-
const importsExportsUnknown = !importedModule || !Array.isArray(importedModule.providedExports);
|
171
|
-
|
172
|
-
const getReexportStatement = this.reexportStatementCreator(dep.originModule, importsExportsUnknown, name);
|
173
|
-
|
174
|
-
// we want to rexport something, but the export isn't used
|
175
|
-
if(!used) {
|
176
|
-
return "/* unused harmony reexport " + dep.name + " */\n";
|
177
|
-
}
|
178
|
-
|
179
|
-
// we want to reexport something but another exports overrides this one
|
180
|
-
if(!active) {
|
181
|
-
return "/* inactive harmony reexport " + (dep.name || "namespace") + " */\n";
|
182
|
-
}
|
183
|
-
|
184
|
-
// we want to reexport the default export from a non-hamory module
|
185
|
-
const isNotAHarmonyModule = !(importedModule && (!importedModule.meta || importedModule.meta.harmonyModule));
|
186
|
-
if(dep.name && dep.id === "default" && isNotAHarmonyModule) {
|
187
|
-
return "/* harmony reexport (default from non-hamory) */ " + getReexportStatement(JSON.stringify(used), null);
|
188
|
-
}
|
189
|
-
|
190
|
-
// we want to reexport a key as new key
|
191
|
-
if(dep.name && dep.id) {
|
192
|
-
var idUsed = importedModule && importedModule.isUsed(dep.id);
|
193
|
-
return "/* harmony reexport (binding) */ " + getReexportStatement(JSON.stringify(used), JSON.stringify(idUsed));
|
194
|
-
}
|
195
|
-
|
196
|
-
// we want to reexport the module object as named export
|
197
|
-
if(dep.name) {
|
198
|
-
return "/* harmony reexport (module object) */ " + getReexportStatement(JSON.stringify(used), "");
|
199
|
-
}
|
200
|
-
|
201
|
-
// we know which exports are used
|
202
|
-
if(Array.isArray(dep.originModule.usedExports)) {
|
203
|
-
const activeExports = HarmonyModulesHelpers.getActiveExports(dep.originModule, dep);
|
204
|
-
const items = dep.originModule.usedExports.map(function(id) {
|
205
|
-
if(id === "default") return;
|
206
|
-
if(activeExports.indexOf(id) >= 0) return;
|
207
|
-
if(importedModule.isProvided(id) === false) return;
|
208
|
-
var exportUsed = dep.originModule.isUsed(id);
|
209
|
-
var idUsed = importedModule && importedModule.isUsed(id);
|
210
|
-
return [exportUsed, idUsed];
|
211
|
-
}).filter(Boolean);
|
212
|
-
|
213
|
-
if(items.length === 0) {
|
214
|
-
return "/* unused harmony namespace reexport */\n";
|
215
|
-
}
|
216
|
-
|
217
|
-
return items.map(function(item) {
|
218
|
-
return "/* harmony namespace reexport (by used) */ " + getReexportStatement(JSON.stringify(item[0]), JSON.stringify(item[1]));
|
219
|
-
}).join("");
|
220
|
-
}
|
221
|
-
|
222
|
-
// not sure which exports are used, but we know which are provided
|
223
|
-
if(dep.originModule.usedExports && importedModule && Array.isArray(importedModule.providedExports)) {
|
224
|
-
const activeExports = HarmonyModulesHelpers.getActiveExports(dep.originModule, dep);
|
225
|
-
const items = importedModule.providedExports.map(function(id) {
|
226
|
-
if(id === "default") return;
|
227
|
-
if(activeExports.indexOf(id) >= 0) return;
|
228
|
-
var exportUsed = dep.originModule.isUsed(id);
|
229
|
-
var idUsed = importedModule && importedModule.isUsed(id);
|
230
|
-
return [exportUsed, idUsed];
|
231
|
-
}).filter(Boolean);
|
232
|
-
|
233
|
-
if(items.length === 0) {
|
234
|
-
return "/* empty harmony namespace reexport */\n";
|
235
|
-
}
|
236
|
-
|
237
|
-
return items.map(function(item) {
|
238
|
-
return "/* harmony namespace reexport (by provided) */ " + getReexportStatement(JSON.stringify(item[0]), JSON.stringify(item[1]));
|
239
|
-
}).join("");
|
240
|
-
}
|
241
|
-
|
242
|
-
// not sure which exports are used and provided
|
243
|
-
if(dep.originModule.usedExports) {
|
244
|
-
const activeExports = HarmonyModulesHelpers.getActiveExports(dep.originModule, dep);
|
245
|
-
let content = "/* harmony namespace reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in " + name + ") ";
|
246
|
-
|
247
|
-
// Filter out exports which are defined by other exports
|
248
|
-
// and filter out default export because it cannot be reexported with *
|
249
|
-
if(activeExports.length > 0)
|
250
|
-
content += "if(" + JSON.stringify(activeExports.concat("default")) + ".indexOf(__WEBPACK_IMPORT_KEY__) < 0) ";
|
251
|
-
else
|
252
|
-
content += "if(__WEBPACK_IMPORT_KEY__ !== 'default') ";
|
253
|
-
const exportsName = dep.originModule.exportsArgument || "exports";
|
254
|
-
return content + `(function(key) { __webpack_require__.d(${exportsName}, key, function() { return ${name}[key]; }) }(__WEBPACK_IMPORT_KEY__));\n`;
|
255
|
-
}
|
256
|
-
|
257
|
-
return "/* unused harmony reexport namespace */\n";
|
258
|
-
}
|
259
|
-
|
260
|
-
reexportStatementCreator(module, importsExportsUnknown, name) {
|
261
|
-
const exportsName = module.exportsArgument || "exports";
|
262
|
-
const getReexportStatement = (key, valueKey) => {
|
263
|
-
const conditional = this.getConditional(importsExportsUnknown, valueKey, name);
|
264
|
-
const returnValue = this.getReturnValue(valueKey);
|
265
|
-
return `${conditional}__webpack_require__.d(${exportsName}, ${key}, function() { return ${name}${returnValue}; });\n`;
|
266
|
-
};
|
267
|
-
return getReexportStatement;
|
268
|
-
}
|
269
|
-
|
270
|
-
getConditional(importsExportsUnknown, valueKey, name) {
|
271
|
-
if(!importsExportsUnknown || !valueKey) {
|
272
|
-
return "";
|
273
|
-
}
|
274
|
-
|
275
|
-
return `if(__webpack_require__.o(${name}, ${valueKey})) `;
|
276
|
-
}
|
277
|
-
|
278
|
-
getReturnValue(valueKey) {
|
279
|
-
if(valueKey === null) {
|
280
|
-
return "_default.a";
|
281
|
-
}
|
282
|
-
|
283
|
-
return valueKey && "[" + valueKey + "]";
|
284
|
-
}
|
285
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
"use strict";
|
6
|
+
const NullDependency = require("./NullDependency");
|
7
|
+
const HarmonyModulesHelpers = require("./HarmonyModulesHelpers");
|
8
|
+
|
9
|
+
class HarmonyExportImportedSpecifierDependency extends NullDependency {
|
10
|
+
constructor(originModule, importDependency, importedVar, id, name) {
|
11
|
+
super();
|
12
|
+
this.originModule = originModule;
|
13
|
+
this.importDependency = importDependency;
|
14
|
+
this.importedVar = importedVar;
|
15
|
+
this.id = id;
|
16
|
+
this.name = name;
|
17
|
+
}
|
18
|
+
|
19
|
+
get type() {
|
20
|
+
return "harmony export imported specifier";
|
21
|
+
}
|
22
|
+
|
23
|
+
getReference() {
|
24
|
+
const name = this.name;
|
25
|
+
const used = this.originModule.isUsed(name);
|
26
|
+
const active = HarmonyModulesHelpers.isActive(this.originModule, this);
|
27
|
+
const importedModule = this.importDependency.module;
|
28
|
+
|
29
|
+
if(!importedModule || !used || !active || !this.originModule.usedExports) return null;
|
30
|
+
|
31
|
+
const hasUsedExports = Array.isArray(this.originModule.usedExports);
|
32
|
+
|
33
|
+
if(name) {
|
34
|
+
const nameIsNotInUsedExports = hasUsedExports && this.originModule.usedExports.indexOf(name) < 0;
|
35
|
+
if(nameIsNotInUsedExports) return null;
|
36
|
+
|
37
|
+
// export { name as name }
|
38
|
+
if(this.id) {
|
39
|
+
return {
|
40
|
+
module: importedModule,
|
41
|
+
importedNames: [this.id]
|
42
|
+
};
|
43
|
+
}
|
44
|
+
|
45
|
+
// export { * as name }
|
46
|
+
return {
|
47
|
+
module: importedModule,
|
48
|
+
importedNames: true
|
49
|
+
};
|
50
|
+
}
|
51
|
+
|
52
|
+
const hasProvidedExports = Array.isArray(importedModule.providedExports);
|
53
|
+
|
54
|
+
// export *
|
55
|
+
if(hasUsedExports) {
|
56
|
+
// reexport * with known used exports
|
57
|
+
const activeExports = HarmonyModulesHelpers.getActiveExports(this.originModule, this);
|
58
|
+
const importedNames = this.originModule.usedExports.filter(id => {
|
59
|
+
const notInActiveExports = activeExports.indexOf(id) < 0;
|
60
|
+
const notDefault = id !== "default";
|
61
|
+
|
62
|
+
if(hasProvidedExports) {
|
63
|
+
const inProvidedExports = importedModule.providedExports.indexOf(id) >= 0;
|
64
|
+
return notInActiveExports && notDefault && inProvidedExports;
|
65
|
+
} else {
|
66
|
+
return notInActiveExports && notDefault;
|
67
|
+
}
|
68
|
+
});
|
69
|
+
|
70
|
+
return {
|
71
|
+
module: importedModule,
|
72
|
+
importedNames
|
73
|
+
};
|
74
|
+
}
|
75
|
+
|
76
|
+
if(hasProvidedExports) {
|
77
|
+
return {
|
78
|
+
module: importedModule,
|
79
|
+
importedNames: importedModule.providedExports.filter(id => id !== "default"),
|
80
|
+
};
|
81
|
+
}
|
82
|
+
|
83
|
+
return {
|
84
|
+
module: importedModule,
|
85
|
+
importedNames: true,
|
86
|
+
};
|
87
|
+
}
|
88
|
+
|
89
|
+
getExports() {
|
90
|
+
if(this.name) {
|
91
|
+
return {
|
92
|
+
exports: [this.name]
|
93
|
+
};
|
94
|
+
}
|
95
|
+
|
96
|
+
const importedModule = this.importDependency.module;
|
97
|
+
|
98
|
+
if(!importedModule) {
|
99
|
+
// no imported module available
|
100
|
+
return {
|
101
|
+
exports: null
|
102
|
+
};
|
103
|
+
}
|
104
|
+
|
105
|
+
if(Array.isArray(importedModule.providedExports)) {
|
106
|
+
return {
|
107
|
+
exports: importedModule.providedExports.filter(id => id !== "default"),
|
108
|
+
dependencies: [importedModule]
|
109
|
+
};
|
110
|
+
}
|
111
|
+
|
112
|
+
if(importedModule.providedExports) {
|
113
|
+
return {
|
114
|
+
exports: true
|
115
|
+
};
|
116
|
+
}
|
117
|
+
|
118
|
+
return {
|
119
|
+
exports: null,
|
120
|
+
dependencies: [importedModule]
|
121
|
+
};
|
122
|
+
}
|
123
|
+
|
124
|
+
describeHarmonyExport() {
|
125
|
+
const importedModule = this.importDependency.module;
|
126
|
+
if(!this.name && importedModule && Array.isArray(importedModule.providedExports)) {
|
127
|
+
// for a star export and when we know which exports are provided, we can tell so
|
128
|
+
return {
|
129
|
+
exportedName: importedModule.providedExports,
|
130
|
+
precedence: 3
|
131
|
+
};
|
132
|
+
}
|
133
|
+
|
134
|
+
return {
|
135
|
+
exportedName: this.name,
|
136
|
+
precedence: this.name ? 2 : 3
|
137
|
+
};
|
138
|
+
}
|
139
|
+
|
140
|
+
updateHash(hash) {
|
141
|
+
super.updateHash(hash);
|
142
|
+
const hashValue = this.getHashValue(this.importDependency.module);
|
143
|
+
hash.update(hashValue);
|
144
|
+
}
|
145
|
+
|
146
|
+
getHashValue(importedModule) {
|
147
|
+
if(!importedModule) {
|
148
|
+
return "";
|
149
|
+
}
|
150
|
+
|
151
|
+
const stringifiedUsedExport = JSON.stringify(importedModule.usedExports);
|
152
|
+
const stringifiedProvidedExport = JSON.stringify(importedModule.providedExports);
|
153
|
+
return importedModule.used + stringifiedUsedExport + stringifiedProvidedExport;
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
157
|
+
module.exports = HarmonyExportImportedSpecifierDependency;
|
158
|
+
|
159
|
+
HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedSpecifierDependencyTemplate {
|
160
|
+
apply(dep, source, outputOptions, requestShortener) {
|
161
|
+
const content = this.getContent(dep);
|
162
|
+
source.insert(-1, content);
|
163
|
+
}
|
164
|
+
|
165
|
+
getContent(dep) {
|
166
|
+
const name = dep.importedVar;
|
167
|
+
const used = dep.originModule.isUsed(dep.name);
|
168
|
+
const importedModule = dep.importDependency.module;
|
169
|
+
const active = HarmonyModulesHelpers.isActive(dep.originModule, dep);
|
170
|
+
const importsExportsUnknown = !importedModule || !Array.isArray(importedModule.providedExports);
|
171
|
+
|
172
|
+
const getReexportStatement = this.reexportStatementCreator(dep.originModule, importsExportsUnknown, name);
|
173
|
+
|
174
|
+
// we want to rexport something, but the export isn't used
|
175
|
+
if(!used) {
|
176
|
+
return "/* unused harmony reexport " + dep.name + " */\n";
|
177
|
+
}
|
178
|
+
|
179
|
+
// we want to reexport something but another exports overrides this one
|
180
|
+
if(!active) {
|
181
|
+
return "/* inactive harmony reexport " + (dep.name || "namespace") + " */\n";
|
182
|
+
}
|
183
|
+
|
184
|
+
// we want to reexport the default export from a non-hamory module
|
185
|
+
const isNotAHarmonyModule = !(importedModule && (!importedModule.meta || importedModule.meta.harmonyModule));
|
186
|
+
if(dep.name && dep.id === "default" && isNotAHarmonyModule) {
|
187
|
+
return "/* harmony reexport (default from non-hamory) */ " + getReexportStatement(JSON.stringify(used), null);
|
188
|
+
}
|
189
|
+
|
190
|
+
// we want to reexport a key as new key
|
191
|
+
if(dep.name && dep.id) {
|
192
|
+
var idUsed = importedModule && importedModule.isUsed(dep.id);
|
193
|
+
return "/* harmony reexport (binding) */ " + getReexportStatement(JSON.stringify(used), JSON.stringify(idUsed));
|
194
|
+
}
|
195
|
+
|
196
|
+
// we want to reexport the module object as named export
|
197
|
+
if(dep.name) {
|
198
|
+
return "/* harmony reexport (module object) */ " + getReexportStatement(JSON.stringify(used), "");
|
199
|
+
}
|
200
|
+
|
201
|
+
// we know which exports are used
|
202
|
+
if(Array.isArray(dep.originModule.usedExports)) {
|
203
|
+
const activeExports = HarmonyModulesHelpers.getActiveExports(dep.originModule, dep);
|
204
|
+
const items = dep.originModule.usedExports.map(function(id) {
|
205
|
+
if(id === "default") return;
|
206
|
+
if(activeExports.indexOf(id) >= 0) return;
|
207
|
+
if(importedModule.isProvided(id) === false) return;
|
208
|
+
var exportUsed = dep.originModule.isUsed(id);
|
209
|
+
var idUsed = importedModule && importedModule.isUsed(id);
|
210
|
+
return [exportUsed, idUsed];
|
211
|
+
}).filter(Boolean);
|
212
|
+
|
213
|
+
if(items.length === 0) {
|
214
|
+
return "/* unused harmony namespace reexport */\n";
|
215
|
+
}
|
216
|
+
|
217
|
+
return items.map(function(item) {
|
218
|
+
return "/* harmony namespace reexport (by used) */ " + getReexportStatement(JSON.stringify(item[0]), JSON.stringify(item[1]));
|
219
|
+
}).join("");
|
220
|
+
}
|
221
|
+
|
222
|
+
// not sure which exports are used, but we know which are provided
|
223
|
+
if(dep.originModule.usedExports && importedModule && Array.isArray(importedModule.providedExports)) {
|
224
|
+
const activeExports = HarmonyModulesHelpers.getActiveExports(dep.originModule, dep);
|
225
|
+
const items = importedModule.providedExports.map(function(id) {
|
226
|
+
if(id === "default") return;
|
227
|
+
if(activeExports.indexOf(id) >= 0) return;
|
228
|
+
var exportUsed = dep.originModule.isUsed(id);
|
229
|
+
var idUsed = importedModule && importedModule.isUsed(id);
|
230
|
+
return [exportUsed, idUsed];
|
231
|
+
}).filter(Boolean);
|
232
|
+
|
233
|
+
if(items.length === 0) {
|
234
|
+
return "/* empty harmony namespace reexport */\n";
|
235
|
+
}
|
236
|
+
|
237
|
+
return items.map(function(item) {
|
238
|
+
return "/* harmony namespace reexport (by provided) */ " + getReexportStatement(JSON.stringify(item[0]), JSON.stringify(item[1]));
|
239
|
+
}).join("");
|
240
|
+
}
|
241
|
+
|
242
|
+
// not sure which exports are used and provided
|
243
|
+
if(dep.originModule.usedExports) {
|
244
|
+
const activeExports = HarmonyModulesHelpers.getActiveExports(dep.originModule, dep);
|
245
|
+
let content = "/* harmony namespace reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in " + name + ") ";
|
246
|
+
|
247
|
+
// Filter out exports which are defined by other exports
|
248
|
+
// and filter out default export because it cannot be reexported with *
|
249
|
+
if(activeExports.length > 0)
|
250
|
+
content += "if(" + JSON.stringify(activeExports.concat("default")) + ".indexOf(__WEBPACK_IMPORT_KEY__) < 0) ";
|
251
|
+
else
|
252
|
+
content += "if(__WEBPACK_IMPORT_KEY__ !== 'default') ";
|
253
|
+
const exportsName = dep.originModule.exportsArgument || "exports";
|
254
|
+
return content + `(function(key) { __webpack_require__.d(${exportsName}, key, function() { return ${name}[key]; }) }(__WEBPACK_IMPORT_KEY__));\n`;
|
255
|
+
}
|
256
|
+
|
257
|
+
return "/* unused harmony reexport namespace */\n";
|
258
|
+
}
|
259
|
+
|
260
|
+
reexportStatementCreator(module, importsExportsUnknown, name) {
|
261
|
+
const exportsName = module.exportsArgument || "exports";
|
262
|
+
const getReexportStatement = (key, valueKey) => {
|
263
|
+
const conditional = this.getConditional(importsExportsUnknown, valueKey, name);
|
264
|
+
const returnValue = this.getReturnValue(valueKey);
|
265
|
+
return `${conditional}__webpack_require__.d(${exportsName}, ${key}, function() { return ${name}${returnValue}; });\n`;
|
266
|
+
};
|
267
|
+
return getReexportStatement;
|
268
|
+
}
|
269
|
+
|
270
|
+
getConditional(importsExportsUnknown, valueKey, name) {
|
271
|
+
if(!importsExportsUnknown || !valueKey) {
|
272
|
+
return "";
|
273
|
+
}
|
274
|
+
|
275
|
+
return `if(__webpack_require__.o(${name}, ${valueKey})) `;
|
276
|
+
}
|
277
|
+
|
278
|
+
getReturnValue(valueKey) {
|
279
|
+
if(valueKey === null) {
|
280
|
+
return "_default.a";
|
281
|
+
}
|
282
|
+
|
283
|
+
return valueKey && "[" + valueKey + "]";
|
284
|
+
}
|
285
|
+
};
|