webpack 5.100.1 → 5.101.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 +12 -10
- package/bin/webpack.js +7 -7
- package/lib/APIPlugin.js +12 -14
- package/lib/AutomaticPrefetchPlugin.js +2 -2
- package/lib/BannerPlugin.js +4 -4
- package/lib/Cache.js +1 -1
- package/lib/CacheFacade.js +7 -7
- package/lib/CaseSensitiveModulesWarning.js +2 -2
- package/lib/Chunk.js +3 -3
- package/lib/ChunkGraph.js +21 -18
- package/lib/ChunkGroup.js +4 -4
- package/lib/CleanPlugin.js +19 -53
- package/lib/CodeGenerationResults.js +3 -3
- package/lib/CompatibilityPlugin.js +6 -6
- package/lib/Compilation.js +127 -114
- package/lib/Compiler.js +37 -37
- package/lib/ConcatenationScope.js +39 -1
- package/lib/ConstPlugin.js +11 -11
- package/lib/ContextExclusionPlugin.js +3 -3
- package/lib/ContextModule.js +12 -11
- package/lib/ContextModuleFactory.js +11 -11
- package/lib/ContextReplacementPlugin.js +5 -5
- package/lib/DefinePlugin.js +24 -22
- package/lib/DelegatedModuleFactoryPlugin.js +1 -1
- package/lib/DllEntryPlugin.js +1 -1
- package/lib/DllReferencePlugin.js +1 -1
- package/lib/DynamicEntryPlugin.js +3 -3
- package/lib/EntryPlugin.js +1 -1
- package/lib/EnvironmentPlugin.js +1 -1
- package/lib/ErrorHelpers.js +2 -2
- package/lib/EvalDevToolModulePlugin.js +2 -2
- package/lib/EvalSourceMapDevToolPlugin.js +5 -5
- package/lib/ExportsInfo.js +9 -9
- package/lib/ExportsInfoApiPlugin.js +2 -2
- package/lib/ExternalModule.js +163 -48
- package/lib/ExternalModuleFactoryPlugin.js +2 -2
- package/lib/ExternalsPlugin.js +45 -0
- package/lib/FileSystemInfo.js +64 -61
- package/lib/FlagAllModulesAsUsedPlugin.js +2 -2
- package/lib/FlagDependencyExportsPlugin.js +7 -7
- package/lib/FlagDependencyUsagePlugin.js +4 -4
- package/lib/FlagEntryExportAsUsedPlugin.js +1 -1
- package/lib/HotModuleReplacementPlugin.js +27 -27
- package/lib/IgnorePlugin.js +3 -3
- package/lib/IgnoreWarningsPlugin.js +4 -4
- package/lib/InitFragment.js +6 -0
- package/lib/InvalidDependenciesModuleWarning.js +1 -1
- package/lib/JavascriptMetaInfoPlugin.js +1 -1
- package/lib/LibManifestPlugin.js +2 -2
- package/lib/LoaderOptionsPlugin.js +1 -1
- package/lib/LoaderTargetPlugin.js +2 -2
- package/lib/MainTemplate.js +1 -1
- package/lib/Module.js +1 -1
- package/lib/ModuleFilenameHelpers.js +3 -3
- package/lib/ModuleGraph.js +86 -5
- package/lib/ModuleInfoHeaderPlugin.js +3 -3
- package/lib/ModuleParseError.js +5 -3
- package/lib/MultiCompiler.js +29 -24
- package/lib/MultiStats.js +18 -13
- package/lib/MultiWatching.js +1 -1
- package/lib/NoEmitOnErrorsPlugin.js +2 -2
- package/lib/NodeStuffPlugin.js +27 -15
- package/lib/NormalModule.js +28 -24
- package/lib/NormalModuleFactory.js +23 -21
- package/lib/NormalModuleReplacementPlugin.js +3 -3
- package/lib/PrefetchPlugin.js +1 -1
- package/lib/ProgressPlugin.js +11 -11
- package/lib/ProvidePlugin.js +2 -2
- package/lib/RecordIdsPlugin.js +3 -3
- package/lib/ResolverFactory.js +3 -3
- package/lib/RuntimeGlobals.js +20 -0
- package/lib/RuntimePlugin.js +16 -16
- package/lib/RuntimeTemplate.js +42 -44
- package/lib/SizeFormatHelpers.js +1 -1
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +4 -4
- package/lib/SourceMapDevToolPlugin.js +9 -9
- package/lib/Stats.js +2 -2
- package/lib/Template.js +1 -1
- package/lib/TemplatedPathPlugin.js +2 -2
- package/lib/UseStrictPlugin.js +1 -1
- package/lib/WarnCaseSensitiveModulesPlugin.js +1 -1
- package/lib/WarnDeprecatedOptionPlugin.js +1 -1
- package/lib/WarnNoModeSetPlugin.js +1 -1
- package/lib/WatchIgnorePlugin.js +2 -2
- package/lib/Watching.js +12 -12
- package/lib/WebpackIsIncludedPlugin.js +2 -2
- package/lib/WebpackOptionsApply.js +10 -3
- package/lib/asset/AssetGenerator.js +3 -3
- package/lib/asset/AssetModulesPlugin.js +6 -6
- package/lib/async-modules/AsyncModuleHelpers.js +50 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +36 -24
- package/lib/async-modules/InferAsyncModulesPlugin.js +3 -3
- package/lib/buildChunkGraph.js +5 -5
- package/lib/cache/AddBuildDependenciesPlugin.js +1 -1
- package/lib/cache/IdleFileCachePlugin.js +5 -5
- package/lib/cache/PackFileCacheStrategy.js +20 -20
- package/lib/cache/ResolverCachePlugin.js +4 -4
- package/lib/cli.js +196 -14
- package/lib/config/browserslistTargetHandler.js +6 -6
- package/lib/config/defaults.js +23 -14
- package/lib/config/normalization.js +41 -38
- package/lib/config/target.js +4 -4
- package/lib/container/ContainerEntryModule.js +3 -3
- package/lib/container/ContainerPlugin.js +3 -3
- package/lib/container/ContainerReferencePlugin.js +3 -3
- package/lib/container/FallbackModule.js +1 -1
- package/lib/container/HoistContainerReferencesPlugin.js +7 -7
- package/lib/container/options.js +4 -4
- package/lib/css/CssGenerator.js +5 -3
- package/lib/css/CssLoadingRuntimeModule.js +1 -1
- package/lib/css/CssModulesPlugin.js +25 -22
- package/lib/css/CssParser.js +5 -5
- package/lib/css/walkCssTokens.js +9 -9
- package/lib/debug/ProfilingPlugin.js +5 -5
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +4 -4
- package/lib/dependencies/AMDPlugin.js +3 -3
- package/lib/dependencies/AMDRequireArrayDependency.js +1 -1
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +3 -3
- package/lib/dependencies/CommonJsExportRequireDependency.js +2 -2
- package/lib/dependencies/CommonJsExportsParserPlugin.js +12 -10
- package/lib/dependencies/CommonJsImportsParserPlugin.js +21 -19
- package/lib/dependencies/CommonJsPlugin.js +2 -2
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +3 -3
- package/lib/dependencies/CssIcssExportDependency.js +2 -2
- package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssUrlDependency.js +4 -4
- package/lib/dependencies/DynamicExports.js +5 -5
- package/lib/dependencies/HarmonyAcceptDependency.js +39 -5
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +2 -2
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +17 -23
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +7 -8
- package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
- package/lib/dependencies/HarmonyExports.js +1 -1
- package/lib/dependencies/HarmonyImportDependency.js +28 -9
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +59 -75
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -5
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +3 -4
- package/lib/dependencies/HarmonyModulesPlugin.js +2 -8
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +1 -1
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +4 -4
- package/lib/dependencies/ImportMetaPlugin.js +7 -7
- package/lib/dependencies/ImportParserPlugin.js +4 -4
- package/lib/dependencies/JsonExportsDependency.js +1 -1
- package/lib/dependencies/LoaderPlugin.js +4 -4
- package/lib/dependencies/ProvidedDependency.js +2 -2
- package/lib/dependencies/PureExpressionDependency.js +1 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -1
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +3 -3
- package/lib/dependencies/SystemPlugin.js +3 -3
- package/lib/dependencies/WorkerPlugin.js +5 -5
- package/lib/dependencies/getFunctionExpression.js +1 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +5 -5
- package/lib/esm/ModuleChunkLoadingPlugin.js +2 -2
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +15 -11
- package/lib/formatLocation.js +2 -2
- package/lib/hmr/HotModuleReplacement.runtime.js +39 -27
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +43 -32
- package/lib/hmr/JavascriptHotModuleReplacementHelper.js +1 -1
- package/lib/hmr/LazyCompilationPlugin.js +6 -6
- package/lib/hmr/lazyCompilationBackend.js +6 -6
- package/lib/ids/ChunkModuleIdRangePlugin.js +4 -4
- package/lib/ids/DeterministicChunkIdsPlugin.js +5 -4
- package/lib/ids/DeterministicModuleIdsPlugin.js +2 -2
- package/lib/ids/HashedModuleIdsPlugin.js +1 -1
- package/lib/ids/IdHelpers.js +9 -9
- package/lib/ids/NamedChunkIdsPlugin.js +5 -5
- package/lib/ids/NamedModuleIdsPlugin.js +2 -2
- package/lib/ids/NaturalChunkIdsPlugin.js +2 -2
- package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +2 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +4 -4
- package/lib/ids/SyncModuleIdsPlugin.js +4 -4
- package/lib/index.js +10 -6
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +1 -1
- package/lib/javascript/BasicEvaluatedExpression.js +3 -3
- package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
- package/lib/javascript/EnableChunkLoadingPlugin.js +1 -1
- package/lib/javascript/JavascriptGenerator.js +1 -1
- package/lib/javascript/JavascriptModulesPlugin.js +16 -16
- package/lib/javascript/JavascriptParser.js +90 -83
- package/lib/javascript/JavascriptParserHelpers.js +3 -3
- package/lib/javascript/StartupHelpers.js +2 -2
- package/lib/json/JsonGenerator.js +2 -2
- package/lib/json/JsonModulesPlugin.js +2 -2
- package/lib/library/AbstractLibraryPlugin.js +3 -3
- package/lib/library/AmdLibraryPlugin.js +3 -3
- package/lib/library/AssignLibraryPlugin.js +2 -2
- package/lib/library/EnableLibraryPlugin.js +2 -2
- package/lib/library/ModuleLibraryPlugin.js +7 -2
- package/lib/library/SystemLibraryPlugin.js +6 -4
- package/lib/library/UmdLibraryPlugin.js +14 -14
- package/lib/logging/createConsoleLogger.js +4 -4
- package/lib/logging/runtime.js +3 -3
- package/lib/logging/truncateArgs.js +4 -4
- package/lib/node/CommonJsChunkLoadingPlugin.js +2 -2
- package/lib/node/NodeEnvironmentPlugin.js +1 -1
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +16 -14
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +7 -7
- package/lib/node/ReadFileCompileWasmPlugin.js +7 -7
- package/lib/node/RequireChunkLoadingRuntimeModule.js +6 -4
- package/lib/node/nodeConsole.js +2 -2
- package/lib/optimize/AggressiveMergingPlugin.js +2 -2
- package/lib/optimize/AggressiveSplittingPlugin.js +10 -10
- package/lib/optimize/ConcatenatedModule.js +161 -52
- package/lib/optimize/EnsureChunkConditionsPlugin.js +2 -2
- package/lib/optimize/FlagIncludedChunksPlugin.js +2 -2
- package/lib/optimize/InnerGraph.js +5 -5
- package/lib/optimize/InnerGraphPlugin.js +14 -12
- package/lib/optimize/LimitChunkCountPlugin.js +5 -5
- package/lib/optimize/MangleExportsPlugin.js +5 -5
- package/lib/optimize/MergeDuplicateChunksPlugin.js +2 -2
- package/lib/optimize/MinChunkSizePlugin.js +3 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +45 -38
- package/lib/optimize/RealContentHashPlugin.js +23 -23
- package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -2
- package/lib/optimize/RemoveParentModulesPlugin.js +3 -3
- package/lib/optimize/RuntimeChunkPlugin.js +2 -2
- package/lib/optimize/SideEffectsFlagPlugin.js +22 -6
- package/lib/optimize/SplitChunksPlugin.js +20 -20
- package/lib/performance/AssetsOverSizeLimitWarning.js +1 -1
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +2 -2
- package/lib/performance/SizeLimitsPlugin.js +4 -4
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +1 -1
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +3 -3
- package/lib/rules/BasicMatcherRulePlugin.js +1 -1
- package/lib/rules/RuleSetCompiler.js +10 -10
- package/lib/rules/UseEffectRulePlugin.js +2 -2
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +15 -15
- package/lib/runtime/GetMainFilenameRuntimeModule.js +1 -1
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -1
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -1
- package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -2
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +3 -3
- package/lib/schemes/DataUriPlugin.js +3 -3
- package/lib/schemes/FileUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +40 -36
- package/lib/schemes/VirtualUrlPlugin.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +11 -11
- package/lib/serialization/FileMiddleware.js +17 -17
- package/lib/serialization/ObjectMiddleware.js +8 -8
- package/lib/serialization/Serializer.js +2 -2
- package/lib/serialization/SerializerMiddleware.js +2 -2
- package/lib/sharing/ConsumeSharedPlugin.js +4 -4
- package/lib/sharing/ProvideSharedPlugin.js +4 -4
- package/lib/sharing/SharePlugin.js +1 -1
- package/lib/sharing/resolveMatchedConfigs.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +86 -80
- package/lib/stats/DefaultStatsPresetPlugin.js +15 -15
- package/lib/stats/DefaultStatsPrinterPlugin.js +87 -87
- package/lib/stats/StatsFactory.js +7 -7
- package/lib/stats/StatsPrinter.js +9 -9
- package/lib/url/URLParserPlugin.js +5 -5
- package/lib/util/AsyncQueue.js +4 -4
- package/lib/util/IterableHelpers.js +2 -2
- package/lib/util/LazyBucketSortedSet.js +3 -3
- package/lib/util/SetHelpers.js +2 -2
- package/lib/util/StackedCacheMap.js +1 -1
- package/lib/util/StackedMap.js +1 -1
- package/lib/util/TupleSet.js +1 -1
- package/lib/util/WeakTupleMap.js +1 -1
- package/lib/util/cleverMerge.js +8 -8
- package/lib/util/comparators.js +107 -8
- package/lib/util/compileBooleanMatcher.js +20 -20
- package/lib/util/concatenate.js +3 -3
- package/lib/util/conventions.js +4 -4
- package/lib/util/create-schema-validation.js +1 -1
- package/lib/util/createHash.js +1 -1
- package/lib/util/deprecation.js +4 -4
- package/lib/util/deterministicGrouping.js +7 -7
- package/lib/util/findGraphRoots.js +1 -1
- package/lib/util/fs.js +3 -3
- package/lib/util/identifier.js +14 -14
- package/lib/util/magicComment.js +5 -1
- package/lib/util/memoize.js +1 -1
- package/lib/util/processAsyncTree.js +2 -2
- package/lib/util/propertyName.js +1 -1
- package/lib/util/removeBOM.js +1 -1
- package/lib/util/runtime.js +6 -6
- package/lib/util/semver.js +16 -16
- package/lib/util/serialization.js +5 -5
- package/lib/util/smartGrouping.js +1 -1
- package/lib/validateSchema.js +2 -2
- package/lib/wasm/EnableWasmLoadingPlugin.js +1 -1
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +1 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +4 -4
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +13 -9
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +2 -2
- package/lib/wasm-sync/WebAssemblyGenerator.js +14 -14
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +4 -2
- package/lib/wasm-sync/WebAssemblyParser.js +2 -2
- package/lib/web/FetchCompileAsyncWasmPlugin.js +4 -4
- package/lib/web/FetchCompileWasmPlugin.js +4 -4
- package/lib/web/JsonpChunkLoadingPlugin.js +2 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
- package/lib/webpack.js +17 -12
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +2 -2
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +13 -13
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +4 -0
- package/types.d.ts +186 -54
|
@@ -97,7 +97,7 @@ const subtractSizeFrom = (total, size) => {
|
|
|
97
97
|
* @param {Iterable<Node<T>>} nodes some nodes
|
|
98
98
|
* @returns {Record<string, number>} total size
|
|
99
99
|
*/
|
|
100
|
-
const sumSize = nodes => {
|
|
100
|
+
const sumSize = (nodes) => {
|
|
101
101
|
const sum = Object.create(null);
|
|
102
102
|
for (const node of nodes) {
|
|
103
103
|
addSizeTo(sum, node.size);
|
|
@@ -249,7 +249,7 @@ class Group {
|
|
|
249
249
|
* @param {Iterable<Node<T>>} nodes nodes
|
|
250
250
|
* @returns {number[]} similarities
|
|
251
251
|
*/
|
|
252
|
-
const getSimilarities = nodes => {
|
|
252
|
+
const getSimilarities = (nodes) => {
|
|
253
253
|
// calculate similarities between lexically adjacent nodes
|
|
254
254
|
/** @type {number[]} */
|
|
255
255
|
const similarities = [];
|
|
@@ -292,7 +292,7 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
|
|
|
292
292
|
|
|
293
293
|
const nodes = Array.from(
|
|
294
294
|
items,
|
|
295
|
-
item => new Node(item, getKey(item), getSize(item))
|
|
295
|
+
(item) => new Node(item, getKey(item), getSize(item))
|
|
296
296
|
);
|
|
297
297
|
|
|
298
298
|
/** @type {Node<T>[]} */
|
|
@@ -329,12 +329,12 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
|
|
|
329
329
|
// We hit an edge case where the working set is already smaller than minSize
|
|
330
330
|
// We merge problematic nodes with the smallest result node to keep minSize intact
|
|
331
331
|
const problemNodes = group.popNodes(
|
|
332
|
-
n => getNumberOfMatchingSizeTypes(n.size, problemTypes) > 0
|
|
332
|
+
(n) => getNumberOfMatchingSizeTypes(n.size, problemTypes) > 0
|
|
333
333
|
);
|
|
334
334
|
if (problemNodes === undefined) return false;
|
|
335
335
|
// Only merge it with result nodes that have the problematic size type
|
|
336
336
|
const possibleResultGroups = result.filter(
|
|
337
|
-
n => getNumberOfMatchingSizeTypes(n.size, problemTypes) > 0
|
|
337
|
+
(n) => getNumberOfMatchingSizeTypes(n.size, problemTypes) > 0
|
|
338
338
|
);
|
|
339
339
|
if (possibleResultGroups.length > 0) {
|
|
340
340
|
const bestGroup = possibleResultGroups.reduce((min, group) => {
|
|
@@ -531,11 +531,11 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
|
|
|
531
531
|
|
|
532
532
|
// return the results
|
|
533
533
|
return result.map(
|
|
534
|
-
group =>
|
|
534
|
+
(group) =>
|
|
535
535
|
/** @type {GroupedItems<T>} */
|
|
536
536
|
({
|
|
537
537
|
key: group.key,
|
|
538
|
-
items: group.nodes.map(node => node.item),
|
|
538
|
+
items: group.nodes.map((node) => node.item),
|
|
539
539
|
size: group.size
|
|
540
540
|
})
|
|
541
541
|
);
|
|
@@ -224,7 +224,7 @@ module.exports = (items, getDependencies) => {
|
|
|
224
224
|
|
|
225
225
|
// When roots were found, return them
|
|
226
226
|
if (roots.size > 0) {
|
|
227
|
-
return Array.from(roots, r => r.item);
|
|
227
|
+
return Array.from(roots, (r) => r.item);
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
throw new Error("Implementation of findGraphRoots is broken");
|
package/lib/util/fs.js
CHANGED
|
@@ -523,7 +523,7 @@ const dirname = (fs, absPath) => {
|
|
|
523
523
|
* @returns {void}
|
|
524
524
|
*/
|
|
525
525
|
const mkdirp = (fs, p, callback) => {
|
|
526
|
-
fs.mkdir(p, err => {
|
|
526
|
+
fs.mkdir(p, (err) => {
|
|
527
527
|
if (err) {
|
|
528
528
|
if (err.code === "ENOENT") {
|
|
529
529
|
const dir = dirname(fs, p);
|
|
@@ -531,12 +531,12 @@ const mkdirp = (fs, p, callback) => {
|
|
|
531
531
|
callback(err);
|
|
532
532
|
return;
|
|
533
533
|
}
|
|
534
|
-
mkdirp(fs, dir, err => {
|
|
534
|
+
mkdirp(fs, dir, (err) => {
|
|
535
535
|
if (err) {
|
|
536
536
|
callback(err);
|
|
537
537
|
return;
|
|
538
538
|
}
|
|
539
|
-
fs.mkdir(p, err => {
|
|
539
|
+
fs.mkdir(p, (err) => {
|
|
540
540
|
if (err) {
|
|
541
541
|
if (err.code === "EEXIST") {
|
|
542
542
|
callback();
|
package/lib/util/identifier.js
CHANGED
|
@@ -14,7 +14,7 @@ const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g;
|
|
|
14
14
|
* @param {string} relativePath relative path
|
|
15
15
|
* @returns {string} request
|
|
16
16
|
*/
|
|
17
|
-
const relativePathToRequest = relativePath => {
|
|
17
|
+
const relativePathToRequest = (relativePath) => {
|
|
18
18
|
if (relativePath === "") return "./.";
|
|
19
19
|
if (relativePath === "..") return "../.";
|
|
20
20
|
if (relativePath.startsWith("../")) return relativePath;
|
|
@@ -103,7 +103,7 @@ const requestToAbsolute = (context, relativePath) => {
|
|
|
103
103
|
* @param {((value: string) => T)} realFn real function
|
|
104
104
|
* @returns {MakeCacheableResult<T> & { bindCache: BindCache<T> }} cacheable function
|
|
105
105
|
*/
|
|
106
|
-
const makeCacheable = realFn => {
|
|
106
|
+
const makeCacheable = (realFn) => {
|
|
107
107
|
/**
|
|
108
108
|
* @template T
|
|
109
109
|
* @typedef {Map<string, T>} CacheItem
|
|
@@ -115,7 +115,7 @@ const makeCacheable = realFn => {
|
|
|
115
115
|
* @param {AssociatedObjectForCache} associatedObjectForCache an object to which the cache will be attached
|
|
116
116
|
* @returns {CacheItem<T>} cache item
|
|
117
117
|
*/
|
|
118
|
-
const getCache = associatedObjectForCache => {
|
|
118
|
+
const getCache = (associatedObjectForCache) => {
|
|
119
119
|
const entry = cache.get(associatedObjectForCache);
|
|
120
120
|
if (entry !== undefined) return entry;
|
|
121
121
|
/** @type {Map<string, T>} */
|
|
@@ -136,13 +136,13 @@ const makeCacheable = realFn => {
|
|
|
136
136
|
};
|
|
137
137
|
|
|
138
138
|
/** @type {BindCache<T>} */
|
|
139
|
-
fn.bindCache = associatedObjectForCache => {
|
|
139
|
+
fn.bindCache = (associatedObjectForCache) => {
|
|
140
140
|
const cache = getCache(associatedObjectForCache);
|
|
141
141
|
/**
|
|
142
142
|
* @param {string} str string
|
|
143
143
|
* @returns {T} value
|
|
144
144
|
*/
|
|
145
|
-
return str => {
|
|
145
|
+
return (str) => {
|
|
146
146
|
const entry = cache.get(str);
|
|
147
147
|
if (entry !== undefined) return entry;
|
|
148
148
|
const result = realFn(str);
|
|
@@ -164,7 +164,7 @@ const makeCacheable = realFn => {
|
|
|
164
164
|
* @param {(context: string, identifier: string) => string} fn function
|
|
165
165
|
* @returns {MakeCacheableWithContextResult & { bindCache: BindCacheForContext, bindContextCache: BindContextCacheForContext }} cacheable function with context
|
|
166
166
|
*/
|
|
167
|
-
const makeCacheableWithContext = fn => {
|
|
167
|
+
const makeCacheableWithContext = (fn) => {
|
|
168
168
|
/** @type {WeakMap<AssociatedObjectForCache, Map<string, Map<string, string>>>} */
|
|
169
169
|
const cache = new WeakMap();
|
|
170
170
|
|
|
@@ -195,7 +195,7 @@ const makeCacheableWithContext = fn => {
|
|
|
195
195
|
};
|
|
196
196
|
|
|
197
197
|
/** @type {BindCacheForContext} */
|
|
198
|
-
cachedFn.bindCache = associatedObjectForCache => {
|
|
198
|
+
cachedFn.bindCache = (associatedObjectForCache) => {
|
|
199
199
|
let innerCache;
|
|
200
200
|
if (associatedObjectForCache) {
|
|
201
201
|
innerCache = cache.get(associatedObjectForCache);
|
|
@@ -254,7 +254,7 @@ const makeCacheableWithContext = fn => {
|
|
|
254
254
|
* @param {string} identifier identifier used to create relative path
|
|
255
255
|
* @returns {string} the returned relative path
|
|
256
256
|
*/
|
|
257
|
-
const boundFn = identifier => {
|
|
257
|
+
const boundFn = (identifier) => {
|
|
258
258
|
const cachedResult = innerSubCache.get(identifier);
|
|
259
259
|
if (cachedResult !== undefined) {
|
|
260
260
|
return cachedResult;
|
|
@@ -278,7 +278,7 @@ const makeCacheableWithContext = fn => {
|
|
|
278
278
|
const _makePathsRelative = (context, identifier) =>
|
|
279
279
|
identifier
|
|
280
280
|
.split(SEGMENTS_SPLIT_REGEXP)
|
|
281
|
-
.map(str => absoluteToRequest(context, str))
|
|
281
|
+
.map((str) => absoluteToRequest(context, str))
|
|
282
282
|
.join("");
|
|
283
283
|
|
|
284
284
|
/**
|
|
@@ -289,7 +289,7 @@ const _makePathsRelative = (context, identifier) =>
|
|
|
289
289
|
const _makePathsAbsolute = (context, identifier) =>
|
|
290
290
|
identifier
|
|
291
291
|
.split(SEGMENTS_SPLIT_REGEXP)
|
|
292
|
-
.map(str => requestToAbsolute(context, str))
|
|
292
|
+
.map((str) => requestToAbsolute(context, str))
|
|
293
293
|
.join("");
|
|
294
294
|
|
|
295
295
|
/**
|
|
@@ -300,7 +300,7 @@ const _makePathsAbsolute = (context, identifier) =>
|
|
|
300
300
|
const _contextify = (context, request) =>
|
|
301
301
|
request
|
|
302
302
|
.split("!")
|
|
303
|
-
.map(r => absoluteToRequest(context, r))
|
|
303
|
+
.map((r) => absoluteToRequest(context, r))
|
|
304
304
|
.join("!");
|
|
305
305
|
|
|
306
306
|
const contextify = makeCacheableWithContext(_contextify);
|
|
@@ -313,7 +313,7 @@ const contextify = makeCacheableWithContext(_contextify);
|
|
|
313
313
|
const _absolutify = (context, request) =>
|
|
314
314
|
request
|
|
315
315
|
.split("!")
|
|
316
|
-
.map(r => requestToAbsolute(context, r))
|
|
316
|
+
.map((r) => requestToAbsolute(context, r))
|
|
317
317
|
.join("!");
|
|
318
318
|
|
|
319
319
|
const absolutify = makeCacheableWithContext(_absolutify);
|
|
@@ -329,7 +329,7 @@ const PATH_QUERY_REGEXP = /^((?:\0.|[^?\0])*)(\?.*)?$/;
|
|
|
329
329
|
* @param {string} str the path with query and fragment
|
|
330
330
|
* @returns {ParsedResource} parsed parts
|
|
331
331
|
*/
|
|
332
|
-
const _parseResource = str => {
|
|
332
|
+
const _parseResource = (str) => {
|
|
333
333
|
const match =
|
|
334
334
|
/** @type {[string, string, string | undefined, string | undefined]} */
|
|
335
335
|
(/** @type {unknown} */ (PATH_QUERY_FRAGMENT_REGEXP.exec(str)));
|
|
@@ -346,7 +346,7 @@ const _parseResource = str => {
|
|
|
346
346
|
* @param {string} str the path with query and fragment
|
|
347
347
|
* @returns {ParsedResourceWithoutFragment} parsed parts
|
|
348
348
|
*/
|
|
349
|
-
const _parseResourceWithoutFragment = str => {
|
|
349
|
+
const _parseResourceWithoutFragment = (str) => {
|
|
350
350
|
const match =
|
|
351
351
|
/** @type {[string, string, string | undefined]} */
|
|
352
352
|
(/** @type {unknown} */ (PATH_QUERY_REGEXP.exec(str)));
|
package/lib/util/magicComment.js
CHANGED
|
@@ -5,9 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
+
const memoize = require("./memoize");
|
|
9
|
+
|
|
10
|
+
const getVm = memoize(() => require("vm"));
|
|
11
|
+
|
|
8
12
|
// regexp to match at least one "magic comment"
|
|
9
13
|
module.exports.createMagicCommentContext = () =>
|
|
10
|
-
|
|
14
|
+
getVm().createContext(undefined, {
|
|
11
15
|
name: "Webpack Magic Comment Parser",
|
|
12
16
|
codeGeneration: { strings: false, wasm: false }
|
|
13
17
|
});
|
package/lib/util/memoize.js
CHANGED
|
@@ -24,7 +24,7 @@ const processAsyncTree = (items, concurrency, processor, callback) => {
|
|
|
24
24
|
/**
|
|
25
25
|
* @param {T} item item
|
|
26
26
|
*/
|
|
27
|
-
const push = item => {
|
|
27
|
+
const push = (item) => {
|
|
28
28
|
queue.push(item);
|
|
29
29
|
if (!processScheduled && processing < concurrency) {
|
|
30
30
|
processScheduled = true;
|
|
@@ -35,7 +35,7 @@ const processAsyncTree = (items, concurrency, processor, callback) => {
|
|
|
35
35
|
/**
|
|
36
36
|
* @param {E | null | undefined} err error
|
|
37
37
|
*/
|
|
38
|
-
const processorCallback = err => {
|
|
38
|
+
const processorCallback = (err) => {
|
|
39
39
|
processing--;
|
|
40
40
|
if (err && !finished) {
|
|
41
41
|
finished = true;
|
package/lib/util/propertyName.js
CHANGED
|
@@ -66,7 +66,7 @@ const RESERVED_IDENTIFIER = new Set([
|
|
|
66
66
|
* @param {string} prop property name to analyze
|
|
67
67
|
* @returns {string} valid JS property name
|
|
68
68
|
*/
|
|
69
|
-
const propertyName = prop => {
|
|
69
|
+
const propertyName = (prop) => {
|
|
70
70
|
if (SAFE_IDENTIFIER.test(prop) && !RESERVED_IDENTIFIER.has(prop)) {
|
|
71
71
|
return prop;
|
|
72
72
|
}
|
package/lib/util/removeBOM.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @param {string | Buffer} strOrBuffer string or buffer
|
|
10
10
|
* @returns {string | Buffer} result without BOM
|
|
11
11
|
*/
|
|
12
|
-
module.exports = strOrBuffer => {
|
|
12
|
+
module.exports = (strOrBuffer) => {
|
|
13
13
|
if (typeof strOrBuffer === "string" && strOrBuffer.charCodeAt(0) === 0xfeff) {
|
|
14
14
|
return strOrBuffer.slice(1);
|
|
15
15
|
} else if (
|
package/lib/util/runtime.js
CHANGED
|
@@ -74,7 +74,7 @@ const forEachRuntime = (runtime, fn, deterministicOrder = false) => {
|
|
|
74
74
|
* @param {SortableSet<T>} set set
|
|
75
75
|
* @returns {string} runtime key
|
|
76
76
|
*/
|
|
77
|
-
const getRuntimesKey = set => {
|
|
77
|
+
const getRuntimesKey = (set) => {
|
|
78
78
|
set.sort();
|
|
79
79
|
return [...set].join("\n");
|
|
80
80
|
};
|
|
@@ -83,7 +83,7 @@ const getRuntimesKey = set => {
|
|
|
83
83
|
* @param {RuntimeSpec} runtime runtime(s)
|
|
84
84
|
* @returns {string} key of runtimes
|
|
85
85
|
*/
|
|
86
|
-
const getRuntimeKey = runtime => {
|
|
86
|
+
const getRuntimeKey = (runtime) => {
|
|
87
87
|
if (runtime === undefined) return "*";
|
|
88
88
|
if (typeof runtime === "string") return runtime;
|
|
89
89
|
return runtime.getFromUnorderedCache(getRuntimesKey);
|
|
@@ -93,7 +93,7 @@ const getRuntimeKey = runtime => {
|
|
|
93
93
|
* @param {string} key key of runtimes
|
|
94
94
|
* @returns {RuntimeSpec} runtime(s)
|
|
95
95
|
*/
|
|
96
|
-
const keyToRuntime = key => {
|
|
96
|
+
const keyToRuntime = (key) => {
|
|
97
97
|
if (key === "*") return;
|
|
98
98
|
const items = key.split("\n");
|
|
99
99
|
if (items.length === 1) return items[0];
|
|
@@ -105,7 +105,7 @@ const keyToRuntime = key => {
|
|
|
105
105
|
* @param {SortableSet<T>} set set
|
|
106
106
|
* @returns {string} runtime string
|
|
107
107
|
*/
|
|
108
|
-
const getRuntimesString = set => {
|
|
108
|
+
const getRuntimesString = (set) => {
|
|
109
109
|
set.sort();
|
|
110
110
|
return [...set].join("+");
|
|
111
111
|
};
|
|
@@ -114,7 +114,7 @@ const getRuntimesString = set => {
|
|
|
114
114
|
* @param {RuntimeSpec} runtime runtime(s)
|
|
115
115
|
* @returns {string} readable version
|
|
116
116
|
*/
|
|
117
|
-
const runtimeToString = runtime => {
|
|
117
|
+
const runtimeToString = (runtime) => {
|
|
118
118
|
if (runtime === undefined) return "*";
|
|
119
119
|
if (typeof runtime === "string") return runtime;
|
|
120
120
|
return runtime.getFromUnorderedCache(getRuntimesString);
|
|
@@ -124,7 +124,7 @@ const runtimeToString = runtime => {
|
|
|
124
124
|
* @param {RuntimeCondition} runtimeCondition runtime condition
|
|
125
125
|
* @returns {string} readable version
|
|
126
126
|
*/
|
|
127
|
-
const runtimeConditionToString = runtimeCondition => {
|
|
127
|
+
const runtimeConditionToString = (runtimeCondition) => {
|
|
128
128
|
if (runtimeCondition === true) return "true";
|
|
129
129
|
if (runtimeCondition === false) return "false";
|
|
130
130
|
return runtimeToString(runtimeCondition);
|
package/lib/util/semver.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* @param {string} str version string
|
|
14
14
|
* @returns {SemVerRange} parsed version
|
|
15
15
|
*/
|
|
16
|
-
const parseVersion = str => {
|
|
16
|
+
const parseVersion = (str) => {
|
|
17
17
|
/**
|
|
18
18
|
* @param {str} str str
|
|
19
19
|
* @returns {(string | number)[]} result
|
|
@@ -100,15 +100,15 @@ module.exports.versionLt = versionLt;
|
|
|
100
100
|
* @param {string} str range string
|
|
101
101
|
* @returns {SemVerRange} parsed range
|
|
102
102
|
*/
|
|
103
|
-
module.exports.parseRange = str => {
|
|
103
|
+
module.exports.parseRange = (str) => {
|
|
104
104
|
/**
|
|
105
105
|
* @param {string} str str
|
|
106
106
|
* @returns {(string | number)[]} result
|
|
107
107
|
*/
|
|
108
|
-
const splitAndConvert = str => {
|
|
108
|
+
const splitAndConvert = (str) => {
|
|
109
109
|
return str
|
|
110
110
|
.split(".")
|
|
111
|
-
.map(item => (item !== "NaN" && `${+item}` === item ? +item : item));
|
|
111
|
+
.map((item) => (item !== "NaN" && `${+item}` === item ? +item : item));
|
|
112
112
|
};
|
|
113
113
|
|
|
114
114
|
// see https://docs.npmjs.com/misc/semver#range-grammar for grammar
|
|
@@ -116,7 +116,7 @@ module.exports.parseRange = str => {
|
|
|
116
116
|
* @param {string} str str
|
|
117
117
|
* @returns {SemVerRangeItem[]}
|
|
118
118
|
*/
|
|
119
|
-
const parsePartial = str => {
|
|
119
|
+
const parsePartial = (str) => {
|
|
120
120
|
const match =
|
|
121
121
|
/** @type {RegExpExecArray} */
|
|
122
122
|
(/^([^-+]+)?(?:-([^+]+))?(?:\+(.+))?$/.exec(str));
|
|
@@ -146,7 +146,7 @@ module.exports.parseRange = str => {
|
|
|
146
146
|
* @param {SemVerRangeItem[]} range range
|
|
147
147
|
* @returns {SemVerRangeItem[]}
|
|
148
148
|
*/
|
|
149
|
-
const toFixed = range => {
|
|
149
|
+
const toFixed = (range) => {
|
|
150
150
|
if (range.length === 1) {
|
|
151
151
|
// Special case for "*" is "x.x.x" instead of "="
|
|
152
152
|
return [0];
|
|
@@ -166,7 +166,7 @@ module.exports.parseRange = str => {
|
|
|
166
166
|
* @param {SemVerRangeItem[]} range
|
|
167
167
|
* @returns {SemVerRangeItem[]} result
|
|
168
168
|
*/
|
|
169
|
-
const negate = range => {
|
|
169
|
+
const negate = (range) => {
|
|
170
170
|
return [-(/** @type { [number]} */ (range)[0]) - 1, ...range.slice(1)];
|
|
171
171
|
};
|
|
172
172
|
|
|
@@ -174,7 +174,7 @@ module.exports.parseRange = str => {
|
|
|
174
174
|
* @param {string} str str
|
|
175
175
|
* @returns {SemVerRange}
|
|
176
176
|
*/
|
|
177
|
-
const parseSimple = str => {
|
|
177
|
+
const parseSimple = (str) => {
|
|
178
178
|
// simple ::= primitive | partial | tilde | caret
|
|
179
179
|
// primitive ::= ( '<' | '>' | '>=' | '<=' | '=' | '!' ) ( ' ' ) * partial
|
|
180
180
|
// tilde ::= '~' ( ' ' ) * partial
|
|
@@ -253,7 +253,7 @@ module.exports.parseRange = str => {
|
|
|
253
253
|
* @param {string} str str
|
|
254
254
|
* @returns {SemVerRange}
|
|
255
255
|
*/
|
|
256
|
-
const parseRange = str => {
|
|
256
|
+
const parseRange = (str) => {
|
|
257
257
|
// range ::= hyphen | simple ( ' ' ( ' ' ) * simple ) * | ''
|
|
258
258
|
// hyphen ::= partial ( ' ' ) * ' - ' ( ' ' ) * partial
|
|
259
259
|
const items = str.split(/\s+-\s+/);
|
|
@@ -292,7 +292,7 @@ module.exports.parseRange = str => {
|
|
|
292
292
|
* @param {string} str str
|
|
293
293
|
* @returns {SemVerRange}
|
|
294
294
|
*/
|
|
295
|
-
const parseLogicalOr = str => {
|
|
295
|
+
const parseLogicalOr = (str) => {
|
|
296
296
|
// range-set ::= range ( logical-or range ) *
|
|
297
297
|
// logical-or ::= ( ' ' ) * '||' ( ' ' ) *
|
|
298
298
|
const items =
|
|
@@ -310,7 +310,7 @@ module.exports.parseRange = str => {
|
|
|
310
310
|
* @param {SemVerRange} range
|
|
311
311
|
* @returns {string}
|
|
312
312
|
*/
|
|
313
|
-
const rangeToString = range => {
|
|
313
|
+
const rangeToString = (range) => {
|
|
314
314
|
var fixCount = /** @type {number} */ (range[0]);
|
|
315
315
|
var str = "";
|
|
316
316
|
if (range.length === 1) {
|
|
@@ -532,7 +532,7 @@ module.exports.satisfy = satisfy;
|
|
|
532
532
|
* @param {SemVerRange | string | number | false | undefined} json
|
|
533
533
|
* @returns {string}
|
|
534
534
|
*/
|
|
535
|
-
module.exports.stringifyHoley = json => {
|
|
535
|
+
module.exports.stringifyHoley = (json) => {
|
|
536
536
|
switch (typeof json) {
|
|
537
537
|
case "undefined":
|
|
538
538
|
return "";
|
|
@@ -558,7 +558,7 @@ module.exports.stringifyHoley = json => {
|
|
|
558
558
|
* @param {RuntimeTemplate} runtimeTemplate
|
|
559
559
|
* @returns {string}
|
|
560
560
|
*/
|
|
561
|
-
exports.parseVersionRuntimeCode = runtimeTemplate =>
|
|
561
|
+
exports.parseVersionRuntimeCode = (runtimeTemplate) =>
|
|
562
562
|
`var parseVersion = ${runtimeTemplate.basicFunction("str", [
|
|
563
563
|
"// see webpack/lib/util/semver.js for original code",
|
|
564
564
|
`var p=${runtimeTemplate.supportsArrowFunction() ? "p=>" : "function(p)"}{return p.split(".").map(${runtimeTemplate.supportsArrowFunction() ? "p=>" : "function(p)"}{return+p==p?+p:p})},n=/^([^-+]+)?(?:-([^+]+))?(?:\\+(.+))?$/.exec(str),r=n[1]?p(n[1]):[];return n[2]&&(r.length++,r.push.apply(r,p(n[2]))),n[3]&&(r.push([]),r.push.apply(r,p(n[3]))),r;`
|
|
@@ -570,7 +570,7 @@ exports.parseVersionRuntimeCode = runtimeTemplate =>
|
|
|
570
570
|
* @param {RuntimeTemplate} runtimeTemplate
|
|
571
571
|
* @returns {string}
|
|
572
572
|
*/
|
|
573
|
-
exports.versionLtRuntimeCode = runtimeTemplate =>
|
|
573
|
+
exports.versionLtRuntimeCode = (runtimeTemplate) =>
|
|
574
574
|
`var versionLt = ${runtimeTemplate.basicFunction("a, b", [
|
|
575
575
|
"// see webpack/lib/util/semver.js for original code",
|
|
576
576
|
'a=parseVersion(a),b=parseVersion(b);for(var r=0;;){if(r>=a.length)return r<b.length&&"u"!=(typeof b[r])[0];var e=a[r],n=(typeof e)[0];if(r>=b.length)return"u"==n;var t=b[r],f=(typeof t)[0];if(n!=f)return"o"==n&&"n"==f||("s"==f||"u"==n);if("o"!=n&&"u"!=n&&e!=t)return e<t;r++}'
|
|
@@ -582,7 +582,7 @@ exports.versionLtRuntimeCode = runtimeTemplate =>
|
|
|
582
582
|
* @param {RuntimeTemplate} runtimeTemplate
|
|
583
583
|
* @returns {string}
|
|
584
584
|
*/
|
|
585
|
-
exports.rangeToStringRuntimeCode = runtimeTemplate =>
|
|
585
|
+
exports.rangeToStringRuntimeCode = (runtimeTemplate) =>
|
|
586
586
|
`var rangeToString = ${runtimeTemplate.basicFunction("range", [
|
|
587
587
|
"// see webpack/lib/util/semver.js for original code",
|
|
588
588
|
'var r=range[0],n="";if(1===range.length)return"*";if(r+.5){n+=0==r?">=":-1==r?"<":1==r?"^":2==r?"~":r>0?"=":"!=";for(var e=1,a=1;a<range.length;a++){e--,n+="u"==(typeof(t=range[a]))[0]?"-":(e>0?".":"")+(e=2,t)}return n}var g=[];for(a=1;a<range.length;a++){var t=range[a];g.push(0===t?"not("+o()+")":1===t?"("+o()+" || "+o()+")":2===t?g.pop()+" "+g.pop():rangeToString(t))}return o();function o(){return g.pop().replace(/^\\((.+)\\)$/,"$1")}'
|
|
@@ -594,7 +594,7 @@ exports.rangeToStringRuntimeCode = runtimeTemplate =>
|
|
|
594
594
|
* @param {RuntimeTemplate} runtimeTemplate
|
|
595
595
|
* @returns {string}
|
|
596
596
|
*/
|
|
597
|
-
exports.satisfyRuntimeCode = runtimeTemplate =>
|
|
597
|
+
exports.satisfyRuntimeCode = (runtimeTemplate) =>
|
|
598
598
|
`var satisfy = ${runtimeTemplate.basicFunction("range, version", [
|
|
599
599
|
"// see webpack/lib/util/semver.js for original code",
|
|
600
600
|
'if(0 in range){version=parseVersion(version);var e=range[0],r=e<0;r&&(e=-e-1);for(var n=0,i=1,a=!0;;i++,n++){var f,s,g=i<range.length?(typeof range[i])[0]:"";if(n>=version.length||"o"==(s=(typeof(f=version[n]))[0]))return!a||("u"==g?i>e&&!r:""==g!=r);if("u"==s){if(!a||"u"!=g)return!1}else if(a)if(g==s)if(i<=e){if(f!=range[i])return!1}else{if(r?f>range[i]:f<range[i])return!1;f!=range[i]&&(a=!1)}else if("s"!=g&&"n"!=g){if(r||i<=e)return!1;a=!1,i--}else{if(i<=e||s<g!=r)return!1;a=!1}else"s"!=g&&"n"!=g&&(a=!1,i--)}}var t=[],o=t.pop.bind(t);for(n=1;n<range.length;n++){var u=range[n];t.push(1==u?o()|o():2==u?o()&o():u?satisfy(u,version):!o())}return!!o();'
|
|
@@ -42,7 +42,7 @@ const registerSerializers = memoize(() => {
|
|
|
42
42
|
// This allows bundling all internal serializers
|
|
43
43
|
const internalSerializables = require("./internalSerializables");
|
|
44
44
|
|
|
45
|
-
getObjectMiddleware().registerLoader(/^webpack\/lib\//, req => {
|
|
45
|
+
getObjectMiddleware().registerLoader(/^webpack\/lib\//, (req) => {
|
|
46
46
|
const loader =
|
|
47
47
|
internalSerializables[
|
|
48
48
|
/** @type {keyof import("./internalSerializables")} */
|
|
@@ -95,9 +95,9 @@ module.exports = {
|
|
|
95
95
|
return /** @type {Serializer<EXPECTED_ANY, EXPECTED_ANY, EXPECTED_ANY>} */ (
|
|
96
96
|
buffersSerializer = new Serializer([
|
|
97
97
|
new SingleItemMiddleware(),
|
|
98
|
-
new (getObjectMiddleware())(context => {
|
|
98
|
+
new (getObjectMiddleware())((context) => {
|
|
99
99
|
if ("write" in context) {
|
|
100
|
-
context.writeLazy = value => {
|
|
100
|
+
context.writeLazy = (value) => {
|
|
101
101
|
context.write(
|
|
102
102
|
SerializerMiddleware.createLazy(value, binaryMiddleware)
|
|
103
103
|
);
|
|
@@ -127,9 +127,9 @@ module.exports = {
|
|
|
127
127
|
return /** @type {Serializer<D, S, C>} */ (
|
|
128
128
|
new Serializer([
|
|
129
129
|
new SingleItemMiddleware(),
|
|
130
|
-
new (getObjectMiddleware())(context => {
|
|
130
|
+
new (getObjectMiddleware())((context) => {
|
|
131
131
|
if ("write" in context) {
|
|
132
|
-
context.writeLazy = value => {
|
|
132
|
+
context.writeLazy = (value) => {
|
|
133
133
|
context.write(
|
|
134
134
|
SerializerMiddleware.createLazy(value, binaryMiddleware)
|
|
135
135
|
);
|
|
@@ -81,7 +81,7 @@ const smartGrouping = (items, groupConfigs) => {
|
|
|
81
81
|
* @param {Set<ItemWithGroups<T, R>>} itemsWithGroups input items with groups
|
|
82
82
|
* @returns {(T | R)[]} groups items
|
|
83
83
|
*/
|
|
84
|
-
const runGrouping = itemsWithGroups => {
|
|
84
|
+
const runGrouping = (itemsWithGroups) => {
|
|
85
85
|
const totalSize = itemsWithGroups.size;
|
|
86
86
|
for (const entry of itemsWithGroups) {
|
|
87
87
|
for (const group of entry.groups) {
|
package/lib/validateSchema.js
CHANGED
|
@@ -85,7 +85,7 @@ const validateSchema = (schema, options, validationConfiguration) => {
|
|
|
85
85
|
if (
|
|
86
86
|
children &&
|
|
87
87
|
children.some(
|
|
88
|
-
child =>
|
|
88
|
+
(child) =>
|
|
89
89
|
child.keyword === "absolutePath" &&
|
|
90
90
|
child.instancePath === "/output/filename"
|
|
91
91
|
)
|
|
@@ -96,7 +96,7 @@ const validateSchema = (schema, options, validationConfiguration) => {
|
|
|
96
96
|
if (
|
|
97
97
|
children &&
|
|
98
98
|
children.some(
|
|
99
|
-
child =>
|
|
99
|
+
(child) =>
|
|
100
100
|
child.keyword === "pattern" && child.instancePath === "/devtool"
|
|
101
101
|
)
|
|
102
102
|
) {
|
|
@@ -16,7 +16,7 @@ const enabledTypes = new WeakMap();
|
|
|
16
16
|
* @param {Compiler} compiler compiler instance
|
|
17
17
|
* @returns {Set<WasmLoadingType>} enabled types
|
|
18
18
|
*/
|
|
19
|
-
const getEnabledTypes = compiler => {
|
|
19
|
+
const getEnabledTypes = (compiler) => {
|
|
20
20
|
let set = enabledTypes.get(compiler);
|
|
21
21
|
if (set === undefined) {
|
|
22
22
|
set = new Set();
|
|
@@ -50,7 +50,7 @@ class AsyncWasmLoadingRuntimeModule extends RuntimeModule {
|
|
|
50
50
|
JSON.stringify(outputOptions.webassemblyModuleFilename),
|
|
51
51
|
{
|
|
52
52
|
hash: `" + ${RuntimeGlobals.getFullHash}() + "`,
|
|
53
|
-
hashWithLength: length =>
|
|
53
|
+
hashWithLength: (length) =>
|
|
54
54
|
`" + ${RuntimeGlobals.getFullHash}}().slice(0, ${length}) + "`,
|
|
55
55
|
module: {
|
|
56
56
|
id: '" + wasmModuleId + "',
|
|
@@ -120,7 +120,7 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
|
|
|
120
120
|
const importObjRequestItems = Array.from(
|
|
121
121
|
wasmDepsByRequest,
|
|
122
122
|
([request, deps]) => {
|
|
123
|
-
const exportItems = deps.map(dep => {
|
|
123
|
+
const exportItems = deps.map((dep) => {
|
|
124
124
|
const importedModule =
|
|
125
125
|
/** @type {Module} */
|
|
126
126
|
(moduleGraph.getModule(dep));
|
|
@@ -22,13 +22,13 @@ class UniversalCompileAsyncWasmPlugin {
|
|
|
22
22
|
* @returns {void}
|
|
23
23
|
*/
|
|
24
24
|
apply(compiler) {
|
|
25
|
-
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
|
25
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
26
26
|
const globalWasmLoading = compilation.outputOptions.wasmLoading;
|
|
27
27
|
/**
|
|
28
28
|
* @param {Chunk} chunk chunk
|
|
29
29
|
* @returns {boolean} true, if wasm loading is enabled for the chunk
|
|
30
30
|
*/
|
|
31
|
-
const isEnabledForChunk = chunk => {
|
|
31
|
+
const isEnabledForChunk = (chunk) => {
|
|
32
32
|
const options = chunk.getEntryOptions();
|
|
33
33
|
const wasmLoading =
|
|
34
34
|
options && options.wasmLoading !== undefined
|
|
@@ -46,7 +46,7 @@ class UniversalCompileAsyncWasmPlugin {
|
|
|
46
46
|
* @param {string} path path
|
|
47
47
|
* @returns {string} code
|
|
48
48
|
*/
|
|
49
|
-
const generateBeforeLoadBinaryCode = path =>
|
|
49
|
+
const generateBeforeLoadBinaryCode = (path) =>
|
|
50
50
|
Template.asString([
|
|
51
51
|
"var useFetch = typeof document !== 'undefined' || typeof self !== 'undefined';",
|
|
52
52
|
`var wasmUrl = ${path};`
|
|
@@ -85,7 +85,7 @@ class UniversalCompileAsyncWasmPlugin {
|
|
|
85
85
|
if (
|
|
86
86
|
!chunkGraph.hasModuleInGraph(
|
|
87
87
|
chunk,
|
|
88
|
-
m => m.type === WEBASSEMBLY_MODULE_TYPE_ASYNC
|
|
88
|
+
(m) => m.type === WEBASSEMBLY_MODULE_TYPE_ASYNC
|
|
89
89
|
)
|
|
90
90
|
) {
|
|
91
91
|
return;
|
|
@@ -139,7 +139,9 @@ const generateImportObject = (
|
|
|
139
139
|
importObject = [
|
|
140
140
|
"return {",
|
|
141
141
|
Template.indent([
|
|
142
|
-
properties
|
|
142
|
+
properties
|
|
143
|
+
.map((p) => `${JSON.stringify(p.name)}: ${p.value}`)
|
|
144
|
+
.join(",\n")
|
|
143
145
|
]),
|
|
144
146
|
"};"
|
|
145
147
|
];
|
|
@@ -160,7 +162,9 @@ const generateImportObject = (
|
|
|
160
162
|
Template.asString([
|
|
161
163
|
`${JSON.stringify(module)}: {`,
|
|
162
164
|
Template.indent([
|
|
163
|
-
list
|
|
165
|
+
list
|
|
166
|
+
.map((p) => `${JSON.stringify(p.name)}: ${p.value}`)
|
|
167
|
+
.join(",\n")
|
|
164
168
|
]),
|
|
165
169
|
"}"
|
|
166
170
|
])
|
|
@@ -187,7 +191,7 @@ const generateImportObject = (
|
|
|
187
191
|
} else if (waitForInstances.size > 0) {
|
|
188
192
|
const promises = Array.from(
|
|
189
193
|
waitForInstances.values(),
|
|
190
|
-
id => `installedWasmModules[${JSON.stringify(id)}]`
|
|
194
|
+
(id) => `installedWasmModules[${JSON.stringify(id)}]`
|
|
191
195
|
).join(", ");
|
|
192
196
|
const variables = Array.from(
|
|
193
197
|
waitForInstances.keys(),
|
|
@@ -251,7 +255,7 @@ class WasmChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
251
255
|
const { mangleImports } = this;
|
|
252
256
|
/** @type {string[]} */
|
|
253
257
|
const declarations = [];
|
|
254
|
-
const importObjects = wasmModules.map(module =>
|
|
258
|
+
const importObjects = wasmModules.map((module) =>
|
|
255
259
|
generateImportObject(
|
|
256
260
|
chunkGraph,
|
|
257
261
|
module,
|
|
@@ -260,14 +264,14 @@ class WasmChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
260
264
|
chunk.runtime
|
|
261
265
|
)
|
|
262
266
|
);
|
|
263
|
-
const chunkModuleIdMap = chunkGraph.getChunkModuleIdMap(chunk, m =>
|
|
267
|
+
const chunkModuleIdMap = chunkGraph.getChunkModuleIdMap(chunk, (m) =>
|
|
264
268
|
m.type.startsWith("webassembly")
|
|
265
269
|
);
|
|
266
270
|
/**
|
|
267
271
|
* @param {string} content content
|
|
268
272
|
* @returns {string} created import object
|
|
269
273
|
*/
|
|
270
|
-
const createImportObject = content =>
|
|
274
|
+
const createImportObject = (content) =>
|
|
271
275
|
mangleImports
|
|
272
276
|
? `{ ${JSON.stringify(WebAssemblyUtils.MANGLED_MODULE)}: ${content} }`
|
|
273
277
|
: content;
|
|
@@ -275,12 +279,12 @@ class WasmChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
275
279
|
JSON.stringify(outputOptions.webassemblyModuleFilename),
|
|
276
280
|
{
|
|
277
281
|
hash: `" + ${RuntimeGlobals.getFullHash}() + "`,
|
|
278
|
-
hashWithLength: length =>
|
|
282
|
+
hashWithLength: (length) =>
|
|
279
283
|
`" + ${RuntimeGlobals.getFullHash}}().slice(0, ${length}) + "`,
|
|
280
284
|
module: {
|
|
281
285
|
id: '" + wasmModuleId + "',
|
|
282
286
|
hash: `" + ${JSON.stringify(
|
|
283
|
-
chunkGraph.getChunkModuleRenderedHashMap(chunk, m =>
|
|
287
|
+
chunkGraph.getChunkModuleRenderedHashMap(chunk, (m) =>
|
|
284
288
|
m.type.startsWith("webassembly")
|
|
285
289
|
)
|
|
286
290
|
)}[chunkId][wasmModuleId] + "`,
|
|
@@ -288,7 +292,7 @@ class WasmChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
288
292
|
return `" + ${JSON.stringify(
|
|
289
293
|
chunkGraph.getChunkModuleRenderedHashMap(
|
|
290
294
|
chunk,
|
|
291
|
-
m => m.type.startsWith("webassembly"),
|
|
295
|
+
(m) => m.type.startsWith("webassembly"),
|
|
292
296
|
length
|
|
293
297
|
)
|
|
294
298
|
)}[chunkId][wasmModuleId] + "`;
|