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
@@ -688,6 +688,17 @@
|
|
688
688
|
"description": "Support WebAssembly as asynchronous EcmaScript Module.",
|
689
689
|
"type": "boolean"
|
690
690
|
},
|
691
|
+
"buildHttp": {
|
692
|
+
"description": "Build http(s): urls using a lockfile and resource content cache.",
|
693
|
+
"anyOf": [
|
694
|
+
{
|
695
|
+
"type": "boolean"
|
696
|
+
},
|
697
|
+
{
|
698
|
+
"$ref": "#/definitions/HttpUriOptions"
|
699
|
+
}
|
700
|
+
]
|
701
|
+
},
|
691
702
|
"executeModule": {
|
692
703
|
"description": "Enable build-time execution of modules from the module graph for plugins and loaders.",
|
693
704
|
"type": "boolean"
|
@@ -1184,6 +1195,38 @@
|
|
1184
1195
|
"type": "string",
|
1185
1196
|
"absolutePath": false
|
1186
1197
|
},
|
1198
|
+
"HttpUriOptions": {
|
1199
|
+
"description": "Options for building http resources.",
|
1200
|
+
"type": "object",
|
1201
|
+
"additionalProperties": false,
|
1202
|
+
"properties": {
|
1203
|
+
"cacheLocation": {
|
1204
|
+
"description": "Location where resource content is stored for lockfile entries. It's also possible to disable storing by passing false.",
|
1205
|
+
"anyOf": [
|
1206
|
+
{
|
1207
|
+
"enum": [false]
|
1208
|
+
},
|
1209
|
+
{
|
1210
|
+
"type": "string",
|
1211
|
+
"absolutePath": true
|
1212
|
+
}
|
1213
|
+
]
|
1214
|
+
},
|
1215
|
+
"frozen": {
|
1216
|
+
"description": "When set, anything that would lead to a modification of the lockfile or any resource content, will result in an error.",
|
1217
|
+
"type": "boolean"
|
1218
|
+
},
|
1219
|
+
"lockfileLocation": {
|
1220
|
+
"description": "Location of the lockfile.",
|
1221
|
+
"type": "string",
|
1222
|
+
"absolutePath": true
|
1223
|
+
},
|
1224
|
+
"upgrade": {
|
1225
|
+
"description": "When set, resources of existing lockfile entries will be fetched and entries will be upgraded when resource content has changed.",
|
1226
|
+
"type": "boolean"
|
1227
|
+
}
|
1228
|
+
}
|
1229
|
+
},
|
1187
1230
|
"IgnoreWarnings": {
|
1188
1231
|
"description": "Ignore specific warnings.",
|
1189
1232
|
"type": "array",
|
@@ -3585,6 +3628,13 @@
|
|
3585
3628
|
"type": "object",
|
3586
3629
|
"additionalProperties": false,
|
3587
3630
|
"properties": {
|
3631
|
+
"assert": {
|
3632
|
+
"description": "Match on import assertions of the dependency.",
|
3633
|
+
"type": "object",
|
3634
|
+
"additionalProperties": {
|
3635
|
+
"$ref": "#/definitions/RuleSetConditionOrConditions"
|
3636
|
+
}
|
3637
|
+
},
|
3588
3638
|
"compiler": {
|
3589
3639
|
"description": "Match the child compiler name.",
|
3590
3640
|
"oneOf": [
|
@@ -0,0 +1,6 @@
|
|
1
|
+
/*
|
2
|
+
* This file was automatically generated.
|
3
|
+
* DO NOT MODIFY BY HAND.
|
4
|
+
* Run `yarn special-lint-fix` to update
|
5
|
+
*/
|
6
|
+
const o=/^(?:[A-Za-z]:[\\/]|\\\\|\/)/;function t(e,{instancePath:n="",parentData:s,parentDataProperty:l,rootData:a=e}={}){let i=null,r=0;const c=r;let p=!1,u=null;const f=r;if(r==r)if(e&&"object"==typeof e&&!Array.isArray(e)){const t=r;for(const o in e)if("cacheLocation"!==o&&"frozen"!==o&&"lockfileLocation"!==o&&"upgrade"!==o){const t={params:{additionalProperty:o}};null===i?i=[t]:i.push(t),r++;break}if(t===r){if(void 0!==e.cacheLocation){let t=e.cacheLocation;const n=r,s=r;let l=!1;const a=r;if(!1!==t){const o={params:{}};null===i?i=[o]:i.push(o),r++}var h=a===r;if(l=l||h,!l){const e=r;if(r===e)if("string"==typeof t){if(t.includes("!")||!0!==o.test(t)){const o={params:{}};null===i?i=[o]:i.push(o),r++}}else{const o={params:{type:"string"}};null===i?i=[o]:i.push(o),r++}h=e===r,l=l||h}if(l)r=s,null!==i&&(s?i.length=s:i=null);else{const o={params:{}};null===i?i=[o]:i.push(o),r++}var d=n===r}else d=!0;if(d){if(void 0!==e.frozen){const o=r;if("boolean"!=typeof e.frozen){const o={params:{type:"boolean"}};null===i?i=[o]:i.push(o),r++}d=o===r}else d=!0;if(d){if(void 0!==e.lockfileLocation){let t=e.lockfileLocation;const n=r;if(r===n)if("string"==typeof t){if(t.includes("!")||!0!==o.test(t)){const o={params:{}};null===i?i=[o]:i.push(o),r++}}else{const o={params:{type:"string"}};null===i?i=[o]:i.push(o),r++}d=n===r}else d=!0;if(d)if(void 0!==e.upgrade){const o=r;if("boolean"!=typeof e.upgrade){const o={params:{type:"boolean"}};null===i?i=[o]:i.push(o),r++}d=o===r}else d=!0}}}}else{const o={params:{type:"object"}};null===i?i=[o]:i.push(o),r++}if(f===r&&(p=!0,u=0),!p){const o={params:{passingSchemas:u}};return null===i?i=[o]:i.push(o),r++,t.errors=i,!1}return r=c,null!==i&&(c?i.length=c:i=null),t.errors=i,0===r}module.exports=t,module.exports.default=t;
|
@@ -0,0 +1,42 @@
|
|
1
|
+
{
|
2
|
+
"definitions": {
|
3
|
+
"HttpUriOptions": {
|
4
|
+
"description": "Options for building http resources.",
|
5
|
+
"type": "object",
|
6
|
+
"additionalProperties": false,
|
7
|
+
"properties": {
|
8
|
+
"cacheLocation": {
|
9
|
+
"description": "Location where resource content is stored for lockfile entries. It's also possible to disable storing by passing false.",
|
10
|
+
"anyOf": [
|
11
|
+
{
|
12
|
+
"enum": [false]
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"type": "string",
|
16
|
+
"absolutePath": true
|
17
|
+
}
|
18
|
+
]
|
19
|
+
},
|
20
|
+
"frozen": {
|
21
|
+
"description": "When set, anything that would lead to a modification of the lockfile or any resource content, will result in an error.",
|
22
|
+
"type": "boolean"
|
23
|
+
},
|
24
|
+
"lockfileLocation": {
|
25
|
+
"description": "Location of the lockfile.",
|
26
|
+
"type": "string",
|
27
|
+
"absolutePath": true
|
28
|
+
},
|
29
|
+
"upgrade": {
|
30
|
+
"description": "When set, resources of existing lockfile entries will be fetched and entries will be upgraded when resource content has changed.",
|
31
|
+
"type": "boolean"
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
},
|
36
|
+
"title": "HttpUriPluginOptions",
|
37
|
+
"oneOf": [
|
38
|
+
{
|
39
|
+
"$ref": "#/definitions/HttpUriOptions"
|
40
|
+
}
|
41
|
+
]
|
42
|
+
}
|
package/types.d.ts
CHANGED
@@ -3249,6 +3249,11 @@ declare interface Experiments {
|
|
3249
3249
|
*/
|
3250
3250
|
asyncWebAssembly?: boolean;
|
3251
3251
|
|
3252
|
+
/**
|
3253
|
+
* Build http(s): urls using a lockfile and resource content cache.
|
3254
|
+
*/
|
3255
|
+
buildHttp?: boolean | HttpUriOptions;
|
3256
|
+
|
3252
3257
|
/**
|
3253
3258
|
* Enable build-time execution of modules from the module graph for plugins and loaders.
|
3254
3259
|
*/
|
@@ -4285,16 +4290,53 @@ declare interface HotModuleReplacementPluginLoaderContext {
|
|
4285
4290
|
declare class HotUpdateChunk extends Chunk {
|
4286
4291
|
constructor();
|
4287
4292
|
}
|
4288
|
-
|
4289
|
-
|
4293
|
+
|
4294
|
+
/**
|
4295
|
+
* Options for building http resources.
|
4296
|
+
*/
|
4297
|
+
declare interface HttpUriOptions {
|
4298
|
+
/**
|
4299
|
+
* Location where resource content is stored for lockfile entries. It's also possible to disable storing by passing false.
|
4300
|
+
*/
|
4301
|
+
cacheLocation?: string | false;
|
4290
4302
|
|
4291
4303
|
/**
|
4292
|
-
*
|
4304
|
+
* When set, anything that would lead to a modification of the lockfile or any resource content, will result in an error.
|
4293
4305
|
*/
|
4294
|
-
|
4306
|
+
frozen?: boolean;
|
4307
|
+
|
4308
|
+
/**
|
4309
|
+
* Location of the lockfile.
|
4310
|
+
*/
|
4311
|
+
lockfileLocation?: string;
|
4312
|
+
|
4313
|
+
/**
|
4314
|
+
* When set, resources of existing lockfile entries will be fetched and entries will be upgraded when resource content has changed.
|
4315
|
+
*/
|
4316
|
+
upgrade?: boolean;
|
4295
4317
|
}
|
4296
|
-
declare class
|
4297
|
-
constructor(
|
4318
|
+
declare class HttpUriPlugin {
|
4319
|
+
constructor(options?: {
|
4320
|
+
/**
|
4321
|
+
* Location where resource content is stored for lockfile entries. It's also possible to disable storing by passing false.
|
4322
|
+
*/
|
4323
|
+
cacheLocation?: string | false;
|
4324
|
+
/**
|
4325
|
+
* When set, anything that would lead to a modification of the lockfile or any resource content, will result in an error.
|
4326
|
+
*/
|
4327
|
+
frozen?: boolean;
|
4328
|
+
/**
|
4329
|
+
* Location of the lockfile.
|
4330
|
+
*/
|
4331
|
+
lockfileLocation?: string;
|
4332
|
+
/**
|
4333
|
+
* When set, resources of existing lockfile entries will be fetched and entries will be upgraded when resource content has changed.
|
4334
|
+
*/
|
4335
|
+
upgrade?: boolean;
|
4336
|
+
hashFunction?: string | typeof Hash;
|
4337
|
+
hashDigest?: string;
|
4338
|
+
hashDigestLength?: number;
|
4339
|
+
});
|
4298
4340
|
|
4299
4341
|
/**
|
4300
4342
|
* Apply the plugin
|
@@ -4742,21 +4784,44 @@ declare class JavascriptParser extends Parser {
|
|
4742
4784
|
boolean | void
|
4743
4785
|
>;
|
4744
4786
|
label: HookMap<SyncBailHook<[LabeledStatement], boolean | void>>;
|
4745
|
-
import: SyncBailHook<[
|
4787
|
+
import: SyncBailHook<[ImportDeclaration, ImportSource], boolean | void>;
|
4746
4788
|
importSpecifier: SyncBailHook<
|
4747
|
-
[
|
4789
|
+
[ImportDeclaration, ImportSource, string, string],
|
4790
|
+
boolean | void
|
4791
|
+
>;
|
4792
|
+
export: SyncBailHook<
|
4793
|
+
[ExportNamedDeclaration | ExportAllDeclaration],
|
4794
|
+
boolean | void
|
4795
|
+
>;
|
4796
|
+
exportImport: SyncBailHook<
|
4797
|
+
[ExportNamedDeclaration | ExportAllDeclaration, ImportSource],
|
4798
|
+
boolean | void
|
4799
|
+
>;
|
4800
|
+
exportDeclaration: SyncBailHook<
|
4801
|
+
[ExportNamedDeclaration | ExportAllDeclaration, Declaration],
|
4802
|
+
boolean | void
|
4803
|
+
>;
|
4804
|
+
exportExpression: SyncBailHook<
|
4805
|
+
[ExportDefaultDeclaration, Declaration],
|
4748
4806
|
boolean | void
|
4749
4807
|
>;
|
4750
|
-
export: SyncBailHook<[Statement], boolean | void>;
|
4751
|
-
exportImport: SyncBailHook<[Statement, ImportSource], boolean | void>;
|
4752
|
-
exportDeclaration: SyncBailHook<[Statement, Declaration], boolean | void>;
|
4753
|
-
exportExpression: SyncBailHook<[Statement, Declaration], boolean | void>;
|
4754
4808
|
exportSpecifier: SyncBailHook<
|
4755
|
-
[
|
4809
|
+
[
|
4810
|
+
ExportNamedDeclaration | ExportAllDeclaration,
|
4811
|
+
string,
|
4812
|
+
string,
|
4813
|
+
undefined | number
|
4814
|
+
],
|
4756
4815
|
boolean | void
|
4757
4816
|
>;
|
4758
4817
|
exportImportSpecifier: SyncBailHook<
|
4759
|
-
[
|
4818
|
+
[
|
4819
|
+
ExportNamedDeclaration | ExportAllDeclaration,
|
4820
|
+
ImportSource,
|
4821
|
+
string,
|
4822
|
+
string,
|
4823
|
+
undefined | number
|
4824
|
+
],
|
4760
4825
|
boolean | void
|
4761
4826
|
>;
|
4762
4827
|
preDeclarator: SyncBailHook<
|
@@ -6386,6 +6451,7 @@ declare class ModuleDependency extends Dependency {
|
|
6386
6451
|
request: string;
|
6387
6452
|
userRequest: string;
|
6388
6453
|
range: any;
|
6454
|
+
assertions?: Record<string, any>;
|
6389
6455
|
static Template: typeof DependencyTemplate;
|
6390
6456
|
static NO_EXPORTS_REFERENCED: string[][];
|
6391
6457
|
static EXPORTS_OBJECT_REFERENCED: string[][];
|
@@ -6937,6 +7003,7 @@ declare class NaturalModuleIdsPlugin {
|
|
6937
7003
|
apply(compiler: Compiler): void;
|
6938
7004
|
}
|
6939
7005
|
declare interface NeedBuildContext {
|
7006
|
+
compilation: Compilation;
|
6940
7007
|
fileSystemInfo: FileSystemInfo;
|
6941
7008
|
valueCacheVersions: Map<string, string | Set<string>>;
|
6942
7009
|
}
|
@@ -7120,6 +7187,10 @@ declare class NormalModule extends Module {
|
|
7120
7187
|
* resource resolve data
|
7121
7188
|
*/
|
7122
7189
|
resourceResolveData?: Record<string, any>;
|
7190
|
+
/**
|
7191
|
+
* context directory for resolving
|
7192
|
+
*/
|
7193
|
+
context: string;
|
7123
7194
|
/**
|
7124
7195
|
* path + query of the matched resource (virtual)
|
7125
7196
|
*/
|
@@ -7203,6 +7274,7 @@ declare interface NormalModuleCompilationHooks {
|
|
7203
7274
|
readResourceForScheme: HookMap<
|
7204
7275
|
AsyncSeriesBailHook<[string, NormalModule], string | Buffer>
|
7205
7276
|
>;
|
7277
|
+
needBuild: AsyncSeriesBailHook<[NormalModule, NeedBuildContext], boolean>;
|
7206
7278
|
}
|
7207
7279
|
declare abstract class NormalModuleFactory extends ModuleFactory {
|
7208
7280
|
hooks: Readonly<{
|
@@ -7210,6 +7282,9 @@ declare abstract class NormalModuleFactory extends ModuleFactory {
|
|
7210
7282
|
resolveForScheme: HookMap<
|
7211
7283
|
AsyncSeriesBailHook<[ResourceDataWithData, ResolveData], true | void>
|
7212
7284
|
>;
|
7285
|
+
resolveInScheme: HookMap<
|
7286
|
+
AsyncSeriesBailHook<[ResourceDataWithData, ResolveData], true | void>
|
7287
|
+
>;
|
7213
7288
|
factorize: AsyncSeriesBailHook<[ResolveData], any>;
|
7214
7289
|
beforeResolve: AsyncSeriesBailHook<[ResolveData], any>;
|
7215
7290
|
afterResolve: AsyncSeriesBailHook<[ResolveData], any>;
|
@@ -8395,6 +8470,7 @@ declare interface ParserOptionsByModuleTypeUnknown {
|
|
8395
8470
|
}
|
8396
8471
|
type ParserState = Record<string, any> & ParserStateBase;
|
8397
8472
|
declare interface ParserStateBase {
|
8473
|
+
source: string | Buffer;
|
8398
8474
|
current: NormalModule;
|
8399
8475
|
module: NormalModule;
|
8400
8476
|
compilation: Compilation;
|
@@ -8947,7 +9023,9 @@ declare interface ResolveData {
|
|
8947
9023
|
resolveOptions?: ResolveOptionsWebpackOptions;
|
8948
9024
|
context: string;
|
8949
9025
|
request: string;
|
9026
|
+
assertions?: Record<string, any>;
|
8950
9027
|
dependencies: ModuleDependency[];
|
9028
|
+
dependencyType: string;
|
8951
9029
|
createData: Object;
|
8952
9030
|
fileDependencies: LazySet<string>;
|
8953
9031
|
missingDependencies: LazySet<string>;
|
@@ -9271,6 +9349,7 @@ declare interface ResourceDataWithData {
|
|
9271
9349
|
path: string;
|
9272
9350
|
query: string;
|
9273
9351
|
fragment: string;
|
9352
|
+
context?: string;
|
9274
9353
|
data: Record<string, any>;
|
9275
9354
|
}
|
9276
9355
|
type Rule = string | RegExp;
|
@@ -9358,6 +9437,11 @@ declare interface RuleSetLogicalConditionsAbsolute {
|
|
9358
9437
|
* A rule description with conditions and effects for modules.
|
9359
9438
|
*/
|
9360
9439
|
declare interface RuleSetRule {
|
9440
|
+
/**
|
9441
|
+
* Match on import assertions of the dependency.
|
9442
|
+
*/
|
9443
|
+
assert?: { [index: string]: RuleSetConditionOrConditions };
|
9444
|
+
|
9361
9445
|
/**
|
9362
9446
|
* Match the child compiler name.
|
9363
9447
|
*/
|
@@ -12164,7 +12248,7 @@ declare namespace exports {
|
|
12164
12248
|
}
|
12165
12249
|
export namespace experiments {
|
12166
12250
|
export namespace schemes {
|
12167
|
-
export { HttpUriPlugin
|
12251
|
+
export { HttpUriPlugin };
|
12168
12252
|
}
|
12169
12253
|
}
|
12170
12254
|
export type WebpackPluginFunction = (
|
@@ -1,63 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
|
6
|
-
"use strict";
|
7
|
-
|
8
|
-
const { URL } = require("url");
|
9
|
-
const NormalModule = require("../NormalModule");
|
10
|
-
|
11
|
-
/** @typedef {import("../Compiler")} Compiler */
|
12
|
-
|
13
|
-
class HttpsUriPlugin {
|
14
|
-
/**
|
15
|
-
* Apply the plugin
|
16
|
-
* @param {Compiler} compiler the compiler instance
|
17
|
-
* @returns {void}
|
18
|
-
*/
|
19
|
-
apply(compiler) {
|
20
|
-
compiler.hooks.compilation.tap(
|
21
|
-
"HttpsUriPlugin",
|
22
|
-
(compilation, { normalModuleFactory }) => {
|
23
|
-
normalModuleFactory.hooks.resolveForScheme
|
24
|
-
.for("https")
|
25
|
-
.tap("HttpsUriPlugin", resourceData => {
|
26
|
-
const url = new URL(resourceData.resource);
|
27
|
-
resourceData.path = url.origin + url.pathname;
|
28
|
-
resourceData.query = url.search;
|
29
|
-
resourceData.fragment = url.hash;
|
30
|
-
return /** @type {true} */ (true);
|
31
|
-
});
|
32
|
-
NormalModule.getCompilationHooks(compilation)
|
33
|
-
.readResourceForScheme.for("https")
|
34
|
-
.tapAsync("HttpsUriPlugin", (resource, module, callback) => {
|
35
|
-
return require("https").get(new URL(resource), res => {
|
36
|
-
if (res.statusCode !== 200) {
|
37
|
-
res.destroy();
|
38
|
-
return callback(
|
39
|
-
new Error(`https request status code = ${res.statusCode}`)
|
40
|
-
);
|
41
|
-
}
|
42
|
-
|
43
|
-
const bufferArr = [];
|
44
|
-
|
45
|
-
res.on("data", chunk => {
|
46
|
-
bufferArr.push(chunk);
|
47
|
-
});
|
48
|
-
|
49
|
-
res.on("end", () => {
|
50
|
-
if (!res.complete) {
|
51
|
-
return callback(new Error("https request was terminated"));
|
52
|
-
}
|
53
|
-
|
54
|
-
callback(null, Buffer.concat(bufferArr));
|
55
|
-
});
|
56
|
-
});
|
57
|
-
});
|
58
|
-
}
|
59
|
-
);
|
60
|
-
}
|
61
|
-
}
|
62
|
-
|
63
|
-
module.exports = HttpsUriPlugin;
|