webpack 5.59.0 → 5.76.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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/README.md +22 -24
- package/bin/webpack.js +0 -0
- package/hot/dev-server.js +17 -4
- package/hot/lazy-compilation-node.js +3 -1
- package/hot/poll.js +1 -1
- package/hot/signal.js +1 -1
- package/lib/APIPlugin.js +33 -0
- package/lib/BannerPlugin.js +13 -5
- package/lib/Cache.js +1 -1
- package/lib/CacheFacade.js +4 -11
- package/lib/Chunk.js +6 -3
- package/lib/ChunkGraph.js +94 -8
- package/lib/ChunkGroup.js +1 -1
- package/lib/CleanPlugin.js +81 -20
- package/lib/Compilation.js +188 -93
- package/lib/Compiler.js +87 -18
- package/lib/ConstPlugin.js +2 -2
- package/lib/ContextModule.js +142 -51
- package/lib/ContextModuleFactory.js +65 -25
- package/lib/DelegatedModule.js +1 -1
- package/lib/DelegatedModuleFactoryPlugin.js +1 -1
- package/lib/Dependency.js +17 -0
- package/lib/DependencyTemplate.js +9 -0
- package/lib/DependencyTemplates.js +1 -1
- package/lib/DllModule.js +1 -1
- package/lib/DllReferencePlugin.js +1 -1
- package/lib/EntryOptionPlugin.js +2 -0
- package/lib/ErrorHelpers.js +2 -2
- package/lib/EvalDevToolModulePlugin.js +16 -1
- package/lib/EvalSourceMapDevToolPlugin.js +25 -4
- package/lib/ExportsInfo.js +5 -5
- package/lib/ExternalModule.js +94 -54
- package/lib/ExternalModuleFactoryPlugin.js +5 -5
- package/lib/FileSystemInfo.js +124 -58
- package/lib/Generator.js +3 -0
- package/lib/HookWebpackError.js +1 -1
- package/lib/HotModuleReplacementPlugin.js +3 -1
- package/lib/LoaderOptionsPlugin.js +1 -1
- package/lib/Module.js +28 -4
- package/lib/ModuleFilenameHelpers.js +8 -4
- package/lib/ModuleHashingError.js +29 -0
- package/lib/MultiCompiler.js +1 -1
- package/lib/MultiWatching.js +1 -1
- package/lib/NodeStuffPlugin.js +13 -3
- package/lib/NormalModule.js +51 -33
- package/lib/NormalModuleFactory.js +42 -37
- package/lib/ProgressPlugin.js +4 -5
- package/lib/RawModule.js +1 -1
- package/lib/RuntimeGlobals.js +29 -1
- package/lib/RuntimeModule.js +1 -1
- package/lib/RuntimePlugin.js +84 -1
- package/lib/RuntimeTemplate.js +114 -2
- package/lib/Template.js +3 -2
- package/lib/TemplatedPathPlugin.js +48 -23
- package/lib/WatchIgnorePlugin.js +19 -7
- package/lib/Watching.js +33 -19
- package/lib/WebpackOptionsApply.js +79 -11
- package/lib/asset/AssetGenerator.js +228 -71
- package/lib/asset/AssetModulesPlugin.js +3 -0
- package/lib/asset/AssetParser.js +1 -0
- package/lib/asset/AssetSourceGenerator.js +31 -6
- package/lib/asset/AssetSourceParser.js +1 -0
- package/lib/asset/RawDataUrlModule.js +148 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -4
- package/lib/buildChunkGraph.js +38 -7
- package/lib/cache/PackFileCacheStrategy.js +15 -8
- package/lib/cache/ResolverCachePlugin.js +90 -29
- package/lib/cli.js +44 -3
- package/lib/config/browserslistTargetHandler.js +41 -6
- package/lib/config/defaults.js +123 -19
- package/lib/config/normalization.js +10 -2
- package/lib/config/target.js +10 -0
- package/lib/container/ContainerEntryModule.js +8 -5
- package/lib/container/FallbackModule.js +4 -4
- package/lib/container/ModuleFederationPlugin.js +2 -0
- package/lib/container/RemoteModule.js +4 -2
- package/lib/container/RemoteRuntimeModule.js +8 -7
- package/lib/css/CssExportsGenerator.js +139 -0
- package/lib/css/CssGenerator.js +109 -0
- package/lib/css/CssLoadingRuntimeModule.js +442 -0
- package/lib/css/CssModulesPlugin.js +462 -0
- package/lib/css/CssParser.js +618 -0
- package/lib/css/walkCssTokens.js +659 -0
- package/lib/debug/ProfilingPlugin.js +24 -21
- package/lib/dependencies/AMDRequireDependency.js +6 -6
- package/lib/dependencies/CommonJsExportsParserPlugin.js +1 -2
- package/lib/dependencies/CommonJsFullRequireDependency.js +5 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +344 -61
- package/lib/dependencies/CommonJsRequireContextDependency.js +6 -2
- package/lib/dependencies/CommonJsRequireDependency.js +2 -1
- package/lib/dependencies/ContextDependency.js +16 -2
- package/lib/dependencies/ContextDependencyHelpers.js +21 -8
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +4 -1
- package/lib/dependencies/ContextElementDependency.js +25 -3
- package/lib/dependencies/CreateScriptUrlDependency.js +12 -0
- package/lib/dependencies/CssExportDependency.js +85 -0
- package/lib/dependencies/CssImportDependency.js +75 -0
- package/lib/dependencies/CssLocalIdentifierDependency.js +119 -0
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +101 -0
- package/lib/dependencies/CssUrlDependency.js +132 -0
- package/lib/dependencies/ExportsInfoDependency.js +6 -0
- package/lib/dependencies/HarmonyAcceptImportDependency.js +5 -3
- package/lib/dependencies/HarmonyCompatibilityDependency.js +5 -5
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +127 -0
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +12 -3
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +25 -17
- package/lib/dependencies/HarmonyExportInitFragment.js +4 -1
- package/lib/dependencies/HarmonyImportDependency.js +23 -0
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +142 -45
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -22
- package/lib/dependencies/HarmonyModulesPlugin.js +10 -0
- package/lib/dependencies/ImportContextDependency.js +0 -2
- package/lib/dependencies/ImportMetaContextDependency.js +35 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +252 -0
- package/lib/dependencies/ImportMetaContextPlugin.js +59 -0
- package/lib/dependencies/ImportMetaPlugin.js +22 -3
- package/lib/dependencies/ImportParserPlugin.js +35 -29
- package/lib/dependencies/JsonExportsDependency.js +17 -21
- package/lib/dependencies/LoaderDependency.js +13 -0
- package/lib/dependencies/LoaderImportDependency.js +13 -0
- package/lib/dependencies/LoaderPlugin.js +4 -2
- package/lib/dependencies/ModuleDependency.js +11 -1
- package/lib/dependencies/ProvidedDependency.js +31 -8
- package/lib/dependencies/RequireContextDependency.js +0 -16
- package/lib/dependencies/RequireEnsureDependency.js +2 -2
- package/lib/dependencies/RequireResolveContextDependency.js +2 -2
- package/lib/dependencies/RequireResolveDependency.js +2 -1
- package/lib/dependencies/URLDependency.js +3 -8
- package/lib/dependencies/URLPlugin.js +22 -1
- package/lib/dependencies/WorkerPlugin.js +2 -0
- package/lib/esm/ModuleChunkFormatPlugin.js +74 -49
- package/lib/esm/ModuleChunkLoadingPlugin.js +3 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +25 -9
- package/lib/hmr/HotModuleReplacement.runtime.js +29 -14
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +4 -3
- package/lib/hmr/LazyCompilationPlugin.js +54 -26
- package/lib/hmr/lazyCompilationBackend.js +51 -12
- package/lib/ids/DeterministicModuleIdsPlugin.js +55 -35
- package/lib/ids/HashedModuleIdsPlugin.js +11 -14
- package/lib/ids/IdHelpers.js +26 -12
- package/lib/ids/NamedModuleIdsPlugin.js +6 -9
- package/lib/ids/NaturalModuleIdsPlugin.js +10 -13
- package/lib/ids/OccurrenceModuleIdsPlugin.js +13 -10
- package/lib/ids/SyncModuleIdsPlugin.js +140 -0
- package/lib/index.js +20 -0
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +2 -2
- package/lib/javascript/BasicEvaluatedExpression.js +5 -2
- package/lib/javascript/ChunkHelpers.js +33 -0
- package/lib/javascript/JavascriptGenerator.js +1 -0
- package/lib/javascript/JavascriptModulesPlugin.js +27 -2
- package/lib/javascript/JavascriptParser.js +143 -73
- package/lib/javascript/StartupHelpers.js +7 -30
- package/lib/json/JsonData.js +8 -0
- package/lib/json/JsonParser.js +4 -6
- package/lib/library/AssignLibraryPlugin.js +39 -15
- package/lib/library/EnableLibraryPlugin.js +11 -0
- package/lib/library/UmdLibraryPlugin.js +5 -3
- package/lib/node/NodeTargetPlugin.js +3 -0
- package/lib/node/NodeWatchFileSystem.js +85 -31
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +23 -8
- package/lib/node/RequireChunkLoadingRuntimeModule.js +24 -9
- package/lib/optimize/ConcatenatedModule.js +62 -26
- package/lib/optimize/ModuleConcatenationPlugin.js +26 -4
- package/lib/optimize/RealContentHashPlugin.js +45 -15
- package/lib/optimize/SplitChunksPlugin.js +8 -1
- package/lib/runtime/AsyncModuleRuntimeModule.js +50 -66
- package/lib/runtime/BaseUriRuntimeModule.js +31 -0
- package/lib/runtime/CreateScriptRuntimeModule.js +36 -0
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +9 -34
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +76 -0
- package/lib/runtime/LoadScriptRuntimeModule.js +11 -9
- package/lib/runtime/NonceRuntimeModule.js +24 -0
- package/lib/schemes/HttpUriPlugin.js +77 -14
- package/lib/serialization/FileMiddleware.js +44 -9
- package/lib/sharing/ConsumeSharedModule.js +8 -2
- package/lib/sharing/ConsumeSharedRuntimeModule.js +26 -5
- package/lib/sharing/ProvideSharedModule.js +4 -2
- package/lib/sharing/ProvideSharedPlugin.js +1 -2
- package/lib/sharing/ShareRuntimeModule.js +1 -1
- package/lib/sharing/utils.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +113 -68
- package/lib/stats/DefaultStatsPrinterPlugin.js +90 -25
- package/lib/util/ArrayHelpers.js +30 -0
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/compileBooleanMatcher.js +1 -1
- package/lib/util/create-schema-validation.js +9 -2
- package/lib/util/createHash.js +12 -0
- package/lib/util/deprecation.js +10 -2
- package/lib/util/deterministicGrouping.js +1 -1
- package/lib/util/extractUrlAndGlobal.js +3 -0
- package/lib/util/fs.js +11 -0
- package/lib/util/hash/BatchedHash.js +7 -4
- package/lib/util/hash/md4.js +20 -0
- package/lib/util/hash/wasm-hash.js +163 -0
- package/lib/util/hash/xxhash64.js +5 -139
- package/lib/util/identifier.js +65 -44
- package/lib/util/internalSerializables.js +15 -0
- package/lib/util/nonNumericOnlyHash.js +22 -0
- package/lib/util/semver.js +17 -10
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +9 -3
- package/lib/wasm-sync/WebAssemblyParser.js +1 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +31 -18
- package/lib/webpack.js +10 -3
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -11
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +33 -22
- package/module.d.ts +215 -0
- package/package.json +28 -32
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +321 -30
- package/schemas/plugins/BannerPlugin.check.js +1 -1
- package/schemas/plugins/BannerPlugin.json +4 -0
- package/schemas/plugins/DllReferencePlugin.check.js +1 -1
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetParserOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.json +2 -1
- 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 +3 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssGeneratorOptions.check.js +6 -0
- package/schemas/plugins/css/CssGeneratorOptions.json +3 -0
- package/schemas/plugins/css/CssParserOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssParserOptions.json +3 -0
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +1 -1
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +1 -1
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.json +4 -0
- package/types.d.ts +869 -296
@@ -1658,84 +1658,121 @@ const collapse = children => {
|
|
1658
1658
|
return newChildren;
|
1659
1659
|
};
|
1660
1660
|
|
1661
|
-
const spaceLimited = (
|
1661
|
+
const spaceLimited = (
|
1662
|
+
itemsAndGroups,
|
1663
|
+
max,
|
1664
|
+
filteredChildrenLineReserved = false
|
1665
|
+
) => {
|
1666
|
+
if (max < 1) {
|
1667
|
+
return {
|
1668
|
+
children: undefined,
|
1669
|
+
filteredChildren: getTotalItems(itemsAndGroups)
|
1670
|
+
};
|
1671
|
+
}
|
1662
1672
|
/** @type {any[] | undefined} */
|
1663
1673
|
let children = undefined;
|
1664
1674
|
/** @type {number | undefined} */
|
1665
1675
|
let filteredChildren = undefined;
|
1666
1676
|
// This are the groups, which take 1+ lines each
|
1667
|
-
const groups =
|
1677
|
+
const groups = [];
|
1668
1678
|
// The sizes of the groups are stored in groupSizes
|
1669
|
-
const groupSizes =
|
1679
|
+
const groupSizes = [];
|
1670
1680
|
// This are the items, which take 1 line each
|
1671
|
-
const items =
|
1681
|
+
const items = [];
|
1672
1682
|
// The total of group sizes
|
1673
|
-
let groupsSize =
|
1683
|
+
let groupsSize = 0;
|
1684
|
+
|
1685
|
+
for (const itemOrGroup of itemsAndGroups) {
|
1686
|
+
// is item
|
1687
|
+
if (!itemOrGroup.children && !itemOrGroup.filteredChildren) {
|
1688
|
+
items.push(itemOrGroup);
|
1689
|
+
} else {
|
1690
|
+
groups.push(itemOrGroup);
|
1691
|
+
const size = getItemSize(itemOrGroup);
|
1692
|
+
groupSizes.push(size);
|
1693
|
+
groupsSize += size;
|
1694
|
+
}
|
1695
|
+
}
|
1696
|
+
|
1674
1697
|
if (groupsSize + items.length <= max) {
|
1675
1698
|
// The total size in the current state fits into the max
|
1676
1699
|
// keep all
|
1677
|
-
children = groups.concat(items);
|
1678
|
-
} else if (
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1700
|
+
children = groups.length > 0 ? groups.concat(items) : items;
|
1701
|
+
} else if (groups.length === 0) {
|
1702
|
+
// slice items to max
|
1703
|
+
// inner space marks that lines for filteredChildren already reserved
|
1704
|
+
const limit = max - (filteredChildrenLineReserved ? 0 : 1);
|
1705
|
+
filteredChildren = items.length - limit;
|
1706
|
+
items.length = limit;
|
1707
|
+
children = items;
|
1708
|
+
} else {
|
1709
|
+
// limit is the size when all groups are collapsed
|
1710
|
+
const limit =
|
1711
|
+
groups.length +
|
1712
|
+
(filteredChildrenLineReserved || items.length === 0 ? 0 : 1);
|
1713
|
+
if (limit < max) {
|
1685
1714
|
// calculate how much we are over the size limit
|
1686
1715
|
// this allows to approach the limit faster
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1716
|
+
let oversize;
|
1717
|
+
// If each group would take 1 line the total would be below the maximum
|
1718
|
+
// collapse some groups, keep items
|
1719
|
+
while (
|
1720
|
+
(oversize =
|
1721
|
+
groupsSize +
|
1722
|
+
items.length +
|
1723
|
+
(filteredChildren && !filteredChildrenLineReserved ? 1 : 0) -
|
1724
|
+
max) > 0
|
1725
|
+
) {
|
1726
|
+
// Find the maximum group and process only this one
|
1727
|
+
const maxGroupSize = Math.max(...groupSizes);
|
1728
|
+
if (maxGroupSize < items.length) {
|
1729
|
+
filteredChildren = items.length;
|
1730
|
+
items.length = 0;
|
1731
|
+
continue;
|
1732
|
+
}
|
1733
|
+
for (let i = 0; i < groups.length; i++) {
|
1734
|
+
if (groupSizes[i] === maxGroupSize) {
|
1735
|
+
const group = groups[i];
|
1736
|
+
// run this algorithm recursively and limit the size of the children to
|
1737
|
+
// current size - oversize / number of groups
|
1738
|
+
// So it should always end up being smaller
|
1739
|
+
const headerSize = group.filteredChildren ? 2 : 1;
|
1740
|
+
const limited = spaceLimited(
|
1741
|
+
group.children,
|
1742
|
+
maxGroupSize -
|
1743
|
+
// we should use ceil to always feet in max
|
1744
|
+
Math.ceil(oversize / groups.length) -
|
1745
|
+
// we substitute size of group head
|
1746
|
+
headerSize,
|
1747
|
+
headerSize === 2
|
1748
|
+
);
|
1749
|
+
groups[i] = {
|
1750
|
+
...group,
|
1751
|
+
children: limited.children,
|
1752
|
+
filteredChildren: limited.filteredChildren
|
1753
|
+
? (group.filteredChildren || 0) + limited.filteredChildren
|
1754
|
+
: group.filteredChildren
|
1755
|
+
};
|
1756
|
+
const newSize = getItemSize(groups[i]);
|
1757
|
+
groupsSize -= maxGroupSize - newSize;
|
1758
|
+
groupSizes[i] = newSize;
|
1759
|
+
break;
|
1760
|
+
}
|
1722
1761
|
}
|
1723
1762
|
}
|
1763
|
+
children = groups.concat(items);
|
1764
|
+
} else if (limit === max) {
|
1765
|
+
// If we have only enough space to show one line per group and one line for the filtered items
|
1766
|
+
// collapse all groups and items
|
1767
|
+
children = collapse(groups);
|
1768
|
+
filteredChildren = items.length;
|
1769
|
+
} else {
|
1770
|
+
// If we have no space
|
1771
|
+
// collapse complete group
|
1772
|
+
filteredChildren = getTotalItems(itemsAndGroups);
|
1724
1773
|
}
|
1725
|
-
children = groups.concat(items);
|
1726
|
-
} else if (
|
1727
|
-
groups.length > 0 &&
|
1728
|
-
groups.length + Math.min(1, items.length) <= max
|
1729
|
-
) {
|
1730
|
-
// If we have only enough space to show one line per group and one line for the filtered items
|
1731
|
-
// collapse all groups and items
|
1732
|
-
children = groups.length ? collapse(groups) : undefined;
|
1733
|
-
filteredChildren = items.length;
|
1734
|
-
} else {
|
1735
|
-
// If we have no space
|
1736
|
-
// collapse complete group
|
1737
|
-
filteredChildren = getTotalItems(itemsAndGroups);
|
1738
1774
|
}
|
1775
|
+
|
1739
1776
|
return {
|
1740
1777
|
children,
|
1741
1778
|
filteredChildren
|
@@ -1777,6 +1814,9 @@ const reasonGroup = (children, reasons) => {
|
|
1777
1814
|
};
|
1778
1815
|
};
|
1779
1816
|
|
1817
|
+
const GROUP_EXTENSION_REGEXP = /(\.[^.]+?)(?:\?|(?: \+ \d+ modules?)?$)/;
|
1818
|
+
const GROUP_PATH_REGEXP = /(.+)[/\\][^/\\]+?(?:\?|(?: \+ \d+ modules?)?$)/;
|
1819
|
+
|
1780
1820
|
/** @type {Record<string, (groupConfigs: GroupConfig[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>} */
|
1781
1821
|
const ASSETS_GROUPERS = {
|
1782
1822
|
_: (groupConfigs, context, options) => {
|
@@ -1825,10 +1865,10 @@ const ASSETS_GROUPERS = {
|
|
1825
1865
|
groupConfigs.push({
|
1826
1866
|
getKeys: asset => {
|
1827
1867
|
const extensionMatch =
|
1828
|
-
groupAssetsByExtension &&
|
1868
|
+
groupAssetsByExtension && GROUP_EXTENSION_REGEXP.exec(asset.name);
|
1829
1869
|
const extension = extensionMatch ? extensionMatch[1] : "";
|
1830
1870
|
const pathMatch =
|
1831
|
-
groupAssetsByPath &&
|
1871
|
+
groupAssetsByPath && GROUP_PATH_REGEXP.exec(asset.name);
|
1832
1872
|
const path = pathMatch ? pathMatch[1].split(/[/\\]/) : [];
|
1833
1873
|
const keys = [];
|
1834
1874
|
if (groupAssetsByPath) {
|
@@ -2022,11 +2062,13 @@ const MODULES_GROUPERS = type => ({
|
|
2022
2062
|
getKeys: module => {
|
2023
2063
|
if (!module.name) return;
|
2024
2064
|
const resource = parseResource(module.name.split("!").pop()).path;
|
2065
|
+
const dataUrl = /^data:[^,;]+/.exec(resource);
|
2066
|
+
if (dataUrl) return [dataUrl[0]];
|
2025
2067
|
const extensionMatch =
|
2026
|
-
groupModulesByExtension &&
|
2068
|
+
groupModulesByExtension && GROUP_EXTENSION_REGEXP.exec(resource);
|
2027
2069
|
const extension = extensionMatch ? extensionMatch[1] : "";
|
2028
2070
|
const pathMatch =
|
2029
|
-
groupModulesByPath &&
|
2071
|
+
groupModulesByPath && GROUP_PATH_REGEXP.exec(resource);
|
2030
2072
|
const path = pathMatch ? pathMatch[1].split(/[/\\]/) : [];
|
2031
2073
|
const keys = [];
|
2032
2074
|
if (groupModulesByPath) {
|
@@ -2046,11 +2088,14 @@ const MODULES_GROUPERS = type => ({
|
|
2046
2088
|
return keys;
|
2047
2089
|
},
|
2048
2090
|
createGroup: (key, children, modules) => {
|
2091
|
+
const isDataUrl = key.startsWith("data:");
|
2049
2092
|
return {
|
2050
|
-
type:
|
2093
|
+
type: isDataUrl
|
2094
|
+
? "modules by mime type"
|
2095
|
+
: groupModulesByPath
|
2051
2096
|
? "modules by path"
|
2052
2097
|
: "modules by extension",
|
2053
|
-
name: key,
|
2098
|
+
name: isDataUrl ? key.slice(/* 'data:'.length */ 5) : key,
|
2054
2099
|
children,
|
2055
2100
|
...moduleGroup(children, modules)
|
2056
2101
|
};
|
@@ -2110,7 +2155,7 @@ const RESULT_GROUPERS = {
|
|
2110
2155
|
// remove a prefixed "!" that can be specified to reverse sort order
|
2111
2156
|
const normalizeFieldKey = field => {
|
2112
2157
|
if (field[0] === "!") {
|
2113
|
-
return field.
|
2158
|
+
return field.slice(1);
|
2114
2159
|
}
|
2115
2160
|
return field;
|
2116
2161
|
};
|
@@ -9,6 +9,8 @@
|
|
9
9
|
/** @typedef {import("./StatsPrinter")} StatsPrinter */
|
10
10
|
/** @typedef {import("./StatsPrinter").StatsPrinterContext} StatsPrinterContext */
|
11
11
|
|
12
|
+
const DATA_URI_CONTENT_LENGTH = 16;
|
13
|
+
|
12
14
|
const plural = (n, singular, plural) => (n === 1 ? singular : plural);
|
13
15
|
|
14
16
|
/**
|
@@ -26,6 +28,23 @@ const printSizes = (sizes, { formatSize = n => `${n}` }) => {
|
|
26
28
|
}
|
27
29
|
};
|
28
30
|
|
31
|
+
const getResourceName = resource => {
|
32
|
+
const dataUrl = /^data:[^,]+,/.exec(resource);
|
33
|
+
if (!dataUrl) return resource;
|
34
|
+
|
35
|
+
const len = dataUrl[0].length + DATA_URI_CONTENT_LENGTH;
|
36
|
+
if (resource.length < len) return resource;
|
37
|
+
return `${resource.slice(
|
38
|
+
0,
|
39
|
+
Math.min(resource.length - /* '..'.length */ 2, len)
|
40
|
+
)}..`;
|
41
|
+
};
|
42
|
+
|
43
|
+
const getModuleName = name => {
|
44
|
+
const [, prefix, resource] = /^(.*!)?([^!]*)$/.exec(name);
|
45
|
+
return [prefix, getResourceName(resource)];
|
46
|
+
};
|
47
|
+
|
29
48
|
const mapLines = (str, fn) => str.split("\n").map(fn).join("\n");
|
30
49
|
|
31
50
|
/**
|
@@ -38,6 +57,10 @@ const isValidId = id => {
|
|
38
57
|
return typeof id === "number" || id;
|
39
58
|
};
|
40
59
|
|
60
|
+
const moreCount = (list, count) => {
|
61
|
+
return list && list.length > 0 ? `+ ${count}` : `${count}`;
|
62
|
+
};
|
63
|
+
|
41
64
|
/** @type {Record<string, (thing: any, context: StatsPrinterContext, printer: StatsPrinter) => string | void>} */
|
42
65
|
const SIMPLE_PRINTERS = {
|
43
66
|
"compilation.summary!": (
|
@@ -163,13 +186,24 @@ const SIMPLE_PRINTERS = {
|
|
163
186
|
},
|
164
187
|
"compilation.assetsByChunkName": () => "",
|
165
188
|
|
166
|
-
"compilation.filteredModules":
|
189
|
+
"compilation.filteredModules": (
|
190
|
+
filteredModules,
|
191
|
+
{ compilation: { modules } }
|
192
|
+
) =>
|
167
193
|
filteredModules > 0
|
168
|
-
? `${filteredModules} ${plural(
|
194
|
+
? `${moreCount(modules, filteredModules)} ${plural(
|
195
|
+
filteredModules,
|
196
|
+
"module",
|
197
|
+
"modules"
|
198
|
+
)}`
|
169
199
|
: undefined,
|
170
200
|
"compilation.filteredAssets": (filteredAssets, { compilation: { assets } }) =>
|
171
201
|
filteredAssets > 0
|
172
|
-
? `${filteredAssets} ${plural(
|
202
|
+
? `${moreCount(assets, filteredAssets)} ${plural(
|
203
|
+
filteredAssets,
|
204
|
+
"asset",
|
205
|
+
"assets"
|
206
|
+
)}`
|
173
207
|
: undefined,
|
174
208
|
"compilation.logging": (logging, context, printer) =>
|
175
209
|
Array.isArray(logging)
|
@@ -262,15 +296,19 @@ const SIMPLE_PRINTERS = {
|
|
262
296
|
"asset.separator!": () => "\n",
|
263
297
|
"asset.filteredRelated": (filteredRelated, { asset: { related } }) =>
|
264
298
|
filteredRelated > 0
|
265
|
-
? `${filteredRelated} related ${plural(
|
299
|
+
? `${moreCount(related, filteredRelated)} related ${plural(
|
266
300
|
filteredRelated,
|
267
301
|
"asset",
|
268
302
|
"assets"
|
269
303
|
)}`
|
270
304
|
: undefined,
|
271
|
-
"asset.filteredChildren": filteredChildren =>
|
305
|
+
"asset.filteredChildren": (filteredChildren, { asset: { children } }) =>
|
272
306
|
filteredChildren > 0
|
273
|
-
? `${filteredChildren} ${plural(
|
307
|
+
? `${moreCount(children, filteredChildren)} ${plural(
|
308
|
+
filteredChildren,
|
309
|
+
"asset",
|
310
|
+
"assets"
|
311
|
+
)}`
|
274
312
|
: undefined,
|
275
313
|
|
276
314
|
assetChunk: (id, { formatChunkId }) => formatChunkId(id),
|
@@ -282,8 +320,8 @@ const SIMPLE_PRINTERS = {
|
|
282
320
|
"module.id": (id, { formatModuleId }) =>
|
283
321
|
isValidId(id) ? formatModuleId(id) : undefined,
|
284
322
|
"module.name": (name, { bold }) => {
|
285
|
-
const [
|
286
|
-
return
|
323
|
+
const [prefix, resource] = getModuleName(name);
|
324
|
+
return `${prefix || ""}${bold(resource || "")}`;
|
287
325
|
},
|
288
326
|
"module.identifier": identifier => undefined,
|
289
327
|
"module.layer": (layer, { formatLayer }) =>
|
@@ -366,21 +404,29 @@ const SIMPLE_PRINTERS = {
|
|
366
404
|
"module.issuerPath": (issuerPath, { module }) =>
|
367
405
|
module.profile ? undefined : "",
|
368
406
|
"module.profile": profile => undefined,
|
369
|
-
"module.filteredModules": filteredModules =>
|
407
|
+
"module.filteredModules": (filteredModules, { module: { modules } }) =>
|
370
408
|
filteredModules > 0
|
371
|
-
? `${filteredModules} nested ${plural(
|
409
|
+
? `${moreCount(modules, filteredModules)} nested ${plural(
|
372
410
|
filteredModules,
|
373
411
|
"module",
|
374
412
|
"modules"
|
375
413
|
)}`
|
376
414
|
: undefined,
|
377
|
-
"module.filteredReasons": filteredReasons =>
|
415
|
+
"module.filteredReasons": (filteredReasons, { module: { reasons } }) =>
|
378
416
|
filteredReasons > 0
|
379
|
-
? `${filteredReasons} ${plural(
|
417
|
+
? `${moreCount(reasons, filteredReasons)} ${plural(
|
418
|
+
filteredReasons,
|
419
|
+
"reason",
|
420
|
+
"reasons"
|
421
|
+
)}`
|
380
422
|
: undefined,
|
381
|
-
"module.filteredChildren": filteredChildren =>
|
423
|
+
"module.filteredChildren": (filteredChildren, { module: { children } }) =>
|
382
424
|
filteredChildren > 0
|
383
|
-
? `${filteredChildren} ${plural(
|
425
|
+
? `${moreCount(children, filteredChildren)} ${plural(
|
426
|
+
filteredChildren,
|
427
|
+
"module",
|
428
|
+
"modules"
|
429
|
+
)}`
|
384
430
|
: undefined,
|
385
431
|
"module.separator!": () => "\n",
|
386
432
|
|
@@ -388,7 +434,8 @@ const SIMPLE_PRINTERS = {
|
|
388
434
|
"moduleIssuer.profile.total": (value, { formatTime }) => formatTime(value),
|
389
435
|
|
390
436
|
"moduleReason.type": type => type,
|
391
|
-
"moduleReason.userRequest": (userRequest, { cyan }) =>
|
437
|
+
"moduleReason.userRequest": (userRequest, { cyan }) =>
|
438
|
+
cyan(getResourceName(userRequest)),
|
392
439
|
"moduleReason.moduleId": (moduleId, { formatModuleId }) =>
|
393
440
|
isValidId(moduleId) ? formatModuleId(moduleId) : undefined,
|
394
441
|
"moduleReason.module": (module, { magenta }) => magenta(module),
|
@@ -397,9 +444,16 @@ const SIMPLE_PRINTERS = {
|
|
397
444
|
"moduleReason.active": (active, { formatFlag }) =>
|
398
445
|
active ? undefined : formatFlag("inactive"),
|
399
446
|
"moduleReason.resolvedModule": (module, { magenta }) => magenta(module),
|
400
|
-
"moduleReason.filteredChildren":
|
447
|
+
"moduleReason.filteredChildren": (
|
448
|
+
filteredChildren,
|
449
|
+
{ moduleReason: { children } }
|
450
|
+
) =>
|
401
451
|
filteredChildren > 0
|
402
|
-
? `${filteredChildren} ${plural(
|
452
|
+
? `${moreCount(children, filteredChildren)} ${plural(
|
453
|
+
filteredChildren,
|
454
|
+
"reason",
|
455
|
+
"reasons"
|
456
|
+
)}`
|
403
457
|
: undefined,
|
404
458
|
|
405
459
|
"module.profile.total": (value, { formatTime }) => formatTime(value),
|
@@ -427,10 +481,21 @@ const SIMPLE_PRINTERS = {
|
|
427
481
|
size ? formatSize(size) : undefined,
|
428
482
|
"chunkGroup.auxiliaryAssetsSize": (size, { formatSize }) =>
|
429
483
|
size ? `(${formatSize(size)})` : undefined,
|
430
|
-
"chunkGroup.filteredAssets": n =>
|
431
|
-
n > 0
|
432
|
-
|
433
|
-
|
484
|
+
"chunkGroup.filteredAssets": (n, { chunkGroup: { assets } }) =>
|
485
|
+
n > 0
|
486
|
+
? `${moreCount(assets, n)} ${plural(n, "asset", "assets")}`
|
487
|
+
: undefined,
|
488
|
+
"chunkGroup.filteredAuxiliaryAssets": (
|
489
|
+
n,
|
490
|
+
{ chunkGroup: { auxiliaryAssets } }
|
491
|
+
) =>
|
492
|
+
n > 0
|
493
|
+
? `${moreCount(auxiliaryAssets, n)} auxiliary ${plural(
|
494
|
+
n,
|
495
|
+
"asset",
|
496
|
+
"assets"
|
497
|
+
)}`
|
498
|
+
: undefined,
|
434
499
|
"chunkGroup.is!": () => "=",
|
435
500
|
"chunkGroupAsset.name": (asset, { green }) => green(asset),
|
436
501
|
"chunkGroupAsset.size": (size, { formatSize, chunkGroup }) =>
|
@@ -490,9 +555,9 @@ const SIMPLE_PRINTERS = {
|
|
490
555
|
"chunk.recorded": (recorded, { formatFlag, green }) =>
|
491
556
|
recorded ? green(formatFlag("recorded")) : undefined,
|
492
557
|
"chunk.reason": (reason, { yellow }) => (reason ? yellow(reason) : undefined),
|
493
|
-
"chunk.filteredModules": filteredModules =>
|
558
|
+
"chunk.filteredModules": (filteredModules, { chunk: { modules } }) =>
|
494
559
|
filteredModules > 0
|
495
|
-
? `${filteredModules} chunk ${plural(
|
560
|
+
? `${moreCount(modules, filteredModules)} chunk ${plural(
|
496
561
|
filteredModules,
|
497
562
|
"module",
|
498
563
|
"modules"
|
@@ -1088,7 +1153,7 @@ const SIMPLE_ELEMENT_JOINERS = {
|
|
1088
1153
|
chunkOrigin: items => "> " + joinOneLine(items),
|
1089
1154
|
"errors[].error": joinError(true),
|
1090
1155
|
"warnings[].error": joinError(false),
|
1091
|
-
loggingGroup: items => joinExplicitNewLine(items, "").
|
1156
|
+
loggingGroup: items => joinExplicitNewLine(items, "").trimEnd(),
|
1092
1157
|
moduleTraceItem: items => " @ " + joinOneLine(items),
|
1093
1158
|
moduleTraceDependency: joinOneLine
|
1094
1159
|
};
|
@@ -1160,7 +1225,7 @@ const AVAILABLE_FORMATS = {
|
|
1160
1225
|
},
|
1161
1226
|
{ regExp: /(\(module has no exports\))/g, format: red },
|
1162
1227
|
{ regExp: /\(possible exports: (.+)\)/g, format: green },
|
1163
|
-
{ regExp:
|
1228
|
+
{ regExp: /(?:^|\n)(.* doesn't exist)/g, format: red },
|
1164
1229
|
{ regExp: /('\w+' option has not been set)/g, format: red },
|
1165
1230
|
{
|
1166
1231
|
regExp: /(Emitted value instead of an instance of Error)/g,
|
package/lib/util/ArrayHelpers.js
CHANGED
@@ -5,6 +5,14 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
/**
|
9
|
+
* Compare two arrays or strings by performing strict equality check for each value.
|
10
|
+
* @template T [T=any]
|
11
|
+
* @param {ArrayLike<T>} a Array of values to be compared
|
12
|
+
* @param {ArrayLike<T>} b Array of values to be compared
|
13
|
+
* @returns {boolean} returns true if all the elements of passed arrays are strictly equal.
|
14
|
+
*/
|
15
|
+
|
8
16
|
exports.equals = (a, b) => {
|
9
17
|
if (a.length !== b.length) return false;
|
10
18
|
for (let i = 0; i < a.length; i++) {
|
@@ -12,3 +20,25 @@ exports.equals = (a, b) => {
|
|
12
20
|
}
|
13
21
|
return true;
|
14
22
|
};
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Partition an array by calling a predicate function on each value.
|
26
|
+
* @template T [T=any]
|
27
|
+
* @param {Array<T>} arr Array of values to be partitioned
|
28
|
+
* @param {(value: T) => boolean} fn Partition function which partitions based on truthiness of result.
|
29
|
+
* @returns {[Array<T>, Array<T>]} returns the values of `arr` partitioned into two new arrays based on fn predicate.
|
30
|
+
*/
|
31
|
+
exports.groupBy = (arr = [], fn) => {
|
32
|
+
return arr.reduce(
|
33
|
+
/**
|
34
|
+
* @param {[Array<T>, Array<T>]} groups An accumulator storing already partitioned values returned from previous call.
|
35
|
+
* @param {T} value The value of the current element
|
36
|
+
* @returns {[Array<T>, Array<T>]} returns an array of partitioned groups accumulator resulting from calling a predicate on the current value.
|
37
|
+
*/
|
38
|
+
(groups, value) => {
|
39
|
+
groups[fn(value) ? 0 : 1].push(value);
|
40
|
+
return groups;
|
41
|
+
},
|
42
|
+
[[], []]
|
43
|
+
);
|
44
|
+
};
|
package/lib/util/AsyncQueue.js
CHANGED
@@ -18,7 +18,7 @@ const toSimpleString = str => {
|
|
18
18
|
|
19
19
|
/**
|
20
20
|
* @param {Record<string|number, boolean>} map value map
|
21
|
-
* @returns {
|
21
|
+
* @returns {boolean|(function(string): string)} true/false, when unconditionally true/false, or a template function to determine the value at runtime
|
22
22
|
*/
|
23
23
|
const compileBooleanMatcher = map => {
|
24
24
|
const positiveItems = Object.keys(map).filter(i => map[i]);
|
@@ -9,11 +9,18 @@ const memoize = require("./memoize");
|
|
9
9
|
|
10
10
|
const getValidate = memoize(() => require("schema-utils").validate);
|
11
11
|
|
12
|
-
const createSchemaValidation = (check
|
12
|
+
const createSchemaValidation = (check, getSchema, options) => {
|
13
13
|
getSchema = memoize(getSchema);
|
14
14
|
return value => {
|
15
|
-
if (!check(value)) {
|
15
|
+
if (check && !check(value)) {
|
16
16
|
getValidate()(getSchema(), value, options);
|
17
|
+
if (check) {
|
18
|
+
require("util").deprecate(
|
19
|
+
() => {},
|
20
|
+
"webpack bug: Pre-compiled schema reports error while real schema is happy. This has performance drawbacks.",
|
21
|
+
"DEP_WEBPACK_PRE_COMPILED_SCHEMA_INVALID"
|
22
|
+
)();
|
23
|
+
}
|
17
24
|
}
|
18
25
|
};
|
19
26
|
};
|
package/lib/util/createHash.js
CHANGED
@@ -126,6 +126,7 @@ class DebugHash extends Hash {
|
|
126
126
|
|
127
127
|
let crypto = undefined;
|
128
128
|
let createXXHash64 = undefined;
|
129
|
+
let createMd4 = undefined;
|
129
130
|
let BatchedHash = undefined;
|
130
131
|
|
131
132
|
/**
|
@@ -149,6 +150,17 @@ module.exports = algorithm => {
|
|
149
150
|
}
|
150
151
|
}
|
151
152
|
return new BatchedHash(createXXHash64());
|
153
|
+
case "md4":
|
154
|
+
if (createMd4 === undefined) {
|
155
|
+
createMd4 = require("./hash/md4");
|
156
|
+
if (BatchedHash === undefined) {
|
157
|
+
BatchedHash = require("./hash/BatchedHash");
|
158
|
+
}
|
159
|
+
}
|
160
|
+
return new BatchedHash(createMd4());
|
161
|
+
case "native-md4":
|
162
|
+
if (crypto === undefined) crypto = require("crypto");
|
163
|
+
return new BulkUpdateDecorator(() => crypto.createHash("md4"), "md4");
|
152
164
|
default:
|
153
165
|
if (crypto === undefined) crypto = require("crypto");
|
154
166
|
return new BulkUpdateDecorator(
|
package/lib/util/deprecation.js
CHANGED
@@ -165,8 +165,16 @@ exports.arrayToSetDeprecation = (set, name) => {
|
|
165
165
|
};
|
166
166
|
|
167
167
|
exports.createArrayToSetDeprecationSet = name => {
|
168
|
-
|
169
|
-
|
168
|
+
let initialized = false;
|
169
|
+
class SetDeprecatedArray extends Set {
|
170
|
+
constructor(items) {
|
171
|
+
super(items);
|
172
|
+
if (!initialized) {
|
173
|
+
initialized = true;
|
174
|
+
exports.arrayToSetDeprecation(SetDeprecatedArray.prototype, name);
|
175
|
+
}
|
176
|
+
}
|
177
|
+
}
|
170
178
|
return SetDeprecatedArray;
|
171
179
|
};
|
172
180
|
|
@@ -498,7 +498,7 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
|
|
498
498
|
|
499
499
|
// return the results
|
500
500
|
return result.map(group => {
|
501
|
-
/** @type {GroupedItems} */
|
501
|
+
/** @type {GroupedItems<T>} */
|
502
502
|
return {
|
503
503
|
key: group.key,
|
504
504
|
items: group.nodes.map(node => node.item),
|
@@ -11,5 +11,8 @@
|
|
11
11
|
*/
|
12
12
|
module.exports = function extractUrlAndGlobal(urlAndGlobal) {
|
13
13
|
const index = urlAndGlobal.indexOf("@");
|
14
|
+
if (index <= 0 || index === urlAndGlobal.length - 1) {
|
15
|
+
throw new Error(`Invalid request "${urlAndGlobal}"`);
|
16
|
+
}
|
14
17
|
return [urlAndGlobal.substring(index + 1), urlAndGlobal.substring(0, index)];
|
15
18
|
};
|
package/lib/util/fs.js
CHANGED
@@ -61,6 +61,15 @@ const path = require("path");
|
|
61
61
|
/** @typedef {function((NodeJS.ErrnoException | Error | null)=, any=): void} ReadJsonCallback */
|
62
62
|
/** @typedef {function((NodeJS.ErrnoException | Error | null)=, IStats|string=): void} LstatReadlinkAbsoluteCallback */
|
63
63
|
|
64
|
+
/**
|
65
|
+
* @typedef {Object} WatcherInfo
|
66
|
+
* @property {Set<string>} changes get current aggregated changes that have not yet send to callback
|
67
|
+
* @property {Set<string>} removals get current aggregated removals that have not yet send to callback
|
68
|
+
* @property {Map<string, FileSystemInfoEntry | "ignore">} fileTimeInfoEntries get info about files
|
69
|
+
* @property {Map<string, FileSystemInfoEntry | "ignore">} contextTimeInfoEntries get info about directories
|
70
|
+
*/
|
71
|
+
|
72
|
+
// TODO webpack 6 deprecate missing getInfo
|
64
73
|
/**
|
65
74
|
* @typedef {Object} Watcher
|
66
75
|
* @property {function(): void} close closes the watcher and all underlying file watchers
|
@@ -69,6 +78,7 @@ const path = require("path");
|
|
69
78
|
* @property {function(): Set<string>=} getAggregatedRemovals get current aggregated removals that have not yet send to callback
|
70
79
|
* @property {function(): Map<string, FileSystemInfoEntry | "ignore">} getFileTimeInfoEntries get info about files
|
71
80
|
* @property {function(): Map<string, FileSystemInfoEntry | "ignore">} getContextTimeInfoEntries get info about directories
|
81
|
+
* @property {function(): WatcherInfo=} getInfo get info about timestamps and changes
|
72
82
|
*/
|
73
83
|
|
74
84
|
/**
|
@@ -93,6 +103,7 @@ const path = require("path");
|
|
93
103
|
* @property {function(string, Callback): void=} rmdir
|
94
104
|
* @property {function(string, Callback): void=} unlink
|
95
105
|
* @property {function(string, StatsCallback): void} stat
|
106
|
+
* @property {function(string, StatsCallback): void=} lstat
|
96
107
|
* @property {function(string, BufferOrStringCallback): void} readFile
|
97
108
|
* @property {(function(string, string): string)=} join
|
98
109
|
* @property {(function(string, string): string)=} relative
|