webpack 4.1.0 → 4.4.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 +719 -721
- package/bin/webpack.js +69 -10
- package/lib/APIPlugin.js +84 -84
- package/lib/AmdMainTemplatePlugin.js +75 -77
- package/lib/AsyncDependencyToInitialChunkError.js +21 -23
- package/lib/BannerPlugin.js +101 -101
- package/lib/Chunk.js +477 -469
- package/lib/ChunkTemplate.js +51 -53
- package/lib/Compilation.js +1858 -1851
- package/lib/Compiler.js +493 -478
- package/lib/ConcurrentCompilationError.js +19 -0
- package/lib/ContextModule.js +696 -685
- package/lib/ContextModuleFactory.js +245 -243
- package/lib/DefinePlugin.js +197 -197
- package/lib/DelegatedModule.js +101 -101
- package/lib/DependenciesBlockVariable.js +51 -52
- package/lib/Dependency.js +53 -52
- package/lib/DllModule.js +54 -54
- package/lib/DllModuleFactory.js +29 -29
- package/lib/EnvironmentPlugin.js +65 -67
- package/lib/EvalDevToolModuleTemplatePlugin.js +60 -60
- package/lib/EvalSourceMapDevToolModuleTemplatePlugin.js +105 -105
- package/lib/ExportPropertyMainTemplatePlugin.js +40 -40
- package/lib/ExternalModule.js +159 -159
- package/lib/FunctionModuleTemplatePlugin.js +98 -98
- package/lib/HotModuleReplacement.runtime.js +631 -631
- package/lib/HotModuleReplacementPlugin.js +407 -406
- package/lib/HotUpdateChunkTemplate.js +78 -80
- package/lib/JavascriptGenerator.js +228 -229
- package/lib/JavascriptModulesPlugin.js +184 -158
- package/lib/JsonGenerator.js +42 -42
- package/lib/MainTemplate.js +406 -402
- package/lib/Module.js +343 -340
- package/lib/ModuleBuildError.js +42 -42
- package/lib/ModuleError.js +28 -28
- package/lib/ModuleFilenameHelpers.js +166 -166
- package/lib/ModuleTemplate.js +77 -79
- package/lib/ModuleWarning.js +30 -30
- package/lib/MultiCompiler.js +271 -259
- package/lib/MultiModule.js +78 -75
- package/lib/MultiModuleFactory.js +23 -23
- package/lib/MultiWatching.js +38 -37
- package/lib/NoModeWarning.js +23 -21
- package/lib/NormalModule.js +478 -470
- package/lib/NormalModuleFactory.js +483 -481
- package/lib/OptionsDefaulter.js +80 -86
- package/lib/Parser.js +2074 -2071
- package/lib/ProgressPlugin.js +231 -231
- package/lib/RawModule.js +54 -55
- package/lib/RecordIdsPlugin.js +160 -160
- package/lib/RemovedPluginError.js +13 -13
- package/lib/ResolverFactory.js +64 -67
- package/lib/RuntimeTemplate.js +267 -297
- package/lib/SetVarMainTemplatePlugin.js +57 -57
- package/lib/SourceMapDevToolPlugin.js +302 -308
- package/lib/Stats.js +1234 -1212
- package/lib/Template.js +205 -205
- package/lib/TemplatedPathPlugin.js +170 -143
- package/lib/UmdMainTemplatePlugin.js +264 -269
- package/lib/Watching.js +193 -193
- package/lib/WebAssemblyParser.js +50 -54
- package/lib/WebpackOptionsApply.js +401 -401
- package/lib/WebpackOptionsDefaulter.js +337 -317
- package/lib/WebpackOptionsValidationError.js +316 -319
- package/lib/debug/ProfilingPlugin.js +409 -405
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +328 -311
- package/lib/dependencies/AMDRequireContextDependency.js +20 -20
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +270 -241
- package/lib/dependencies/HarmonyAcceptImportDependency.js +23 -23
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +620 -606
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +53 -53
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +214 -214
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +154 -156
- package/lib/dependencies/ImportDependenciesBlock.js +17 -17
- package/lib/dependencies/ImportDependency.js +34 -34
- package/lib/dependencies/ImportEagerDependency.js +32 -32
- package/lib/dependencies/ImportParserPlugin.js +175 -179
- package/lib/dependencies/ImportWeakDependency.js +34 -34
- package/lib/dependencies/JsonExportsDependency.js +25 -25
- package/lib/dependencies/ModuleDependency.js +20 -20
- package/lib/dependencies/NullDependency.js +20 -20
- package/lib/dependencies/RequireContextDependency.js +22 -22
- package/lib/dependencies/RequireIncludeDependency.js +40 -40
- package/lib/dependencies/WebpackMissingModule.js +20 -22
- package/lib/node/NodeChunkTemplatePlugin.js +31 -31
- package/lib/node/NodeHotUpdateChunkTemplatePlugin.js +36 -36
- package/lib/node/NodeMainTemplatePlugin.js +320 -273
- package/lib/node/ReadFileCompileWasmMainTemplatePlugin.js +113 -115
- package/lib/optimize/AggressiveSplittingPlugin.js +281 -281
- package/lib/optimize/ConcatenatedModule.js +1364 -1366
- package/lib/optimize/RemoveParentModulesPlugin.js +114 -114
- package/lib/optimize/SplitChunksPlugin.js +519 -491
- package/lib/performance/SizeLimitsPlugin.js +105 -105
- package/lib/util/TrackingSet.js +35 -35
- package/lib/util/objectToMap.js +10 -10
- package/lib/wasm/WasmModuleTemplatePlugin.js +106 -106
- package/lib/web/JsonpChunkTemplatePlugin.js +47 -47
- package/lib/web/JsonpExportMainTemplatePlugin.js +47 -47
- package/lib/web/JsonpHotUpdateChunkTemplatePlugin.js +39 -39
- package/lib/web/JsonpMainTemplatePlugin.js +425 -403
- package/lib/webpack.js +182 -179
- package/lib/webworker/WebWorkerChunkTemplatePlugin.js +35 -35
- package/lib/webworker/WebWorkerHotUpdateChunkTemplatePlugin.js +40 -40
- package/lib/webworker/WebWorkerMainTemplatePlugin.js +177 -154
- package/package.json +9 -8
- package/schemas/WebpackOptions.json +1973 -1951
- package/schemas/ajv.absolutePath.js +55 -29
- package/schemas/plugins/BannerPlugin.json +85 -85
- package/schemas/plugins/DllPlugin.json +28 -28
- package/schemas/plugins/DllReferencePlugin.json +99 -99
- package/schemas/plugins/HashedModuleIdsPlugin.json +24 -24
- package/schemas/plugins/LoaderOptionsPlugin.json +26 -26
- package/schemas/plugins/SourceMapDevToolPlugin.json +187 -187
- package/schemas/plugins/WatchIgnorePlugin.json +16 -16
- package/schemas/plugins/debug/ProfilingPlugin.json +12 -12
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.json +22 -22
- package/schemas/plugins/optimize/LimitChunkCountPlugin.json +15 -15
- package/schemas/plugins/optimize/MinChunkSizePlugin.json +13 -13
@@ -1,606 +1,620 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
"use strict";
|
6
|
-
const HarmonyImportDependency = require("./HarmonyImportDependency");
|
7
|
-
const Template = require("../Template");
|
8
|
-
|
9
|
-
class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
10
|
-
constructor(
|
11
|
-
request,
|
12
|
-
originModule,
|
13
|
-
sourceOrder,
|
14
|
-
parserScope,
|
15
|
-
id,
|
16
|
-
name,
|
17
|
-
activeExports,
|
18
|
-
otherStarExports,
|
19
|
-
strictExportPresence
|
20
|
-
) {
|
21
|
-
super(request, originModule, sourceOrder, parserScope);
|
22
|
-
this.id = id;
|
23
|
-
this.name = name;
|
24
|
-
this.activeExports = activeExports;
|
25
|
-
this.otherStarExports = otherStarExports;
|
26
|
-
this.strictExportPresence = strictExportPresence;
|
27
|
-
}
|
28
|
-
|
29
|
-
get type() {
|
30
|
-
return "harmony export imported specifier";
|
31
|
-
}
|
32
|
-
|
33
|
-
getMode(ignoreUnused) {
|
34
|
-
const name = this.name;
|
35
|
-
const id = this.id;
|
36
|
-
const used = this.originModule.isUsed(name);
|
37
|
-
const importedModule = this.module;
|
38
|
-
|
39
|
-
if (!importedModule) {
|
40
|
-
return {
|
41
|
-
type: "missing",
|
42
|
-
userRequest: this.userRequest
|
43
|
-
};
|
44
|
-
}
|
45
|
-
|
46
|
-
if (
|
47
|
-
!ignoreUnused &&
|
48
|
-
(name ? !used : this.originModule.usedExports === false)
|
49
|
-
) {
|
50
|
-
return {
|
51
|
-
type: "unused",
|
52
|
-
name: name || "*"
|
53
|
-
};
|
54
|
-
}
|
55
|
-
|
56
|
-
const
|
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
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
.
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
case "reexport-
|
220
|
-
case "
|
221
|
-
return {
|
222
|
-
module: mode.module,
|
223
|
-
importedNames:
|
224
|
-
};
|
225
|
-
|
226
|
-
case "
|
227
|
-
case "
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
}
|
266
|
-
}
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
return {
|
273
|
-
exports:
|
274
|
-
};
|
275
|
-
}
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
};
|
284
|
-
}
|
285
|
-
|
286
|
-
if (importedModule.buildMeta.providedExports) {
|
287
|
-
return {
|
288
|
-
exports:
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
}
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
this.
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
}
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
const
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
)
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
item[
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
const
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
}
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
"use strict";
|
6
|
+
const HarmonyImportDependency = require("./HarmonyImportDependency");
|
7
|
+
const Template = require("../Template");
|
8
|
+
|
9
|
+
class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
10
|
+
constructor(
|
11
|
+
request,
|
12
|
+
originModule,
|
13
|
+
sourceOrder,
|
14
|
+
parserScope,
|
15
|
+
id,
|
16
|
+
name,
|
17
|
+
activeExports,
|
18
|
+
otherStarExports,
|
19
|
+
strictExportPresence
|
20
|
+
) {
|
21
|
+
super(request, originModule, sourceOrder, parserScope);
|
22
|
+
this.id = id;
|
23
|
+
this.name = name;
|
24
|
+
this.activeExports = activeExports;
|
25
|
+
this.otherStarExports = otherStarExports;
|
26
|
+
this.strictExportPresence = strictExportPresence;
|
27
|
+
}
|
28
|
+
|
29
|
+
get type() {
|
30
|
+
return "harmony export imported specifier";
|
31
|
+
}
|
32
|
+
|
33
|
+
getMode(ignoreUnused) {
|
34
|
+
const name = this.name;
|
35
|
+
const id = this.id;
|
36
|
+
const used = this.originModule.isUsed(name);
|
37
|
+
const importedModule = this.module;
|
38
|
+
|
39
|
+
if (!importedModule) {
|
40
|
+
return {
|
41
|
+
type: "missing",
|
42
|
+
userRequest: this.userRequest
|
43
|
+
};
|
44
|
+
}
|
45
|
+
|
46
|
+
if (
|
47
|
+
!ignoreUnused &&
|
48
|
+
(name ? !used : this.originModule.usedExports === false)
|
49
|
+
) {
|
50
|
+
return {
|
51
|
+
type: "unused",
|
52
|
+
name: name || "*"
|
53
|
+
};
|
54
|
+
}
|
55
|
+
|
56
|
+
const strictHarmonyModule = this.originModule.buildMeta.strictHarmonyModule;
|
57
|
+
if (name && id === "default" && importedModule.buildMeta) {
|
58
|
+
if (!importedModule.buildMeta.exportsType) {
|
59
|
+
if (strictHarmonyModule) {
|
60
|
+
return {
|
61
|
+
type: "reexport-non-harmony-default-strict",
|
62
|
+
module: importedModule,
|
63
|
+
name
|
64
|
+
};
|
65
|
+
} else {
|
66
|
+
return {
|
67
|
+
type: "reexport-non-harmony-default",
|
68
|
+
module: importedModule,
|
69
|
+
name
|
70
|
+
};
|
71
|
+
}
|
72
|
+
} else if (importedModule.buildMeta.exportsType === "named") {
|
73
|
+
return {
|
74
|
+
type: "reexport-named-default",
|
75
|
+
module: importedModule,
|
76
|
+
name
|
77
|
+
};
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
const isNotAHarmonyModule =
|
82
|
+
importedModule.buildMeta && !importedModule.buildMeta.exportsType;
|
83
|
+
if (name) {
|
84
|
+
// export { name as name }
|
85
|
+
if (id) {
|
86
|
+
if (isNotAHarmonyModule && strictHarmonyModule) {
|
87
|
+
return {
|
88
|
+
type: "rexport-non-harmony-undefined",
|
89
|
+
module: importedModule,
|
90
|
+
name
|
91
|
+
};
|
92
|
+
} else {
|
93
|
+
return {
|
94
|
+
type: "safe-reexport",
|
95
|
+
module: importedModule,
|
96
|
+
map: new Map([[name, id]])
|
97
|
+
};
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
// export { * as name }
|
102
|
+
if (isNotAHarmonyModule && strictHarmonyModule) {
|
103
|
+
return {
|
104
|
+
type: "reexport-fake-namespace-object",
|
105
|
+
module: importedModule,
|
106
|
+
name
|
107
|
+
};
|
108
|
+
} else {
|
109
|
+
return {
|
110
|
+
type: "reexport-namespace-object",
|
111
|
+
module: importedModule,
|
112
|
+
name
|
113
|
+
};
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
const hasUsedExports = Array.isArray(this.originModule.usedExports);
|
118
|
+
const hasProvidedExports = Array.isArray(
|
119
|
+
importedModule.buildMeta.providedExports
|
120
|
+
);
|
121
|
+
const activeFromOtherStarExports = this._discoverActiveExportsFromOtherStartExports();
|
122
|
+
|
123
|
+
// export *
|
124
|
+
if (hasUsedExports) {
|
125
|
+
// reexport * with known used exports
|
126
|
+
if (hasProvidedExports) {
|
127
|
+
const map = new Map(
|
128
|
+
this.originModule.usedExports
|
129
|
+
.filter(id => {
|
130
|
+
if (id === "default") return false;
|
131
|
+
if (this.activeExports.has(id)) return false;
|
132
|
+
if (activeFromOtherStarExports.has(id)) return false;
|
133
|
+
if (!importedModule.buildMeta.providedExports.includes(id))
|
134
|
+
return false;
|
135
|
+
return true;
|
136
|
+
})
|
137
|
+
.map(item => [item, item])
|
138
|
+
);
|
139
|
+
|
140
|
+
if (map.size === 0) {
|
141
|
+
return {
|
142
|
+
type: "empty-star"
|
143
|
+
};
|
144
|
+
}
|
145
|
+
|
146
|
+
return {
|
147
|
+
type: "safe-reexport",
|
148
|
+
module: importedModule,
|
149
|
+
map
|
150
|
+
};
|
151
|
+
}
|
152
|
+
|
153
|
+
const map = new Map(
|
154
|
+
this.originModule.usedExports
|
155
|
+
.filter(id => {
|
156
|
+
if (id === "default") return false;
|
157
|
+
if (this.activeExports.has(id)) return false;
|
158
|
+
if (activeFromOtherStarExports.has(id)) return false;
|
159
|
+
|
160
|
+
return true;
|
161
|
+
})
|
162
|
+
.map(item => [item, item])
|
163
|
+
);
|
164
|
+
|
165
|
+
if (map.size === 0) {
|
166
|
+
return {
|
167
|
+
type: "empty-star"
|
168
|
+
};
|
169
|
+
}
|
170
|
+
|
171
|
+
return {
|
172
|
+
type: "checked-reexport",
|
173
|
+
module: importedModule,
|
174
|
+
map
|
175
|
+
};
|
176
|
+
}
|
177
|
+
|
178
|
+
if (hasProvidedExports) {
|
179
|
+
const map = new Map(
|
180
|
+
importedModule.buildMeta.providedExports
|
181
|
+
.filter(id => {
|
182
|
+
if (id === "default") return false;
|
183
|
+
if (this.activeExports.has(id)) return false;
|
184
|
+
if (activeFromOtherStarExports.has(id)) return false;
|
185
|
+
|
186
|
+
return true;
|
187
|
+
})
|
188
|
+
.map(item => [item, item])
|
189
|
+
);
|
190
|
+
|
191
|
+
if (map.size === 0) {
|
192
|
+
return {
|
193
|
+
type: "empty-star"
|
194
|
+
};
|
195
|
+
}
|
196
|
+
|
197
|
+
return {
|
198
|
+
type: "safe-reexport",
|
199
|
+
module: importedModule,
|
200
|
+
map
|
201
|
+
};
|
202
|
+
}
|
203
|
+
|
204
|
+
return {
|
205
|
+
type: "dynamic-reexport",
|
206
|
+
module: importedModule
|
207
|
+
};
|
208
|
+
}
|
209
|
+
|
210
|
+
getReference() {
|
211
|
+
const mode = this.getMode();
|
212
|
+
|
213
|
+
switch (mode.type) {
|
214
|
+
case "missing":
|
215
|
+
case "unused":
|
216
|
+
case "empty-star":
|
217
|
+
return null;
|
218
|
+
|
219
|
+
case "reexport-non-harmony-default":
|
220
|
+
case "reexport-named-default":
|
221
|
+
return {
|
222
|
+
module: mode.module,
|
223
|
+
importedNames: ["default"]
|
224
|
+
};
|
225
|
+
|
226
|
+
case "reexport-namespace-object":
|
227
|
+
case "reexport-non-harmony-default-strict":
|
228
|
+
case "reexport-fake-namespace-object":
|
229
|
+
case "rexport-non-harmony-undefined":
|
230
|
+
return {
|
231
|
+
module: mode.module,
|
232
|
+
importedNames: true
|
233
|
+
};
|
234
|
+
|
235
|
+
case "safe-reexport":
|
236
|
+
case "checked-reexport":
|
237
|
+
return {
|
238
|
+
module: mode.module,
|
239
|
+
importedNames: Array.from(mode.map.values())
|
240
|
+
};
|
241
|
+
|
242
|
+
case "dynamic-reexport":
|
243
|
+
return {
|
244
|
+
module: mode.module,
|
245
|
+
importedNames: true
|
246
|
+
};
|
247
|
+
|
248
|
+
default:
|
249
|
+
throw new Error(`Unknown mode ${mode.type}`);
|
250
|
+
}
|
251
|
+
}
|
252
|
+
|
253
|
+
_discoverActiveExportsFromOtherStartExports() {
|
254
|
+
if (!this.otherStarExports) return new Set();
|
255
|
+
const result = new Set();
|
256
|
+
// try to learn impossible exports from other star exports with provided exports
|
257
|
+
for (const otherStarExport of this.otherStarExports) {
|
258
|
+
const otherImportedModule = otherStarExport.module;
|
259
|
+
if (
|
260
|
+
otherImportedModule &&
|
261
|
+
Array.isArray(otherImportedModule.buildMeta.providedExports)
|
262
|
+
) {
|
263
|
+
for (const exportName of otherImportedModule.buildMeta.providedExports)
|
264
|
+
result.add(exportName);
|
265
|
+
}
|
266
|
+
}
|
267
|
+
return result;
|
268
|
+
}
|
269
|
+
|
270
|
+
getExports() {
|
271
|
+
if (this.name) {
|
272
|
+
return {
|
273
|
+
exports: [this.name]
|
274
|
+
};
|
275
|
+
}
|
276
|
+
|
277
|
+
const importedModule = this.module;
|
278
|
+
|
279
|
+
if (!importedModule) {
|
280
|
+
// no imported module available
|
281
|
+
return {
|
282
|
+
exports: null
|
283
|
+
};
|
284
|
+
}
|
285
|
+
|
286
|
+
if (Array.isArray(importedModule.buildMeta.providedExports)) {
|
287
|
+
return {
|
288
|
+
exports: importedModule.buildMeta.providedExports.filter(
|
289
|
+
id => id !== "default"
|
290
|
+
),
|
291
|
+
dependencies: [importedModule]
|
292
|
+
};
|
293
|
+
}
|
294
|
+
|
295
|
+
if (importedModule.buildMeta.providedExports) {
|
296
|
+
return {
|
297
|
+
exports: true
|
298
|
+
};
|
299
|
+
}
|
300
|
+
|
301
|
+
return {
|
302
|
+
exports: null,
|
303
|
+
dependencies: [importedModule]
|
304
|
+
};
|
305
|
+
}
|
306
|
+
|
307
|
+
getWarnings() {
|
308
|
+
if (
|
309
|
+
this.strictExportPresence ||
|
310
|
+
this.originModule.buildMeta.strictHarmonyModule
|
311
|
+
) {
|
312
|
+
return [];
|
313
|
+
}
|
314
|
+
return this._getErrors();
|
315
|
+
}
|
316
|
+
|
317
|
+
getErrors() {
|
318
|
+
if (
|
319
|
+
this.strictExportPresence ||
|
320
|
+
this.originModule.buildMeta.strictHarmonyModule
|
321
|
+
) {
|
322
|
+
return this._getErrors();
|
323
|
+
}
|
324
|
+
return [];
|
325
|
+
}
|
326
|
+
|
327
|
+
_getErrors() {
|
328
|
+
const importedModule = this.module;
|
329
|
+
if (!importedModule) {
|
330
|
+
return;
|
331
|
+
}
|
332
|
+
|
333
|
+
if (!importedModule.buildMeta || !importedModule.buildMeta.exportsType) {
|
334
|
+
// It's not an harmony module
|
335
|
+
if (
|
336
|
+
this.originModule.buildMeta.strictHarmonyModule &&
|
337
|
+
this.id !== "default"
|
338
|
+
) {
|
339
|
+
// In strict harmony modules we only support the default export
|
340
|
+
const exportName = this.id
|
341
|
+
? `the named export '${this.id}'`
|
342
|
+
: "the namespace object";
|
343
|
+
const err = new Error(
|
344
|
+
`Can't reexport ${exportName} from non EcmaScript module (only default export is available)`
|
345
|
+
);
|
346
|
+
err.hideStack = true;
|
347
|
+
return [err];
|
348
|
+
}
|
349
|
+
return;
|
350
|
+
}
|
351
|
+
|
352
|
+
if (!this.id) {
|
353
|
+
return;
|
354
|
+
}
|
355
|
+
|
356
|
+
if (importedModule.isProvided(this.id) !== false) {
|
357
|
+
// It's provided or we are not sure
|
358
|
+
return;
|
359
|
+
}
|
360
|
+
|
361
|
+
// We are sure that it's not provided
|
362
|
+
const idIsNotNameMessage =
|
363
|
+
this.id !== this.name ? ` (reexported as '${this.name}')` : "";
|
364
|
+
const errorMessage = `"export '${
|
365
|
+
this.id
|
366
|
+
}'${idIsNotNameMessage} was not found in '${this.userRequest}'`;
|
367
|
+
const err = new Error(errorMessage);
|
368
|
+
err.hideStack = true;
|
369
|
+
return [err];
|
370
|
+
}
|
371
|
+
|
372
|
+
updateHash(hash) {
|
373
|
+
super.updateHash(hash);
|
374
|
+
const hashValue = this.getHashValue(this.module);
|
375
|
+
hash.update(hashValue);
|
376
|
+
}
|
377
|
+
|
378
|
+
getHashValue(importedModule) {
|
379
|
+
if (!importedModule) {
|
380
|
+
return "";
|
381
|
+
}
|
382
|
+
|
383
|
+
const stringifiedUsedExport = JSON.stringify(importedModule.usedExports);
|
384
|
+
const stringifiedProvidedExport = JSON.stringify(
|
385
|
+
importedModule.buildMeta.providedExports
|
386
|
+
);
|
387
|
+
return (
|
388
|
+
importedModule.used + stringifiedUsedExport + stringifiedProvidedExport
|
389
|
+
);
|
390
|
+
}
|
391
|
+
}
|
392
|
+
|
393
|
+
module.exports = HarmonyExportImportedSpecifierDependency;
|
394
|
+
|
395
|
+
HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedSpecifierDependencyTemplate extends HarmonyImportDependency.Template {
|
396
|
+
harmonyInit(dep, source, runtime, dependencyTemplates) {
|
397
|
+
super.harmonyInit(dep, source, runtime, dependencyTemplates);
|
398
|
+
const content = this.getContent(dep);
|
399
|
+
source.insert(-1, content);
|
400
|
+
}
|
401
|
+
|
402
|
+
getHarmonyInitOrder(dep) {
|
403
|
+
if (dep.name) {
|
404
|
+
const used = dep.originModule.isUsed(dep.name);
|
405
|
+
if (!used) return NaN;
|
406
|
+
} else {
|
407
|
+
const importedModule = dep.module;
|
408
|
+
|
409
|
+
const activeFromOtherStarExports = dep._discoverActiveExportsFromOtherStartExports();
|
410
|
+
|
411
|
+
if (Array.isArray(dep.originModule.usedExports)) {
|
412
|
+
// we know which exports are used
|
413
|
+
|
414
|
+
const unused = dep.originModule.usedExports.every(id => {
|
415
|
+
if (id === "default") return true;
|
416
|
+
if (dep.activeExports.has(id)) return true;
|
417
|
+
if (importedModule.isProvided(id) === false) return true;
|
418
|
+
if (activeFromOtherStarExports.has(id)) return true;
|
419
|
+
return false;
|
420
|
+
});
|
421
|
+
if (unused) return NaN;
|
422
|
+
} else if (
|
423
|
+
dep.originModule.usedExports &&
|
424
|
+
importedModule &&
|
425
|
+
Array.isArray(importedModule.buildMeta.providedExports)
|
426
|
+
) {
|
427
|
+
// not sure which exports are used, but we know which are provided
|
428
|
+
|
429
|
+
const unused = importedModule.buildMeta.providedExports.every(id => {
|
430
|
+
if (id === "default") return true;
|
431
|
+
if (dep.activeExports.has(id)) return true;
|
432
|
+
if (activeFromOtherStarExports.has(id)) return true;
|
433
|
+
return false;
|
434
|
+
});
|
435
|
+
if (unused) return NaN;
|
436
|
+
}
|
437
|
+
}
|
438
|
+
return super.getHarmonyInitOrder(dep);
|
439
|
+
}
|
440
|
+
|
441
|
+
getContent(dep) {
|
442
|
+
const mode = dep.getMode();
|
443
|
+
const module = dep.originModule;
|
444
|
+
const importedModule = dep.module;
|
445
|
+
const importVar = dep.getImportVar();
|
446
|
+
|
447
|
+
switch (mode.type) {
|
448
|
+
case "missing":
|
449
|
+
return `throw new Error(${JSON.stringify(
|
450
|
+
`Cannot find module '${mode.userRequest}'`
|
451
|
+
)});\n`;
|
452
|
+
|
453
|
+
case "unused":
|
454
|
+
return `${Template.toNormalComment(
|
455
|
+
`unused harmony reexport ${mode.name}`
|
456
|
+
)}\n`;
|
457
|
+
|
458
|
+
case "reexport-non-harmony-default":
|
459
|
+
return (
|
460
|
+
"/* harmony reexport (default from non-harmony) */ " +
|
461
|
+
this.getReexportStatement(
|
462
|
+
module,
|
463
|
+
module.isUsed(mode.name),
|
464
|
+
importVar,
|
465
|
+
null
|
466
|
+
)
|
467
|
+
);
|
468
|
+
|
469
|
+
case "reexport-named-default":
|
470
|
+
return (
|
471
|
+
"/* harmony reexport (default from named exports) */ " +
|
472
|
+
this.getReexportStatement(
|
473
|
+
module,
|
474
|
+
module.isUsed(mode.name),
|
475
|
+
importVar,
|
476
|
+
""
|
477
|
+
)
|
478
|
+
);
|
479
|
+
|
480
|
+
case "reexport-fake-namespace-object":
|
481
|
+
return (
|
482
|
+
"/* harmony reexport (fake namespace object from non-harmony) */ " +
|
483
|
+
this.getReexportFakeNamespaceObjectStatement(
|
484
|
+
module,
|
485
|
+
module.isUsed(mode.name),
|
486
|
+
importVar
|
487
|
+
)
|
488
|
+
);
|
489
|
+
|
490
|
+
case "rexport-non-harmony-undefined":
|
491
|
+
return (
|
492
|
+
"/* harmony reexport (non default export from non-harmony) */ " +
|
493
|
+
this.getReexportStatement(
|
494
|
+
module,
|
495
|
+
module.isUsed(mode.name),
|
496
|
+
"undefined",
|
497
|
+
""
|
498
|
+
)
|
499
|
+
);
|
500
|
+
|
501
|
+
case "reexport-non-harmony-default-strict":
|
502
|
+
return (
|
503
|
+
"/* harmony reexport (default from non-harmony) */ " +
|
504
|
+
this.getReexportStatement(
|
505
|
+
module,
|
506
|
+
module.isUsed(mode.name),
|
507
|
+
importVar,
|
508
|
+
""
|
509
|
+
)
|
510
|
+
);
|
511
|
+
|
512
|
+
case "reexport-namespace-object":
|
513
|
+
return (
|
514
|
+
"/* harmony reexport (module object) */ " +
|
515
|
+
this.getReexportStatement(
|
516
|
+
module,
|
517
|
+
module.isUsed(mode.name),
|
518
|
+
importVar,
|
519
|
+
""
|
520
|
+
)
|
521
|
+
);
|
522
|
+
|
523
|
+
case "empty-star":
|
524
|
+
return "/* empty/unused harmony star reexport */";
|
525
|
+
|
526
|
+
case "safe-reexport":
|
527
|
+
return Array.from(mode.map.entries())
|
528
|
+
.map(item => {
|
529
|
+
return (
|
530
|
+
"/* harmony reexport (safe) */ " +
|
531
|
+
this.getReexportStatement(
|
532
|
+
module,
|
533
|
+
module.isUsed(item[0]),
|
534
|
+
importVar,
|
535
|
+
importedModule.isUsed(item[1])
|
536
|
+
) +
|
537
|
+
"\n"
|
538
|
+
);
|
539
|
+
})
|
540
|
+
.join("");
|
541
|
+
|
542
|
+
case "checked-reexport":
|
543
|
+
return Array.from(mode.map.entries())
|
544
|
+
.map(item => {
|
545
|
+
return (
|
546
|
+
"/* harmony reexport (checked) */ " +
|
547
|
+
this.getConditionalReexportStatement(
|
548
|
+
module,
|
549
|
+
item[0],
|
550
|
+
importVar,
|
551
|
+
item[1]
|
552
|
+
) +
|
553
|
+
"\n"
|
554
|
+
);
|
555
|
+
})
|
556
|
+
.join("");
|
557
|
+
|
558
|
+
case "dynamic-reexport": {
|
559
|
+
const activeExports = new Set([
|
560
|
+
...dep.activeExports,
|
561
|
+
...dep._discoverActiveExportsFromOtherStartExports()
|
562
|
+
]);
|
563
|
+
let content =
|
564
|
+
"/* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in " +
|
565
|
+
importVar +
|
566
|
+
") ";
|
567
|
+
|
568
|
+
// Filter out exports which are defined by other exports
|
569
|
+
// and filter out default export because it cannot be reexported with *
|
570
|
+
if (activeExports.length > 0)
|
571
|
+
content +=
|
572
|
+
"if(" +
|
573
|
+
JSON.stringify(activeExports.concat("default")) +
|
574
|
+
".indexOf(__WEBPACK_IMPORT_KEY__) < 0) ";
|
575
|
+
else content += "if(__WEBPACK_IMPORT_KEY__ !== 'default') ";
|
576
|
+
const exportsName = dep.originModule.exportsArgument;
|
577
|
+
return (
|
578
|
+
content +
|
579
|
+
`(function(key) { __webpack_require__.d(${exportsName}, key, function() { return ${importVar}[key]; }) }(__WEBPACK_IMPORT_KEY__));\n`
|
580
|
+
);
|
581
|
+
}
|
582
|
+
|
583
|
+
default:
|
584
|
+
throw new Error(`Unknown mode ${mode.type}`);
|
585
|
+
}
|
586
|
+
}
|
587
|
+
|
588
|
+
getReexportStatement(module, key, name, valueKey) {
|
589
|
+
const exportsName = module.exportsArgument;
|
590
|
+
const returnValue = this.getReturnValue(valueKey);
|
591
|
+
return `__webpack_require__.d(${exportsName}, ${JSON.stringify(
|
592
|
+
key
|
593
|
+
)}, function() { return ${name}${returnValue}; });\n`;
|
594
|
+
}
|
595
|
+
|
596
|
+
getReexportFakeNamespaceObjectStatement(module, key, name) {
|
597
|
+
const exportsName = module.exportsArgument;
|
598
|
+
return `__webpack_require__.d(${exportsName}, ${JSON.stringify(
|
599
|
+
key
|
600
|
+
)}, function() { return { "default": ${name} }; });\n`;
|
601
|
+
}
|
602
|
+
|
603
|
+
getConditionalReexportStatement(module, key, name, valueKey) {
|
604
|
+
const exportsName = module.exportsArgument;
|
605
|
+
const returnValue = this.getReturnValue(valueKey);
|
606
|
+
return `if(__webpack_require__.o(${name}, ${JSON.stringify(
|
607
|
+
valueKey
|
608
|
+
)})) __webpack_require__.d(${exportsName}, ${JSON.stringify(
|
609
|
+
key
|
610
|
+
)}, function() { return ${name}${returnValue}; });\n`;
|
611
|
+
}
|
612
|
+
|
613
|
+
getReturnValue(valueKey) {
|
614
|
+
if (valueKey === null) {
|
615
|
+
return "_default.a";
|
616
|
+
}
|
617
|
+
|
618
|
+
return valueKey && "[" + JSON.stringify(valueKey) + "]";
|
619
|
+
}
|
620
|
+
};
|