@rspack/core 1.0.9 → 1.0.11
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/dist/Dependency.d.ts +7 -6
- package/dist/Module.d.ts +19 -17
- package/dist/builtin-plugin/css-extract/utils.d.ts +1 -0
- package/dist/config/types.d.ts +545 -0
- package/dist/config/zod.d.ts +202 -1347
- package/dist/cssExtractHmr.js +224 -0
- package/dist/cssExtractLoader.js +277 -0
- package/dist/index.js +23347 -31
- package/dist/{builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts → runtime/cssExtractHmr.d.ts} +1 -0
- package/dist/runtime/moduleFederationDefaultRuntime.d.ts +2 -0
- package/dist/stats/statsFactoryUtils.d.ts +1 -0
- package/package.json +8 -5
- package/compiled/json-parse-even-better-errors/index.d.ts +0 -1
- package/compiled/json-parse-even-better-errors/index.js +0 -193
- package/compiled/json-parse-even-better-errors/package.json +0 -1
- package/compiled/neo-async/index.d.ts +0 -685
- package/compiled/neo-async/index.js +0 -9207
- package/compiled/neo-async/license +0 -22
- package/compiled/neo-async/package.json +0 -1
- package/compiled/zod-validation-error/index.d.ts +0 -41
- package/compiled/zod-validation-error/index.js +0 -335
- package/compiled/zod-validation-error/license +0 -9
- package/compiled/zod-validation-error/package.json +0 -1
- package/dist/Chunk.js +0 -118
- package/dist/ChunkGraph.js +0 -27
- package/dist/ChunkGroup.js +0 -76
- package/dist/Compilation.js +0 -854
- package/dist/Compiler.js +0 -920
- package/dist/ContextModuleFactory.js +0 -36
- package/dist/DependenciesBlock.js +0 -30
- package/dist/Dependency.js +0 -32
- package/dist/Entrypoint.js +0 -21
- package/dist/ErrorHelpers.js +0 -62
- package/dist/ExecuteModulePlugin.js +0 -46
- package/dist/FileSystem.js +0 -34
- package/dist/FileSystemInfo.js +0 -2
- package/dist/Module.js +0 -143
- package/dist/ModuleTypeConstants.js +0 -92
- package/dist/MultiCompiler.js +0 -440
- package/dist/MultiStats.js +0 -161
- package/dist/MultiWatching.js +0 -62
- package/dist/NormalModule.js +0 -97
- package/dist/NormalModuleFactory.js +0 -43
- package/dist/Resolver.js +0 -39
- package/dist/ResolverFactory.js +0 -61
- package/dist/RspackError.js +0 -21
- package/dist/RuleSetCompiler.js +0 -10
- package/dist/RuntimeGlobals.js +0 -357
- package/dist/RuntimeModule.js +0 -58
- package/dist/Stats.js +0 -161
- package/dist/Template.js +0 -206
- package/dist/Watching.js +0 -290
- package/dist/builtin-loader/index.js +0 -17
- package/dist/builtin-loader/lightningcss/index.js +0 -175
- package/dist/builtin-loader/swc/index.js +0 -5
- package/dist/builtin-loader/swc/pluginImport.js +0 -35
- package/dist/builtin-loader/swc/react.js +0 -7
- package/dist/builtin-loader/swc/types.js +0 -2
- package/dist/builtin-plugin/APIPlugin.js +0 -6
- package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.js +0 -6
- package/dist/builtin-plugin/AssetModulesPlugin.js +0 -6
- package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.js +0 -6
- package/dist/builtin-plugin/BannerPlugin.js +0 -22
- package/dist/builtin-plugin/BundlerInfoRspackPlugin.js +0 -12
- package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.js +0 -6
- package/dist/builtin-plugin/CommonJsChunkFormatPlugin.js +0 -6
- package/dist/builtin-plugin/ContextReplacementPlugin.js +0 -43
- package/dist/builtin-plugin/CopyRspackPlugin.js +0 -21
- package/dist/builtin-plugin/CssModulesPlugin.js +0 -6
- package/dist/builtin-plugin/DataUriPlugin.js +0 -6
- package/dist/builtin-plugin/DefinePlugin.js +0 -44
- package/dist/builtin-plugin/DeterministicChunkIdsPlugin.js +0 -6
- package/dist/builtin-plugin/DeterministicModuleIdsPlugin.js +0 -6
- package/dist/builtin-plugin/DynamicEntryPlugin.js +0 -36
- package/dist/builtin-plugin/ElectronTargetPlugin.js +0 -6
- package/dist/builtin-plugin/EnableChunkLoadingPlugin.js +0 -6
- package/dist/builtin-plugin/EnableLibraryPlugin.js +0 -39
- package/dist/builtin-plugin/EnableWasmLoadingPlugin.js +0 -6
- package/dist/builtin-plugin/EnsureChunkConditionsPlugin.js +0 -6
- package/dist/builtin-plugin/EntryPlugin.js +0 -34
- package/dist/builtin-plugin/EvalDevToolModulePlugin.js +0 -6
- package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.js +0 -16
- package/dist/builtin-plugin/ExternalsPlugin.js +0 -51
- package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.js +0 -6
- package/dist/builtin-plugin/FileUriPlugin.js +0 -6
- package/dist/builtin-plugin/FlagDependencyExportsPlugin.js +0 -6
- package/dist/builtin-plugin/FlagDependencyUsagePlugin.js +0 -6
- package/dist/builtin-plugin/HotModuleReplacementPlugin.js +0 -18
- package/dist/builtin-plugin/HtmlRspackPlugin.js +0 -285
- package/dist/builtin-plugin/HttpExternalsRspackPlugin.js +0 -11
- package/dist/builtin-plugin/IgnorePlugin.js +0 -20
- package/dist/builtin-plugin/InferAsyncModulesPlugin.js +0 -6
- package/dist/builtin-plugin/JavascriptModulesPlugin.js +0 -55
- package/dist/builtin-plugin/JsLoaderRspackPlugin.js +0 -9
- package/dist/builtin-plugin/JsonModulesPlugin.js +0 -6
- package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +0 -30
- package/dist/builtin-plugin/LimitChunkCountPlugin.js +0 -8
- package/dist/builtin-plugin/MangleExportsPlugin.js +0 -6
- package/dist/builtin-plugin/MergeDuplicateChunksPlugin.js +0 -6
- package/dist/builtin-plugin/ModuleChunkFormatPlugin.js +0 -6
- package/dist/builtin-plugin/ModuleConcatenationPlugin.js +0 -6
- package/dist/builtin-plugin/NamedChunkIdsPlugin.js +0 -6
- package/dist/builtin-plugin/NamedModuleIdsPlugin.js +0 -6
- package/dist/builtin-plugin/NaturalChunkIdsPlugin.js +0 -6
- package/dist/builtin-plugin/NaturalModuleIdsPlugin.js +0 -6
- package/dist/builtin-plugin/NoEmitOnErrorsPlugin.js +0 -6
- package/dist/builtin-plugin/NodeTargetPlugin.js +0 -6
- package/dist/builtin-plugin/ProgressPlugin.js +0 -15
- package/dist/builtin-plugin/ProvidePlugin.js +0 -14
- package/dist/builtin-plugin/RealContentHashPlugin.js +0 -6
- package/dist/builtin-plugin/RemoveEmptyChunksPlugin.js +0 -6
- package/dist/builtin-plugin/RuntimeChunkPlugin.js +0 -6
- package/dist/builtin-plugin/RuntimePlugin.js +0 -6
- package/dist/builtin-plugin/SideEffectsFlagPlugin.js +0 -6
- package/dist/builtin-plugin/SizeLimitsPlugin.js +0 -9
- package/dist/builtin-plugin/SourceMapDevToolPlugin.js +0 -14
- package/dist/builtin-plugin/SplitChunksPlugin.js +0 -92
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +0 -80
- package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.js +0 -6
- package/dist/builtin-plugin/WebWorkerTemplatePlugin.js +0 -6
- package/dist/builtin-plugin/WorkerPlugin.js +0 -31
- package/dist/builtin-plugin/base.js +0 -58
- package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +0 -182
- package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +0 -2
- package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +0 -31
- package/dist/builtin-plugin/css-extract/index.js +0 -105
- package/dist/builtin-plugin/css-extract/loader.js +0 -204
- package/dist/builtin-plugin/css-extract/utils.js +0 -51
- package/dist/builtin-plugin/index.js +0 -84
- package/dist/builtin-plugin/lazy-compilation/backend.js +0 -139
- package/dist/builtin-plugin/lazy-compilation/lazyCompilation.js +0 -6
- package/dist/builtin-plugin/lazy-compilation/plugin.js +0 -60
- package/dist/config/adapter.js +0 -691
- package/dist/config/adapterRuleUse.js +0 -107
- package/dist/config/browserslistTargetHandler.js +0 -345
- package/dist/config/defaults.js +0 -876
- package/dist/config/index.js +0 -20
- package/dist/config/normalization.js +0 -299
- package/dist/config/target.js +0 -318
- package/dist/config/types.js +0 -3
- package/dist/config/zod.js +0 -1028
- package/dist/container/ContainerPlugin.js +0 -50
- package/dist/container/ContainerReferencePlugin.js +0 -49
- package/dist/container/ModuleFederationPlugin.js +0 -137
- package/dist/container/ModuleFederationPluginV1.js +0 -63
- package/dist/container/ModuleFederationRuntimePlugin.js +0 -6
- package/dist/container/options.js +0 -48
- package/dist/error/ConcurrentCompilationError.js +0 -20
- package/dist/exports.js +0 -183
- package/dist/lib/AbstractMethodError.js +0 -51
- package/dist/lib/Cache.js +0 -111
- package/dist/lib/CacheFacade.js +0 -321
- package/dist/lib/Dependency.js +0 -11
- package/dist/lib/EntryOptionPlugin.js +0 -89
- package/dist/lib/EnvironmentPlugin.js +0 -57
- package/dist/lib/HookWebpackError.js +0 -83
- package/dist/lib/IgnoreWarningsPlugin.js +0 -35
- package/dist/lib/LoaderOptionsPlugin.js +0 -74
- package/dist/lib/LoaderTargetPlugin.js +0 -37
- package/dist/lib/ModuleFilenameHelpers.js +0 -83
- package/dist/lib/NormalModuleReplacementPlugin.js +0 -85
- package/dist/lib/WebpackError.js +0 -20
- package/dist/lib/cache/MemoryCachePlugin.js +0 -40
- package/dist/lib/cache/getLazyHashedEtag.js +0 -73
- package/dist/lib/cache/mergeEtags.js +0 -74
- package/dist/lib/formatLocation.js +0 -64
- package/dist/loader-runner/LoaderLoadingError.js +0 -19
- package/dist/loader-runner/index.js +0 -735
- package/dist/loader-runner/loadLoader.js +0 -64
- package/dist/logging/Logger.js +0 -143
- package/dist/logging/createConsoleLogger.js +0 -176
- package/dist/logging/runtime.js +0 -37
- package/dist/logging/truncateArgs.js +0 -81
- package/dist/node/NodeEnvironmentPlugin.js +0 -50
- package/dist/node/NodeTemplatePlugin.js +0 -26
- package/dist/node/NodeWatchFileSystem.js +0 -144
- package/dist/node/nodeConsole.js +0 -146
- package/dist/rspack.js +0 -123
- package/dist/rspackOptionsApply.js +0 -274
- package/dist/sharing/ConsumeSharedPlugin.js +0 -69
- package/dist/sharing/ProvideSharedPlugin.js +0 -50
- package/dist/sharing/SharePlugin.js +0 -66
- package/dist/sharing/ShareRuntimePlugin.js +0 -26
- package/dist/sharing/utils.js +0 -8
- package/dist/stats/DefaultStatsFactoryPlugin.js +0 -1173
- package/dist/stats/DefaultStatsPresetPlugin.js +0 -305
- package/dist/stats/DefaultStatsPrinterPlugin.js +0 -1069
- package/dist/stats/StatsFactory.js +0 -167
- package/dist/stats/StatsPrinter.js +0 -142
- package/dist/stats/statsFactoryUtils.js +0 -341
- package/dist/util/ArrayQueue.js +0 -108
- package/dist/util/AssetInfo.js +0 -39
- package/dist/util/IterableHelpers.js +0 -35
- package/dist/util/MergeCaller.js +0 -24
- package/dist/util/SizeFormatHelpers.js +0 -24
- package/dist/util/SplitChunkSize.js +0 -18
- package/dist/util/assertNotNil.js +0 -9
- package/dist/util/assetCondition.js +0 -2
- package/dist/util/bindingVersionCheck.js +0 -124
- package/dist/util/cleverMerge.js +0 -504
- package/dist/util/comparators.js +0 -108
- package/dist/util/createHash.js +0 -161
- package/dist/util/createReadonlyMap.js +0 -29
- package/dist/util/fake.js +0 -28
- package/dist/util/fs.js +0 -120
- package/dist/util/hash/BatchedHash.js +0 -69
- package/dist/util/hash/index.js +0 -39
- package/dist/util/hash/md4.js +0 -27
- package/dist/util/hash/wasm-hash.js +0 -167
- package/dist/util/hash/xxhash64.js +0 -27
- package/dist/util/identifier.js +0 -330
- package/dist/util/index.js +0 -123
- package/dist/util/memoize.js +0 -61
- package/dist/util/scheme.js +0 -57
- package/dist/util/smartGrouping.js +0 -148
- package/dist/util/source.js +0 -42
- package/dist/util/validate.js +0 -77
- package/dist/util/webpack.js +0 -27
- /package/dist/{container/default.runtime.js → moduleFederationDefaultRuntime.js} +0 -0
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isUseSimpleSourceMap = exports.isUseSourceMap = exports.createRawModuleRuleUses = exports.BUILTIN_LOADER_PREFIX = void 0;
|
|
4
|
-
const builtin_loader_1 = require("../builtin-loader");
|
|
5
|
-
const lightningcss_1 = require("../builtin-loader/lightningcss");
|
|
6
|
-
const loader_runner_1 = require("../loader-runner");
|
|
7
|
-
const util_1 = require("../util");
|
|
8
|
-
exports.BUILTIN_LOADER_PREFIX = "builtin:";
|
|
9
|
-
function createRawModuleRuleUses(uses, path, options) {
|
|
10
|
-
const normalizeRuleSetUseItem = (item) => typeof item === "string" ? { loader: item } : item;
|
|
11
|
-
const allUses = Array.isArray(uses)
|
|
12
|
-
? [...uses].map(normalizeRuleSetUseItem)
|
|
13
|
-
: [normalizeRuleSetUseItem(uses)];
|
|
14
|
-
return createRawModuleRuleUsesImpl(allUses, path, options);
|
|
15
|
-
}
|
|
16
|
-
exports.createRawModuleRuleUses = createRawModuleRuleUses;
|
|
17
|
-
const getSwcLoaderOptions = (o, _) => {
|
|
18
|
-
if (o && typeof o === "object" && o.rspackExperiments) {
|
|
19
|
-
const expr = o.rspackExperiments;
|
|
20
|
-
if (expr.import || expr.pluginImport) {
|
|
21
|
-
expr.import = (0, builtin_loader_1.resolvePluginImport)(expr.import || expr.pluginImport);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return o;
|
|
25
|
-
};
|
|
26
|
-
const getLightningcssLoaderOptions = (o, _) => {
|
|
27
|
-
if (o && typeof o === "object") {
|
|
28
|
-
if (typeof o.targets === "string") {
|
|
29
|
-
o.targets = [o.targets];
|
|
30
|
-
}
|
|
31
|
-
if (o.include && typeof o.include === "object") {
|
|
32
|
-
o.include = (0, lightningcss_1.toFeatures)(o.include);
|
|
33
|
-
}
|
|
34
|
-
if (o.exclude && typeof o.exclude === "object") {
|
|
35
|
-
o.exclude = (0, lightningcss_1.toFeatures)(o.exclude);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return o;
|
|
39
|
-
};
|
|
40
|
-
function getBuiltinLoaderOptions(identifier, o, options) {
|
|
41
|
-
if (identifier.startsWith(`${exports.BUILTIN_LOADER_PREFIX}swc-loader`)) {
|
|
42
|
-
return getSwcLoaderOptions(o, options);
|
|
43
|
-
}
|
|
44
|
-
if (identifier.startsWith(`${exports.BUILTIN_LOADER_PREFIX}lightningcss-loader`)) {
|
|
45
|
-
return getLightningcssLoaderOptions(o, options);
|
|
46
|
-
}
|
|
47
|
-
return o;
|
|
48
|
-
}
|
|
49
|
-
function createRawModuleRuleUsesImpl(uses, path, options) {
|
|
50
|
-
if (!uses.length) {
|
|
51
|
-
return [];
|
|
52
|
-
}
|
|
53
|
-
return uses.map((use, index) => {
|
|
54
|
-
let o;
|
|
55
|
-
let isBuiltin = false;
|
|
56
|
-
if (use.loader.startsWith(exports.BUILTIN_LOADER_PREFIX)) {
|
|
57
|
-
const temp = getBuiltinLoaderOptions(use.loader, use.options, options);
|
|
58
|
-
// keep json with indent so miette can show pretty error
|
|
59
|
-
o = (0, util_1.isNil)(temp)
|
|
60
|
-
? undefined
|
|
61
|
-
: typeof temp === "string"
|
|
62
|
-
? temp
|
|
63
|
-
: JSON.stringify(temp, null, 2);
|
|
64
|
-
isBuiltin = true;
|
|
65
|
-
}
|
|
66
|
-
return {
|
|
67
|
-
loader: resolveStringifyLoaders(use, `${path}[${index}]`, options.compiler, isBuiltin),
|
|
68
|
-
options: o
|
|
69
|
-
};
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
function resolveStringifyLoaders(use, path, compiler, isBuiltin) {
|
|
73
|
-
const obj = (0, loader_runner_1.parsePathQueryFragment)(use.loader);
|
|
74
|
-
let ident = null;
|
|
75
|
-
if (use.options === null) {
|
|
76
|
-
}
|
|
77
|
-
else if (use.options === undefined) {
|
|
78
|
-
}
|
|
79
|
-
else if (typeof use.options === "string")
|
|
80
|
-
obj.query = `?${use.options}`;
|
|
81
|
-
else if (use.ident)
|
|
82
|
-
obj.query = `??${(ident = use.ident)}`;
|
|
83
|
-
else if (typeof use.options === "object" && use.options.ident)
|
|
84
|
-
obj.query = `??${(ident = use.options.ident)}`;
|
|
85
|
-
else if (typeof use.options === "object")
|
|
86
|
-
obj.query = `??${(ident = path)}`;
|
|
87
|
-
else
|
|
88
|
-
obj.query = `?${JSON.stringify(use.options)}`;
|
|
89
|
-
if (use.options && typeof use.options === "object") {
|
|
90
|
-
if (!ident)
|
|
91
|
-
ident = "[[missing ident]]";
|
|
92
|
-
compiler.__internal__ruleSet.references.set(ident, use.options);
|
|
93
|
-
if (isBuiltin) {
|
|
94
|
-
compiler.__internal__ruleSet.builtinReferences.set(ident, use.options);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return obj.path + obj.query + obj.fragment;
|
|
98
|
-
}
|
|
99
|
-
function isUseSourceMap(devtool) {
|
|
100
|
-
return (devtool.includes("source-map") &&
|
|
101
|
-
(devtool.includes("module") || !devtool.includes("cheap")));
|
|
102
|
-
}
|
|
103
|
-
exports.isUseSourceMap = isUseSourceMap;
|
|
104
|
-
function isUseSimpleSourceMap(devtool) {
|
|
105
|
-
return devtool.includes("source-map") && !isUseSourceMap(devtool);
|
|
106
|
-
}
|
|
107
|
-
exports.isUseSimpleSourceMap = isUseSimpleSourceMap;
|
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* The following code is modified based on
|
|
4
|
-
* https://github.com/webpack/webpack/blob/4b4ca3b/lib/config/browserslistTargetHandler.js
|
|
5
|
-
*
|
|
6
|
-
* MIT Licensed
|
|
7
|
-
* Author Sergey Melyukov @smelukov
|
|
8
|
-
* Copyright (c) JS Foundation and other contributors
|
|
9
|
-
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
10
|
-
*/
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.resolve = exports.load = void 0;
|
|
16
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
17
|
-
// [[C:]/path/to/config][:env]
|
|
18
|
-
const inputRx = /^(?:((?:[A-Z]:)?[/\\].*?))?(?::(.+?))?$/i;
|
|
19
|
-
/**
|
|
20
|
-
* @param input input string
|
|
21
|
-
* @param context the context directory
|
|
22
|
-
* @returns config
|
|
23
|
-
*/
|
|
24
|
-
const parse = (input, context) => {
|
|
25
|
-
if (!input) {
|
|
26
|
-
return {};
|
|
27
|
-
}
|
|
28
|
-
if (node_path_1.default.isAbsolute(input)) {
|
|
29
|
-
const [, configPath, env] = inputRx.exec(input) || [];
|
|
30
|
-
return { configPath, env };
|
|
31
|
-
}
|
|
32
|
-
const browserslist = require("../../compiled/browserslist");
|
|
33
|
-
const config = browserslist.findConfig(context);
|
|
34
|
-
if (config && Object.keys(config).includes(input)) {
|
|
35
|
-
return { env: input };
|
|
36
|
-
}
|
|
37
|
-
return { query: input };
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* @param input input string
|
|
41
|
-
* @param context the context directory
|
|
42
|
-
* @returns selected browsers
|
|
43
|
-
*/
|
|
44
|
-
const load = (input, context) => {
|
|
45
|
-
const browserslist = require("../../compiled/browserslist");
|
|
46
|
-
const { configPath, env, query } = parse(input, context);
|
|
47
|
-
// if a query is specified, then use it, else
|
|
48
|
-
// if a path to a config is specified then load it, else
|
|
49
|
-
// find a nearest config
|
|
50
|
-
const config = query
|
|
51
|
-
? query
|
|
52
|
-
: configPath
|
|
53
|
-
? browserslist.loadConfig({
|
|
54
|
-
config: configPath,
|
|
55
|
-
env
|
|
56
|
-
})
|
|
57
|
-
: browserslist.loadConfig({ path: context, env });
|
|
58
|
-
if (!config)
|
|
59
|
-
return;
|
|
60
|
-
return browserslist(config);
|
|
61
|
-
};
|
|
62
|
-
exports.load = load;
|
|
63
|
-
/**
|
|
64
|
-
* @param browsers supported browsers list
|
|
65
|
-
* @returns target properties
|
|
66
|
-
*/
|
|
67
|
-
const resolve = (browsers) => {
|
|
68
|
-
/**
|
|
69
|
-
* Checks all against a version number
|
|
70
|
-
* @param versions first supported version
|
|
71
|
-
* @returns true if supports
|
|
72
|
-
*/
|
|
73
|
-
const rawChecker = (versions) => {
|
|
74
|
-
return browsers.every(v => {
|
|
75
|
-
const [name, parsedVersion] = v.split(" ");
|
|
76
|
-
if (!name)
|
|
77
|
-
return false;
|
|
78
|
-
const requiredVersion = versions[name];
|
|
79
|
-
if (!requiredVersion)
|
|
80
|
-
return false;
|
|
81
|
-
const [parsedMajor, parserMinor] =
|
|
82
|
-
// safari TP supports all features for normal safari
|
|
83
|
-
parsedVersion === "TP"
|
|
84
|
-
? [Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY]
|
|
85
|
-
: parsedVersion.includes("-")
|
|
86
|
-
? parsedVersion.split("-")[0].split(".")
|
|
87
|
-
: parsedVersion.split(".");
|
|
88
|
-
if (typeof requiredVersion === "number") {
|
|
89
|
-
return +parsedMajor >= requiredVersion;
|
|
90
|
-
}
|
|
91
|
-
return requiredVersion[0] === +parsedMajor
|
|
92
|
-
? +parserMinor >= requiredVersion[1]
|
|
93
|
-
: +parsedMajor > requiredVersion[0];
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
const anyNode = browsers.some(b => b.startsWith("node "));
|
|
97
|
-
const anyBrowser = browsers.some(b => /^(?!node)/.test(b));
|
|
98
|
-
const browserProperty = !anyBrowser ? false : anyNode ? null : true;
|
|
99
|
-
const nodeProperty = !anyNode ? false : anyBrowser ? null : true;
|
|
100
|
-
// Internet Explorer Mobile, Blackberry browser and Opera Mini are very old browsers, they do not support new features
|
|
101
|
-
const es6DynamicImport = rawChecker({
|
|
102
|
-
chrome: 63,
|
|
103
|
-
and_chr: 63,
|
|
104
|
-
edge: 79,
|
|
105
|
-
firefox: 67,
|
|
106
|
-
and_ff: 67,
|
|
107
|
-
// ie: Not supported
|
|
108
|
-
opera: 50,
|
|
109
|
-
op_mob: 46,
|
|
110
|
-
safari: [11, 1],
|
|
111
|
-
ios_saf: [11, 3],
|
|
112
|
-
samsung: [8, 2],
|
|
113
|
-
android: 63,
|
|
114
|
-
and_qq: [10, 4],
|
|
115
|
-
baidu: [13, 18],
|
|
116
|
-
and_uc: [15, 5],
|
|
117
|
-
kaios: [3, 0],
|
|
118
|
-
node: [12, 17]
|
|
119
|
-
});
|
|
120
|
-
return {
|
|
121
|
-
const: rawChecker({
|
|
122
|
-
chrome: 49,
|
|
123
|
-
and_chr: 49,
|
|
124
|
-
edge: 12,
|
|
125
|
-
// Prior to Firefox 13, <code>const</code> is implemented, but re-assignment is not failing.
|
|
126
|
-
// Prior to Firefox 46, a <code>TypeError</code> was thrown on redeclaration instead of a <code>SyntaxError</code>.
|
|
127
|
-
firefox: 36,
|
|
128
|
-
and_ff: 36,
|
|
129
|
-
// Not supported in for-in and for-of loops
|
|
130
|
-
// ie: Not supported
|
|
131
|
-
opera: 36,
|
|
132
|
-
op_mob: 36,
|
|
133
|
-
safari: [10, 0],
|
|
134
|
-
ios_saf: [10, 0],
|
|
135
|
-
// Before 5.0 supported correctly in strict mode, otherwise supported without block scope
|
|
136
|
-
samsung: [5, 0],
|
|
137
|
-
android: 37,
|
|
138
|
-
and_qq: [10, 4],
|
|
139
|
-
// Supported correctly in strict mode, otherwise supported without block scope
|
|
140
|
-
baidu: [13, 18],
|
|
141
|
-
and_uc: [12, 12],
|
|
142
|
-
kaios: [2, 5],
|
|
143
|
-
node: [6, 0]
|
|
144
|
-
}),
|
|
145
|
-
arrowFunction: rawChecker({
|
|
146
|
-
chrome: 45,
|
|
147
|
-
and_chr: 45,
|
|
148
|
-
edge: 12,
|
|
149
|
-
// The initial implementation of arrow functions in Firefox made them automatically strict. This has been changed as of Firefox 24. The use of <code>'use strict';</code> is now required.
|
|
150
|
-
// Prior to Firefox 39, a line terminator (<code>\\n</code>) was incorrectly allowed after arrow function arguments. This has been fixed to conform to the ES2015 specification and code like <code>() \\n => {}</code> will now throw a <code>SyntaxError</code> in this and later versions.
|
|
151
|
-
firefox: 39,
|
|
152
|
-
and_ff: 39,
|
|
153
|
-
// ie: Not supported,
|
|
154
|
-
opera: 32,
|
|
155
|
-
op_mob: 32,
|
|
156
|
-
safari: 10,
|
|
157
|
-
ios_saf: 10,
|
|
158
|
-
samsung: [5, 0],
|
|
159
|
-
android: 45,
|
|
160
|
-
and_qq: [10, 4],
|
|
161
|
-
baidu: [7, 12],
|
|
162
|
-
and_uc: [12, 12],
|
|
163
|
-
kaios: [2, 5],
|
|
164
|
-
node: [6, 0]
|
|
165
|
-
}),
|
|
166
|
-
forOf: rawChecker({
|
|
167
|
-
chrome: 38,
|
|
168
|
-
and_chr: 38,
|
|
169
|
-
edge: 12,
|
|
170
|
-
// Prior to Firefox 51, using the for...of loop construct with the const keyword threw a SyntaxError ("missing = in const declaration").
|
|
171
|
-
firefox: 51,
|
|
172
|
-
and_ff: 51,
|
|
173
|
-
// ie: Not supported,
|
|
174
|
-
opera: 25,
|
|
175
|
-
op_mob: 25,
|
|
176
|
-
safari: 7,
|
|
177
|
-
ios_saf: 7,
|
|
178
|
-
samsung: [3, 0],
|
|
179
|
-
android: 38,
|
|
180
|
-
// and_qq: Unknown support
|
|
181
|
-
// baidu: Unknown support
|
|
182
|
-
// and_uc: Unknown support
|
|
183
|
-
kaios: [3, 0],
|
|
184
|
-
node: [0, 12]
|
|
185
|
-
}),
|
|
186
|
-
destructuring: rawChecker({
|
|
187
|
-
chrome: 49,
|
|
188
|
-
and_chr: 49,
|
|
189
|
-
edge: 14,
|
|
190
|
-
firefox: 41,
|
|
191
|
-
and_ff: 41,
|
|
192
|
-
// ie: Not supported,
|
|
193
|
-
opera: 36,
|
|
194
|
-
op_mob: 36,
|
|
195
|
-
safari: 8,
|
|
196
|
-
ios_saf: 8,
|
|
197
|
-
samsung: [5, 0],
|
|
198
|
-
android: 49,
|
|
199
|
-
// and_qq: Unknown support
|
|
200
|
-
// baidu: Unknown support
|
|
201
|
-
// and_uc: Unknown support
|
|
202
|
-
kaios: [2, 5],
|
|
203
|
-
node: [6, 0]
|
|
204
|
-
}),
|
|
205
|
-
bigIntLiteral: rawChecker({
|
|
206
|
-
chrome: 67,
|
|
207
|
-
and_chr: 67,
|
|
208
|
-
edge: 79,
|
|
209
|
-
firefox: 68,
|
|
210
|
-
and_ff: 68,
|
|
211
|
-
// ie: Not supported,
|
|
212
|
-
opera: 54,
|
|
213
|
-
op_mob: 48,
|
|
214
|
-
safari: 14,
|
|
215
|
-
ios_saf: 14,
|
|
216
|
-
samsung: [9, 2],
|
|
217
|
-
android: 67,
|
|
218
|
-
and_qq: [13, 1],
|
|
219
|
-
baidu: [13, 18],
|
|
220
|
-
and_uc: [15, 5],
|
|
221
|
-
kaios: [3, 0],
|
|
222
|
-
node: [10, 4]
|
|
223
|
-
}),
|
|
224
|
-
// Support syntax `import` and `export` and no limitations and bugs on Node.js
|
|
225
|
-
// Not include `export * as namespace`
|
|
226
|
-
module: rawChecker({
|
|
227
|
-
chrome: 61,
|
|
228
|
-
and_chr: 61,
|
|
229
|
-
edge: 16,
|
|
230
|
-
firefox: 60,
|
|
231
|
-
and_ff: 60,
|
|
232
|
-
// ie: Not supported,
|
|
233
|
-
opera: 48,
|
|
234
|
-
op_mob: 45,
|
|
235
|
-
safari: [10, 1],
|
|
236
|
-
ios_saf: [10, 3],
|
|
237
|
-
samsung: [8, 0],
|
|
238
|
-
android: 61,
|
|
239
|
-
and_qq: [10, 4],
|
|
240
|
-
baidu: [13, 18],
|
|
241
|
-
and_uc: [15, 5],
|
|
242
|
-
kaios: [3, 0],
|
|
243
|
-
node: [12, 17]
|
|
244
|
-
}),
|
|
245
|
-
dynamicImport: es6DynamicImport,
|
|
246
|
-
dynamicImportInWorker: es6DynamicImport && !anyNode,
|
|
247
|
-
// browserslist does not have info about globalThis
|
|
248
|
-
// so this is based on mdn-browser-compat-data
|
|
249
|
-
globalThis: rawChecker({
|
|
250
|
-
chrome: 71,
|
|
251
|
-
and_chr: 71,
|
|
252
|
-
edge: 79,
|
|
253
|
-
firefox: 65,
|
|
254
|
-
and_ff: 65,
|
|
255
|
-
// ie: Not supported,
|
|
256
|
-
opera: 58,
|
|
257
|
-
op_mob: 50,
|
|
258
|
-
safari: [12, 1],
|
|
259
|
-
ios_saf: [12, 2],
|
|
260
|
-
samsung: [10, 1],
|
|
261
|
-
android: 71,
|
|
262
|
-
// and_qq: Unknown support
|
|
263
|
-
// baidu: Unknown support
|
|
264
|
-
// and_uc: Unknown support
|
|
265
|
-
kaios: [3, 0],
|
|
266
|
-
node: 12
|
|
267
|
-
}),
|
|
268
|
-
optionalChaining: rawChecker({
|
|
269
|
-
chrome: 80,
|
|
270
|
-
and_chr: 80,
|
|
271
|
-
edge: 80,
|
|
272
|
-
firefox: 74,
|
|
273
|
-
and_ff: 79,
|
|
274
|
-
// ie: Not supported,
|
|
275
|
-
opera: 67,
|
|
276
|
-
op_mob: 64,
|
|
277
|
-
safari: [13, 1],
|
|
278
|
-
ios_saf: [13, 4],
|
|
279
|
-
samsung: 13,
|
|
280
|
-
android: 80,
|
|
281
|
-
// and_qq: Not supported
|
|
282
|
-
// baidu: Not supported
|
|
283
|
-
// and_uc: Not supported
|
|
284
|
-
kaios: [3, 0],
|
|
285
|
-
node: 14
|
|
286
|
-
}),
|
|
287
|
-
templateLiteral: rawChecker({
|
|
288
|
-
chrome: 41,
|
|
289
|
-
and_chr: 41,
|
|
290
|
-
edge: 13,
|
|
291
|
-
firefox: 34,
|
|
292
|
-
and_ff: 34,
|
|
293
|
-
// ie: Not supported,
|
|
294
|
-
opera: 29,
|
|
295
|
-
op_mob: 64,
|
|
296
|
-
safari: [9, 1],
|
|
297
|
-
ios_saf: 9,
|
|
298
|
-
samsung: 4,
|
|
299
|
-
android: 41,
|
|
300
|
-
and_qq: [10, 4],
|
|
301
|
-
baidu: [7, 12],
|
|
302
|
-
and_uc: [12, 12],
|
|
303
|
-
kaios: [2, 5],
|
|
304
|
-
node: 4
|
|
305
|
-
}),
|
|
306
|
-
asyncFunction: rawChecker({
|
|
307
|
-
chrome: 55,
|
|
308
|
-
and_chr: 55,
|
|
309
|
-
edge: 15,
|
|
310
|
-
firefox: 52,
|
|
311
|
-
and_ff: 52,
|
|
312
|
-
// ie: Not supported,
|
|
313
|
-
opera: 42,
|
|
314
|
-
op_mob: 42,
|
|
315
|
-
safari: 11,
|
|
316
|
-
ios_saf: 11,
|
|
317
|
-
samsung: [6, 2],
|
|
318
|
-
android: 55,
|
|
319
|
-
and_qq: [13, 1],
|
|
320
|
-
baidu: [13, 18],
|
|
321
|
-
and_uc: [15, 5],
|
|
322
|
-
kaios: 3,
|
|
323
|
-
node: [7, 6]
|
|
324
|
-
}),
|
|
325
|
-
browser: browserProperty,
|
|
326
|
-
electron: false,
|
|
327
|
-
node: nodeProperty,
|
|
328
|
-
nwjs: false,
|
|
329
|
-
web: browserProperty,
|
|
330
|
-
webworker: false,
|
|
331
|
-
document: browserProperty,
|
|
332
|
-
fetchWasm: browserProperty,
|
|
333
|
-
global: nodeProperty,
|
|
334
|
-
importScripts: false,
|
|
335
|
-
importScriptsInWorker: true,
|
|
336
|
-
nodeBuiltins: nodeProperty,
|
|
337
|
-
nodePrefixForCoreModules: nodeProperty &&
|
|
338
|
-
!browsers.some(b => b.startsWith("node 15")) &&
|
|
339
|
-
rawChecker({
|
|
340
|
-
node: [14, 18]
|
|
341
|
-
}),
|
|
342
|
-
require: nodeProperty
|
|
343
|
-
};
|
|
344
|
-
};
|
|
345
|
-
exports.resolve = resolve;
|