webpack 5.102.0 → 5.103.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 +121 -134
- package/lib/ChunkGraph.js +2 -2
- package/lib/CodeGenerationResults.js +1 -1
- package/lib/CompatibilityPlugin.js +25 -2
- package/lib/Compilation.js +30 -13
- package/lib/ConcatenationScope.js +0 -15
- package/lib/ContextModule.js +3 -1
- package/lib/CssModule.js +6 -1
- package/lib/DefinePlugin.js +12 -12
- package/lib/Dependency.js +8 -1
- package/lib/DependencyTemplate.js +1 -0
- package/lib/DependencyTemplates.js +1 -1
- package/lib/DotenvPlugin.js +457 -0
- package/lib/EnvironmentPlugin.js +19 -16
- package/lib/EvalSourceMapDevToolPlugin.js +16 -0
- package/lib/ExportsInfo.js +6 -2
- package/lib/ExternalModule.js +20 -28
- package/lib/ExternalModuleFactoryPlugin.js +10 -8
- package/lib/ExternalsPlugin.js +2 -1
- package/lib/FileSystemInfo.js +9 -12
- package/lib/ManifestPlugin.js +235 -0
- package/lib/Module.js +3 -0
- package/lib/ModuleFilenameHelpers.js +1 -1
- package/lib/ModuleGraph.js +2 -1
- package/lib/ModuleSourceTypesConstants.js +0 -6
- package/lib/MultiCompiler.js +1 -1
- package/lib/NodeStuffPlugin.js +419 -121
- package/lib/NormalModule.js +18 -17
- package/lib/NormalModuleFactory.js +75 -4
- package/lib/RuntimeGlobals.js +22 -4
- package/lib/RuntimePlugin.js +27 -6
- package/lib/RuntimeTemplate.js +125 -57
- package/lib/SourceMapDevToolPlugin.js +26 -8
- package/lib/WebpackOptionsApply.js +33 -9
- package/lib/asset/AssetBytesGenerator.js +2 -1
- package/lib/asset/AssetGenerator.js +3 -5
- package/lib/asset/AssetSourceGenerator.js +1 -1
- package/lib/cache/getLazyHashedEtag.js +1 -1
- package/lib/config/browserslistTargetHandler.js +82 -76
- package/lib/config/defaults.js +105 -20
- package/lib/config/normalization.js +2 -1
- package/lib/config/target.js +7 -1
- package/lib/css/CssGenerator.js +283 -57
- package/lib/css/CssLoadingRuntimeModule.js +2 -0
- package/lib/css/CssMergeStyleSheetsRuntimeModule.js +56 -0
- package/lib/css/CssModulesPlugin.js +86 -40
- package/lib/css/CssParser.js +1174 -667
- package/lib/css/walkCssTokens.js +98 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +0 -9
- package/lib/dependencies/CommonJsPlugin.js +12 -0
- package/lib/dependencies/ContextElementDependency.js +2 -2
- package/lib/dependencies/CssIcssExportDependency.js +247 -8
- package/lib/dependencies/CssIcssFromIdentifierDependency.js +124 -0
- package/lib/dependencies/CssIcssGlobalIdentifierDependency.js +48 -0
- package/lib/dependencies/CssIcssImportDependency.js +60 -54
- package/lib/dependencies/CssIcssLocalIdentifierDependency.js +61 -0
- package/lib/dependencies/{CssSelfLocalIdentifierDependency.js → CssIcssSelfLocalIdentifierDependency.js} +88 -10
- package/lib/dependencies/CssIcssSymbolDependency.js +31 -29
- package/lib/dependencies/CssImportDependency.js +15 -5
- package/lib/dependencies/ExternalModuleInitFragment.js +1 -1
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +95 -0
- package/lib/dependencies/HarmonyAcceptDependency.js +6 -1
- package/lib/dependencies/HarmonyAcceptImportDependency.js +2 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +12 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +32 -21
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +12 -8
- package/lib/dependencies/HarmonyImportDependency.js +27 -28
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +28 -69
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -3
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +10 -8
- package/lib/dependencies/ImportContextDependency.js +13 -0
- package/lib/dependencies/ImportDependency.js +10 -4
- package/lib/dependencies/ImportEagerDependency.js +6 -3
- package/lib/dependencies/ImportMetaPlugin.js +98 -10
- package/lib/dependencies/ImportParserPlugin.js +19 -21
- package/lib/dependencies/ImportPhase.js +121 -0
- package/lib/dependencies/ImportWeakDependency.js +6 -3
- package/lib/dependencies/ModuleDependency.js +5 -1
- package/lib/dependencies/ModuleHotAcceptDependency.js +1 -1
- package/lib/dependencies/WorkerPlugin.js +1 -3
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +1 -8
- package/lib/hmr/LazyCompilationPlugin.js +1 -0
- package/lib/ids/HashedModuleIdsPlugin.js +5 -7
- package/lib/ids/IdHelpers.js +5 -2
- package/lib/index.js +6 -0
- package/lib/javascript/ChunkHelpers.js +16 -5
- package/lib/javascript/JavascriptGenerator.js +101 -101
- package/lib/javascript/JavascriptModulesPlugin.js +25 -16
- package/lib/javascript/JavascriptParser.js +143 -39
- package/lib/json/JsonParser.js +7 -1
- package/lib/library/ModuleLibraryPlugin.js +0 -10
- package/lib/library/SystemLibraryPlugin.js +19 -5
- package/lib/library/UmdLibraryPlugin.js +1 -1
- package/lib/node/NodeTargetPlugin.js +9 -1
- package/lib/node/ReadFileCompileWasmPlugin.js +0 -2
- package/lib/optimize/ConcatenatedModule.js +161 -135
- package/lib/optimize/RealContentHashPlugin.js +5 -3
- package/lib/runtime/AsyncModuleRuntimeModule.js +28 -18
- package/lib/runtime/AutoPublicPathRuntimeModule.js +8 -3
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +89 -55
- package/lib/serialization/FileMiddleware.js +1 -1
- package/lib/serialization/ObjectMiddleware.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +1 -1
- package/lib/util/Hash.js +35 -5
- package/lib/util/comparators.js +4 -3
- package/lib/util/create-schema-validation.js +1 -1
- package/lib/util/createHash.js +85 -15
- package/lib/util/hash/BatchedHash.js +47 -8
- package/lib/util/hash/wasm-hash.js +53 -13
- package/lib/util/internalSerializables.js +4 -4
- package/lib/util/jsonParseEvenBetterErrors.js +10 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +10 -4
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +8 -5
- package/lib/wasm-async/AsyncWebAssemblyParser.js +0 -9
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +8 -4
- package/lib/wasm-sync/WebAssemblyParser.js +0 -9
- package/lib/web/FetchCompileWasmPlugin.js +0 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
- package/lib/webpack.js +85 -82
- package/module.d.ts +5 -0
- package/package.json +28 -26
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +110 -15
- package/schemas/plugins/{HashedModuleIdsPlugin.check.d.ts → ManifestPlugin.check.d.ts} +1 -1
- package/schemas/plugins/ManifestPlugin.check.js +6 -0
- package/schemas/plugins/ManifestPlugin.json +98 -0
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +16 -3
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +4 -1
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +4 -1
- package/schemas/plugins/css/CssAutoParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssGlobalParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.d.ts +7 -0
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +6 -0
- package/schemas/plugins/{HashedModuleIdsPlugin.json → ids/HashedModuleIdsPlugin.json} +15 -2
- package/schemas/plugins/json/JsonModulesPluginParser.check.js +1 -1
- package/types.d.ts +788 -127
- package/lib/dependencies/CssLocalIdentifierDependency.js +0 -252
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +0 -6
|
@@ -20,6 +20,7 @@ const { makePathsAbsolute } = require("./util/identifier");
|
|
|
20
20
|
/** @typedef {import("webpack-sources").MapOptions} MapOptions */
|
|
21
21
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
22
22
|
/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */
|
|
23
|
+
/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").Rules} Rules */
|
|
23
24
|
/** @typedef {import("./CacheFacade").ItemCacheFacade} ItemCacheFacade */
|
|
24
25
|
/** @typedef {import("./Chunk")} Chunk */
|
|
25
26
|
/** @typedef {import("./Compilation").Asset} Asset */
|
|
@@ -433,6 +434,25 @@ class SourceMapDevToolPlugin {
|
|
|
433
434
|
moduleToSourceNameMapping.get(m)
|
|
434
435
|
);
|
|
435
436
|
sourceMap.sources = /** @type {string[]} */ (moduleFilenames);
|
|
437
|
+
sourceMap.ignoreList = options.ignoreList
|
|
438
|
+
? sourceMap.sources.reduce(
|
|
439
|
+
/** @type {(acc: number[], sourceName: string, idx: number) => number[]} */ (
|
|
440
|
+
(acc, sourceName, idx) => {
|
|
441
|
+
const rule = /** @type {Rules} */ (
|
|
442
|
+
options.ignoreList
|
|
443
|
+
);
|
|
444
|
+
if (
|
|
445
|
+
ModuleFilenameHelpers.matchPart(sourceName, rule)
|
|
446
|
+
) {
|
|
447
|
+
acc.push(idx);
|
|
448
|
+
}
|
|
449
|
+
return acc;
|
|
450
|
+
}
|
|
451
|
+
),
|
|
452
|
+
[]
|
|
453
|
+
)
|
|
454
|
+
: [];
|
|
455
|
+
|
|
436
456
|
if (options.noSources) {
|
|
437
457
|
sourceMap.sourcesContent = undefined;
|
|
438
458
|
}
|
|
@@ -482,14 +502,12 @@ class SourceMapDevToolPlugin {
|
|
|
482
502
|
const sourceMapString = JSON.stringify(sourceMap);
|
|
483
503
|
if (sourceMapFilename) {
|
|
484
504
|
const filename = file;
|
|
485
|
-
const sourceMapContentHash =
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
.digest("hex")
|
|
492
|
-
);
|
|
505
|
+
const sourceMapContentHash = usesContentHash
|
|
506
|
+
? createHash(compilation.outputOptions.hashFunction)
|
|
507
|
+
.update(sourceMapString)
|
|
508
|
+
.digest("hex")
|
|
509
|
+
: undefined;
|
|
510
|
+
|
|
493
511
|
const pathParams = {
|
|
494
512
|
chunk,
|
|
495
513
|
filename: options.fileContext
|
|
@@ -18,6 +18,7 @@ const FlagDependencyExportsPlugin = require("./FlagDependencyExportsPlugin");
|
|
|
18
18
|
|
|
19
19
|
const JavascriptMetaInfoPlugin = require("./JavascriptMetaInfoPlugin");
|
|
20
20
|
|
|
21
|
+
const NodeStuffPlugin = require("./NodeStuffPlugin");
|
|
21
22
|
const OptionsApply = require("./OptionsApply");
|
|
22
23
|
|
|
23
24
|
const RecordIdsPlugin = require("./RecordIdsPlugin");
|
|
@@ -109,7 +110,15 @@ class WebpackOptionsApply extends OptionsApply {
|
|
|
109
110
|
if (options.externalsPresets.node) {
|
|
110
111
|
const NodeTargetPlugin = require("./node/NodeTargetPlugin");
|
|
111
112
|
|
|
112
|
-
|
|
113
|
+
// Some older versions of Node.js don't support all built-in modules via import, only via `require`,
|
|
114
|
+
// but шt seems like there shouldn't be a warning here since these versions are rarely used in real applications
|
|
115
|
+
new NodeTargetPlugin(
|
|
116
|
+
options.output.module &&
|
|
117
|
+
compiler.platform.node === null &&
|
|
118
|
+
compiler.platform.web === null
|
|
119
|
+
? "module-import"
|
|
120
|
+
: "node-commonjs"
|
|
121
|
+
).apply(compiler);
|
|
113
122
|
|
|
114
123
|
// Handle external CSS `@import` and `url()`
|
|
115
124
|
if (options.experiments.css) {
|
|
@@ -126,7 +135,9 @@ class WebpackOptionsApply extends OptionsApply {
|
|
|
126
135
|
if (dependencyType === "url") {
|
|
127
136
|
return callback(null, `asset ${request}`);
|
|
128
137
|
} else if (
|
|
129
|
-
dependencyType === "css-import"
|
|
138
|
+
(dependencyType === "css-import" ||
|
|
139
|
+
dependencyType === "css-import-local-module" ||
|
|
140
|
+
dependencyType === "css-import-global-module") &&
|
|
130
141
|
options.experiments.css
|
|
131
142
|
) {
|
|
132
143
|
return callback(null, `css-import ${request}`);
|
|
@@ -149,7 +160,9 @@ class WebpackOptionsApply extends OptionsApply {
|
|
|
149
160
|
if (dependencyType === "url") {
|
|
150
161
|
return callback(null, `asset ${request}`);
|
|
151
162
|
} else if (
|
|
152
|
-
dependencyType === "css-import"
|
|
163
|
+
(dependencyType === "css-import" ||
|
|
164
|
+
dependencyType === "css-import-local-module" ||
|
|
165
|
+
dependencyType === "css-import-global-module") &&
|
|
153
166
|
options.experiments.css
|
|
154
167
|
) {
|
|
155
168
|
return callback(null, `css-import ${request}`);
|
|
@@ -294,6 +307,14 @@ class WebpackOptionsApply extends OptionsApply {
|
|
|
294
307
|
).apply(compiler);
|
|
295
308
|
}
|
|
296
309
|
|
|
310
|
+
if (options.dotenv) {
|
|
311
|
+
const DotenvPlugin = require("./DotenvPlugin");
|
|
312
|
+
|
|
313
|
+
new DotenvPlugin(
|
|
314
|
+
typeof options.dotenv === "boolean" ? {} : options.dotenv
|
|
315
|
+
).apply(compiler);
|
|
316
|
+
}
|
|
317
|
+
|
|
297
318
|
if (options.devtool) {
|
|
298
319
|
if (options.devtool.includes("source-map")) {
|
|
299
320
|
const hidden = options.devtool.includes("hidden");
|
|
@@ -444,11 +465,11 @@ class WebpackOptionsApply extends OptionsApply {
|
|
|
444
465
|
}
|
|
445
466
|
new CommonJsPlugin().apply(compiler);
|
|
446
467
|
new LoaderPlugin().apply(compiler);
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
}
|
|
468
|
+
new NodeStuffPlugin({
|
|
469
|
+
global: options.node ? options.node.global : false,
|
|
470
|
+
__dirname: options.node ? options.node.__dirname : false,
|
|
471
|
+
__filename: options.node ? options.node.__filename : false
|
|
472
|
+
}).apply(compiler);
|
|
452
473
|
new APIPlugin().apply(compiler);
|
|
453
474
|
new ExportsInfoApiPlugin().apply(compiler);
|
|
454
475
|
new WebpackIsIncludedPlugin().apply(compiler);
|
|
@@ -667,8 +688,11 @@ class WebpackOptionsApply extends OptionsApply {
|
|
|
667
688
|
if (options.optimization.nodeEnv) {
|
|
668
689
|
const DefinePlugin = require("./DefinePlugin");
|
|
669
690
|
|
|
691
|
+
const defValue = JSON.stringify(options.optimization.nodeEnv);
|
|
692
|
+
|
|
670
693
|
new DefinePlugin({
|
|
671
|
-
"process.env.NODE_ENV":
|
|
694
|
+
"process.env.NODE_ENV": defValue,
|
|
695
|
+
"import.meta.env.NODE_ENV": defValue
|
|
672
696
|
}).apply(compiler);
|
|
673
697
|
}
|
|
674
698
|
if (options.optimization.minimize) {
|
|
@@ -53,6 +53,7 @@ class AssetSourceGenerator extends Generator {
|
|
|
53
53
|
|
|
54
54
|
const encodedSource = originalSource.buffer().toString("base64");
|
|
55
55
|
|
|
56
|
+
runtimeRequirements.add(RuntimeGlobals.requireScope);
|
|
56
57
|
runtimeRequirements.add(RuntimeGlobals.toBinary);
|
|
57
58
|
|
|
58
59
|
let sourceContent;
|
|
@@ -65,7 +66,7 @@ class AssetSourceGenerator extends Generator {
|
|
|
65
66
|
} = ${RuntimeGlobals.toBinary}(${JSON.stringify(encodedSource)});`;
|
|
66
67
|
} else {
|
|
67
68
|
runtimeRequirements.add(RuntimeGlobals.module);
|
|
68
|
-
sourceContent = `${
|
|
69
|
+
sourceContent = `${module.moduleArgument}.exports = ${RuntimeGlobals.toBinary}(${JSON.stringify(
|
|
69
70
|
encodedSource
|
|
70
71
|
)});`;
|
|
71
72
|
}
|
|
@@ -244,11 +244,10 @@ class AssetGenerator extends Generator {
|
|
|
244
244
|
hash.update(module.error.toString());
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
const fullContentHash =
|
|
248
|
-
|
|
247
|
+
const fullContentHash = hash.digest(
|
|
248
|
+
runtimeTemplate.outputOptions.hashDigest
|
|
249
249
|
);
|
|
250
250
|
|
|
251
|
-
/** @type {string} */
|
|
252
251
|
const contentHash = nonNumericOnlyHash(
|
|
253
252
|
fullContentHash,
|
|
254
253
|
runtimeTemplate.outputOptions.hashDigestLength
|
|
@@ -381,7 +380,6 @@ class AssetGenerator extends Generator {
|
|
|
381
380
|
}
|
|
382
381
|
|
|
383
382
|
return {
|
|
384
|
-
// eslint-disable-next-line object-shorthand
|
|
385
383
|
assetPath: /** @type {string} */ (assetPath),
|
|
386
384
|
assetInfo: { sourceFilename, ...assetInfo }
|
|
387
385
|
};
|
|
@@ -615,7 +613,7 @@ class AssetGenerator extends Generator {
|
|
|
615
613
|
|
|
616
614
|
runtimeRequirements.add(RuntimeGlobals.module);
|
|
617
615
|
|
|
618
|
-
return new RawSource(`${
|
|
616
|
+
return new RawSource(`${module.moduleArgument}.exports = ${content};`);
|
|
619
617
|
} else if (type === "css-url") {
|
|
620
618
|
return null;
|
|
621
619
|
}
|
|
@@ -65,7 +65,7 @@ class AssetSourceGenerator extends Generator {
|
|
|
65
65
|
} = ${JSON.stringify(encodedSource)};`;
|
|
66
66
|
} else {
|
|
67
67
|
runtimeRequirements.add(RuntimeGlobals.module);
|
|
68
|
-
sourceContent = `${
|
|
68
|
+
sourceContent = `${module.moduleArgument}.exports = ${JSON.stringify(
|
|
69
69
|
encodedSource
|
|
70
70
|
)};`;
|
|
71
71
|
}
|
|
@@ -34,7 +34,7 @@ class LazyHashedEtag {
|
|
|
34
34
|
if (this._hash === undefined) {
|
|
35
35
|
const hash = createHash(this._hashFunction);
|
|
36
36
|
this._obj.updateHash(hash);
|
|
37
|
-
this._hash =
|
|
37
|
+
this._hash = hash.digest("base64");
|
|
38
38
|
}
|
|
39
39
|
return this._hash;
|
|
40
40
|
}
|
|
@@ -15,59 +15,46 @@ const browserslist = require("browserslist");
|
|
|
15
15
|
// [[C:]/path/to/config][:env]
|
|
16
16
|
const inputRx = /^(?:((?:[A-Z]:)?[/\\].*?))?(?::(.+?))?$/i;
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* @typedef {object} BrowserslistHandlerConfig
|
|
20
|
-
* @property {string=} configPath
|
|
21
|
-
* @property {string=} env
|
|
22
|
-
* @property {string=} query
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
18
|
/**
|
|
26
19
|
* @param {string | null | undefined} input input string
|
|
27
20
|
* @param {string} context the context directory
|
|
28
|
-
* @returns {
|
|
21
|
+
* @returns {string[] | undefined} selected browsers
|
|
29
22
|
*/
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (path.isAbsolute(input)) {
|
|
23
|
+
const load = (input, context) => {
|
|
24
|
+
// browserslist:path-to-config
|
|
25
|
+
// browserslist:path-to-config:env
|
|
26
|
+
if (input && path.isAbsolute(input)) {
|
|
36
27
|
const [, configPath, env] = inputRx.exec(input) || [];
|
|
37
|
-
return { configPath, env };
|
|
38
|
-
}
|
|
39
28
|
|
|
40
|
-
|
|
29
|
+
const config = browserslist.loadConfig({
|
|
30
|
+
config: configPath,
|
|
31
|
+
env
|
|
32
|
+
});
|
|
41
33
|
|
|
42
|
-
|
|
43
|
-
return { env: input };
|
|
34
|
+
return browserslist(config, { env });
|
|
44
35
|
}
|
|
45
36
|
|
|
46
|
-
|
|
47
|
-
};
|
|
37
|
+
const env = input || undefined;
|
|
48
38
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
*/
|
|
54
|
-
const load = (input, context) => {
|
|
55
|
-
const { configPath, env, query } = parse(input, context);
|
|
39
|
+
const config = browserslist.loadConfig({
|
|
40
|
+
path: context,
|
|
41
|
+
env
|
|
42
|
+
});
|
|
56
43
|
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
})
|
|
67
|
-
: browserslist.loadConfig({ path: context, env }));
|
|
44
|
+
// browserslist
|
|
45
|
+
// browserslist:env
|
|
46
|
+
if (config) {
|
|
47
|
+
try {
|
|
48
|
+
return browserslist(config, { env, throwOnMissing: true });
|
|
49
|
+
} catch (_err) {
|
|
50
|
+
// Nothing, no `env` was found in browserslist, maybe input is `queries`
|
|
51
|
+
}
|
|
52
|
+
}
|
|
68
53
|
|
|
69
|
-
|
|
70
|
-
|
|
54
|
+
// browserslist:query
|
|
55
|
+
if (env) {
|
|
56
|
+
return browserslist(env);
|
|
57
|
+
}
|
|
71
58
|
};
|
|
72
59
|
|
|
73
60
|
/**
|
|
@@ -104,28 +91,6 @@ const resolve = (browsers) => {
|
|
|
104
91
|
const anyBrowser = browsers.some((b) => /^(?!node)/.test(b));
|
|
105
92
|
const browserProperty = !anyBrowser ? false : anyNode ? null : true;
|
|
106
93
|
const nodeProperty = !anyNode ? false : anyBrowser ? null : true;
|
|
107
|
-
// Internet Explorer Mobile, Blackberry browser and Opera Mini are very old browsers, they do not support new features
|
|
108
|
-
const es6DynamicImport = rawChecker({
|
|
109
|
-
/* eslint-disable camelcase */
|
|
110
|
-
chrome: 63,
|
|
111
|
-
and_chr: 63,
|
|
112
|
-
edge: 79,
|
|
113
|
-
firefox: 67,
|
|
114
|
-
and_ff: 67,
|
|
115
|
-
// ie: Not supported
|
|
116
|
-
opera: 50,
|
|
117
|
-
op_mob: 46,
|
|
118
|
-
safari: [11, 1],
|
|
119
|
-
ios_saf: [11, 3],
|
|
120
|
-
samsung: [8, 2],
|
|
121
|
-
android: 63,
|
|
122
|
-
and_qq: [10, 4],
|
|
123
|
-
baidu: [13, 18],
|
|
124
|
-
and_uc: [15, 5],
|
|
125
|
-
kaios: [3, 0],
|
|
126
|
-
node: [12, 17]
|
|
127
|
-
/* eslint-enable camelcase */
|
|
128
|
-
});
|
|
129
94
|
|
|
130
95
|
return {
|
|
131
96
|
/* eslint-disable camelcase */
|
|
@@ -188,9 +153,9 @@ const resolve = (browsers) => {
|
|
|
188
153
|
ios_saf: 7,
|
|
189
154
|
samsung: [3, 0],
|
|
190
155
|
android: 38,
|
|
191
|
-
|
|
156
|
+
and_qq: [10, 4],
|
|
192
157
|
// baidu: Unknown support
|
|
193
|
-
|
|
158
|
+
and_uc: [12, 12],
|
|
194
159
|
kaios: [3, 0],
|
|
195
160
|
node: [0, 12]
|
|
196
161
|
}),
|
|
@@ -207,9 +172,9 @@ const resolve = (browsers) => {
|
|
|
207
172
|
ios_saf: 8,
|
|
208
173
|
samsung: [5, 0],
|
|
209
174
|
android: 49,
|
|
210
|
-
|
|
175
|
+
and_qq: [10, 4],
|
|
211
176
|
// baidu: Unknown support
|
|
212
|
-
|
|
177
|
+
and_uc: [12, 12],
|
|
213
178
|
kaios: [2, 5],
|
|
214
179
|
node: [6, 0]
|
|
215
180
|
}),
|
|
@@ -253,8 +218,44 @@ const resolve = (browsers) => {
|
|
|
253
218
|
kaios: [3, 0],
|
|
254
219
|
node: [12, 17]
|
|
255
220
|
}),
|
|
256
|
-
dynamicImport:
|
|
257
|
-
|
|
221
|
+
dynamicImport: rawChecker({
|
|
222
|
+
chrome: 63,
|
|
223
|
+
and_chr: 63,
|
|
224
|
+
edge: 79,
|
|
225
|
+
firefox: 67,
|
|
226
|
+
and_ff: 67,
|
|
227
|
+
// ie: Not supported
|
|
228
|
+
opera: 50,
|
|
229
|
+
op_mob: 46,
|
|
230
|
+
safari: [11, 1],
|
|
231
|
+
ios_saf: [11, 3],
|
|
232
|
+
samsung: [8, 2],
|
|
233
|
+
android: 63,
|
|
234
|
+
and_qq: [10, 4],
|
|
235
|
+
baidu: [13, 18],
|
|
236
|
+
and_uc: [15, 5],
|
|
237
|
+
kaios: [3, 0],
|
|
238
|
+
node: [12, 17]
|
|
239
|
+
}),
|
|
240
|
+
dynamicImportInWorker: rawChecker({
|
|
241
|
+
chrome: 80,
|
|
242
|
+
and_chr: 80,
|
|
243
|
+
edge: 80,
|
|
244
|
+
firefox: 114,
|
|
245
|
+
and_ff: 114,
|
|
246
|
+
// ie: Not supported
|
|
247
|
+
opera: 67,
|
|
248
|
+
op_mob: 57,
|
|
249
|
+
safari: [15, 0],
|
|
250
|
+
ios_saf: [15, 0],
|
|
251
|
+
samsung: [13, 0],
|
|
252
|
+
android: 80,
|
|
253
|
+
and_qq: [10, 4],
|
|
254
|
+
baidu: [13, 18],
|
|
255
|
+
and_uc: [15, 5],
|
|
256
|
+
kaios: [3, 0],
|
|
257
|
+
node: [12, 17]
|
|
258
|
+
}),
|
|
258
259
|
// browserslist does not have info about globalThis
|
|
259
260
|
// so this is based on mdn-browser-compat-data
|
|
260
261
|
globalThis: rawChecker({
|
|
@@ -270,9 +271,9 @@ const resolve = (browsers) => {
|
|
|
270
271
|
ios_saf: [12, 2],
|
|
271
272
|
samsung: [10, 1],
|
|
272
273
|
android: 71,
|
|
273
|
-
|
|
274
|
+
and_qq: [13, 1],
|
|
274
275
|
// baidu: Unknown support
|
|
275
|
-
|
|
276
|
+
and_uc: [15, 5],
|
|
276
277
|
kaios: [3, 0],
|
|
277
278
|
node: 12
|
|
278
279
|
}),
|
|
@@ -289,9 +290,9 @@ const resolve = (browsers) => {
|
|
|
289
290
|
ios_saf: [13, 4],
|
|
290
291
|
samsung: 13,
|
|
291
292
|
android: 80,
|
|
292
|
-
|
|
293
|
+
and_qq: [13, 1],
|
|
293
294
|
// baidu: Not supported
|
|
294
|
-
|
|
295
|
+
and_uc: [15, 5],
|
|
295
296
|
kaios: [3, 0],
|
|
296
297
|
node: 14
|
|
297
298
|
}),
|
|
@@ -327,9 +328,9 @@ const resolve = (browsers) => {
|
|
|
327
328
|
ios_saf: 11,
|
|
328
329
|
samsung: [6, 2],
|
|
329
330
|
android: 55,
|
|
330
|
-
and_qq: [
|
|
331
|
+
and_qq: [10, 4],
|
|
331
332
|
baidu: [13, 18],
|
|
332
|
-
and_uc: [
|
|
333
|
+
and_uc: [12, 12],
|
|
333
334
|
kaios: 3,
|
|
334
335
|
node: [7, 6]
|
|
335
336
|
}),
|
|
@@ -345,7 +346,7 @@ const resolve = (browsers) => {
|
|
|
345
346
|
fetchWasm: browserProperty,
|
|
346
347
|
global: nodeProperty,
|
|
347
348
|
importScripts: false,
|
|
348
|
-
importScriptsInWorker:
|
|
349
|
+
importScriptsInWorker: Boolean(browserProperty),
|
|
349
350
|
nodeBuiltins: nodeProperty,
|
|
350
351
|
nodePrefixForCoreModules:
|
|
351
352
|
nodeProperty &&
|
|
@@ -353,6 +354,11 @@ const resolve = (browsers) => {
|
|
|
353
354
|
rawChecker({
|
|
354
355
|
node: [14, 18]
|
|
355
356
|
}),
|
|
357
|
+
importMetaDirnameAndFilename:
|
|
358
|
+
nodeProperty &&
|
|
359
|
+
rawChecker({
|
|
360
|
+
node: [22, 16]
|
|
361
|
+
}),
|
|
356
362
|
require: nodeProperty
|
|
357
363
|
};
|
|
358
364
|
};
|