webpack 5.99.9 → 5.100.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/bin/webpack.js +8 -2
- package/hot/log.js +15 -15
- package/hot/poll.js +1 -0
- package/lib/APIPlugin.js +3 -3
- package/lib/AbstractMethodError.js +1 -0
- package/lib/AutomaticPrefetchPlugin.js +1 -0
- package/lib/BannerPlugin.js +1 -1
- package/lib/CaseSensitiveModulesWarning.js +4 -4
- package/lib/Chunk.js +6 -6
- package/lib/ChunkGraph.js +37 -31
- package/lib/ChunkGroup.js +4 -4
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +94 -17
- package/lib/CodeGenerationResults.js +1 -1
- package/lib/CompatibilityPlugin.js +5 -2
- package/lib/Compilation.js +67 -45
- package/lib/Compiler.js +46 -16
- package/lib/ConcatenationScope.js +15 -6
- package/lib/ConstPlugin.js +5 -3
- package/lib/ContextModule.js +16 -12
- package/lib/ContextModuleFactory.js +4 -3
- package/lib/ContextReplacementPlugin.js +4 -2
- package/lib/CssModule.js +2 -2
- package/lib/DefinePlugin.js +111 -3
- package/lib/DelegatedModuleFactoryPlugin.js +18 -18
- package/lib/Dependency.js +6 -1
- package/lib/DependencyTemplate.js +1 -0
- package/lib/DllEntryPlugin.js +3 -1
- package/lib/DllPlugin.js +4 -3
- package/lib/DllReferencePlugin.js +2 -2
- package/lib/DynamicEntryPlugin.js +1 -1
- package/lib/EntryOptionPlugin.js +5 -0
- package/lib/ErrorHelpers.js +4 -4
- package/lib/EvalDevToolModulePlugin.js +3 -3
- package/lib/EvalSourceMapDevToolPlugin.js +7 -7
- package/lib/ExportsInfo.js +48 -39
- package/lib/ExternalModule.js +15 -11
- package/lib/ExternalModuleFactoryPlugin.js +5 -2
- package/lib/FileSystemInfo.js +51 -36
- package/lib/FlagDependencyExportsPlugin.js +14 -7
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/Generator.js +14 -1
- package/lib/HookWebpackError.js +1 -0
- package/lib/HotModuleReplacementPlugin.js +77 -50
- package/lib/IgnorePlugin.js +1 -1
- package/lib/InvalidDependenciesModuleWarning.js +1 -1
- package/lib/JavascriptMetaInfoPlugin.js +0 -1
- package/lib/LibManifestPlugin.js +4 -2
- package/lib/LoaderOptionsPlugin.js +6 -4
- package/lib/MainTemplate.js +2 -2
- package/lib/Module.js +21 -6
- package/lib/ModuleFactory.js +1 -0
- package/lib/ModuleGraph.js +24 -2
- package/lib/ModuleGraphConnection.js +5 -5
- package/lib/ModuleInfoHeaderPlugin.js +2 -1
- package/lib/ModuleParseError.js +1 -0
- package/lib/ModuleSourceTypesConstants.js +12 -12
- package/lib/ModuleTemplate.js +1 -1
- package/lib/ModuleTypeConstants.js +21 -21
- package/lib/MultiCompiler.js +6 -6
- package/lib/NormalModule.js +31 -44
- package/lib/NormalModuleFactory.js +29 -19
- package/lib/NormalModuleReplacementPlugin.js +1 -1
- package/lib/NullFactory.js +1 -0
- package/lib/OptimizationStages.js +1 -1
- package/lib/Parser.js +1 -0
- package/lib/ProgressPlugin.js +12 -5
- package/lib/ProvidePlugin.js +5 -1
- package/lib/RecordIdsPlugin.js +3 -3
- package/lib/RuntimeGlobals.js +175 -155
- package/lib/RuntimeModule.js +1 -0
- package/lib/RuntimePlugin.js +33 -7
- package/lib/RuntimeTemplate.js +111 -11
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +15 -25
- package/lib/SourceMapDevToolPlugin.js +19 -17
- package/lib/Template.js +2 -2
- package/lib/TemplatedPathPlugin.js +1 -1
- package/lib/WarnDeprecatedOptionPlugin.js +7 -8
- package/lib/WatchIgnorePlugin.js +4 -3
- package/lib/WebpackIsIncludedPlugin.js +2 -1
- package/lib/WebpackOptionsApply.js +115 -27
- package/lib/asset/AssetGenerator.js +15 -11
- package/lib/asset/AssetModulesPlugin.js +19 -17
- package/lib/asset/AssetSourceGenerator.js +4 -4
- package/lib/asset/RawDataUrlModule.js +4 -2
- package/lib/async-modules/AwaitDependenciesInitFragment.js +1 -1
- package/lib/buildChunkGraph.js +6 -3
- package/lib/cache/AddBuildDependenciesPlugin.js +5 -6
- package/lib/cache/IdleFileCachePlugin.js +7 -4
- package/lib/cache/MemoryCachePlugin.js +1 -0
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +26 -20
- package/lib/cache/ResolverCachePlugin.js +16 -8
- package/lib/cli.js +15 -10
- package/lib/config/browserslistTargetHandler.js +3 -3
- package/lib/config/defaults.js +25 -17
- package/lib/config/normalization.js +2 -1
- package/lib/config/target.js +6 -5
- package/lib/container/ContainerPlugin.js +1 -1
- package/lib/container/ContainerReferencePlugin.js +1 -1
- package/lib/container/FallbackModule.js +2 -1
- package/lib/container/HoistContainerReferencesPlugin.js +1 -1
- package/lib/container/ModuleFederationPlugin.js +2 -2
- package/lib/container/RemoteModule.js +1 -1
- package/lib/css/CssGenerator.js +9 -6
- package/lib/css/CssModulesPlugin.js +44 -31
- package/lib/css/CssParser.js +6 -4
- package/lib/css/walkCssTokens.js +33 -37
- package/lib/debug/ProfilingPlugin.js +6 -6
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -8
- package/lib/dependencies/AMDPlugin.js +12 -8
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +28 -26
- package/lib/dependencies/CachedConstDependency.js +1 -5
- package/lib/dependencies/CommonJsExportRequireDependency.js +6 -4
- package/lib/dependencies/CommonJsExportsParserPlugin.js +22 -25
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -9
- package/lib/dependencies/CommonJsImportsParserPlugin.js +100 -114
- package/lib/dependencies/CommonJsPlugin.js +15 -16
- package/lib/dependencies/ContextDependencyHelpers.js +2 -1
- package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -0
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +1 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/DynamicExports.js +9 -9
- package/lib/dependencies/ExportsInfoDependency.js +1 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +122 -101
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +95 -19
- package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
- package/lib/dependencies/HarmonyImportDependency.js +11 -5
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +238 -162
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +20 -9
- package/lib/dependencies/HarmonyModulesPlugin.js +23 -12
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
- package/lib/dependencies/ImportMetaContextPlugin.js +2 -1
- package/lib/dependencies/ImportMetaPlugin.js +2 -2
- package/lib/dependencies/ImportParserPlugin.js +40 -9
- package/lib/dependencies/ImportPlugin.js +3 -1
- package/lib/dependencies/LoaderPlugin.js +1 -0
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +1 -0
- package/lib/dependencies/RequireContextPlugin.js +3 -1
- package/lib/dependencies/RequireEnsurePlugin.js +6 -6
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +33 -34
- package/lib/dependencies/RequireIncludePlugin.js +1 -0
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/URLContextDependency.js +65 -0
- package/lib/dependencies/URLPlugin.js +17 -157
- package/lib/dependencies/WorkerPlugin.js +23 -10
- package/lib/dependencies/processExportInfo.js +2 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +269 -185
- package/lib/esm/ModuleChunkLoadingPlugin.js +39 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +70 -3
- package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
- package/lib/hmr/JavascriptHotModuleReplacementHelper.js +37 -0
- package/lib/hmr/LazyCompilationPlugin.js +4 -2
- package/lib/hmr/lazyCompilationBackend.js +4 -2
- package/lib/ids/ChunkModuleIdRangePlugin.js +6 -3
- package/lib/ids/DeterministicChunkIdsPlugin.js +30 -35
- package/lib/ids/DeterministicModuleIdsPlugin.js +4 -3
- package/lib/ids/HashedModuleIdsPlugin.js +5 -4
- package/lib/ids/IdHelpers.js +21 -17
- package/lib/ids/NamedChunkIdsPlugin.js +5 -5
- package/lib/ids/NamedModuleIdsPlugin.js +4 -4
- package/lib/ids/NaturalChunkIdsPlugin.js +2 -1
- package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +3 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +1 -1
- package/lib/ids/SyncModuleIdsPlugin.js +1 -1
- package/lib/index.js +13 -3
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +113 -119
- package/lib/javascript/BasicEvaluatedExpression.js +2 -1
- package/lib/javascript/ChunkHelpers.js +1 -0
- package/lib/javascript/CommonJsChunkFormatPlugin.js +121 -136
- package/lib/javascript/EnableChunkLoadingPlugin.js +6 -3
- package/lib/javascript/JavascriptGenerator.js +14 -2
- package/lib/javascript/JavascriptModulesPlugin.js +68 -27
- package/lib/javascript/JavascriptParser.js +117 -76
- package/lib/javascript/JavascriptParserHelpers.js +41 -41
- package/lib/javascript/StartupHelpers.js +17 -17
- package/lib/json/JsonGenerator.js +4 -2
- package/lib/json/JsonModulesPlugin.js +2 -2
- package/lib/json/JsonParser.js +1 -1
- package/lib/library/AbstractLibraryPlugin.js +6 -2
- package/lib/library/AssignLibraryPlugin.js +21 -6
- package/lib/library/EnableLibraryPlugin.js +23 -3
- package/lib/library/UmdLibraryPlugin.js +15 -6
- package/lib/logging/createConsoleLogger.js +3 -3
- package/lib/logging/runtime.js +9 -9
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +4 -22
- package/lib/node/RequireChunkLoadingRuntimeModule.js +4 -22
- package/lib/node/nodeConsole.js +4 -2
- package/lib/optimize/AggressiveMergingPlugin.js +45 -46
- package/lib/optimize/AggressiveSplittingPlugin.js +13 -12
- package/lib/optimize/ConcatenatedModule.js +227 -57
- package/lib/optimize/EnsureChunkConditionsPlugin.js +58 -58
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -1
- package/lib/optimize/InnerGraph.js +115 -112
- package/lib/optimize/InnerGraphPlugin.js +2 -2
- package/lib/optimize/LimitChunkCountPlugin.js +4 -2
- package/lib/optimize/MangleExportsPlugin.js +4 -3
- package/lib/optimize/MergeDuplicateChunksPlugin.js +80 -81
- package/lib/optimize/MinChunkSizePlugin.js +6 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +31 -22
- package/lib/optimize/RealContentHashPlugin.js +26 -20
- package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -1
- package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -2
- package/lib/optimize/SplitChunksPlugin.js +16 -13
- package/lib/rules/BasicEffectRulePlugin.js +4 -2
- package/lib/rules/BasicMatcherRulePlugin.js +3 -1
- package/lib/rules/ObjectMatcherRulePlugin.js +3 -1
- package/lib/rules/RuleSetCompiler.js +6 -3
- package/lib/rules/UseEffectRulePlugin.js +3 -1
- package/lib/runtime/AsyncModuleRuntimeModule.js +64 -9
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +1 -1
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +214 -0
- package/lib/runtime/RuntimeIdRuntimeModule.js +2 -1
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +8 -7
- package/lib/schemes/FileUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +27 -19
- package/lib/schemes/VirtualUrlPlugin.js +222 -0
- package/lib/serialization/AggregateErrorSerializer.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +5 -4
- package/lib/serialization/FileMiddleware.js +7 -4
- package/lib/serialization/ObjectMiddleware.js +14 -8
- package/lib/serialization/Serializer.js +5 -3
- package/lib/serialization/SerializerMiddleware.js +2 -0
- package/lib/sharing/ConsumeSharedModule.js +1 -1
- package/lib/sharing/ConsumeSharedPlugin.js +3 -3
- package/lib/sharing/ConsumeSharedRuntimeModule.js +2 -2
- package/lib/sharing/ProvideSharedModule.js +1 -1
- package/lib/sharing/ProvideSharedPlugin.js +3 -2
- package/lib/sharing/SharePlugin.js +2 -1
- package/lib/sharing/ShareRuntimeModule.js +3 -5
- package/lib/sharing/utils.js +34 -34
- package/lib/stats/DefaultStatsFactoryPlugin.js +49 -46
- package/lib/stats/DefaultStatsPresetPlugin.js +4 -2
- package/lib/stats/DefaultStatsPrinterPlugin.js +15 -9
- package/lib/stats/StatsFactory.js +4 -2
- package/lib/stats/StatsPrinter.js +3 -2
- package/lib/url/URLParserPlugin.js +266 -0
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/Hash.js +2 -0
- package/lib/util/IterableHelpers.js +1 -1
- package/lib/util/LazyBucketSortedSet.js +2 -1
- package/lib/util/LazySet.js +11 -6
- package/lib/util/ParallelismFactorCalculator.js +1 -1
- package/lib/util/SetHelpers.js +3 -3
- package/lib/util/SortableSet.js +2 -2
- package/lib/util/StackedCacheMap.js +3 -1
- package/lib/util/StackedMap.js +2 -2
- package/lib/util/StringXor.js +1 -0
- package/lib/util/TupleSet.js +1 -0
- package/lib/util/URLAbsoluteSpecifier.js +1 -1
- package/lib/util/cleverMerge.js +12 -8
- package/lib/util/comparators.js +154 -127
- package/lib/util/compileBooleanMatcher.js +8 -3
- package/lib/util/concatenate.js +8 -7
- package/lib/util/conventions.js +72 -73
- package/lib/util/create-schema-validation.js +2 -1
- package/lib/util/createHash.js +10 -4
- package/lib/util/deprecation.js +69 -66
- package/lib/util/deterministicGrouping.js +4 -2
- package/lib/util/extractUrlAndGlobal.js +1 -1
- package/lib/util/findGraphRoots.js +2 -2
- package/lib/util/fs.js +30 -23
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/wasm-hash.js +4 -2
- package/lib/util/identifier.js +13 -12
- package/lib/util/internalSerializables.js +2 -0
- package/lib/util/magicComment.js +5 -5
- package/lib/util/processAsyncTree.js +1 -1
- package/lib/util/propertyAccess.js +1 -1
- package/lib/util/propertyName.js +1 -1
- package/lib/util/registerExternalSerializer.js +1 -2
- package/lib/util/removeBOM.js +1 -1
- package/lib/util/runtime.js +29 -21
- package/lib/util/semver.js +1 -1
- package/lib/util/serialization.js +3 -0
- package/lib/util/source.js +3 -2
- package/lib/validateSchema.js +1 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +6 -3
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +46 -49
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
- package/lib/wasm-sync/WebAssemblyGenerator.js +2 -3
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +3 -2
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +3 -0
- package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -22
- package/lib/webpack.js +4 -5
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -24
- package/lib/webworker/WebWorkerTemplatePlugin.js +1 -0
- package/package.json +119 -113
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +17 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.d.ts +7 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +6 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +77 -0
- package/types.d.ts +1230 -360
package/lib/util/cleverMerge.js
CHANGED
|
@@ -30,10 +30,12 @@ const DYNAMIC_INFO = Symbol("cleverMerge dynamic info");
|
|
|
30
30
|
const cachedCleverMerge = (first, second) => {
|
|
31
31
|
if (second === undefined) return /** @type {T} */ (first);
|
|
32
32
|
if (first === undefined) return /** @type {O} */ (second);
|
|
33
|
-
if (typeof second !== "object" || second === null)
|
|
33
|
+
if (typeof second !== "object" || second === null) {
|
|
34
34
|
return /** @type {O} */ (second);
|
|
35
|
-
|
|
35
|
+
}
|
|
36
|
+
if (typeof first !== "object" || first === null) {
|
|
36
37
|
return /** @type {T} */ (first);
|
|
38
|
+
}
|
|
37
39
|
|
|
38
40
|
let innerCache = mergeCache.get(first);
|
|
39
41
|
if (innerCache === undefined) {
|
|
@@ -171,9 +173,10 @@ const parseObject = obj => {
|
|
|
171
173
|
/** @type {ByValues<V>} */
|
|
172
174
|
(entry.byValues).has(otherByValue)
|
|
173
175
|
)
|
|
174
|
-
)
|
|
176
|
+
) {
|
|
175
177
|
/** @type {ByValues<V>} */
|
|
176
178
|
(entry.byValues).set(otherByValue, undefined);
|
|
179
|
+
}
|
|
177
180
|
}
|
|
178
181
|
}
|
|
179
182
|
}
|
|
@@ -424,7 +427,7 @@ const mergeEntries = (firstEntry, secondEntry, internalCaching) => {
|
|
|
424
427
|
);
|
|
425
428
|
}
|
|
426
429
|
if (
|
|
427
|
-
|
|
430
|
+
[...firstEntry.byValues.values()].every(value => {
|
|
428
431
|
const type = getValueType(value);
|
|
429
432
|
return type === VALUE_TYPE_ATOM || type === VALUE_TYPE_DELETE;
|
|
430
433
|
})
|
|
@@ -438,8 +441,9 @@ const mergeEntries = (firstEntry, secondEntry, internalCaching) => {
|
|
|
438
441
|
} else {
|
|
439
442
|
// = first.base + ((first.byProperty (+default) + second.base) + second.byProperty)
|
|
440
443
|
newBase = firstEntry.base;
|
|
441
|
-
if (!intermediateByValues.has("default"))
|
|
444
|
+
if (!intermediateByValues.has("default")) {
|
|
442
445
|
intermediateByValues.set("default", secondEntry.base);
|
|
446
|
+
}
|
|
443
447
|
}
|
|
444
448
|
if (!secondEntry.byProperty) {
|
|
445
449
|
// = first.base + (first.byProperty + second.base)
|
|
@@ -629,9 +633,9 @@ const resolveByProperty = (obj, byProperty, ...values) => {
|
|
|
629
633
|
return obj;
|
|
630
634
|
};
|
|
631
635
|
|
|
632
|
-
module.exports.
|
|
636
|
+
module.exports.DELETE = DELETE;
|
|
633
637
|
module.exports.cachedCleverMerge = cachedCleverMerge;
|
|
638
|
+
module.exports.cachedSetProperty = cachedSetProperty;
|
|
634
639
|
module.exports.cleverMerge = cleverMerge;
|
|
635
|
-
module.exports.resolveByProperty = resolveByProperty;
|
|
636
640
|
module.exports.removeOperations = removeOperations;
|
|
637
|
-
module.exports.
|
|
641
|
+
module.exports.resolveByProperty = resolveByProperty;
|
package/lib/util/comparators.js
CHANGED
|
@@ -55,20 +55,113 @@ const createCachedParameterizedComparator = fn => {
|
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
* @param {
|
|
59
|
-
* @param {
|
|
60
|
-
* @returns {-1|0|1} compare result
|
|
58
|
+
* @param {string | number} a first id
|
|
59
|
+
* @param {string | number} b second id
|
|
60
|
+
* @returns {-1 | 0 | 1} compare result
|
|
61
61
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
const compareIds = (a, b) => {
|
|
63
|
+
if (typeof a !== typeof b) {
|
|
64
|
+
return typeof a < typeof b ? -1 : 1;
|
|
65
|
+
}
|
|
66
|
+
if (a < b) return -1;
|
|
67
|
+
if (a > b) return 1;
|
|
68
|
+
return 0;
|
|
69
|
+
};
|
|
64
70
|
|
|
65
71
|
/**
|
|
66
|
-
* @
|
|
67
|
-
* @param {
|
|
68
|
-
* @returns {
|
|
72
|
+
* @template T
|
|
73
|
+
* @param {Comparator<T>} elementComparator comparator for elements
|
|
74
|
+
* @returns {Comparator<Iterable<T>>} comparator for iterables of elements
|
|
69
75
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
76
|
+
const compareIterables = elementComparator => {
|
|
77
|
+
const cacheEntry = compareIteratorsCache.get(elementComparator);
|
|
78
|
+
if (cacheEntry !== undefined) return cacheEntry;
|
|
79
|
+
/**
|
|
80
|
+
* @param {Iterable<T>} a first value
|
|
81
|
+
* @param {Iterable<T>} b second value
|
|
82
|
+
* @returns {-1|0|1} compare result
|
|
83
|
+
*/
|
|
84
|
+
const result = (a, b) => {
|
|
85
|
+
const aI = a[Symbol.iterator]();
|
|
86
|
+
const bI = b[Symbol.iterator]();
|
|
87
|
+
while (true) {
|
|
88
|
+
const aItem = aI.next();
|
|
89
|
+
const bItem = bI.next();
|
|
90
|
+
if (aItem.done) {
|
|
91
|
+
return bItem.done ? 0 : -1;
|
|
92
|
+
} else if (bItem.done) {
|
|
93
|
+
return 1;
|
|
94
|
+
}
|
|
95
|
+
const res = elementComparator(aItem.value, bItem.value);
|
|
96
|
+
if (res !== 0) return res;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
compareIteratorsCache.set(elementComparator, result);
|
|
100
|
+
return result;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Compare two locations
|
|
105
|
+
* @param {DependencyLocation} a A location node
|
|
106
|
+
* @param {DependencyLocation} b A location node
|
|
107
|
+
* @returns {-1|0|1} sorting comparator value
|
|
108
|
+
*/
|
|
109
|
+
const compareLocations = (a, b) => {
|
|
110
|
+
const isObjectA = typeof a === "object" && a !== null;
|
|
111
|
+
const isObjectB = typeof b === "object" && b !== null;
|
|
112
|
+
if (!isObjectA || !isObjectB) {
|
|
113
|
+
if (isObjectA) return 1;
|
|
114
|
+
if (isObjectB) return -1;
|
|
115
|
+
return 0;
|
|
116
|
+
}
|
|
117
|
+
if ("start" in a) {
|
|
118
|
+
if ("start" in b) {
|
|
119
|
+
const ap = a.start;
|
|
120
|
+
const bp = b.start;
|
|
121
|
+
if (ap.line < bp.line) return -1;
|
|
122
|
+
if (ap.line > bp.line) return 1;
|
|
123
|
+
if (
|
|
124
|
+
/** @type {number} */ (ap.column) < /** @type {number} */ (bp.column)
|
|
125
|
+
) {
|
|
126
|
+
return -1;
|
|
127
|
+
}
|
|
128
|
+
if (
|
|
129
|
+
/** @type {number} */ (ap.column) > /** @type {number} */ (bp.column)
|
|
130
|
+
) {
|
|
131
|
+
return 1;
|
|
132
|
+
}
|
|
133
|
+
} else {
|
|
134
|
+
return -1;
|
|
135
|
+
}
|
|
136
|
+
} else if ("start" in b) {
|
|
137
|
+
return 1;
|
|
138
|
+
}
|
|
139
|
+
if ("name" in a) {
|
|
140
|
+
if ("name" in b) {
|
|
141
|
+
if (a.name < b.name) return -1;
|
|
142
|
+
if (a.name > b.name) return 1;
|
|
143
|
+
} else {
|
|
144
|
+
return -1;
|
|
145
|
+
}
|
|
146
|
+
} else if ("name" in b) {
|
|
147
|
+
return 1;
|
|
148
|
+
}
|
|
149
|
+
if ("index" in a) {
|
|
150
|
+
if ("index" in b) {
|
|
151
|
+
if (/** @type {number} */ (a.index) < /** @type {number} */ (b.index)) {
|
|
152
|
+
return -1;
|
|
153
|
+
}
|
|
154
|
+
if (/** @type {number} */ (a.index) > /** @type {number} */ (b.index)) {
|
|
155
|
+
return 1;
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
return -1;
|
|
159
|
+
}
|
|
160
|
+
} else if ("index" in b) {
|
|
161
|
+
return 1;
|
|
162
|
+
}
|
|
163
|
+
return 0;
|
|
164
|
+
};
|
|
72
165
|
|
|
73
166
|
/**
|
|
74
167
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
|
@@ -81,9 +174,6 @@ const compareModulesById = (chunkGraph, a, b) =>
|
|
|
81
174
|
/** @type {ModuleId} */ (chunkGraph.getModuleId(a)),
|
|
82
175
|
/** @type {ModuleId} */ (chunkGraph.getModuleId(b))
|
|
83
176
|
);
|
|
84
|
-
/** @type {ParameterizedComparator<ChunkGraph, Module>} */
|
|
85
|
-
module.exports.compareModulesById =
|
|
86
|
-
createCachedParameterizedComparator(compareModulesById);
|
|
87
177
|
|
|
88
178
|
/**
|
|
89
179
|
* @param {number} a number
|
|
@@ -98,7 +188,6 @@ const compareNumbers = (a, b) => {
|
|
|
98
188
|
if (a > b) return 1;
|
|
99
189
|
return 0;
|
|
100
190
|
};
|
|
101
|
-
module.exports.compareNumbers = compareNumbers;
|
|
102
191
|
|
|
103
192
|
/**
|
|
104
193
|
* @param {string} a string
|
|
@@ -170,7 +259,6 @@ const compareStringsNumeric = (a, b) => {
|
|
|
170
259
|
|
|
171
260
|
return 0;
|
|
172
261
|
};
|
|
173
|
-
module.exports.compareStringsNumeric = compareStringsNumeric;
|
|
174
262
|
|
|
175
263
|
/**
|
|
176
264
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
@@ -186,11 +274,6 @@ const compareModulesByPostOrderIndexOrIdentifier = (moduleGraph, a, b) => {
|
|
|
186
274
|
if (cmp !== 0) return cmp;
|
|
187
275
|
return compareIds(a.identifier(), b.identifier());
|
|
188
276
|
};
|
|
189
|
-
/** @type {ParameterizedComparator<ModuleGraph, Module>} */
|
|
190
|
-
module.exports.compareModulesByPostOrderIndexOrIdentifier =
|
|
191
|
-
createCachedParameterizedComparator(
|
|
192
|
-
compareModulesByPostOrderIndexOrIdentifier
|
|
193
|
-
);
|
|
194
277
|
|
|
195
278
|
/**
|
|
196
279
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
@@ -206,11 +289,6 @@ const compareModulesByPreOrderIndexOrIdentifier = (moduleGraph, a, b) => {
|
|
|
206
289
|
if (cmp !== 0) return cmp;
|
|
207
290
|
return compareIds(a.identifier(), b.identifier());
|
|
208
291
|
};
|
|
209
|
-
/** @type {ParameterizedComparator<ModuleGraph, Module>} */
|
|
210
|
-
module.exports.compareModulesByPreOrderIndexOrIdentifier =
|
|
211
|
-
createCachedParameterizedComparator(
|
|
212
|
-
compareModulesByPreOrderIndexOrIdentifier
|
|
213
|
-
);
|
|
214
292
|
|
|
215
293
|
/**
|
|
216
294
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
|
@@ -226,9 +304,6 @@ const compareModulesByIdOrIdentifier = (chunkGraph, a, b) => {
|
|
|
226
304
|
if (cmp !== 0) return cmp;
|
|
227
305
|
return compareIds(a.identifier(), b.identifier());
|
|
228
306
|
};
|
|
229
|
-
/** @type {ParameterizedComparator<ChunkGraph, Module>} */
|
|
230
|
-
module.exports.compareModulesByIdOrIdentifier =
|
|
231
|
-
createCachedParameterizedComparator(compareModulesByIdOrIdentifier);
|
|
232
307
|
|
|
233
308
|
/**
|
|
234
309
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
|
@@ -237,25 +312,6 @@ module.exports.compareModulesByIdOrIdentifier =
|
|
|
237
312
|
* @returns {-1 | 0 | 1} compare result
|
|
238
313
|
*/
|
|
239
314
|
const compareChunks = (chunkGraph, a, b) => chunkGraph.compareChunks(a, b);
|
|
240
|
-
/** @type {ParameterizedComparator<ChunkGraph, Chunk>} */
|
|
241
|
-
module.exports.compareChunks =
|
|
242
|
-
createCachedParameterizedComparator(compareChunks);
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* @param {string | number} a first id
|
|
246
|
-
* @param {string | number} b second id
|
|
247
|
-
* @returns {-1 | 0 | 1} compare result
|
|
248
|
-
*/
|
|
249
|
-
const compareIds = (a, b) => {
|
|
250
|
-
if (typeof a !== typeof b) {
|
|
251
|
-
return typeof a < typeof b ? -1 : 1;
|
|
252
|
-
}
|
|
253
|
-
if (a < b) return -1;
|
|
254
|
-
if (a > b) return 1;
|
|
255
|
-
return 0;
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
module.exports.compareIds = compareIds;
|
|
259
315
|
|
|
260
316
|
/**
|
|
261
317
|
* @param {string} a first string
|
|
@@ -268,8 +324,6 @@ const compareStrings = (a, b) => {
|
|
|
268
324
|
return 0;
|
|
269
325
|
};
|
|
270
326
|
|
|
271
|
-
module.exports.compareStrings = compareStrings;
|
|
272
|
-
|
|
273
327
|
/**
|
|
274
328
|
* @param {ChunkGroup} a first chunk group
|
|
275
329
|
* @param {ChunkGroup} b second chunk group
|
|
@@ -277,7 +331,6 @@ module.exports.compareStrings = compareStrings;
|
|
|
277
331
|
*/
|
|
278
332
|
const compareChunkGroupsByIndex = (a, b) =>
|
|
279
333
|
/** @type {number} */ (a.index) < /** @type {number} */ (b.index) ? -1 : 1;
|
|
280
|
-
module.exports.compareChunkGroupsByIndex = compareChunkGroupsByIndex;
|
|
281
334
|
|
|
282
335
|
/**
|
|
283
336
|
* @template {EXPECTED_OBJECT} K1
|
|
@@ -354,7 +407,6 @@ const concatComparators = (c1, c2, ...cRest) => {
|
|
|
354
407
|
concatComparatorsCache.set(c1, c2, result);
|
|
355
408
|
return result;
|
|
356
409
|
};
|
|
357
|
-
module.exports.concatComparators = concatComparators;
|
|
358
410
|
|
|
359
411
|
/**
|
|
360
412
|
* @template A, B
|
|
@@ -396,44 +448,10 @@ const compareSelect = (getter, comparator) => {
|
|
|
396
448
|
compareSelectCache.set(getter, comparator, result);
|
|
397
449
|
return result;
|
|
398
450
|
};
|
|
399
|
-
module.exports.compareSelect = compareSelect;
|
|
400
451
|
|
|
401
452
|
/** @type {WeakMap<Comparator<EXPECTED_ANY>, Comparator<Iterable<EXPECTED_ANY>>>} */
|
|
402
453
|
const compareIteratorsCache = new WeakMap();
|
|
403
454
|
|
|
404
|
-
/**
|
|
405
|
-
* @template T
|
|
406
|
-
* @param {Comparator<T>} elementComparator comparator for elements
|
|
407
|
-
* @returns {Comparator<Iterable<T>>} comparator for iterables of elements
|
|
408
|
-
*/
|
|
409
|
-
const compareIterables = elementComparator => {
|
|
410
|
-
const cacheEntry = compareIteratorsCache.get(elementComparator);
|
|
411
|
-
if (cacheEntry !== undefined) return cacheEntry;
|
|
412
|
-
/**
|
|
413
|
-
* @param {Iterable<T>} a first value
|
|
414
|
-
* @param {Iterable<T>} b second value
|
|
415
|
-
* @returns {-1|0|1} compare result
|
|
416
|
-
*/
|
|
417
|
-
const result = (a, b) => {
|
|
418
|
-
const aI = a[Symbol.iterator]();
|
|
419
|
-
const bI = b[Symbol.iterator]();
|
|
420
|
-
while (true) {
|
|
421
|
-
const aItem = aI.next();
|
|
422
|
-
const bItem = bI.next();
|
|
423
|
-
if (aItem.done) {
|
|
424
|
-
return bItem.done ? 0 : -1;
|
|
425
|
-
} else if (bItem.done) {
|
|
426
|
-
return 1;
|
|
427
|
-
}
|
|
428
|
-
const res = elementComparator(aItem.value, bItem.value);
|
|
429
|
-
if (res !== 0) return res;
|
|
430
|
-
}
|
|
431
|
-
};
|
|
432
|
-
compareIteratorsCache.set(elementComparator, result);
|
|
433
|
-
return result;
|
|
434
|
-
};
|
|
435
|
-
module.exports.compareIterables = compareIterables;
|
|
436
|
-
|
|
437
455
|
// TODO this is no longer needed when minimum node.js version is >= 12
|
|
438
456
|
// since these versions ship with a stable sort function
|
|
439
457
|
/**
|
|
@@ -441,7 +459,7 @@ module.exports.compareIterables = compareIterables;
|
|
|
441
459
|
* @param {Iterable<T>} iterable original ordered list
|
|
442
460
|
* @returns {Comparator<T>} comparator
|
|
443
461
|
*/
|
|
444
|
-
|
|
462
|
+
const keepOriginalOrder = iterable => {
|
|
445
463
|
/** @type {Map<T, number>} */
|
|
446
464
|
const map = new Map();
|
|
447
465
|
let i = 0;
|
|
@@ -459,7 +477,7 @@ module.exports.keepOriginalOrder = iterable => {
|
|
|
459
477
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
|
460
478
|
* @returns {Comparator<Chunk>} comparator
|
|
461
479
|
*/
|
|
462
|
-
|
|
480
|
+
const compareChunksNatural = chunkGraph => {
|
|
463
481
|
const cmpFn = module.exports.compareModulesById(chunkGraph);
|
|
464
482
|
const cmpIterableFn = compareIterables(cmpFn);
|
|
465
483
|
return concatComparators(
|
|
@@ -479,45 +497,54 @@ module.exports.compareChunksNatural = chunkGraph => {
|
|
|
479
497
|
);
|
|
480
498
|
};
|
|
481
499
|
|
|
500
|
+
module.exports.compareChunkGroupsByIndex = compareChunkGroupsByIndex;
|
|
501
|
+
/** @type {ParameterizedComparator<ChunkGraph, Chunk>} */
|
|
502
|
+
module.exports.compareChunks =
|
|
503
|
+
createCachedParameterizedComparator(compareChunks);
|
|
482
504
|
/**
|
|
483
|
-
*
|
|
484
|
-
* @param {
|
|
485
|
-
* @
|
|
486
|
-
* @returns {-1|0|1} sorting comparator value
|
|
505
|
+
* @param {Chunk} a chunk
|
|
506
|
+
* @param {Chunk} b chunk
|
|
507
|
+
* @returns {-1|0|1} compare result
|
|
487
508
|
*/
|
|
488
|
-
module.exports.
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
509
|
+
module.exports.compareChunksById = (a, b) =>
|
|
510
|
+
compareIds(/** @type {ChunkId} */ (a.id), /** @type {ChunkId} */ (b.id));
|
|
511
|
+
module.exports.compareChunksNatural = compareChunksNatural;
|
|
512
|
+
|
|
513
|
+
module.exports.compareIds = compareIds;
|
|
514
|
+
|
|
515
|
+
module.exports.compareIterables = compareIterables;
|
|
516
|
+
|
|
517
|
+
module.exports.compareLocations = compareLocations;
|
|
518
|
+
|
|
519
|
+
/** @type {ParameterizedComparator<ChunkGraph, Module>} */
|
|
520
|
+
module.exports.compareModulesById =
|
|
521
|
+
createCachedParameterizedComparator(compareModulesById);
|
|
522
|
+
/** @type {ParameterizedComparator<ChunkGraph, Module>} */
|
|
523
|
+
module.exports.compareModulesByIdOrIdentifier =
|
|
524
|
+
createCachedParameterizedComparator(compareModulesByIdOrIdentifier);
|
|
525
|
+
/**
|
|
526
|
+
* @param {Module} a module
|
|
527
|
+
* @param {Module} b module
|
|
528
|
+
* @returns {-1|0|1} compare result
|
|
529
|
+
*/
|
|
530
|
+
module.exports.compareModulesByIdentifier = (a, b) =>
|
|
531
|
+
compareIds(a.identifier(), b.identifier());
|
|
532
|
+
/** @type {ParameterizedComparator<ModuleGraph, Module>} */
|
|
533
|
+
module.exports.compareModulesByPostOrderIndexOrIdentifier =
|
|
534
|
+
createCachedParameterizedComparator(
|
|
535
|
+
compareModulesByPostOrderIndexOrIdentifier
|
|
536
|
+
);
|
|
537
|
+
/** @type {ParameterizedComparator<ModuleGraph, Module>} */
|
|
538
|
+
module.exports.compareModulesByPreOrderIndexOrIdentifier =
|
|
539
|
+
createCachedParameterizedComparator(
|
|
540
|
+
compareModulesByPreOrderIndexOrIdentifier
|
|
541
|
+
);
|
|
542
|
+
|
|
543
|
+
module.exports.compareNumbers = compareNumbers;
|
|
544
|
+
module.exports.compareSelect = compareSelect;
|
|
545
|
+
module.exports.compareStrings = compareStrings;
|
|
546
|
+
module.exports.compareStringsNumeric = compareStringsNumeric;
|
|
547
|
+
|
|
548
|
+
module.exports.concatComparators = concatComparators;
|
|
549
|
+
|
|
550
|
+
module.exports.keepOriginalOrder = keepOriginalOrder;
|
|
@@ -42,10 +42,12 @@ const compileBooleanMatcher = map => {
|
|
|
42
42
|
const compileBooleanMatcherFromLists = (positiveItems, negativeItems) => {
|
|
43
43
|
if (positiveItems.length === 0) return () => "false";
|
|
44
44
|
if (negativeItems.length === 0) return () => "true";
|
|
45
|
-
if (positiveItems.length === 1)
|
|
45
|
+
if (positiveItems.length === 1) {
|
|
46
46
|
return value => `${toSimpleString(positiveItems[0])} == ${value}`;
|
|
47
|
-
|
|
47
|
+
}
|
|
48
|
+
if (negativeItems.length === 1) {
|
|
48
49
|
return value => `${toSimpleString(negativeItems[0])} != ${value}`;
|
|
50
|
+
}
|
|
49
51
|
const positiveRegexp = itemsToRegexp(positiveItems);
|
|
50
52
|
const negativeRegexp = itemsToRegexp(negativeItems);
|
|
51
53
|
if (positiveRegexp.length <= negativeRegexp.length) {
|
|
@@ -146,6 +148,7 @@ const itemsToRegexp = itemsArr => {
|
|
|
146
148
|
if (countOfSingleCharItems === itemsArr.length) {
|
|
147
149
|
return `[${quoteMeta(itemsArr.sort().join(""))}]`;
|
|
148
150
|
}
|
|
151
|
+
/** @type {Set<string>} */
|
|
149
152
|
const items = new Set(itemsArr.sort());
|
|
150
153
|
if (countOfSingleCharItems > 2) {
|
|
151
154
|
let singleCharItems = "";
|
|
@@ -224,11 +227,13 @@ const itemsToRegexp = itemsArr => {
|
|
|
224
227
|
|
|
225
228
|
// TODO further optimize regexp, i. e.
|
|
226
229
|
// use ranges: (1|2|3|4|a) => [1-4a]
|
|
227
|
-
|
|
230
|
+
/** @type {string[]} */
|
|
231
|
+
const conditional = [...finishedItems, ...Array.from(items, quoteMeta)];
|
|
228
232
|
if (conditional.length === 1) return conditional[0];
|
|
229
233
|
return `(${conditional.join("|")})`;
|
|
230
234
|
};
|
|
231
235
|
|
|
232
236
|
compileBooleanMatcher.fromLists = compileBooleanMatcherFromLists;
|
|
233
237
|
compileBooleanMatcher.itemsToRegexp = itemsToRegexp;
|
|
238
|
+
|
|
234
239
|
module.exports = compileBooleanMatcher;
|
package/lib/util/concatenate.js
CHANGED
|
@@ -29,7 +29,7 @@ const getAllReferences = variable => {
|
|
|
29
29
|
for (const scope of variable.scope.childScopes) {
|
|
30
30
|
for (const innerVar of scope.variables) {
|
|
31
31
|
if (innerVar.identifiers.some(id => identifiers.has(id))) {
|
|
32
|
-
set = set
|
|
32
|
+
set = [...set, ...innerVar.references];
|
|
33
33
|
break;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -122,8 +122,9 @@ function findNewName(oldName, usedNamed1, usedNamed2, extraInfo) {
|
|
|
122
122
|
if (
|
|
123
123
|
!usedNamed1.has(nameIdent) &&
|
|
124
124
|
(!usedNamed2 || !usedNamed2.has(nameIdent))
|
|
125
|
-
)
|
|
125
|
+
) {
|
|
126
126
|
return nameIdent;
|
|
127
|
+
}
|
|
127
128
|
}
|
|
128
129
|
|
|
129
130
|
let i = 0;
|
|
@@ -220,12 +221,12 @@ const getUsedNamesInScopeInfo = (usedNamesInScopeInfo, module, id) => {
|
|
|
220
221
|
};
|
|
221
222
|
|
|
222
223
|
module.exports = {
|
|
223
|
-
|
|
224
|
+
DEFAULT_EXPORT,
|
|
225
|
+
NAMESPACE_OBJECT_EXPORT,
|
|
226
|
+
RESERVED_NAMES,
|
|
227
|
+
addScopeSymbols,
|
|
224
228
|
findNewName,
|
|
225
229
|
getAllReferences,
|
|
226
230
|
getPathInAst,
|
|
227
|
-
|
|
228
|
-
DEFAULT_EXPORT,
|
|
229
|
-
RESERVED_NAMES,
|
|
230
|
-
addScopeSymbols
|
|
231
|
+
getUsedNamesInScopeInfo
|
|
231
232
|
};
|
package/lib/util/conventions.js
CHANGED
|
@@ -6,6 +6,77 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
/** @typedef {import("../../declarations/WebpackOptions").CssGeneratorExportsConvention} CssGeneratorExportsConvention */
|
|
9
|
+
// Copy from css-loader
|
|
10
|
+
/**
|
|
11
|
+
* @param {string} string string
|
|
12
|
+
* @returns {string} result
|
|
13
|
+
*/
|
|
14
|
+
const preserveCamelCase = string => {
|
|
15
|
+
let result = string;
|
|
16
|
+
let isLastCharLower = false;
|
|
17
|
+
let isLastCharUpper = false;
|
|
18
|
+
let isLastLastCharUpper = false;
|
|
19
|
+
|
|
20
|
+
for (let i = 0; i < result.length; i++) {
|
|
21
|
+
const character = result[i];
|
|
22
|
+
|
|
23
|
+
if (isLastCharLower && /[\p{Lu}]/u.test(character)) {
|
|
24
|
+
result = `${result.slice(0, i)}-${result.slice(i)}`;
|
|
25
|
+
isLastCharLower = false;
|
|
26
|
+
isLastLastCharUpper = isLastCharUpper;
|
|
27
|
+
isLastCharUpper = true;
|
|
28
|
+
i += 1;
|
|
29
|
+
} else if (
|
|
30
|
+
isLastCharUpper &&
|
|
31
|
+
isLastLastCharUpper &&
|
|
32
|
+
/[\p{Ll}]/u.test(character)
|
|
33
|
+
) {
|
|
34
|
+
result = `${result.slice(0, i - 1)}-${result.slice(i - 1)}`;
|
|
35
|
+
isLastLastCharUpper = isLastCharUpper;
|
|
36
|
+
isLastCharUpper = false;
|
|
37
|
+
isLastCharLower = true;
|
|
38
|
+
} else {
|
|
39
|
+
isLastCharLower =
|
|
40
|
+
character.toLowerCase() === character &&
|
|
41
|
+
character.toUpperCase() !== character;
|
|
42
|
+
isLastLastCharUpper = isLastCharUpper;
|
|
43
|
+
isLastCharUpper =
|
|
44
|
+
character.toUpperCase() === character &&
|
|
45
|
+
character.toLowerCase() !== character;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return result;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// Copy from css-loader
|
|
53
|
+
/**
|
|
54
|
+
* @param {string} input input
|
|
55
|
+
* @returns {string} result
|
|
56
|
+
*/
|
|
57
|
+
module.exports.camelCase = input => {
|
|
58
|
+
let result = input.trim();
|
|
59
|
+
|
|
60
|
+
if (result.length === 0) {
|
|
61
|
+
return "";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (result.length === 1) {
|
|
65
|
+
return result.toLowerCase();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const hasUpperCase = result !== result.toLowerCase();
|
|
69
|
+
|
|
70
|
+
if (hasUpperCase) {
|
|
71
|
+
result = preserveCamelCase(result);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return result
|
|
75
|
+
.replace(/^[_.\- ]+/, "")
|
|
76
|
+
.toLowerCase()
|
|
77
|
+
.replace(/[_.\- ]+([\p{Alpha}\p{N}_]|$)/gu, (_, p1) => p1.toUpperCase())
|
|
78
|
+
.replace(/\d+([\p{Alpha}\p{N}_]|$)/gu, m => m.toUpperCase());
|
|
79
|
+
};
|
|
9
80
|
|
|
10
81
|
/**
|
|
11
82
|
* @param {string} input input
|
|
@@ -42,7 +113,7 @@ module.exports.cssExportConvention = (input, convention) => {
|
|
|
42
113
|
}
|
|
43
114
|
}
|
|
44
115
|
}
|
|
45
|
-
return
|
|
116
|
+
return [...set];
|
|
46
117
|
};
|
|
47
118
|
|
|
48
119
|
// Copy from css-loader
|
|
@@ -52,75 +123,3 @@ module.exports.cssExportConvention = (input, convention) => {
|
|
|
52
123
|
*/
|
|
53
124
|
module.exports.dashesCamelCase = input =>
|
|
54
125
|
input.replace(/-+(\w)/g, (match, firstLetter) => firstLetter.toUpperCase());
|
|
55
|
-
|
|
56
|
-
// Copy from css-loader
|
|
57
|
-
/**
|
|
58
|
-
* @param {string} input input
|
|
59
|
-
* @returns {string} result
|
|
60
|
-
*/
|
|
61
|
-
module.exports.camelCase = input => {
|
|
62
|
-
let result = input.trim();
|
|
63
|
-
|
|
64
|
-
if (result.length === 0) {
|
|
65
|
-
return "";
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (result.length === 1) {
|
|
69
|
-
return result.toLowerCase();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const hasUpperCase = result !== result.toLowerCase();
|
|
73
|
-
|
|
74
|
-
if (hasUpperCase) {
|
|
75
|
-
result = preserveCamelCase(result);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return result
|
|
79
|
-
.replace(/^[_.\- ]+/, "")
|
|
80
|
-
.toLowerCase()
|
|
81
|
-
.replace(/[_.\- ]+([\p{Alpha}\p{N}_]|$)/gu, (_, p1) => p1.toUpperCase())
|
|
82
|
-
.replace(/\d+([\p{Alpha}\p{N}_]|$)/gu, m => m.toUpperCase());
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
// Copy from css-loader
|
|
86
|
-
/**
|
|
87
|
-
* @param {string} string string
|
|
88
|
-
* @returns {string} result
|
|
89
|
-
*/
|
|
90
|
-
const preserveCamelCase = string => {
|
|
91
|
-
let result = string;
|
|
92
|
-
let isLastCharLower = false;
|
|
93
|
-
let isLastCharUpper = false;
|
|
94
|
-
let isLastLastCharUpper = false;
|
|
95
|
-
|
|
96
|
-
for (let i = 0; i < result.length; i++) {
|
|
97
|
-
const character = result[i];
|
|
98
|
-
|
|
99
|
-
if (isLastCharLower && /[\p{Lu}]/u.test(character)) {
|
|
100
|
-
result = `${result.slice(0, i)}-${result.slice(i)}`;
|
|
101
|
-
isLastCharLower = false;
|
|
102
|
-
isLastLastCharUpper = isLastCharUpper;
|
|
103
|
-
isLastCharUpper = true;
|
|
104
|
-
i += 1;
|
|
105
|
-
} else if (
|
|
106
|
-
isLastCharUpper &&
|
|
107
|
-
isLastLastCharUpper &&
|
|
108
|
-
/[\p{Ll}]/u.test(character)
|
|
109
|
-
) {
|
|
110
|
-
result = `${result.slice(0, i - 1)}-${result.slice(i - 1)}`;
|
|
111
|
-
isLastLastCharUpper = isLastCharUpper;
|
|
112
|
-
isLastCharUpper = false;
|
|
113
|
-
isLastCharLower = true;
|
|
114
|
-
} else {
|
|
115
|
-
isLastCharLower =
|
|
116
|
-
character.toLowerCase() === character &&
|
|
117
|
-
character.toUpperCase() !== character;
|
|
118
|
-
isLastLastCharUpper = isLastCharUpper;
|
|
119
|
-
isLastCharUpper =
|
|
120
|
-
character.toUpperCase() === character &&
|
|
121
|
-
character.toLowerCase() !== character;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return result;
|
|
126
|
-
};
|