webpack 5.47.0 → 5.50.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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/lib/CompatibilityPlugin.js +21 -4
- package/lib/Compilation.js +5 -2
- package/lib/ExternalModuleFactoryPlugin.js +1 -1
- package/lib/HotModuleReplacementPlugin.js +4 -4
- package/lib/Module.js +1 -0
- package/lib/MultiCompiler.js +0 -2
- package/lib/NormalModule.js +47 -20
- package/lib/NormalModuleFactory.js +145 -76
- package/lib/Parser.js +1 -0
- package/lib/WebpackOptionsApply.js +8 -0
- package/lib/asset/AssetModulesPlugin.js +0 -1
- package/lib/config/defaults.js +45 -18
- package/lib/config/normalization.js +6 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +6 -3
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +4 -2
- package/lib/dependencies/HarmonyImportDependency.js +5 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +40 -5
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +2 -2
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +10 -2
- package/lib/dependencies/ModuleDependency.js +8 -1
- package/lib/hmr/HotModuleReplacement.runtime.js +5 -1
- package/lib/index.js +0 -3
- package/lib/javascript/JavascriptParser.js +16 -9
- package/lib/optimize/SplitChunksPlugin.js +4 -4
- package/lib/rules/{DescriptionDataMatcherRulePlugin.js → ObjectMatcherRulePlugin.js} +14 -10
- package/lib/schemes/HttpUriPlugin.js +942 -25
- package/lib/serialization/BinaryMiddleware.js +293 -267
- package/package.json +3 -2
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +50 -0
- package/schemas/plugins/schemes/HttpUriPlugin.check.d.ts +7 -0
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +6 -0
- package/schemas/plugins/schemes/HttpUriPlugin.json +42 -0
- package/types.d.ts +99 -15
- package/lib/schemes/HttpsUriPlugin.js +0 -63
@@ -5,6 +5,7 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
const { getContext } = require("loader-runner");
|
8
9
|
const asyncLib = require("neo-async");
|
9
10
|
const {
|
10
11
|
AsyncSeriesBailHook,
|
@@ -20,7 +21,7 @@ const ModuleGraph = require("./ModuleGraph");
|
|
20
21
|
const NormalModule = require("./NormalModule");
|
21
22
|
const BasicEffectRulePlugin = require("./rules/BasicEffectRulePlugin");
|
22
23
|
const BasicMatcherRulePlugin = require("./rules/BasicMatcherRulePlugin");
|
23
|
-
const
|
24
|
+
const ObjectMatcherRulePlugin = require("./rules/ObjectMatcherRulePlugin");
|
24
25
|
const RuleSetCompiler = require("./rules/RuleSetCompiler");
|
25
26
|
const UseEffectRulePlugin = require("./rules/UseEffectRulePlugin");
|
26
27
|
const LazySet = require("./util/LazySet");
|
@@ -44,7 +45,9 @@ const { parseResource } = require("./util/identifier");
|
|
44
45
|
* @property {ModuleFactoryCreateData["resolveOptions"]} resolveOptions
|
45
46
|
* @property {string} context
|
46
47
|
* @property {string} request
|
48
|
+
* @property {Record<string, any> | undefined} assertions
|
47
49
|
* @property {ModuleDependency[]} dependencies
|
50
|
+
* @property {string} dependencyType
|
48
51
|
* @property {Object} createData
|
49
52
|
* @property {LazySet<string>} fileDependencies
|
50
53
|
* @property {LazySet<string>} missingDependencies
|
@@ -58,6 +61,7 @@ const { parseResource } = require("./util/identifier");
|
|
58
61
|
* @property {string} path
|
59
62
|
* @property {string} query
|
60
63
|
* @property {string} fragment
|
64
|
+
* @property {string=} context
|
61
65
|
*/
|
62
66
|
|
63
67
|
/** @typedef {ResourceData & { data: Record<string, any> }} ResourceDataWithData */
|
@@ -65,6 +69,7 @@ const { parseResource } = require("./util/identifier");
|
|
65
69
|
const EMPTY_RESOLVE_OPTIONS = {};
|
66
70
|
const EMPTY_PARSER_OPTIONS = {};
|
67
71
|
const EMPTY_GENERATOR_OPTIONS = {};
|
72
|
+
const EMPTY_ELEMENTS = [];
|
68
73
|
|
69
74
|
const MATCH_RESOURCE_REGEX = /^([^!]+)!=!/;
|
70
75
|
|
@@ -182,7 +187,8 @@ const ruleSetCompiler = new RuleSetCompiler([
|
|
182
187
|
new BasicMatcherRulePlugin("issuer"),
|
183
188
|
new BasicMatcherRulePlugin("compiler"),
|
184
189
|
new BasicMatcherRulePlugin("issuerLayer"),
|
185
|
-
new
|
190
|
+
new ObjectMatcherRulePlugin("assert", "assertions"),
|
191
|
+
new ObjectMatcherRulePlugin("descriptionData"),
|
186
192
|
new BasicEffectRulePlugin("type"),
|
187
193
|
new BasicEffectRulePlugin("sideEffects"),
|
188
194
|
new BasicEffectRulePlugin("parser"),
|
@@ -218,6 +224,10 @@ class NormalModuleFactory extends ModuleFactory {
|
|
218
224
|
resolveForScheme: new HookMap(
|
219
225
|
() => new AsyncSeriesBailHook(["resourceData", "resolveData"])
|
220
226
|
),
|
227
|
+
/** @type {HookMap<AsyncSeriesBailHook<[ResourceDataWithData, ResolveData], true | void>>} */
|
228
|
+
resolveInScheme: new HookMap(
|
229
|
+
() => new AsyncSeriesBailHook(["resourceData", "resolveData"])
|
230
|
+
),
|
221
231
|
/** @type {AsyncSeriesBailHook<[ResolveData], TODO>} */
|
222
232
|
factorize: new AsyncSeriesBailHook(["resolveData"]),
|
223
233
|
/** @type {AsyncSeriesBailHook<[ResolveData], TODO>} */
|
@@ -338,55 +348,84 @@ class NormalModuleFactory extends ModuleFactory {
|
|
338
348
|
contextInfo,
|
339
349
|
context,
|
340
350
|
dependencies,
|
351
|
+
dependencyType,
|
341
352
|
request,
|
353
|
+
assertions,
|
342
354
|
resolveOptions,
|
343
355
|
fileDependencies,
|
344
356
|
missingDependencies,
|
345
357
|
contextDependencies
|
346
358
|
} = data;
|
347
|
-
const dependencyType =
|
348
|
-
(dependencies.length > 0 && dependencies[0].category) || "";
|
349
359
|
const loaderResolver = this.getResolver("loader");
|
350
360
|
|
351
361
|
/** @type {ResourceData | undefined} */
|
352
362
|
let matchResourceData = undefined;
|
353
363
|
/** @type {string} */
|
354
|
-
let
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
364
|
+
let unresolvedResource;
|
365
|
+
/** @type {{loader: string, options: string|undefined}[]} */
|
366
|
+
let elements;
|
367
|
+
let noPreAutoLoaders = false;
|
368
|
+
let noAutoLoaders = false;
|
369
|
+
let noPrePostAutoLoaders = false;
|
370
|
+
|
371
|
+
const contextScheme = getScheme(context);
|
372
|
+
/** @type {string | undefined} */
|
373
|
+
let scheme = getScheme(request);
|
374
|
+
|
375
|
+
if (!scheme) {
|
376
|
+
/** @type {string} */
|
377
|
+
let requestWithoutMatchResource = request;
|
378
|
+
const matchResourceMatch = MATCH_RESOURCE_REGEX.exec(request);
|
379
|
+
if (matchResourceMatch) {
|
380
|
+
let matchResource = matchResourceMatch[1];
|
381
|
+
if (matchResource.charCodeAt(0) === 46) {
|
382
|
+
// 46 === ".", 47 === "/"
|
383
|
+
const secondChar = matchResource.charCodeAt(1);
|
384
|
+
if (
|
385
|
+
secondChar === 47 ||
|
386
|
+
(secondChar === 46 && matchResource.charCodeAt(2) === 47)
|
387
|
+
) {
|
388
|
+
// if matchResources startsWith ../ or ./
|
389
|
+
matchResource = join(this.fs, context, matchResource);
|
390
|
+
}
|
367
391
|
}
|
392
|
+
matchResourceData = {
|
393
|
+
resource: matchResource,
|
394
|
+
...cacheParseResource(matchResource)
|
395
|
+
};
|
396
|
+
requestWithoutMatchResource = request.substr(
|
397
|
+
matchResourceMatch[0].length
|
398
|
+
);
|
368
399
|
}
|
369
|
-
matchResourceData = {
|
370
|
-
resource: matchResource,
|
371
|
-
...cacheParseResource(matchResource)
|
372
|
-
};
|
373
|
-
requestWithoutMatchResource = request.substr(
|
374
|
-
matchResourceMatch[0].length
|
375
|
-
);
|
376
|
-
}
|
377
400
|
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
401
|
+
scheme = getScheme(requestWithoutMatchResource);
|
402
|
+
|
403
|
+
if (!scheme && !contextScheme) {
|
404
|
+
const firstChar = requestWithoutMatchResource.charCodeAt(0);
|
405
|
+
const secondChar = requestWithoutMatchResource.charCodeAt(1);
|
406
|
+
noPreAutoLoaders = firstChar === 45 && secondChar === 33; // startsWith "-!"
|
407
|
+
noAutoLoaders = noPreAutoLoaders || firstChar === 33; // startsWith "!"
|
408
|
+
noPrePostAutoLoaders = firstChar === 33 && secondChar === 33; // startsWith "!!";
|
409
|
+
const rawElements = requestWithoutMatchResource
|
410
|
+
.slice(
|
411
|
+
noPreAutoLoaders || noPrePostAutoLoaders
|
412
|
+
? 2
|
413
|
+
: noAutoLoaders
|
414
|
+
? 1
|
415
|
+
: 0
|
416
|
+
)
|
417
|
+
.split(/!+/);
|
418
|
+
unresolvedResource = rawElements.pop();
|
419
|
+
elements = rawElements.map(identToLoaderRequest);
|
420
|
+
scheme = getScheme(unresolvedResource);
|
421
|
+
} else {
|
422
|
+
unresolvedResource = requestWithoutMatchResource;
|
423
|
+
elements = EMPTY_ELEMENTS;
|
424
|
+
}
|
425
|
+
} else {
|
426
|
+
unresolvedResource = request;
|
427
|
+
elements = EMPTY_ELEMENTS;
|
428
|
+
}
|
390
429
|
|
391
430
|
const resolveContext = {
|
392
431
|
fileDependencies,
|
@@ -396,8 +435,6 @@ class NormalModuleFactory extends ModuleFactory {
|
|
396
435
|
|
397
436
|
/** @type {ResourceDataWithData} */
|
398
437
|
let resourceData;
|
399
|
-
/** @type {string | undefined} */
|
400
|
-
const scheme = getScheme(unresolvedResource);
|
401
438
|
|
402
439
|
let loaders;
|
403
440
|
|
@@ -447,6 +484,7 @@ class NormalModuleFactory extends ModuleFactory {
|
|
447
484
|
resourceQuery: resourceDataForRules.query,
|
448
485
|
resourceFragment: resourceDataForRules.fragment,
|
449
486
|
scheme,
|
487
|
+
assertions,
|
450
488
|
mimetype: matchResourceData ? "" : resourceData.data.mimetype || "",
|
451
489
|
dependency: dependencyType,
|
452
490
|
descriptionData: matchResourceData
|
@@ -536,6 +574,8 @@ class NormalModuleFactory extends ModuleFactory {
|
|
536
574
|
rawRequest: request,
|
537
575
|
loaders: allLoaders,
|
538
576
|
resource: resourceData.resource,
|
577
|
+
context:
|
578
|
+
resourceData.context || getContext(resourceData.resource),
|
539
579
|
matchResource: matchResourceData
|
540
580
|
? matchResourceData.resource
|
541
581
|
: undefined,
|
@@ -590,7 +630,7 @@ class NormalModuleFactory extends ModuleFactory {
|
|
590
630
|
|
591
631
|
this.resolveRequestArray(
|
592
632
|
contextInfo,
|
593
|
-
context,
|
633
|
+
contextScheme ? this.context : context,
|
594
634
|
elements,
|
595
635
|
loaderResolver,
|
596
636
|
resolveContext,
|
@@ -601,6 +641,49 @@ class NormalModuleFactory extends ModuleFactory {
|
|
601
641
|
}
|
602
642
|
);
|
603
643
|
|
644
|
+
const defaultResolve = context => {
|
645
|
+
if (/^($|\?)/.test(unresolvedResource)) {
|
646
|
+
resourceData = {
|
647
|
+
resource: unresolvedResource,
|
648
|
+
data: {},
|
649
|
+
...cacheParseResource(unresolvedResource)
|
650
|
+
};
|
651
|
+
continueCallback();
|
652
|
+
}
|
653
|
+
|
654
|
+
// resource without scheme and with path
|
655
|
+
else {
|
656
|
+
const normalResolver = this.getResolver(
|
657
|
+
"normal",
|
658
|
+
dependencyType
|
659
|
+
? cachedSetProperty(
|
660
|
+
resolveOptions || EMPTY_RESOLVE_OPTIONS,
|
661
|
+
"dependencyType",
|
662
|
+
dependencyType
|
663
|
+
)
|
664
|
+
: resolveOptions
|
665
|
+
);
|
666
|
+
this.resolveResource(
|
667
|
+
contextInfo,
|
668
|
+
context,
|
669
|
+
unresolvedResource,
|
670
|
+
normalResolver,
|
671
|
+
resolveContext,
|
672
|
+
(err, resolvedResource, resolvedResourceResolveData) => {
|
673
|
+
if (err) return continueCallback(err);
|
674
|
+
if (resolvedResource !== false) {
|
675
|
+
resourceData = {
|
676
|
+
resource: resolvedResource,
|
677
|
+
data: resolvedResourceResolveData,
|
678
|
+
...cacheParseResource(resolvedResource)
|
679
|
+
};
|
680
|
+
}
|
681
|
+
continueCallback();
|
682
|
+
}
|
683
|
+
);
|
684
|
+
}
|
685
|
+
};
|
686
|
+
|
604
687
|
// resource with scheme
|
605
688
|
if (scheme) {
|
606
689
|
resourceData = {
|
@@ -608,7 +691,8 @@ class NormalModuleFactory extends ModuleFactory {
|
|
608
691
|
data: {},
|
609
692
|
path: undefined,
|
610
693
|
query: undefined,
|
611
|
-
fragment: undefined
|
694
|
+
fragment: undefined,
|
695
|
+
context: undefined
|
612
696
|
};
|
613
697
|
this.hooks.resolveForScheme
|
614
698
|
.for(scheme)
|
@@ -618,47 +702,27 @@ class NormalModuleFactory extends ModuleFactory {
|
|
618
702
|
});
|
619
703
|
}
|
620
704
|
|
621
|
-
// resource
|
622
|
-
else if (
|
705
|
+
// resource within scheme
|
706
|
+
else if (contextScheme) {
|
623
707
|
resourceData = {
|
624
708
|
resource: unresolvedResource,
|
625
709
|
data: {},
|
626
|
-
|
710
|
+
path: undefined,
|
711
|
+
query: undefined,
|
712
|
+
fragment: undefined,
|
713
|
+
context: undefined
|
627
714
|
};
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
// resource without scheme and with path
|
632
|
-
else {
|
633
|
-
const normalResolver = this.getResolver(
|
634
|
-
"normal",
|
635
|
-
dependencyType
|
636
|
-
? cachedSetProperty(
|
637
|
-
resolveOptions || EMPTY_RESOLVE_OPTIONS,
|
638
|
-
"dependencyType",
|
639
|
-
dependencyType
|
640
|
-
)
|
641
|
-
: resolveOptions
|
642
|
-
);
|
643
|
-
this.resolveResource(
|
644
|
-
contextInfo,
|
645
|
-
context,
|
646
|
-
unresolvedResource,
|
647
|
-
normalResolver,
|
648
|
-
resolveContext,
|
649
|
-
(err, resolvedResource, resolvedResourceResolveData) => {
|
715
|
+
this.hooks.resolveInScheme
|
716
|
+
.for(contextScheme)
|
717
|
+
.callAsync(resourceData, data, (err, handled) => {
|
650
718
|
if (err) return continueCallback(err);
|
651
|
-
if (
|
652
|
-
resourceData = {
|
653
|
-
resource: resolvedResource,
|
654
|
-
data: resolvedResourceResolveData,
|
655
|
-
...cacheParseResource(resolvedResource)
|
656
|
-
};
|
657
|
-
}
|
719
|
+
if (!handled) return defaultResolve(this.context);
|
658
720
|
continueCallback();
|
659
|
-
}
|
660
|
-
);
|
721
|
+
});
|
661
722
|
}
|
723
|
+
|
724
|
+
// resource without scheme and without path
|
725
|
+
else defaultResolve(context);
|
662
726
|
}
|
663
727
|
);
|
664
728
|
}
|
@@ -694,17 +758,22 @@ class NormalModuleFactory extends ModuleFactory {
|
|
694
758
|
const resolveOptions = data.resolveOptions || EMPTY_RESOLVE_OPTIONS;
|
695
759
|
const dependency = dependencies[0];
|
696
760
|
const request = dependency.request;
|
761
|
+
const assertions = dependency.assertions;
|
697
762
|
const contextInfo = data.contextInfo;
|
698
763
|
const fileDependencies = new LazySet();
|
699
764
|
const missingDependencies = new LazySet();
|
700
765
|
const contextDependencies = new LazySet();
|
766
|
+
const dependencyType =
|
767
|
+
(dependencies.length > 0 && dependencies[0].category) || "";
|
701
768
|
/** @type {ResolveData} */
|
702
769
|
const resolveData = {
|
703
770
|
contextInfo,
|
704
771
|
resolveOptions,
|
705
772
|
context,
|
706
773
|
request,
|
774
|
+
assertions,
|
707
775
|
dependencies,
|
776
|
+
dependencyType,
|
708
777
|
fileDependencies,
|
709
778
|
missingDependencies,
|
710
779
|
contextDependencies,
|
@@ -851,7 +920,7 @@ ${hints.join("\n\n")}`;
|
|
851
920
|
null,
|
852
921
|
`Did you mean '${resource}'?
|
853
922
|
BREAKING CHANGE: The request '${unresolvedResource}' failed to resolve only because it was resolved as fully specified
|
854
|
-
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
|
923
|
+
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
|
855
924
|
The extension in the request is mandatory for it to be fully specified.
|
856
925
|
Add the extension to the request.`
|
857
926
|
);
|
package/lib/Parser.js
CHANGED
@@ -276,6 +276,14 @@ class WebpackOptionsApply extends OptionsApply {
|
|
276
276
|
}).apply(compiler);
|
277
277
|
}
|
278
278
|
|
279
|
+
if (options.experiments.buildHttp) {
|
280
|
+
const HttpUriPlugin = require("./schemes/HttpUriPlugin");
|
281
|
+
const httpOptions = options.experiments.buildHttp;
|
282
|
+
if (httpOptions === true)
|
283
|
+
throw new Error("Unexpected due to normalization");
|
284
|
+
new HttpUriPlugin(httpOptions).apply(compiler);
|
285
|
+
}
|
286
|
+
|
279
287
|
new EntryOptionPlugin().apply(compiler);
|
280
288
|
compiler.hooks.entryOption.call(options.context, options.entry);
|
281
289
|
|
@@ -120,7 +120,6 @@ class AssetModulesPlugin {
|
|
120
120
|
for (const type of ["asset", "asset/inline", "asset/resource"]) {
|
121
121
|
normalModuleFactory.hooks.createGenerator
|
122
122
|
.for(type)
|
123
|
-
// eslint-disable-next-line no-loop-func
|
124
123
|
.tap(plugin, generatorOptions => {
|
125
124
|
validateGeneratorOptions[type](generatorOptions);
|
126
125
|
|
package/lib/config/defaults.js
CHANGED
@@ -171,7 +171,7 @@ const applyWebpackOptionsDefaults = options => {
|
|
171
171
|
|
172
172
|
applySnapshotDefaults(options.snapshot, { production });
|
173
173
|
|
174
|
-
applyExperimentsDefaults(options.experiments);
|
174
|
+
applyExperimentsDefaults(options.experiments, { production, development });
|
175
175
|
|
176
176
|
applyModuleDefaults(options.module, {
|
177
177
|
cache,
|
@@ -193,7 +193,10 @@ const applyWebpackOptionsDefaults = options => {
|
|
193
193
|
module: options.module
|
194
194
|
});
|
195
195
|
|
196
|
-
applyExternalsPresetsDefaults(options.externalsPresets, {
|
196
|
+
applyExternalsPresetsDefaults(options.externalsPresets, {
|
197
|
+
targetProperties,
|
198
|
+
buildHttp: !!options.experiments.buildHttp
|
199
|
+
});
|
197
200
|
|
198
201
|
applyLoaderDefaults(options.loader, { targetProperties });
|
199
202
|
|
@@ -245,13 +248,26 @@ const applyWebpackOptionsDefaults = options => {
|
|
245
248
|
|
246
249
|
/**
|
247
250
|
* @param {Experiments} experiments options
|
251
|
+
* @param {Object} options options
|
252
|
+
* @param {boolean} options.production is production
|
253
|
+
* @param {boolean} options.development is development mode
|
248
254
|
* @returns {void}
|
249
255
|
*/
|
250
|
-
const applyExperimentsDefaults = experiments => {
|
256
|
+
const applyExperimentsDefaults = (experiments, { production, development }) => {
|
251
257
|
D(experiments, "topLevelAwait", false);
|
252
258
|
D(experiments, "syncWebAssembly", false);
|
253
259
|
D(experiments, "asyncWebAssembly", false);
|
254
260
|
D(experiments, "outputModule", false);
|
261
|
+
D(experiments, "asset", false);
|
262
|
+
D(experiments, "executeModule", false);
|
263
|
+
D(experiments, "layers", false);
|
264
|
+
D(experiments, "lazyCompilation", false);
|
265
|
+
D(experiments, "buildHttp", false);
|
266
|
+
|
267
|
+
if (typeof experiments.buildHttp === "object") {
|
268
|
+
D(experiments.buildHttp, "frozen", production);
|
269
|
+
D(experiments.buildHttp, "upgrade", development);
|
270
|
+
}
|
255
271
|
};
|
256
272
|
|
257
273
|
/**
|
@@ -298,7 +314,7 @@ const applyCacheDefaults = (cache, { name, mode, development }) => {
|
|
298
314
|
);
|
299
315
|
D(cache, "hashAlgorithm", "md4");
|
300
316
|
D(cache, "store", "pack");
|
301
|
-
D(cache, "compression",
|
317
|
+
D(cache, "compression", false);
|
302
318
|
D(cache, "profile", false);
|
303
319
|
D(cache, "idleTimeout", 60000);
|
304
320
|
D(cache, "idleTimeoutForInitialStore", 5000);
|
@@ -482,18 +498,6 @@ const applyModuleDefaults = (
|
|
482
498
|
or: ["text/javascript", "application/javascript"]
|
483
499
|
},
|
484
500
|
...esm
|
485
|
-
},
|
486
|
-
{
|
487
|
-
dependency: "url",
|
488
|
-
oneOf: [
|
489
|
-
{
|
490
|
-
scheme: /^data$/,
|
491
|
-
type: "asset/inline"
|
492
|
-
},
|
493
|
-
{
|
494
|
-
type: "asset/resource"
|
495
|
-
}
|
496
|
-
]
|
497
501
|
}
|
498
502
|
];
|
499
503
|
if (asyncWebAssembly) {
|
@@ -541,6 +545,24 @@ const applyModuleDefaults = (
|
|
541
545
|
...wasm
|
542
546
|
});
|
543
547
|
}
|
548
|
+
rules.push(
|
549
|
+
{
|
550
|
+
dependency: "url",
|
551
|
+
oneOf: [
|
552
|
+
{
|
553
|
+
scheme: /^data$/,
|
554
|
+
type: "asset/inline"
|
555
|
+
},
|
556
|
+
{
|
557
|
+
type: "asset/resource"
|
558
|
+
}
|
559
|
+
]
|
560
|
+
},
|
561
|
+
{
|
562
|
+
assert: { type: "json" },
|
563
|
+
type: "json"
|
564
|
+
}
|
565
|
+
);
|
544
566
|
return rules;
|
545
567
|
});
|
546
568
|
};
|
@@ -854,13 +876,18 @@ const applyOutputDefaults = (
|
|
854
876
|
* @param {ExternalsPresets} externalsPresets options
|
855
877
|
* @param {Object} options options
|
856
878
|
* @param {TargetProperties | false} options.targetProperties target properties
|
879
|
+
* @param {boolean} options.buildHttp buildHttp experiment enabled
|
857
880
|
* @returns {void}
|
858
881
|
*/
|
859
882
|
const applyExternalsPresetsDefaults = (
|
860
883
|
externalsPresets,
|
861
|
-
{ targetProperties }
|
884
|
+
{ targetProperties, buildHttp }
|
862
885
|
) => {
|
863
|
-
D(
|
886
|
+
D(
|
887
|
+
externalsPresets,
|
888
|
+
"web",
|
889
|
+
!buildHttp && targetProperties && targetProperties.web
|
890
|
+
);
|
864
891
|
D(externalsPresets, "node", targetProperties && targetProperties.node);
|
865
892
|
D(externalsPresets, "nwjs", targetProperties && targetProperties.nwjs);
|
866
893
|
D(
|
@@ -171,7 +171,12 @@ const getNormalizedWebpackOptions = config => {
|
|
171
171
|
Promise.resolve().then(fn).then(getNormalizedEntryStatic)
|
172
172
|
)(config.entry)
|
173
173
|
: getNormalizedEntryStatic(config.entry),
|
174
|
-
experiments:
|
174
|
+
experiments: nestedConfig(config.experiments, experiments => ({
|
175
|
+
...experiments,
|
176
|
+
buildHttp: optionalNestedConfig(experiments.buildHttp, options =>
|
177
|
+
options === true ? {} : options
|
178
|
+
)
|
179
|
+
})),
|
175
180
|
externals: config.externals,
|
176
181
|
externalsPresets: cloneObject(config.externalsPresets),
|
177
182
|
externalsType: config.externalsType,
|
@@ -12,7 +12,8 @@ const HarmonyExportHeaderDependency = require("./HarmonyExportHeaderDependency")
|
|
12
12
|
const HarmonyExportImportedSpecifierDependency = require("./HarmonyExportImportedSpecifierDependency");
|
13
13
|
const HarmonyExportSpecifierDependency = require("./HarmonyExportSpecifierDependency");
|
14
14
|
const {
|
15
|
-
harmonySpecifierTag
|
15
|
+
harmonySpecifierTag,
|
16
|
+
getAssertions
|
16
17
|
} = require("./HarmonyImportDependencyParserPlugin");
|
17
18
|
const HarmonyImportSideEffectDependency = require("./HarmonyImportSideEffectDependency");
|
18
19
|
|
@@ -48,7 +49,8 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
48
49
|
parser.state.module.addPresentationalDependency(clearDep);
|
49
50
|
const sideEffectDep = new HarmonyImportSideEffectDependency(
|
50
51
|
source,
|
51
|
-
parser.state.lastHarmonyImportOrder
|
52
|
+
parser.state.lastHarmonyImportOrder,
|
53
|
+
getAssertions(statement)
|
52
54
|
);
|
53
55
|
sideEffectDep.loc = Object.create(statement.loc);
|
54
56
|
sideEffectDep.loc.index = -1;
|
@@ -127,7 +129,8 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
127
129
|
harmonyNamedExports,
|
128
130
|
null,
|
129
131
|
this.strictExportPresence,
|
130
|
-
null
|
132
|
+
null,
|
133
|
+
settings.assertions
|
131
134
|
);
|
132
135
|
} else {
|
133
136
|
dep = new HarmonyExportSpecifierDependency(id, name);
|
@@ -159,6 +159,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
159
159
|
* @param {ReadonlyArray<HarmonyExportImportedSpecifierDependency> | Iterable<HarmonyExportImportedSpecifierDependency>} otherStarExports other star exports in the module before this import
|
160
160
|
* @param {boolean} strictExportPresence when true, missing exports in the imported module lead to errors instead of warnings
|
161
161
|
* @param {HarmonyStarExportsList} allStarExports all star exports in the module
|
162
|
+
* @param {Record<string, any>=} assertions import assertions
|
162
163
|
*/
|
163
164
|
constructor(
|
164
165
|
request,
|
@@ -168,9 +169,10 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
168
169
|
activeExports,
|
169
170
|
otherStarExports,
|
170
171
|
strictExportPresence,
|
171
|
-
allStarExports
|
172
|
+
allStarExports,
|
173
|
+
assertions
|
172
174
|
) {
|
173
|
-
super(request, sourceOrder);
|
175
|
+
super(request, sourceOrder, assertions);
|
174
176
|
|
175
177
|
this.ids = ids;
|
176
178
|
this.name = name;
|
@@ -32,10 +32,12 @@ class HarmonyImportDependency extends ModuleDependency {
|
|
32
32
|
*
|
33
33
|
* @param {string} request request string
|
34
34
|
* @param {number} sourceOrder source order
|
35
|
+
* @param {Record<string, any>=} assertions import assertions
|
35
36
|
*/
|
36
|
-
constructor(request, sourceOrder) {
|
37
|
+
constructor(request, sourceOrder, assertions) {
|
37
38
|
super(request);
|
38
39
|
this.sourceOrder = sourceOrder;
|
40
|
+
this.assertions = assertions;
|
39
41
|
}
|
40
42
|
|
41
43
|
get category() {
|
@@ -201,12 +203,14 @@ class HarmonyImportDependency extends ModuleDependency {
|
|
201
203
|
serialize(context) {
|
202
204
|
const { write } = context;
|
203
205
|
write(this.sourceOrder);
|
206
|
+
write(this.assertions);
|
204
207
|
super.serialize(context);
|
205
208
|
}
|
206
209
|
|
207
210
|
deserialize(context) {
|
208
211
|
const { read } = context;
|
209
212
|
this.sourceOrder = read();
|
213
|
+
this.assertions = read();
|
210
214
|
super.deserialize(context);
|
211
215
|
}
|
212
216
|
}
|