webpack 5.93.0 → 5.95.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 +8 -5
- package/bin/webpack.js +6 -7
- package/hot/log.js +1 -2
- package/hot/only-dev-server.js +1 -1
- package/hot/poll.js +1 -1
- package/hot/signal.js +1 -1
- package/lib/APIPlugin.js +4 -3
- package/lib/AbstractMethodError.js +10 -5
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/BannerPlugin.js +12 -6
- package/lib/Cache.js +8 -10
- package/lib/CacheFacade.js +3 -3
- package/lib/CaseSensitiveModulesWarning.js +5 -7
- package/lib/Chunk.js +14 -11
- package/lib/ChunkGraph.js +58 -36
- package/lib/ChunkGroup.js +2 -3
- package/lib/ChunkTemplate.js +43 -0
- package/lib/CleanPlugin.js +10 -11
- package/lib/CodeGenerationResults.js +6 -5
- package/lib/CommentCompilationWarning.js +0 -1
- package/lib/Compilation.js +223 -191
- package/lib/Compiler.js +81 -82
- package/lib/ConcatenationScope.js +3 -6
- package/lib/ConditionalInitFragment.js +6 -7
- package/lib/ConstPlugin.js +7 -15
- package/lib/ContextExclusionPlugin.js +3 -3
- package/lib/ContextModule.js +33 -20
- package/lib/ContextModuleFactory.js +89 -44
- package/lib/ContextReplacementPlugin.js +10 -9
- package/lib/DefinePlugin.js +75 -68
- package/lib/DelegatedModule.js +7 -3
- package/lib/DelegatedModuleFactoryPlugin.js +36 -22
- package/lib/DelegatedPlugin.js +4 -0
- package/lib/DependenciesBlock.js +0 -1
- package/lib/Dependency.js +10 -14
- package/lib/DllEntryPlugin.js +4 -2
- package/lib/DllModuleFactory.js +1 -0
- package/lib/DllPlugin.js +9 -7
- package/lib/DllReferencePlugin.js +30 -15
- package/lib/EntryPlugin.js +1 -3
- package/lib/EnvironmentPlugin.js +6 -2
- package/lib/ErrorHelpers.js +11 -12
- package/lib/EvalDevToolModulePlugin.js +10 -12
- package/lib/EvalSourceMapDevToolPlugin.js +15 -13
- package/lib/ExportsInfo.js +185 -120
- package/lib/ExternalModule.js +41 -15
- package/lib/ExternalModuleFactoryPlugin.js +23 -10
- package/lib/FileSystemInfo.js +791 -422
- package/lib/FlagAllModulesAsUsedPlugin.js +1 -1
- package/lib/FlagDependencyExportsPlugin.js +12 -11
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/Generator.js +2 -5
- package/lib/GraphHelpers.js +3 -2
- package/lib/HookWebpackError.js +8 -10
- package/lib/HotModuleReplacementPlugin.js +78 -64
- package/lib/IgnoreErrorModuleFactory.js +3 -3
- package/lib/IgnorePlugin.js +1 -3
- package/lib/IgnoreWarningsPlugin.js +6 -9
- package/lib/InitFragment.js +2 -3
- package/lib/LibManifestPlugin.js +4 -3
- package/lib/MainTemplate.js +72 -19
- package/lib/Module.js +25 -9
- package/lib/ModuleBuildError.js +4 -11
- package/lib/ModuleDependencyError.js +5 -5
- package/lib/ModuleDependencyWarning.js +5 -5
- package/lib/ModuleError.js +1 -5
- package/lib/ModuleFilenameHelpers.js +29 -46
- package/lib/ModuleGraph.js +7 -6
- package/lib/ModuleGraphConnection.js +6 -6
- package/lib/ModuleInfoHeaderPlugin.js +82 -30
- package/lib/ModuleParseError.js +8 -9
- package/lib/ModuleRestoreError.js +1 -1
- package/lib/ModuleStoreError.js +1 -1
- package/lib/ModuleTemplate.js +33 -1
- package/lib/ModuleTypeConstants.js +21 -22
- package/lib/ModuleWarning.js +1 -5
- package/lib/MultiCompiler.js +24 -26
- package/lib/MultiStats.js +73 -31
- package/lib/MultiWatching.js +1 -1
- package/lib/NormalModule.js +130 -69
- package/lib/NormalModuleFactory.js +53 -49
- package/lib/OptimizationStages.js +3 -3
- package/lib/ProgressPlugin.js +9 -9
- package/lib/ProvidePlugin.js +4 -4
- package/lib/RuntimeGlobals.js +71 -70
- package/lib/RuntimeModule.js +1 -1
- package/lib/RuntimePlugin.js +24 -12
- package/lib/RuntimeTemplate.js +40 -44
- package/lib/SizeFormatHelpers.js +2 -4
- package/lib/SourceMapDevToolPlugin.js +42 -34
- package/lib/Stats.js +5 -11
- package/lib/Template.js +18 -24
- package/lib/TemplatedPathPlugin.js +21 -13
- package/lib/WarnDeprecatedOptionPlugin.js +0 -1
- package/lib/WatchIgnorePlugin.js +26 -9
- package/lib/Watching.js +10 -5
- package/lib/WebpackOptionsApply.js +84 -62
- package/lib/asset/AssetGenerator.js +107 -42
- package/lib/asset/AssetModulesPlugin.js +29 -23
- package/lib/asset/AssetSourceGenerator.js +2 -7
- package/lib/async-modules/AwaitDependenciesInitFragment.js +6 -7
- package/lib/buildChunkGraph.js +93 -81
- package/lib/cache/IdleFileCachePlugin.js +4 -4
- package/lib/cache/MemoryWithGcCachePlugin.js +5 -5
- package/lib/cache/PackFileCacheStrategy.js +51 -50
- package/lib/cache/ResolverCachePlugin.js +6 -6
- package/lib/cache/mergeEtags.js +16 -21
- package/lib/cli.js +148 -104
- package/lib/config/browserslistTargetHandler.js +16 -13
- package/lib/config/defaults.js +32 -28
- package/lib/config/normalization.js +335 -344
- package/lib/config/target.js +42 -52
- package/lib/container/ContainerEntryModule.js +2 -2
- package/lib/container/ContainerPlugin.js +1 -1
- package/lib/container/RemoteRuntimeModule.js +11 -8
- package/lib/container/options.js +18 -4
- package/lib/css/CssExportsGenerator.js +26 -24
- package/lib/css/CssGenerator.js +9 -4
- package/lib/css/CssLoadingRuntimeModule.js +10 -10
- package/lib/css/CssModulesPlugin.js +127 -47
- package/lib/css/CssParser.js +20 -18
- package/lib/css/walkCssTokens.js +80 -95
- package/lib/debug/ProfilingPlugin.js +19 -20
- package/lib/dependencies/AMDDefineDependency.js +1 -1
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +83 -47
- package/lib/dependencies/AMDRequireArrayDependency.js +9 -10
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +22 -16
- package/lib/dependencies/AMDRuntimeModules.js +2 -2
- package/lib/dependencies/CommonJsDependencyHelpers.js +6 -2
- package/lib/dependencies/CommonJsExportRequireDependency.js +37 -41
- package/lib/dependencies/CommonJsExportsDependency.js +0 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +19 -23
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +52 -61
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +6 -8
- package/lib/dependencies/ConstDependency.js +1 -1
- package/lib/dependencies/ContextDependency.js +7 -2
- package/lib/dependencies/ContextDependencyHelpers.js +31 -34
- package/lib/dependencies/ContextElementDependency.js +35 -8
- package/lib/dependencies/CriticalDependencyWarning.js +1 -1
- package/lib/dependencies/CssExportDependency.js +7 -7
- package/lib/dependencies/CssImportDependency.js +0 -2
- package/lib/dependencies/CssLocalIdentifierDependency.js +3 -3
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/CssUrlDependency.js +4 -5
- package/lib/dependencies/DynamicExports.js +5 -5
- package/lib/dependencies/ExportsInfoDependency.js +1 -2
- package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -5
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +27 -16
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +107 -64
- package/lib/dependencies/HarmonyExports.js +2 -2
- package/lib/dependencies/HarmonyImportDependency.js +2 -4
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +19 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -15
- package/lib/dependencies/ImportDependency.js +1 -1
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +5 -5
- package/lib/dependencies/ImportMetaPlugin.js +11 -13
- package/lib/dependencies/ImportParserPlugin.js +39 -44
- package/lib/dependencies/JsonExportsDependency.js +22 -18
- package/lib/dependencies/LoaderPlugin.js +47 -36
- package/lib/dependencies/LocalModule.js +1 -1
- package/lib/dependencies/LocalModulesHelpers.js +4 -4
- package/lib/dependencies/ModuleDecoratorDependency.js +1 -1
- package/lib/dependencies/ProvidedDependency.js +1 -1
- package/lib/dependencies/PureExpressionDependency.js +6 -6
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/URLDependency.js +3 -3
- package/lib/dependencies/URLPlugin.js +66 -12
- package/lib/dependencies/WorkerPlugin.js +25 -24
- package/lib/dependencies/processExportInfo.js +3 -1
- package/lib/electron/ElectronTargetPlugin.js +1 -0
- package/lib/esm/ModuleChunkFormatPlugin.js +3 -3
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -3
- package/lib/formatLocation.js +1 -2
- package/lib/hmr/HotModuleReplacement.runtime.js +4 -5
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -0
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +9 -12
- package/lib/hmr/LazyCompilationPlugin.js +27 -12
- package/lib/hmr/lazyCompilationBackend.js +64 -40
- package/lib/ids/ChunkModuleIdRangePlugin.js +1 -3
- package/lib/ids/DeterministicChunkIdsPlugin.js +2 -4
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
- package/lib/ids/HashedModuleIdsPlugin.js +5 -1
- package/lib/ids/IdHelpers.js +29 -39
- package/lib/ids/SyncModuleIdsPlugin.js +7 -2
- package/lib/index.js +1 -5
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +5 -4
- package/lib/javascript/BasicEvaluatedExpression.js +4 -19
- package/lib/javascript/ChunkHelpers.js +1 -1
- package/lib/javascript/CommonJsChunkFormatPlugin.js +3 -2
- package/lib/javascript/EnableChunkLoadingPlugin.js +7 -6
- package/lib/javascript/JavascriptGenerator.js +23 -7
- package/lib/javascript/JavascriptModulesPlugin.js +133 -86
- package/lib/javascript/JavascriptParser.js +179 -200
- package/lib/javascript/JavascriptParserHelpers.js +20 -21
- package/lib/javascript/StartupHelpers.js +41 -13
- package/lib/json/JsonGenerator.js +7 -13
- package/lib/json/JsonModulesPlugin.js +1 -4
- package/lib/json/JsonParser.js +5 -3
- package/lib/library/AmdLibraryPlugin.js +12 -16
- package/lib/library/AssignLibraryPlugin.js +8 -10
- package/lib/library/EnableLibraryPlugin.js +15 -14
- package/lib/library/JsonpLibraryPlugin.js +2 -1
- package/lib/library/ModernModuleLibraryPlugin.js +8 -6
- package/lib/library/ModuleLibraryPlugin.js +2 -1
- package/lib/library/SystemLibraryPlugin.js +2 -1
- package/lib/library/UmdLibraryPlugin.js +66 -92
- package/lib/logging/Logger.js +32 -4
- package/lib/logging/createConsoleLogger.js +12 -13
- package/lib/logging/runtime.js +7 -8
- package/lib/logging/truncateArgs.js +5 -8
- package/lib/node/NodeWatchFileSystem.js +3 -18
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -0
- package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/nodeConsole.js +22 -22
- package/lib/optimize/AggressiveMergingPlugin.js +2 -4
- package/lib/optimize/AggressiveSplittingPlugin.js +16 -19
- package/lib/optimize/ConcatenatedModule.js +81 -51
- package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -1
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -3
- package/lib/optimize/InnerGraph.js +17 -17
- package/lib/optimize/InnerGraphPlugin.js +8 -7
- package/lib/optimize/LimitChunkCountPlugin.js +2 -3
- package/lib/optimize/MangleExportsPlugin.js +1 -0
- package/lib/optimize/MergeDuplicateChunksPlugin.js +2 -2
- package/lib/optimize/MinMaxSizeWarning.js +1 -1
- package/lib/optimize/ModuleConcatenationPlugin.js +54 -78
- package/lib/optimize/RealContentHashPlugin.js +7 -10
- package/lib/optimize/RemoveParentModulesPlugin.js +3 -3
- package/lib/optimize/SideEffectsFlagPlugin.js +6 -2
- package/lib/optimize/SplitChunksPlugin.js +34 -30
- package/lib/performance/SizeLimitsPlugin.js +2 -2
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -1
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -1
- package/lib/rules/BasicEffectRulePlugin.js +3 -1
- package/lib/rules/BasicMatcherRulePlugin.js +3 -1
- package/lib/rules/ObjectMatcherRulePlugin.js +4 -1
- package/lib/rules/RuleSetCompiler.js +41 -22
- package/lib/rules/UseEffectRulePlugin.js +36 -32
- package/lib/runtime/AsyncModuleRuntimeModule.js +1 -1
- package/lib/runtime/AutoPublicPathRuntimeModule.js +8 -3
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +2 -2
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +1 -1
- package/lib/runtime/EnsureChunkRuntimeModule.js +10 -11
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +11 -17
- package/lib/runtime/LoadScriptRuntimeModule.js +17 -18
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -3
- package/lib/schemes/DataUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +241 -126
- package/lib/serialization/BinaryMiddleware.js +44 -28
- package/lib/serialization/DateObjectSerializer.js +1 -0
- package/lib/serialization/ErrorObjectSerializer.js +2 -0
- package/lib/serialization/FileMiddleware.js +154 -106
- package/lib/serialization/MapObjectSerializer.js +2 -1
- package/lib/serialization/NullPrototypeObjectSerializer.js +3 -2
- package/lib/serialization/ObjectMiddleware.js +52 -56
- package/lib/serialization/PlainObjectSerializer.js +32 -6
- package/lib/serialization/RegExpObjectSerializer.js +1 -0
- package/lib/serialization/Serializer.js +4 -5
- package/lib/serialization/SerializerMiddleware.js +6 -6
- package/lib/serialization/SetObjectSerializer.js +2 -1
- package/lib/sharing/ConsumeSharedPlugin.js +116 -97
- package/lib/sharing/ConsumeSharedRuntimeModule.js +4 -4
- package/lib/sharing/ProvideForSharedDependency.js +0 -1
- package/lib/sharing/ProvideSharedPlugin.js +2 -2
- package/lib/sharing/resolveMatchedConfigs.js +2 -1
- package/lib/sharing/utils.js +15 -27
- package/lib/stats/DefaultStatsFactoryPlugin.js +424 -281
- package/lib/stats/DefaultStatsPresetPlugin.js +73 -18
- package/lib/stats/DefaultStatsPrinterPlugin.js +370 -101
- package/lib/stats/StatsFactory.js +127 -56
- package/lib/stats/StatsPrinter.js +75 -44
- package/lib/util/ArrayHelpers.js +8 -4
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +31 -12
- package/lib/util/IterableHelpers.js +3 -4
- package/lib/util/LazyBucketSortedSet.js +60 -44
- package/lib/util/LazySet.js +13 -0
- package/lib/util/MapHelpers.js +1 -3
- package/lib/util/ParallelismFactorCalculator.js +1 -1
- package/lib/util/Queue.js +1 -1
- package/lib/util/Semaphore.js +4 -7
- package/lib/util/SetHelpers.js +5 -5
- package/lib/util/SortableSet.js +4 -3
- package/lib/util/StackedCacheMap.js +4 -6
- package/lib/util/StackedMap.js +1 -3
- package/lib/util/StringXor.js +0 -5
- package/lib/util/TupleQueue.js +1 -1
- package/lib/util/TupleSet.js +15 -5
- package/lib/util/URLAbsoluteSpecifier.js +7 -7
- package/lib/util/WeakTupleMap.js +19 -21
- package/lib/util/binarySearchBounds.js +5 -12
- package/lib/util/chainedImports.js +1 -1
- package/lib/util/cleverMerge.js +21 -19
- package/lib/util/comparators.js +57 -52
- package/lib/util/compileBooleanMatcher.js +3 -6
- package/lib/util/conventions.js +8 -11
- package/lib/util/createHash.js +9 -6
- package/lib/util/deprecation.js +22 -12
- package/lib/util/deterministicGrouping.js +19 -26
- package/lib/util/findGraphRoots.js +2 -2
- package/lib/util/fs.js +32 -32
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/wasm-hash.js +7 -7
- package/lib/util/hash/xxhash64.js +2 -2
- package/lib/util/identifier.js +81 -59
- package/lib/util/memoize.js +8 -10
- package/lib/util/mergeScope.js +6 -9
- package/lib/util/nonNumericOnlyHash.js +2 -2
- package/lib/util/numberHash.js +1 -6
- package/lib/util/objectToMap.js +0 -1
- package/lib/util/propertyAccess.js +2 -5
- package/lib/util/propertyName.js +1 -3
- package/lib/util/registerExternalSerializer.js +1 -1
- package/lib/util/runtime.js +109 -113
- package/lib/util/semver.js +29 -27
- package/lib/util/serialization.js +16 -1
- package/lib/util/smartGrouping.js +5 -5
- package/lib/util/source.js +1 -1
- package/lib/wasm/EnableWasmLoadingPlugin.js +5 -4
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -6
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +20 -19
- package/lib/wasm-sync/WebAssemblyGenerator.js +14 -29
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -3
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +18 -17
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +5 -0
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
- package/types.d.ts +681 -355
@@ -36,7 +36,7 @@ function getScheme(specifier) {
|
|
36
36
|
(start < aLowerCaseCharCode || start > zLowerCaseCharCode) &&
|
37
37
|
(start < aUpperCaseCharCode || start > zUpperCaseCharCode)
|
38
38
|
) {
|
39
|
-
return
|
39
|
+
return;
|
40
40
|
}
|
41
41
|
|
42
42
|
let i = 1;
|
@@ -49,12 +49,12 @@ function getScheme(specifier) {
|
|
49
49
|
ch === plusCharCode ||
|
50
50
|
ch === hyphenCharCode
|
51
51
|
) {
|
52
|
-
if (++i === specifier.length) return
|
52
|
+
if (++i === specifier.length) return;
|
53
53
|
ch = specifier.charCodeAt(i);
|
54
54
|
}
|
55
55
|
|
56
56
|
// Scheme must end with colon
|
57
|
-
if (ch !== colonCharCode) return
|
57
|
+
if (ch !== colonCharCode) return;
|
58
58
|
|
59
59
|
// Check for Windows absolute path
|
60
60
|
// https://url.spec.whatwg.org/#url-miscellaneous
|
@@ -67,7 +67,7 @@ function getScheme(specifier) {
|
|
67
67
|
nextChar === hashCharCode ||
|
68
68
|
nextChar === queryCharCode
|
69
69
|
) {
|
70
|
-
return
|
70
|
+
return;
|
71
71
|
}
|
72
72
|
}
|
73
73
|
|
@@ -80,8 +80,8 @@ function getScheme(specifier) {
|
|
80
80
|
*/
|
81
81
|
function getProtocol(specifier) {
|
82
82
|
const scheme = getScheme(specifier);
|
83
|
-
return scheme === undefined ? undefined : scheme
|
83
|
+
return scheme === undefined ? undefined : `${scheme}:`;
|
84
84
|
}
|
85
85
|
|
86
|
-
exports.getScheme = getScheme;
|
87
|
-
exports.getProtocol = getProtocol;
|
86
|
+
module.exports.getScheme = getScheme;
|
87
|
+
module.exports.getProtocol = getProtocol;
|
package/lib/util/WeakTupleMap.js
CHANGED
@@ -83,7 +83,7 @@ class WeakTupleMap {
|
|
83
83
|
let node = this;
|
84
84
|
for (let i = 0; i < args.length; i++) {
|
85
85
|
node = node._peek(args[i]);
|
86
|
-
if (node === undefined) return
|
86
|
+
if (node === undefined) return;
|
87
87
|
}
|
88
88
|
return node._getValue();
|
89
89
|
}
|
@@ -158,12 +158,11 @@ class WeakTupleMap {
|
|
158
158
|
*/
|
159
159
|
_peek(thing) {
|
160
160
|
if (isWeakKey(thing)) {
|
161
|
-
if ((this.f & 4) !== 4) return
|
161
|
+
if ((this.f & 4) !== 4) return;
|
162
162
|
return /** @type {W<T, V>} */ (this.w).get(thing);
|
163
|
-
} else {
|
164
|
-
if ((this.f & 2) !== 2) return undefined;
|
165
|
-
return /** @type {M<T, V>} */ (this.m).get(thing);
|
166
163
|
}
|
164
|
+
if ((this.f & 2) !== 2) return;
|
165
|
+
return /** @type {M<T, V>} */ (this.m).get(thing);
|
167
166
|
}
|
168
167
|
|
169
168
|
/**
|
@@ -190,25 +189,24 @@ class WeakTupleMap {
|
|
190
189
|
/** @type {W<T, V>} */
|
191
190
|
(this.w).set(thing, newNode);
|
192
191
|
return newNode;
|
193
|
-
}
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
const newNode = new WeakTupleMap();
|
198
|
-
(this.m = newMap).set(thing, newNode);
|
199
|
-
return newNode;
|
200
|
-
}
|
201
|
-
const entry =
|
202
|
-
/** @type {M<T, V>} */
|
203
|
-
(this.m).get(thing);
|
204
|
-
if (entry !== undefined) {
|
205
|
-
return entry;
|
206
|
-
}
|
192
|
+
}
|
193
|
+
if ((this.f & 2) !== 2) {
|
194
|
+
const newMap = new Map();
|
195
|
+
this.f |= 2;
|
207
196
|
const newNode = new WeakTupleMap();
|
208
|
-
|
209
|
-
(this.m).set(thing, newNode);
|
197
|
+
(this.m = newMap).set(thing, newNode);
|
210
198
|
return newNode;
|
211
199
|
}
|
200
|
+
const entry =
|
201
|
+
/** @type {M<T, V>} */
|
202
|
+
(this.m).get(thing);
|
203
|
+
if (entry !== undefined) {
|
204
|
+
return entry;
|
205
|
+
}
|
206
|
+
const newNode = new WeakTupleMap();
|
207
|
+
/** @type {M<T, V>} */
|
208
|
+
(this.m).set(thing, newNode);
|
209
|
+
return newNode;
|
212
210
|
}
|
213
211
|
}
|
214
212
|
|
@@ -22,7 +22,6 @@
|
|
22
22
|
* ```js
|
23
23
|
* function P(a,l,h,y,c){var i=l-1;while(l<=h){var m=(l+h)>>>1,x=a[m];if(c(x,y)<=0){i=m;l=m+1}else{h=m-1}}return i};
|
24
24
|
* ```
|
25
|
-
*
|
26
25
|
* @param {string} funcName The name of the function to be compiled.
|
27
26
|
* @param {string} predicate The predicate / comparison operator to be used in the binary search.
|
28
27
|
* @param {boolean} reversed Whether the search should be reversed.
|
@@ -43,7 +42,7 @@ const compileSearch = (funcName, predicate, reversed, extraArgs, earlyOut) => {
|
|
43
42
|
];
|
44
43
|
|
45
44
|
if (earlyOut) {
|
46
|
-
if (predicate.
|
45
|
+
if (!predicate.includes("c")) {
|
47
46
|
code.push(";if(x===y){return m}else if(x<=y){");
|
48
47
|
} else {
|
49
48
|
code.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){");
|
@@ -70,7 +69,6 @@ const compileSearch = (funcName, predicate, reversed, extraArgs, earlyOut) => {
|
|
70
69
|
* A(): Performs a binary search on an array using the comparison operator specified.
|
71
70
|
* P(): Performs a binary search on an array using a _custom comparison function_
|
72
71
|
* `c(x,y)` **and** comparison operator specified by `predicate`.
|
73
|
-
*
|
74
72
|
* @param {BinarySearchPredicate} predicate The predicate / comparison operator to be used in the binary search.
|
75
73
|
* @param {boolean} reversed Whether the search should be reversed.
|
76
74
|
* @param {SearchPredicateSuffix} suffix The suffix to be used in the function name.
|
@@ -78,17 +76,11 @@ const compileSearch = (funcName, predicate, reversed, extraArgs, earlyOut) => {
|
|
78
76
|
* @returns {Function} The compiled binary search function.
|
79
77
|
*/
|
80
78
|
const compileBoundsSearch = (predicate, reversed, suffix, earlyOut) => {
|
81
|
-
const arg1 = compileSearch(
|
82
|
-
"A",
|
83
|
-
"x" + predicate + "y",
|
84
|
-
reversed,
|
85
|
-
["y"],
|
86
|
-
earlyOut
|
87
|
-
);
|
79
|
+
const arg1 = compileSearch("A", `x${predicate}y`, reversed, ["y"], earlyOut);
|
88
80
|
|
89
81
|
const arg2 = compileSearch(
|
90
82
|
"P",
|
91
|
-
|
83
|
+
`c(x,y)${predicate}0`,
|
92
84
|
reversed,
|
93
85
|
["y", "c"],
|
94
86
|
earlyOut
|
@@ -97,6 +89,7 @@ const compileBoundsSearch = (predicate, reversed, suffix, earlyOut) => {
|
|
97
89
|
const fnHeader = "function dispatchBinarySearch";
|
98
90
|
|
99
91
|
const fnBody =
|
92
|
+
// eslint-disable-next-line no-multi-str
|
100
93
|
"(a,y,c,l,h){\
|
101
94
|
if(typeof(c)==='function'){\
|
102
95
|
return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)\
|
@@ -107,13 +100,13 @@ return dispatchBinarySearch";
|
|
107
100
|
|
108
101
|
const fnArgList = [arg1, arg2, fnHeader, suffix, fnBody, suffix];
|
109
102
|
const fnSource = fnArgList.join("");
|
103
|
+
// eslint-disable-next-line no-new-func
|
110
104
|
const result = new Function(fnSource);
|
111
105
|
return result();
|
112
106
|
};
|
113
107
|
|
114
108
|
/**
|
115
109
|
* These functions are used to perform binary searches on arrays.
|
116
|
-
*
|
117
110
|
* @example
|
118
111
|
* ```js
|
119
112
|
* const { gt, le} = require("./binarySearchBounds");
|
@@ -23,7 +23,7 @@
|
|
23
23
|
* @param {Dependency} dependency dependency
|
24
24
|
* @returns {{trimmedIds: string[], trimmedRange: Range}} computed trimmed ids and cumulative range of those ids
|
25
25
|
*/
|
26
|
-
exports.getTrimmedIdsAndRange = (
|
26
|
+
module.exports.getTrimmedIdsAndRange = (
|
27
27
|
untrimmedIds,
|
28
28
|
untrimmedRange,
|
29
29
|
ranges,
|
package/lib/util/cleverMerge.js
CHANGED
@@ -23,15 +23,17 @@ const DYNAMIC_INFO = Symbol("cleverMerge dynamic info");
|
|
23
23
|
* // when same arguments passed, gets the result from WeakMap and returns it.
|
24
24
|
* cachedCleverMerge({a: 1}, {a: 2})
|
25
25
|
* {a: 2}
|
26
|
-
* @param {T} first first object
|
27
|
-
* @param {O} second second object
|
26
|
+
* @param {T | null | undefined} first first object
|
27
|
+
* @param {O | null | undefined} second second object
|
28
28
|
* @returns {T & O | T | O} merged object of first and second object
|
29
29
|
*/
|
30
30
|
const cachedCleverMerge = (first, second) => {
|
31
|
-
if (second === undefined) return first;
|
32
|
-
if (first === undefined) return second;
|
33
|
-
if (typeof second !== "object" || second === null)
|
34
|
-
|
31
|
+
if (second === undefined) return /** @type {T} */ (first);
|
32
|
+
if (first === undefined) return /** @type {O} */ (second);
|
33
|
+
if (typeof second !== "object" || second === null)
|
34
|
+
return /** @type {O} */ (second);
|
35
|
+
if (typeof first !== "object" || first === null)
|
36
|
+
return /** @type {T} */ (first);
|
35
37
|
|
36
38
|
let innerCache = mergeCache.get(first);
|
37
39
|
if (innerCache === undefined) {
|
@@ -229,7 +231,7 @@ const getValueType = value => {
|
|
229
231
|
} else if (value === DELETE) {
|
230
232
|
return VALUE_TYPE_DELETE;
|
231
233
|
} else if (Array.isArray(value)) {
|
232
|
-
if (value.
|
234
|
+
if (value.includes("...")) return VALUE_TYPE_ARRAY_EXTEND;
|
233
235
|
return VALUE_TYPE_ATOM;
|
234
236
|
} else if (
|
235
237
|
typeof value === "object" &&
|
@@ -550,21 +552,21 @@ const resolveByProperty = (obj, byProperty, ...values) => {
|
|
550
552
|
if (typeof obj !== "object" || obj === null || !(byProperty in obj)) {
|
551
553
|
return obj;
|
552
554
|
}
|
553
|
-
const { [byProperty]: _byValue, ..._remaining } =
|
555
|
+
const { [byProperty]: _byValue, ..._remaining } = obj;
|
554
556
|
const remaining = /** @type {T} */ (_remaining);
|
555
|
-
const byValue =
|
556
|
-
|
557
|
-
|
557
|
+
const byValue =
|
558
|
+
/** @type {Record<string, T> | function(...any[]): T} */
|
559
|
+
(_byValue);
|
558
560
|
if (typeof byValue === "object") {
|
559
561
|
const key = values[0];
|
560
562
|
if (key in byValue) {
|
561
563
|
return cachedCleverMerge(remaining, byValue[key]);
|
562
564
|
} else if ("default" in byValue) {
|
563
565
|
return cachedCleverMerge(remaining, byValue.default);
|
564
|
-
} else {
|
565
|
-
return /** @type {T} */ (remaining);
|
566
566
|
}
|
567
|
+
return remaining;
|
567
568
|
} else if (typeof byValue === "function") {
|
569
|
+
// eslint-disable-next-line prefer-spread
|
568
570
|
const result = byValue.apply(null, values);
|
569
571
|
return cachedCleverMerge(
|
570
572
|
remaining,
|
@@ -573,9 +575,9 @@ const resolveByProperty = (obj, byProperty, ...values) => {
|
|
573
575
|
}
|
574
576
|
};
|
575
577
|
|
576
|
-
exports.cachedSetProperty = cachedSetProperty;
|
577
|
-
exports.cachedCleverMerge = cachedCleverMerge;
|
578
|
-
exports.cleverMerge = cleverMerge;
|
579
|
-
exports.resolveByProperty = resolveByProperty;
|
580
|
-
exports.removeOperations = removeOperations;
|
581
|
-
exports.DELETE = DELETE;
|
578
|
+
module.exports.cachedSetProperty = cachedSetProperty;
|
579
|
+
module.exports.cachedCleverMerge = cachedCleverMerge;
|
580
|
+
module.exports.cleverMerge = cleverMerge;
|
581
|
+
module.exports.resolveByProperty = resolveByProperty;
|
582
|
+
module.exports.removeOperations = removeOperations;
|
583
|
+
module.exports.DELETE = DELETE;
|
package/lib/util/comparators.js
CHANGED
@@ -10,14 +10,26 @@ const { compareRuntime } = require("./runtime");
|
|
10
10
|
/** @typedef {import("../Chunk")} Chunk */
|
11
11
|
/** @typedef {import("../Chunk").ChunkId} ChunkId */
|
12
12
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
13
|
+
/** @typedef {import("../ChunkGraph").ModuleId} ModuleId */
|
13
14
|
/** @typedef {import("../ChunkGroup")} ChunkGroup */
|
14
15
|
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
15
16
|
/** @typedef {import("../Module")} Module */
|
16
17
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
17
18
|
|
18
|
-
/**
|
19
|
-
|
20
|
-
|
19
|
+
/**
|
20
|
+
* @template T
|
21
|
+
* @typedef {function(T, T): -1|0|1} Comparator
|
22
|
+
*/
|
23
|
+
/**
|
24
|
+
* @template TArg
|
25
|
+
* @template T
|
26
|
+
* @typedef {function(TArg, T, T): -1|0|1} RawParameterizedComparator
|
27
|
+
*/
|
28
|
+
/**
|
29
|
+
* @template TArg
|
30
|
+
* @template T
|
31
|
+
* @typedef {function(TArg): Comparator<T>} ParameterizedComparator
|
32
|
+
*/
|
21
33
|
|
22
34
|
/**
|
23
35
|
* @template T
|
@@ -46,21 +58,16 @@ const createCachedParameterizedComparator = fn => {
|
|
46
58
|
* @param {Chunk} b chunk
|
47
59
|
* @returns {-1|0|1} compare result
|
48
60
|
*/
|
49
|
-
exports.compareChunksById = (a, b) =>
|
50
|
-
|
51
|
-
/** @type {ChunkId} */ (a.id),
|
52
|
-
/** @type {ChunkId} */ (b.id)
|
53
|
-
);
|
54
|
-
};
|
61
|
+
module.exports.compareChunksById = (a, b) =>
|
62
|
+
compareIds(/** @type {ChunkId} */ (a.id), /** @type {ChunkId} */ (b.id));
|
55
63
|
|
56
64
|
/**
|
57
65
|
* @param {Module} a module
|
58
66
|
* @param {Module} b module
|
59
67
|
* @returns {-1|0|1} compare result
|
60
68
|
*/
|
61
|
-
exports.compareModulesByIdentifier = (a, b) =>
|
62
|
-
|
63
|
-
};
|
69
|
+
module.exports.compareModulesByIdentifier = (a, b) =>
|
70
|
+
compareIds(a.identifier(), b.identifier());
|
64
71
|
|
65
72
|
/**
|
66
73
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
@@ -68,11 +75,13 @@ exports.compareModulesByIdentifier = (a, b) => {
|
|
68
75
|
* @param {Module} b module
|
69
76
|
* @returns {-1|0|1} compare result
|
70
77
|
*/
|
71
|
-
const compareModulesById = (chunkGraph, a, b) =>
|
72
|
-
|
73
|
-
}
|
78
|
+
const compareModulesById = (chunkGraph, a, b) =>
|
79
|
+
compareIds(
|
80
|
+
/** @type {ModuleId} */ (chunkGraph.getModuleId(a)),
|
81
|
+
/** @type {ModuleId} */ (chunkGraph.getModuleId(b))
|
82
|
+
);
|
74
83
|
/** @type {ParameterizedComparator<ChunkGraph, Module>} */
|
75
|
-
exports.compareModulesById =
|
84
|
+
module.exports.compareModulesById =
|
76
85
|
createCachedParameterizedComparator(compareModulesById);
|
77
86
|
|
78
87
|
/**
|
@@ -88,7 +97,7 @@ const compareNumbers = (a, b) => {
|
|
88
97
|
if (a > b) return 1;
|
89
98
|
return 0;
|
90
99
|
};
|
91
|
-
exports.compareNumbers = compareNumbers;
|
100
|
+
module.exports.compareNumbers = compareNumbers;
|
92
101
|
|
93
102
|
/**
|
94
103
|
* @param {string} a string
|
@@ -160,7 +169,7 @@ const compareStringsNumeric = (a, b) => {
|
|
160
169
|
|
161
170
|
return 0;
|
162
171
|
};
|
163
|
-
exports.compareStringsNumeric = compareStringsNumeric;
|
172
|
+
module.exports.compareStringsNumeric = compareStringsNumeric;
|
164
173
|
|
165
174
|
/**
|
166
175
|
* @param {ModuleGraph} moduleGraph the module graph
|
@@ -177,7 +186,7 @@ const compareModulesByPostOrderIndexOrIdentifier = (moduleGraph, a, b) => {
|
|
177
186
|
return compareIds(a.identifier(), b.identifier());
|
178
187
|
};
|
179
188
|
/** @type {ParameterizedComparator<ModuleGraph, Module>} */
|
180
|
-
exports.compareModulesByPostOrderIndexOrIdentifier =
|
189
|
+
module.exports.compareModulesByPostOrderIndexOrIdentifier =
|
181
190
|
createCachedParameterizedComparator(
|
182
191
|
compareModulesByPostOrderIndexOrIdentifier
|
183
192
|
);
|
@@ -197,7 +206,7 @@ const compareModulesByPreOrderIndexOrIdentifier = (moduleGraph, a, b) => {
|
|
197
206
|
return compareIds(a.identifier(), b.identifier());
|
198
207
|
};
|
199
208
|
/** @type {ParameterizedComparator<ModuleGraph, Module>} */
|
200
|
-
exports.compareModulesByPreOrderIndexOrIdentifier =
|
209
|
+
module.exports.compareModulesByPreOrderIndexOrIdentifier =
|
201
210
|
createCachedParameterizedComparator(
|
202
211
|
compareModulesByPreOrderIndexOrIdentifier
|
203
212
|
);
|
@@ -209,14 +218,16 @@ exports.compareModulesByPreOrderIndexOrIdentifier =
|
|
209
218
|
* @returns {-1|0|1} compare result
|
210
219
|
*/
|
211
220
|
const compareModulesByIdOrIdentifier = (chunkGraph, a, b) => {
|
212
|
-
const cmp = compareIds(
|
221
|
+
const cmp = compareIds(
|
222
|
+
/** @type {ModuleId} */ (chunkGraph.getModuleId(a)),
|
223
|
+
/** @type {ModuleId} */ (chunkGraph.getModuleId(b))
|
224
|
+
);
|
213
225
|
if (cmp !== 0) return cmp;
|
214
226
|
return compareIds(a.identifier(), b.identifier());
|
215
227
|
};
|
216
228
|
/** @type {ParameterizedComparator<ChunkGraph, Module>} */
|
217
|
-
exports.compareModulesByIdOrIdentifier =
|
218
|
-
compareModulesByIdOrIdentifier
|
219
|
-
);
|
229
|
+
module.exports.compareModulesByIdOrIdentifier =
|
230
|
+
createCachedParameterizedComparator(compareModulesByIdOrIdentifier);
|
220
231
|
|
221
232
|
/**
|
222
233
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
@@ -224,11 +235,10 @@ exports.compareModulesByIdOrIdentifier = createCachedParameterizedComparator(
|
|
224
235
|
* @param {Chunk} b chunk
|
225
236
|
* @returns {-1|0|1} compare result
|
226
237
|
*/
|
227
|
-
const compareChunks = (chunkGraph, a, b) =>
|
228
|
-
return chunkGraph.compareChunks(a, b);
|
229
|
-
};
|
238
|
+
const compareChunks = (chunkGraph, a, b) => chunkGraph.compareChunks(a, b);
|
230
239
|
/** @type {ParameterizedComparator<ChunkGraph, Chunk>} */
|
231
|
-
exports.compareChunks =
|
240
|
+
module.exports.compareChunks =
|
241
|
+
createCachedParameterizedComparator(compareChunks);
|
232
242
|
|
233
243
|
/**
|
234
244
|
* @param {string|number} a first id
|
@@ -244,7 +254,7 @@ const compareIds = (a, b) => {
|
|
244
254
|
return 0;
|
245
255
|
};
|
246
256
|
|
247
|
-
exports.compareIds = compareIds;
|
257
|
+
module.exports.compareIds = compareIds;
|
248
258
|
|
249
259
|
/**
|
250
260
|
* @param {string} a first string
|
@@ -257,20 +267,16 @@ const compareStrings = (a, b) => {
|
|
257
267
|
return 0;
|
258
268
|
};
|
259
269
|
|
260
|
-
exports.compareStrings = compareStrings;
|
270
|
+
module.exports.compareStrings = compareStrings;
|
261
271
|
|
262
272
|
/**
|
263
273
|
* @param {ChunkGroup} a first chunk group
|
264
274
|
* @param {ChunkGroup} b second chunk group
|
265
275
|
* @returns {-1|0|1} compare result
|
266
276
|
*/
|
267
|
-
const compareChunkGroupsByIndex = (a, b) =>
|
268
|
-
|
269
|
-
|
270
|
-
: 1;
|
271
|
-
};
|
272
|
-
|
273
|
-
exports.compareChunkGroupsByIndex = compareChunkGroupsByIndex;
|
277
|
+
const compareChunkGroupsByIndex = (a, b) =>
|
278
|
+
/** @type {number} */ (a.index) < /** @type {number} */ (b.index) ? -1 : 1;
|
279
|
+
module.exports.compareChunkGroupsByIndex = compareChunkGroupsByIndex;
|
274
280
|
|
275
281
|
/**
|
276
282
|
* @template K1 {Object}
|
@@ -294,7 +300,7 @@ class TwoKeyWeakMap {
|
|
294
300
|
get(key1, key2) {
|
295
301
|
const childMap = this._map.get(key1);
|
296
302
|
if (childMap === undefined) {
|
297
|
-
return
|
303
|
+
return;
|
298
304
|
}
|
299
305
|
return childMap.get(key2);
|
300
306
|
}
|
@@ -347,7 +353,7 @@ const concatComparators = (c1, c2, ...cRest) => {
|
|
347
353
|
concatComparatorsCache.set(c1, c2, result);
|
348
354
|
return result;
|
349
355
|
};
|
350
|
-
exports.concatComparators = concatComparators;
|
356
|
+
module.exports.concatComparators = concatComparators;
|
351
357
|
|
352
358
|
/**
|
353
359
|
* @template A, B
|
@@ -380,17 +386,16 @@ const compareSelect = (getter, comparator) => {
|
|
380
386
|
return comparator(aValue, bValue);
|
381
387
|
}
|
382
388
|
return -1;
|
383
|
-
} else {
|
384
|
-
if (bValue !== undefined && bValue !== null) {
|
385
|
-
return 1;
|
386
|
-
}
|
387
|
-
return 0;
|
388
389
|
}
|
390
|
+
if (bValue !== undefined && bValue !== null) {
|
391
|
+
return 1;
|
392
|
+
}
|
393
|
+
return 0;
|
389
394
|
};
|
390
395
|
compareSelectCache.set(getter, comparator, result);
|
391
396
|
return result;
|
392
397
|
};
|
393
|
-
exports.compareSelect = compareSelect;
|
398
|
+
module.exports.compareSelect = compareSelect;
|
394
399
|
|
395
400
|
/** @type {WeakMap<Comparator<any>, Comparator<Iterable<any>>>} */
|
396
401
|
const compareIteratorsCache = new WeakMap();
|
@@ -426,7 +431,7 @@ const compareIterables = elementComparator => {
|
|
426
431
|
compareIteratorsCache.set(elementComparator, result);
|
427
432
|
return result;
|
428
433
|
};
|
429
|
-
exports.compareIterables = compareIterables;
|
434
|
+
module.exports.compareIterables = compareIterables;
|
430
435
|
|
431
436
|
// TODO this is no longer needed when minimum node.js version is >= 12
|
432
437
|
// since these versions ship with a stable sort function
|
@@ -435,7 +440,7 @@ exports.compareIterables = compareIterables;
|
|
435
440
|
* @param {Iterable<T>} iterable original ordered list
|
436
441
|
* @returns {Comparator<T>} comparator
|
437
442
|
*/
|
438
|
-
exports.keepOriginalOrder = iterable => {
|
443
|
+
module.exports.keepOriginalOrder = iterable => {
|
439
444
|
/** @type {Map<T, number>} */
|
440
445
|
const map = new Map();
|
441
446
|
let i = 0;
|
@@ -453,8 +458,8 @@ exports.keepOriginalOrder = iterable => {
|
|
453
458
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
454
459
|
* @returns {Comparator<Chunk>} comparator
|
455
460
|
*/
|
456
|
-
exports.compareChunksNatural = chunkGraph => {
|
457
|
-
const cmpFn = exports.compareModulesById(chunkGraph);
|
461
|
+
module.exports.compareChunksNatural = chunkGraph => {
|
462
|
+
const cmpFn = module.exports.compareModulesById(chunkGraph);
|
458
463
|
const cmpIterableFn = compareIterables(cmpFn);
|
459
464
|
return concatComparators(
|
460
465
|
compareSelect(
|
@@ -479,9 +484,9 @@ exports.compareChunksNatural = chunkGraph => {
|
|
479
484
|
* @param {DependencyLocation} b A location node
|
480
485
|
* @returns {-1|0|1} sorting comparator value
|
481
486
|
*/
|
482
|
-
exports.compareLocations = (a, b) => {
|
483
|
-
|
484
|
-
|
487
|
+
module.exports.compareLocations = (a, b) => {
|
488
|
+
const isObjectA = typeof a === "object" && a !== null;
|
489
|
+
const isObjectB = typeof b === "object" && b !== null;
|
485
490
|
if (!isObjectA || !isObjectB) {
|
486
491
|
if (isObjectA) return 1;
|
487
492
|
if (isObjectB) return -1;
|
@@ -9,16 +9,14 @@
|
|
9
9
|
* @param {string} str string
|
10
10
|
* @returns {string} quoted meta
|
11
11
|
*/
|
12
|
-
const quoteMeta = str => {
|
13
|
-
return str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&");
|
14
|
-
};
|
12
|
+
const quoteMeta = str => str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&");
|
15
13
|
|
16
14
|
/**
|
17
15
|
* @param {string} str string
|
18
16
|
* @returns {string} string
|
19
17
|
*/
|
20
18
|
const toSimpleString = str => {
|
21
|
-
if (`${
|
19
|
+
if (`${Number(str)}` === str) {
|
22
20
|
return str;
|
23
21
|
}
|
24
22
|
return JSON.stringify(str);
|
@@ -52,9 +50,8 @@ const compileBooleanMatcherFromLists = (positiveItems, negativeItems) => {
|
|
52
50
|
const negativeRegexp = itemsToRegexp(negativeItems);
|
53
51
|
if (positiveRegexp.length <= negativeRegexp.length) {
|
54
52
|
return value => `/^${positiveRegexp}$/.test(${value})`;
|
55
|
-
} else {
|
56
|
-
return value => `!/^${negativeRegexp}$/.test(${value})`;
|
57
53
|
}
|
54
|
+
return value => `!/^${negativeRegexp}$/.test(${value})`;
|
58
55
|
};
|
59
56
|
|
60
57
|
/**
|
package/lib/util/conventions.js
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
* @param {CssGeneratorExportsConvention | undefined} convention convention
|
13
13
|
* @returns {string[]} results
|
14
14
|
*/
|
15
|
-
exports.cssExportConvention = (input, convention) => {
|
15
|
+
module.exports.cssExportConvention = (input, convention) => {
|
16
16
|
const set = new Set();
|
17
17
|
if (typeof convention === "function") {
|
18
18
|
set.add(convention(input));
|
@@ -20,20 +20,20 @@ exports.cssExportConvention = (input, convention) => {
|
|
20
20
|
switch (convention) {
|
21
21
|
case "camel-case": {
|
22
22
|
set.add(input);
|
23
|
-
set.add(exports.camelCase(input));
|
23
|
+
set.add(module.exports.camelCase(input));
|
24
24
|
break;
|
25
25
|
}
|
26
26
|
case "camel-case-only": {
|
27
|
-
set.add(exports.camelCase(input));
|
27
|
+
set.add(module.exports.camelCase(input));
|
28
28
|
break;
|
29
29
|
}
|
30
30
|
case "dashes": {
|
31
31
|
set.add(input);
|
32
|
-
set.add(exports.dashesCamelCase(input));
|
32
|
+
set.add(module.exports.dashesCamelCase(input));
|
33
33
|
break;
|
34
34
|
}
|
35
35
|
case "dashes-only": {
|
36
|
-
set.add(exports.dashesCamelCase(input));
|
36
|
+
set.add(module.exports.dashesCamelCase(input));
|
37
37
|
break;
|
38
38
|
}
|
39
39
|
case "as-is": {
|
@@ -50,18 +50,15 @@ exports.cssExportConvention = (input, convention) => {
|
|
50
50
|
* @param {string} input input
|
51
51
|
* @returns {string} result
|
52
52
|
*/
|
53
|
-
exports.dashesCamelCase = input =>
|
54
|
-
|
55
|
-
firstLetter.toUpperCase()
|
56
|
-
);
|
57
|
-
};
|
53
|
+
module.exports.dashesCamelCase = input =>
|
54
|
+
input.replace(/-+(\w)/g, (match, firstLetter) => firstLetter.toUpperCase());
|
58
55
|
|
59
56
|
// Copy from css-loader
|
60
57
|
/**
|
61
58
|
* @param {string} input input
|
62
59
|
* @returns {string} result
|
63
60
|
*/
|
64
|
-
exports.camelCase = input => {
|
61
|
+
module.exports.camelCase = input => {
|
65
62
|
let result = input.trim();
|
66
63
|
|
67
64
|
if (result.length === 0) {
|
package/lib/util/createHash.js
CHANGED
@@ -128,26 +128,29 @@ class DebugHash extends Hash {
|
|
128
128
|
* @returns {string|Buffer} digest
|
129
129
|
*/
|
130
130
|
digest(encoding) {
|
131
|
-
return Buffer.from(
|
131
|
+
return Buffer.from(`@webpack-debug-digest@${this.string}`).toString("hex");
|
132
132
|
}
|
133
133
|
}
|
134
134
|
|
135
135
|
/** @type {typeof import("crypto") | undefined} */
|
136
|
-
let crypto
|
136
|
+
let crypto;
|
137
137
|
/** @type {typeof import("./hash/xxhash64") | undefined} */
|
138
|
-
let createXXHash64
|
138
|
+
let createXXHash64;
|
139
139
|
/** @type {typeof import("./hash/md4") | undefined} */
|
140
|
-
let createMd4
|
140
|
+
let createMd4;
|
141
141
|
/** @type {typeof import("./hash/BatchedHash") | undefined} */
|
142
|
-
let BatchedHash
|
142
|
+
let BatchedHash;
|
143
|
+
|
144
|
+
/** @typedef {string | typeof Hash} Algorithm */
|
143
145
|
|
144
146
|
/**
|
145
147
|
* Creates a hash by name or function
|
146
|
-
* @param {
|
148
|
+
* @param {Algorithm} algorithm the algorithm name or a constructor creating a hash
|
147
149
|
* @returns {Hash} the hash
|
148
150
|
*/
|
149
151
|
module.exports = algorithm => {
|
150
152
|
if (typeof algorithm === "function") {
|
153
|
+
// eslint-disable-next-line new-cap
|
151
154
|
return new BulkUpdateDecorator(() => new algorithm());
|
152
155
|
}
|
153
156
|
switch (algorithm) {
|