webpack 5.101.2 → 5.102.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 +21 -26
- package/lib/APIPlugin.js +30 -36
- package/lib/AsyncDependenciesBlock.js +1 -4
- package/lib/BannerPlugin.js +0 -1
- package/lib/Cache.js +7 -6
- package/lib/CacheFacade.js +0 -1
- package/lib/Chunk.js +49 -31
- package/lib/ChunkGraph.js +35 -25
- package/lib/ChunkGroup.js +8 -10
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +3 -3
- package/lib/CodeGenerationResults.js +2 -1
- package/lib/CompatibilityPlugin.js +29 -12
- package/lib/Compilation.js +204 -185
- package/lib/Compiler.js +36 -35
- package/lib/ConcatenationScope.js +6 -1
- package/lib/ConditionalInitFragment.js +1 -1
- package/lib/ConstPlugin.js +18 -10
- package/lib/ContextExclusionPlugin.js +0 -1
- package/lib/ContextModule.js +22 -20
- package/lib/ContextModuleFactory.js +30 -11
- package/lib/ContextReplacementPlugin.js +38 -15
- package/lib/DefinePlugin.js +18 -8
- package/lib/DelegatedModule.js +7 -11
- package/lib/DependenciesBlock.js +0 -2
- package/lib/Dependency.js +9 -11
- package/lib/DependencyTemplates.js +1 -3
- package/lib/DllModule.js +1 -7
- package/lib/DllReferencePlugin.js +2 -4
- package/lib/DynamicEntryPlugin.js +0 -2
- package/lib/EntryOptionPlugin.js +0 -5
- package/lib/EnvironmentNotSupportAsyncWarning.js +0 -3
- package/lib/EvalDevToolModulePlugin.js +4 -3
- package/lib/EvalSourceMapDevToolPlugin.js +3 -4
- package/lib/ExportsInfo.js +50 -49
- package/lib/ExternalModule.js +84 -52
- package/lib/ExternalModuleFactoryPlugin.js +27 -7
- package/lib/ExternalsPlugin.js +24 -17
- package/lib/FileSystemInfo.js +96 -78
- package/lib/FlagDependencyUsagePlugin.js +3 -4
- package/lib/Generator.js +2 -13
- package/lib/GraphHelpers.js +0 -3
- package/lib/HookWebpackError.js +0 -2
- package/lib/HotModuleReplacementPlugin.js +22 -24
- package/lib/HotUpdateChunk.js +0 -3
- package/lib/IgnorePlugin.js +5 -2
- package/lib/InitFragment.js +41 -29
- package/lib/InvalidDependenciesModuleWarning.js +0 -1
- package/lib/LibManifestPlugin.js +4 -6
- package/lib/LoaderOptionsPlugin.js +1 -10
- package/lib/MainTemplate.js +8 -19
- package/lib/Module.js +32 -20
- package/lib/ModuleFactory.js +1 -1
- package/lib/ModuleFilenameHelpers.js +41 -24
- package/lib/ModuleGraph.js +30 -16
- package/lib/ModuleInfoHeaderPlugin.js +0 -1
- package/lib/ModuleTemplate.js +0 -2
- package/lib/ModuleTypeConstants.js +11 -1
- package/lib/MultiCompiler.js +23 -15
- package/lib/MultiWatching.js +6 -10
- package/lib/NodeStuffPlugin.js +2 -10
- package/lib/NormalModule.js +145 -88
- package/lib/NormalModuleFactory.js +59 -40
- package/lib/OptionsApply.js +1 -1
- package/lib/Parser.js +1 -1
- package/lib/ProgressPlugin.js +6 -10
- package/lib/ProvidePlugin.js +5 -7
- package/lib/RawModule.js +1 -6
- package/lib/RecordIdsPlugin.js +10 -6
- package/lib/ResolverFactory.js +0 -2
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimeModule.js +1 -3
- package/lib/RuntimePlugin.js +26 -22
- package/lib/RuntimeTemplate.js +12 -11
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -2
- package/lib/SourceMapDevToolPlugin.js +6 -11
- package/lib/Stats.js +0 -1
- package/lib/Template.js +6 -11
- package/lib/TemplatedPathPlugin.js +2 -1
- package/lib/WatchIgnorePlugin.js +2 -3
- package/lib/Watching.js +15 -15
- package/lib/WebpackIsIncludedPlugin.js +0 -2
- package/lib/WebpackOptionsApply.js +74 -107
- package/lib/asset/AssetBytesGenerator.js +166 -0
- package/lib/asset/AssetBytesParser.js +37 -0
- package/lib/asset/AssetGenerator.js +20 -34
- package/lib/asset/AssetModulesPlugin.js +34 -16
- package/lib/asset/AssetParser.js +7 -3
- package/lib/asset/AssetSourceGenerator.js +1 -1
- package/lib/asset/RawDataUrlModule.js +3 -2
- package/lib/async-modules/AsyncModuleHelpers.js +6 -4
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -1
- package/lib/buildChunkGraph.js +0 -1
- package/lib/cache/MemoryCachePlugin.js +0 -2
- package/lib/cache/MemoryWithGcCachePlugin.js +0 -2
- package/lib/cache/PackFileCacheStrategy.js +14 -1
- package/lib/cache/ResolverCachePlugin.js +9 -15
- package/lib/config/defaults.js +155 -21
- package/lib/config/normalization.js +18 -3
- package/lib/container/ContainerEntryDependency.js +0 -1
- package/lib/container/ContainerEntryModule.js +3 -7
- package/lib/container/ContainerPlugin.js +1 -2
- package/lib/container/ContainerReferencePlugin.js +0 -1
- package/lib/container/FallbackDependency.js +2 -1
- package/lib/container/FallbackModule.js +6 -7
- package/lib/container/ModuleFederationPlugin.js +0 -1
- package/lib/container/RemoteModule.js +8 -8
- package/lib/container/RemoteRuntimeModule.js +2 -2
- package/lib/css/CssGenerator.js +3 -6
- package/lib/css/CssLoadingRuntimeModule.js +6 -9
- package/lib/css/CssModulesPlugin.js +11 -13
- package/lib/css/CssParser.js +3 -3
- package/lib/css/walkCssTokens.js +1 -1
- package/lib/debug/ProfilingPlugin.js +35 -8
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +12 -17
- package/lib/dependencies/AMDPlugin.js +2 -2
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -2
- package/lib/dependencies/CachedConstDependency.js +0 -4
- package/lib/dependencies/CommonJsExportRequireDependency.js +20 -14
- package/lib/dependencies/CommonJsExportsDependency.js +2 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -5
- package/lib/dependencies/CommonJsFullRequireDependency.js +6 -4
- package/lib/dependencies/CommonJsImportsParserPlugin.js +16 -7
- package/lib/dependencies/CommonJsRequireContextDependency.js +1 -1
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +4 -4
- package/lib/dependencies/ConstDependency.js +2 -2
- package/lib/dependencies/ContextDependency.js +9 -4
- package/lib/dependencies/ContextDependencyHelpers.js +2 -2
- package/lib/dependencies/ContextDependencyTemplateAsId.js +9 -9
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +9 -9
- package/lib/dependencies/ContextElementDependency.js +22 -11
- package/lib/dependencies/CssIcssImportDependency.js +0 -2
- package/lib/dependencies/CssIcssSymbolDependency.js +2 -2
- package/lib/dependencies/CssImportDependency.js +0 -8
- package/lib/dependencies/CssLocalIdentifierDependency.js +3 -4
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssUrlDependency.js +0 -6
- package/lib/dependencies/ExportsInfoDependency.js +7 -9
- package/lib/dependencies/ExternalModuleDependency.js +0 -3
- package/lib/dependencies/ExternalModuleInitFragment.js +1 -1
- package/lib/dependencies/HarmonyAcceptDependency.js +1 -1
- package/lib/dependencies/HarmonyAcceptImportDependency.js +0 -4
- package/lib/dependencies/HarmonyCompatibilityDependency.js +0 -1
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +0 -14
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +3 -3
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +4 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +29 -35
- package/lib/dependencies/HarmonyImportDependency.js +30 -14
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +38 -24
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +0 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -31
- package/lib/dependencies/HarmonyModulesPlugin.js +3 -3
- package/lib/dependencies/ImportDependency.js +18 -6
- package/lib/dependencies/ImportEagerDependency.js +2 -3
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +8 -5
- package/lib/dependencies/ImportMetaContextPlugin.js +0 -1
- package/lib/dependencies/ImportMetaPlugin.js +8 -1
- package/lib/dependencies/ImportParserPlugin.js +294 -45
- package/lib/dependencies/ImportWeakDependency.js +2 -3
- package/lib/dependencies/JsonExportsDependency.js +0 -1
- package/lib/dependencies/LoaderDependency.js +0 -3
- package/lib/dependencies/LoaderImportDependency.js +0 -3
- package/lib/dependencies/LoaderPlugin.js +11 -5
- package/lib/dependencies/ModuleDecoratorDependency.js +2 -4
- package/lib/dependencies/ModuleDependency.js +3 -9
- package/lib/dependencies/NullDependency.js +2 -0
- package/lib/dependencies/ProvidedDependency.js +6 -8
- package/lib/dependencies/PureExpressionDependency.js +0 -1
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +0 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -2
- package/lib/dependencies/RequireIncludeDependency.js +2 -2
- package/lib/dependencies/RequireResolveDependency.js +2 -2
- package/lib/dependencies/RuntimeRequirementsDependency.js +2 -3
- package/lib/dependencies/StaticExportsDependency.js +3 -5
- package/lib/dependencies/URLDependency.js +2 -7
- package/lib/dependencies/URLPlugin.js +1 -2
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +2 -2
- package/lib/dependencies/WebAssemblyImportDependency.js +2 -2
- package/lib/dependencies/WebpackIsIncludedDependency.js +2 -3
- package/lib/dependencies/WorkerDependency.js +2 -3
- package/lib/dependencies/WorkerPlugin.js +3 -9
- package/lib/dependencies/processExportInfo.js +2 -3
- package/lib/esm/ModuleChunkFormatPlugin.js +0 -3
- package/lib/esm/ModuleChunkLoadingPlugin.js +2 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -7
- package/lib/hmr/LazyCompilationPlugin.js +6 -4
- package/lib/hmr/lazyCompilationBackend.js +13 -10
- package/lib/ids/DeterministicChunkIdsPlugin.js +0 -1
- package/lib/ids/NamedChunkIdsPlugin.js +1 -6
- package/lib/ids/NamedModuleIdsPlugin.js +1 -5
- package/lib/ids/NaturalChunkIdsPlugin.js +0 -1
- package/lib/ids/NaturalModuleIdsPlugin.js +0 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +0 -1
- package/lib/ids/OccurrenceModuleIdsPlugin.js +0 -1
- package/lib/ids/SyncModuleIdsPlugin.js +4 -3
- package/lib/index.js +8 -7
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -1
- package/lib/javascript/BasicEvaluatedExpression.js +13 -6
- package/lib/javascript/ChunkFormatHelpers.js +1 -1
- package/lib/javascript/CommonJsChunkFormatPlugin.js +0 -1
- package/lib/javascript/JavascriptGenerator.js +2 -3
- package/lib/javascript/JavascriptModulesPlugin.js +44 -21
- package/lib/javascript/JavascriptParser.js +159 -93
- package/lib/javascript/JavascriptParserHelpers.js +2 -2
- package/lib/javascript/StartupHelpers.js +2 -4
- package/lib/json/JsonData.js +1 -1
- package/lib/json/JsonGenerator.js +4 -5
- package/lib/json/JsonModulesPlugin.js +0 -3
- package/lib/json/JsonParser.js +4 -2
- package/lib/library/AbstractLibraryPlugin.js +2 -2
- package/lib/library/AmdLibraryPlugin.js +0 -1
- package/lib/library/AssignLibraryPlugin.js +23 -12
- package/lib/library/EnableLibraryPlugin.js +7 -11
- package/lib/library/ExportPropertyLibraryPlugin.js +8 -20
- package/lib/library/JsonpLibraryPlugin.js +5 -2
- package/lib/library/ModuleLibraryPlugin.js +88 -43
- package/lib/library/SystemLibraryPlugin.js +0 -1
- package/lib/library/UmdLibraryPlugin.js +12 -18
- package/lib/logging/Logger.js +12 -10
- package/lib/logging/createConsoleLogger.js +15 -14
- package/lib/logging/truncateArgs.js +1 -1
- package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
- package/lib/node/NodeWatchFileSystem.js +4 -4
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/RequireChunkLoadingRuntimeModule.js +5 -2
- package/lib/node/nodeConsole.js +2 -2
- package/lib/optimize/AggressiveSplittingPlugin.js +2 -0
- package/lib/optimize/ConcatenatedModule.js +142 -100
- package/lib/optimize/InnerGraph.js +17 -11
- package/lib/optimize/InnerGraphPlugin.js +0 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +3 -4
- package/lib/optimize/RuntimeChunkPlugin.js +0 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -10
- package/lib/optimize/SplitChunksPlugin.js +46 -40
- package/lib/performance/SizeLimitsPlugin.js +2 -1
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +5 -7
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +0 -2
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +0 -1
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +2 -2
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +2 -2
- package/lib/rules/BasicMatcherRulePlugin.js +0 -2
- package/lib/rules/ObjectMatcherRulePlugin.js +0 -1
- package/lib/rules/RuleSetCompiler.js +8 -6
- package/lib/runtime/BaseUriRuntimeModule.js +2 -2
- package/lib/runtime/CompatRuntimeModule.js +0 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +8 -9
- package/lib/runtime/LoadScriptRuntimeModule.js +0 -2
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -1
- package/lib/runtime/PublicPathRuntimeModule.js +2 -2
- package/lib/runtime/StartupEntrypointRuntimeModule.js +0 -1
- package/lib/runtime/SystemContextRuntimeModule.js +0 -2
- package/lib/runtime/ToBinaryRuntimeModule.js +64 -0
- package/lib/schemes/DataUriPlugin.js +2 -28
- package/lib/schemes/FileUriPlugin.js +5 -2
- package/lib/schemes/HttpUriPlugin.js +4 -2
- package/lib/schemes/VirtualUrlPlugin.js +11 -11
- package/lib/serialization/NullPrototypeObjectSerializer.js +5 -3
- package/lib/serialization/ObjectMiddleware.js +30 -19
- package/lib/serialization/SerializerMiddleware.js +1 -3
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +3 -5
- package/lib/sharing/ConsumeSharedPlugin.js +2 -4
- package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -6
- package/lib/sharing/ProvideSharedModule.js +3 -7
- package/lib/sharing/SharePlugin.js +0 -2
- package/lib/sharing/ShareRuntimeModule.js +4 -1
- package/lib/sharing/resolveMatchedConfigs.js +14 -6
- package/lib/sharing/utils.js +0 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +178 -94
- package/lib/stats/DefaultStatsPresetPlugin.js +15 -9
- package/lib/stats/DefaultStatsPrinterPlugin.js +77 -113
- package/lib/stats/StatsFactory.js +14 -11
- package/lib/url/URLParserPlugin.js +2 -4
- package/lib/util/ArrayHelpers.js +4 -4
- package/lib/util/AsyncQueue.js +1 -0
- package/lib/util/LazySet.js +2 -2
- package/lib/util/StackedCacheMap.js +0 -2
- package/lib/util/TupleSet.js +9 -4
- package/lib/util/URLAbsoluteSpecifier.js +0 -1
- package/lib/util/WeakTupleMap.js +1 -1
- package/lib/util/chainedImports.js +3 -1
- package/lib/util/cleverMerge.js +15 -18
- package/lib/util/comparators.js +2 -4
- package/lib/util/compileBooleanMatcher.js +11 -9
- package/lib/util/concatenate.js +1 -2
- package/lib/util/create-schema-validation.js +0 -1
- package/lib/util/dataURL.js +39 -0
- package/lib/util/deprecation.js +29 -31
- package/lib/util/deterministicGrouping.js +34 -30
- package/lib/util/extractSourceMap.js +319 -0
- package/lib/util/findGraphRoots.js +15 -5
- package/lib/util/fs.js +29 -8
- package/lib/util/semver.js +9 -8
- package/lib/util/smartGrouping.js +41 -26
- package/lib/util/traverseDestructuringAssignmentProperties.js +45 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +3 -2
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +5 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +2 -13
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -9
- package/lib/wasm-async/AsyncWebAssemblyParser.js +2 -1
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -4
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -3
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -4
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -7
- package/lib/wasm-sync/WebAssemblyParser.js +1 -4
- package/lib/web/JsonpChunkLoadingPlugin.js +2 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
- package/lib/web/JsonpTemplatePlugin.js +0 -1
- package/lib/webpack.js +21 -8
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +2 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +13 -13
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +77 -93
- package/schemas/plugins/BannerPlugin.check.js +1 -1
- package/schemas/plugins/BannerPlugin.json +4 -0
- package/schemas/plugins/IgnorePlugin.json +1 -1
- package/schemas/plugins/ProgressPlugin.json +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +5 -1
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
- package/types.d.ts +1140 -505
- package/SECURITY.md +0 -9
package/README.md
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
[](https://github.com/webpack/webpack/graphs/contributors)
|
|
21
21
|
[](https://github.com/webpack/webpack/discussions)
|
|
22
22
|
[](https://discord.gg/5sxFZPdx2k)
|
|
23
|
+
[](https://insights.linuxfoundation.org/project/webpack)
|
|
23
24
|
|
|
24
25
|
<h1>webpack</h1>
|
|
25
26
|
<p>
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
- [Backers](#backers)
|
|
46
47
|
- [Special Thanks](#special-thanks-to)
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
## Install
|
|
49
50
|
|
|
50
51
|
Install with npm:
|
|
51
52
|
|
|
@@ -59,7 +60,7 @@ Install with yarn:
|
|
|
59
60
|
yarn add webpack --dev
|
|
60
61
|
```
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
## Introduction
|
|
63
64
|
|
|
64
65
|
Webpack is a bundler for modules. The main purpose is to bundle JavaScript
|
|
65
66
|
files for usage in a browser, yet it is also capable of transforming, bundling,
|
|
@@ -87,7 +88,7 @@ Check out webpack's quick [**Get Started**](https://webpack.js.org/guides/gettin
|
|
|
87
88
|
Webpack supports all browsers that are [ES5-compliant](https://kangax.github.io/compat-table/es5/) (IE8 and below are not supported).
|
|
88
89
|
Webpack also needs `Promise` for `import()` and `require.ensure()`. If you want to support older browsers, you will need to [load a polyfill](https://webpack.js.org/guides/shimming/) before using these expressions.
|
|
89
90
|
|
|
90
|
-
|
|
91
|
+
## Concepts
|
|
91
92
|
|
|
92
93
|
### [Plugins](https://webpack.js.org/plugins/)
|
|
93
94
|
|
|
@@ -264,7 +265,7 @@ If you're working on webpack itself, or building advanced plugins or integration
|
|
|
264
265
|
|
|
265
266
|
[tapable-tracer-npm]: https://img.shields.io/npm/v/tapable-tracer.svg
|
|
266
267
|
|
|
267
|
-
|
|
268
|
+
## Contributing
|
|
268
269
|
|
|
269
270
|
**We want contributing to webpack to be fun, enjoyable, and educational for anyone, and everyone.** We have a [vibrant ecosystem](https://medium.com/webpack/contributors-guide/home) that spans beyond this single repo. We welcome you to check out any of the repositories in [our organization](https://github.com/webpack) or [webpack-contrib organization](https://github.com/webpack-contrib) which houses all of our loaders and plugins.
|
|
270
271
|
|
|
@@ -283,11 +284,11 @@ Contributions go far beyond pull requests and commits. Although we love giving y
|
|
|
283
284
|
|
|
284
285
|
To get started have a look at our [documentation on contributing](https://github.com/webpack/webpack/blob/main/CONTRIBUTING.md).
|
|
285
286
|
|
|
286
|
-
|
|
287
|
+
### Creating your own plugins and loaders
|
|
287
288
|
|
|
288
289
|
If you create a loader or plugin, we would <3 for you to open source it, and put it on npm. We follow the `x-loader`, `x-webpack-plugin` naming convention.
|
|
289
290
|
|
|
290
|
-
|
|
291
|
+
## Support
|
|
291
292
|
|
|
292
293
|
We consider webpack to be a low-level tool used not only individually but also layered beneath other awesome tools. Because of its flexibility, webpack isn't always the _easiest_ entry-level solution, however we do believe it is the most powerful. That said, we're always looking for ways to improve and simplify the tool without compromising functionality. If you have any ideas on ways to accomplish this, we're all ears!
|
|
293
294
|
|
|
@@ -295,11 +296,11 @@ If you're just getting started, take a look at [our new docs and concepts page](
|
|
|
295
296
|
|
|
296
297
|
If you have discovered a 🐜 or have a feature suggestion, feel free to create an issue on GitHub.
|
|
297
298
|
|
|
298
|
-
|
|
299
|
+
## Current project members
|
|
299
300
|
|
|
300
|
-
For information about the governance of the
|
|
301
|
+
For information about the governance of the webpack project, see [GOVERNANCE.md](./GOVERNANCE.md).
|
|
301
302
|
|
|
302
|
-
|
|
303
|
+
### TSC (Technical Steering Committee)
|
|
303
304
|
|
|
304
305
|
- [alexander-akait](https://github.com/alexander-akait) -
|
|
305
306
|
**Alexander Akait** <<sheo13666q@gmail.com>> (he/him)
|
|
@@ -312,18 +313,11 @@ For information about the governance of the Node.js project, see [GOVERNANCE.md]
|
|
|
312
313
|
- [thelarkinn](https://github.com/thelarkinn) -
|
|
313
314
|
**Sean Larkin** <<selarkin@microsoft.com>> (he/him)
|
|
314
315
|
|
|
315
|
-
|
|
316
|
+
### Maintenance
|
|
316
317
|
|
|
317
|
-
|
|
318
|
-
**Johannes Ewald** <<mail@johannesewald.de>>
|
|
319
|
-
- [sokra](https://github.com/sokra) -
|
|
320
|
-
**Tobias Koppers** <<jackworks@protonmail.co>>
|
|
321
|
-
- [spacek33z](https://github.com/spacek33z) -
|
|
322
|
-
**Kees Kluskens** <<kees@webduck.nl>>
|
|
323
|
-
- [TheLarkInn](https://github.com/TheLarkInn) -
|
|
324
|
-
**Sean T. Larkin** <<selarkin@microsoft.com>>
|
|
318
|
+
This webpack repository is maintained by the [`Core Working Group`](./WORKING_GROUP.md).
|
|
325
319
|
|
|
326
|
-
|
|
320
|
+
## Sponsoring
|
|
327
321
|
|
|
328
322
|
Most of the core team members, webpack contributors and contributors in the ecosystem do this open source work in their free time. If you use webpack for a serious task, and you'd like us to invest more time on it, please donate. This project increases your income/productivity too. It makes development and applications faster and it reduces the required bandwidth.
|
|
329
323
|
|
|
@@ -336,7 +330,7 @@ This is how we use the donations:
|
|
|
336
330
|
- Infrastructure cost
|
|
337
331
|
- Fees for money handling
|
|
338
332
|
|
|
339
|
-
|
|
333
|
+
### Premium Partners
|
|
340
334
|
|
|
341
335
|
<div align="center">
|
|
342
336
|
|
|
@@ -345,7 +339,7 @@ This is how we use the donations:
|
|
|
345
339
|
|
|
346
340
|
</div>
|
|
347
341
|
|
|
348
|
-
|
|
342
|
+
### Other Backers and Sponsors
|
|
349
343
|
|
|
350
344
|
Before we started using OpenCollective, donations were made anonymously. Now that we have made the switch, we would like to acknowledge these sponsors (and the ones who continue to donate using OpenCollective). If we've missed someone, please send us a PR, and we'll add you to this list.
|
|
351
345
|
|
|
@@ -357,7 +351,7 @@ Before we started using OpenCollective, donations were made anonymously. Now tha
|
|
|
357
351
|
|
|
358
352
|
</div>
|
|
359
353
|
|
|
360
|
-
|
|
354
|
+
### Gold Sponsors
|
|
361
355
|
|
|
362
356
|
[Become a gold sponsor](https://opencollective.com/webpack#sponsor) and get your logo on our README on GitHub with a link to your site.
|
|
363
357
|
|
|
@@ -396,7 +390,7 @@ Before we started using OpenCollective, donations were made anonymously. Now tha
|
|
|
396
390
|
|
|
397
391
|
</div>
|
|
398
392
|
|
|
399
|
-
|
|
393
|
+
### Silver Sponsors
|
|
400
394
|
|
|
401
395
|
[Become a silver sponsor](https://opencollective.com/webpack#sponsor) and get your logo on our README on GitHub with a link to your site.
|
|
402
396
|
|
|
@@ -435,7 +429,7 @@ Before we started using OpenCollective, donations were made anonymously. Now tha
|
|
|
435
429
|
|
|
436
430
|
</div>
|
|
437
431
|
|
|
438
|
-
|
|
432
|
+
### Bronze Sponsors
|
|
439
433
|
|
|
440
434
|
[Become a bronze sponsor](https://opencollective.com/webpack#sponsor) and get your logo on our README on GitHub with a link to your site.
|
|
441
435
|
|
|
@@ -545,7 +539,7 @@ Before we started using OpenCollective, donations were made anonymously. Now tha
|
|
|
545
539
|
|
|
546
540
|
</div>
|
|
547
541
|
|
|
548
|
-
|
|
542
|
+
### Backers
|
|
549
543
|
|
|
550
544
|
[Become a backer](https://opencollective.com/webpack#backer) and get your image on our README on GitHub with a link to your site.
|
|
551
545
|
|
|
@@ -651,7 +645,8 @@ Before we started using OpenCollective, donations were made anonymously. Now tha
|
|
|
651
645
|
<a href="https://opencollective.com/webpack/backer/99/website?requireActive=false" target="_blank"><img width="30" src="https://opencollective.com/webpack/backer/99/avatar.svg?requireActive=false"></a>
|
|
652
646
|
<a href="https://opencollective.com/webpack/backer/100/website?requireActive=false" target="_blank"><img width="30" src="https://opencollective.com/webpack/backer/100/avatar.svg?requireActive=false"></a>
|
|
653
647
|
|
|
654
|
-
|
|
648
|
+
## Special Thanks to
|
|
649
|
+
|
|
655
650
|
<p>(In chronological order)</p>
|
|
656
651
|
|
|
657
652
|
- [@google](https://github.com/google) for [Google Web Toolkit (GWT)](http://www.gwtproject.org/), which aims to compile Java to JavaScript. It features a similar [Code Splitting](http://www.gwtproject.org/doc/latest/DevGuideCodeSplitting.html) as webpack.
|
package/lib/APIPlugin.js
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const {
|
|
9
|
+
getExternalModuleNodeCommonjsInitFragment
|
|
10
|
+
} = require("./ExternalModule");
|
|
9
11
|
const {
|
|
10
12
|
JAVASCRIPT_MODULE_TYPE_AUTO,
|
|
11
13
|
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
|
@@ -30,11 +32,9 @@ const GetFullHashRuntimeModule = require("./runtime/GetFullHashRuntimeModule");
|
|
|
30
32
|
/** @typedef {import("./javascript/JavascriptParser").Range} Range */
|
|
31
33
|
|
|
32
34
|
/**
|
|
33
|
-
* @param {boolean | undefined} module true if ES module
|
|
34
|
-
* @param {string} importMetaName `import.meta` name
|
|
35
35
|
* @returns {Record<string, {expr: string, req: string[] | null, type?: string, assign: boolean}>} replacements
|
|
36
36
|
*/
|
|
37
|
-
function getReplacements(
|
|
37
|
+
function getReplacements() {
|
|
38
38
|
return {
|
|
39
39
|
__webpack_require__: {
|
|
40
40
|
expr: RuntimeGlobals.require,
|
|
@@ -67,9 +67,7 @@ function getReplacements(module, importMetaName) {
|
|
|
67
67
|
assign: true
|
|
68
68
|
},
|
|
69
69
|
__non_webpack_require__: {
|
|
70
|
-
expr:
|
|
71
|
-
? `__WEBPACK_EXTERNAL_createRequire(${importMetaName}.url)`
|
|
72
|
-
: "require",
|
|
70
|
+
expr: "require",
|
|
73
71
|
req: null,
|
|
74
72
|
type: undefined, // type is not known, depends on environment
|
|
75
73
|
assign: true
|
|
@@ -132,19 +130,7 @@ function getReplacements(module, importMetaName) {
|
|
|
132
130
|
|
|
133
131
|
const PLUGIN_NAME = "APIPlugin";
|
|
134
132
|
|
|
135
|
-
/**
|
|
136
|
-
* @typedef {object} APIPluginOptions
|
|
137
|
-
* @property {boolean=} module the output filename
|
|
138
|
-
*/
|
|
139
|
-
|
|
140
133
|
class APIPlugin {
|
|
141
|
-
/**
|
|
142
|
-
* @param {APIPluginOptions=} options options
|
|
143
|
-
*/
|
|
144
|
-
constructor(options = {}) {
|
|
145
|
-
this.options = options;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
134
|
/**
|
|
149
135
|
* Apply the plugin
|
|
150
136
|
* @param {Compiler} compiler the compiler instance
|
|
@@ -154,13 +140,15 @@ class APIPlugin {
|
|
|
154
140
|
compiler.hooks.compilation.tap(
|
|
155
141
|
PLUGIN_NAME,
|
|
156
142
|
(compilation, { normalModuleFactory }) => {
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
143
|
+
const moduleOutput = compilation.options.output.module;
|
|
144
|
+
const nodeTarget = compiler.platform.node;
|
|
145
|
+
const nodeEsm = moduleOutput && nodeTarget;
|
|
146
|
+
|
|
147
|
+
const REPLACEMENTS = getReplacements();
|
|
148
|
+
if (nodeEsm) {
|
|
149
|
+
REPLACEMENTS.__non_webpack_require__.expr =
|
|
150
|
+
"__WEBPACK_EXTERNAL_createRequire_require";
|
|
151
|
+
}
|
|
164
152
|
|
|
165
153
|
compilation.dependencyTemplates.set(
|
|
166
154
|
ConstDependency,
|
|
@@ -191,13 +179,8 @@ class APIPlugin {
|
|
|
191
179
|
(source, module, renderContext) => {
|
|
192
180
|
if (/** @type {BuildInfo} */ (module.buildInfo).needCreateRequire) {
|
|
193
181
|
const chunkInitFragments = [
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
"module"
|
|
197
|
-
)};\n`,
|
|
198
|
-
InitFragment.STAGE_HARMONY_IMPORTS,
|
|
199
|
-
0,
|
|
200
|
-
"external module node-commonjs"
|
|
182
|
+
getExternalModuleNodeCommonjsInitFragment(
|
|
183
|
+
renderContext.runtimeTemplate
|
|
201
184
|
)
|
|
202
185
|
];
|
|
203
186
|
|
|
@@ -217,9 +200,20 @@ class APIPlugin {
|
|
|
217
200
|
parser.hooks.expression.for(key).tap(PLUGIN_NAME, (expression) => {
|
|
218
201
|
const dep = toConstantDependency(parser, info.expr, info.req);
|
|
219
202
|
|
|
220
|
-
if (key === "__non_webpack_require__" &&
|
|
221
|
-
|
|
222
|
-
|
|
203
|
+
if (key === "__non_webpack_require__" && moduleOutput) {
|
|
204
|
+
if (nodeTarget) {
|
|
205
|
+
/** @type {BuildInfo} */
|
|
206
|
+
(parser.state.module.buildInfo).needCreateRequire = true;
|
|
207
|
+
} else {
|
|
208
|
+
const warning = new WebpackError(
|
|
209
|
+
`${PLUGIN_NAME}\n__non_webpack_require__ is only allowed in target node`
|
|
210
|
+
);
|
|
211
|
+
warning.loc = /** @type {DependencyLocation} */ (
|
|
212
|
+
expression.loc
|
|
213
|
+
);
|
|
214
|
+
warning.module = parser.state.module;
|
|
215
|
+
compilation.warnings.push(warning);
|
|
216
|
+
}
|
|
223
217
|
}
|
|
224
218
|
|
|
225
219
|
return dep(expression);
|
|
@@ -8,13 +8,10 @@
|
|
|
8
8
|
const DependenciesBlock = require("./DependenciesBlock");
|
|
9
9
|
const makeSerializable = require("./util/makeSerializable");
|
|
10
10
|
|
|
11
|
-
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
|
12
|
-
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
|
13
11
|
/** @typedef {import("./ChunkGroup").ChunkGroupOptions} ChunkGroupOptions */
|
|
14
12
|
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
|
15
13
|
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
|
|
16
14
|
/** @typedef {import("./Entrypoint").EntryOptions} EntryOptions */
|
|
17
|
-
/** @typedef {import("./Module")} Module */
|
|
18
15
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
19
16
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
20
17
|
/** @typedef {import("./util/Hash")} Hash */
|
|
@@ -41,7 +38,7 @@ class AsyncDependenciesBlock extends DependenciesBlock {
|
|
|
41
38
|
}
|
|
42
39
|
|
|
43
40
|
/**
|
|
44
|
-
* @returns {
|
|
41
|
+
* @returns {ChunkGroupOptions["name"]} The name of the chunk
|
|
45
42
|
*/
|
|
46
43
|
get chunkName() {
|
|
47
44
|
return this.groupOptions.name;
|
package/lib/BannerPlugin.js
CHANGED
|
@@ -13,7 +13,6 @@ const createSchemaValidation = require("./util/create-schema-validation");
|
|
|
13
13
|
|
|
14
14
|
/** @typedef {import("../declarations/plugins/BannerPlugin").BannerFunction} BannerFunction */
|
|
15
15
|
/** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginArgument} BannerPluginArgument */
|
|
16
|
-
/** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginOptions} BannerPluginOptions */
|
|
17
16
|
/** @typedef {import("./Compilation").PathData} PathData */
|
|
18
17
|
/** @typedef {import("./Compiler")} Compiler */
|
|
19
18
|
/** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
|
package/lib/Cache.js
CHANGED
|
@@ -29,16 +29,17 @@ const {
|
|
|
29
29
|
/** @typedef {EXPECTED_ANY} Data */
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
+
* @template T
|
|
32
33
|
* @callback GotHandler
|
|
33
|
-
* @param {
|
|
34
|
-
* @param {(
|
|
34
|
+
* @param {T} result
|
|
35
|
+
* @param {() => void} callback
|
|
35
36
|
* @returns {void}
|
|
36
37
|
*/
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* @param {number} times times
|
|
40
|
-
* @param {(err?: Error) => void} callback callback
|
|
41
|
-
* @returns {(err?: Error) => void} callback
|
|
41
|
+
* @param {(err?: Error | null) => void} callback callback
|
|
42
|
+
* @returns {(err?: Error | null) => void} callback
|
|
42
43
|
*/
|
|
43
44
|
const needCalls = (times, callback) => (err) => {
|
|
44
45
|
if (--times === 0) {
|
|
@@ -53,7 +54,7 @@ const needCalls = (times, callback) => (err) => {
|
|
|
53
54
|
class Cache {
|
|
54
55
|
constructor() {
|
|
55
56
|
this.hooks = {
|
|
56
|
-
/** @type {AsyncSeriesBailHook<[string, Etag | null, GotHandler[]], Data>} */
|
|
57
|
+
/** @type {AsyncSeriesBailHook<[string, Etag | null, GotHandler<EXPECTED_ANY>[]], Data>} */
|
|
57
58
|
get: new AsyncSeriesBailHook(["identifier", "etag", "gotHandlers"]),
|
|
58
59
|
/** @type {AsyncParallelHook<[string, Etag | null, Data]>} */
|
|
59
60
|
store: new AsyncParallelHook(["identifier", "etag", "data"]),
|
|
@@ -76,7 +77,7 @@ class Cache {
|
|
|
76
77
|
* @returns {void}
|
|
77
78
|
*/
|
|
78
79
|
get(identifier, etag, callback) {
|
|
79
|
-
/** @type {GotHandler[]} */
|
|
80
|
+
/** @type {GotHandler<T>[]} */
|
|
80
81
|
const gotHandlers = [];
|
|
81
82
|
this.hooks.get.callAsync(identifier, etag, gotHandlers, (err, result) => {
|
|
82
83
|
if (err) {
|
package/lib/CacheFacade.js
CHANGED
|
@@ -12,7 +12,6 @@ const mergeEtags = require("./cache/mergeEtags");
|
|
|
12
12
|
|
|
13
13
|
/** @typedef {import("./Cache")} Cache */
|
|
14
14
|
/** @typedef {import("./Cache").Etag} Etag */
|
|
15
|
-
/** @typedef {import("./WebpackError")} WebpackError */
|
|
16
15
|
/** @typedef {import("./cache/getLazyHashedEtag").HashableObject} HashableObject */
|
|
17
16
|
/** @typedef {typeof import("./util/Hash")} HashConstructor */
|
|
18
17
|
|
package/lib/Chunk.js
CHANGED
|
@@ -18,48 +18,56 @@ const {
|
|
|
18
18
|
const { createArrayToSetDeprecationSet } = require("./util/deprecation");
|
|
19
19
|
const { mergeRuntime } = require("./util/runtime");
|
|
20
20
|
|
|
21
|
-
/** @typedef {import("webpack-sources").Source} Source */
|
|
22
21
|
/** @typedef {import("./ChunkGraph").ChunkFilterPredicate} ChunkFilterPredicate */
|
|
23
22
|
/** @typedef {import("./ChunkGraph").ChunkSizeOptions} ChunkSizeOptions */
|
|
24
23
|
/** @typedef {import("./ChunkGraph").ModuleFilterPredicate} ModuleFilterPredicate */
|
|
25
24
|
/** @typedef {import("./ChunkGraph").ModuleId} ModuleId */
|
|
26
25
|
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
|
27
26
|
/** @typedef {import("./ChunkGroup").ChunkGroupOptions} ChunkGroupOptions */
|
|
28
|
-
/** @typedef {import("./Compilation")} Compilation */
|
|
29
|
-
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
|
|
30
27
|
/** @typedef {import("./Entrypoint").EntryOptions} EntryOptions */
|
|
31
28
|
/** @typedef {import("./Module")} Module */
|
|
32
|
-
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
|
33
29
|
/** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
|
|
34
30
|
/** @typedef {import("./util/Hash")} Hash */
|
|
35
31
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
|
36
32
|
|
|
37
33
|
/** @typedef {string | null} ChunkName */
|
|
38
|
-
/** @typedef {
|
|
34
|
+
/** @typedef {string | number} ChunkId */
|
|
39
35
|
/** @typedef {SortableSet<string>} IdNameHints */
|
|
40
36
|
|
|
41
37
|
const ChunkFilesSet = createArrayToSetDeprecationSet("chunk.files");
|
|
42
38
|
|
|
43
39
|
/**
|
|
44
|
-
* @
|
|
45
|
-
* @
|
|
40
|
+
* @deprecated
|
|
41
|
+
* @typedef {object} ChunkMaps
|
|
42
|
+
* @property {Record<ChunkId, string>} hash
|
|
43
|
+
* @property {Record<ChunkId, Record<string, string>>} contentHash
|
|
44
|
+
* @property {Record<ChunkId, string>} name
|
|
46
45
|
*/
|
|
47
46
|
|
|
48
47
|
/**
|
|
49
48
|
* @deprecated
|
|
50
|
-
* @typedef {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
* @typedef {Record<ChunkId, ChunkId[]>} ChunkModuleIdMap
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated
|
|
54
|
+
* @typedef {Record<ModuleId, string>} chunkModuleHashMap
|
|
54
55
|
*/
|
|
55
56
|
|
|
56
57
|
/**
|
|
57
58
|
* @deprecated
|
|
58
59
|
* @typedef {object} ChunkModuleMaps
|
|
59
|
-
* @property {
|
|
60
|
-
* @property {
|
|
60
|
+
* @property {ChunkModuleIdMap} id
|
|
61
|
+
* @property {chunkModuleHashMap} hash
|
|
61
62
|
*/
|
|
62
63
|
|
|
64
|
+
/** @typedef {Set<Chunk>} Chunks */
|
|
65
|
+
/** @typedef {Set<Entrypoint>} Entrypoints */
|
|
66
|
+
/** @typedef {Set<ChunkGroup>} Queue */
|
|
67
|
+
/** @typedef {SortableSet<ChunkGroup>} SortableChunkGroups */
|
|
68
|
+
/** @typedef {Record<string, ChunkId[]>} ChunkChildIdsByOrdersMap */
|
|
69
|
+
/** @typedef {Record<string, ChunkChildIdsByOrdersMap>} ChunkChildIdsByOrdersMapByData */
|
|
70
|
+
|
|
63
71
|
let debugId = 1000;
|
|
64
72
|
|
|
65
73
|
/**
|
|
@@ -90,7 +98,7 @@ class Chunk {
|
|
|
90
98
|
this.cssFilenameTemplate = undefined;
|
|
91
99
|
/**
|
|
92
100
|
* @private
|
|
93
|
-
* @type {
|
|
101
|
+
* @type {SortableChunkGroups}
|
|
94
102
|
*/
|
|
95
103
|
this._groups = new SortableSet(undefined, compareChunkGroupsByIndex);
|
|
96
104
|
/** @type {RuntimeSpec} */
|
|
@@ -353,9 +361,9 @@ class Chunk {
|
|
|
353
361
|
"Chunk.getChunkModuleMaps",
|
|
354
362
|
"DEP_WEBPACK_CHUNK_GET_CHUNK_MODULE_MAPS"
|
|
355
363
|
);
|
|
356
|
-
/** @type {
|
|
364
|
+
/** @type {ChunkModuleIdMap} */
|
|
357
365
|
const chunkModuleIdMap = Object.create(null);
|
|
358
|
-
/** @type {
|
|
366
|
+
/** @type {chunkModuleHashMap} */
|
|
359
367
|
const chunkModuleHashMap = Object.create(null);
|
|
360
368
|
|
|
361
369
|
for (const asyncChunk of this.getAllAsyncChunks()) {
|
|
@@ -408,11 +416,11 @@ class Chunk {
|
|
|
408
416
|
* @returns {ChunkMaps} the chunk map information
|
|
409
417
|
*/
|
|
410
418
|
getChunkMaps(realHash) {
|
|
411
|
-
/** @type {Record<
|
|
419
|
+
/** @type {Record<ChunkId, string>} */
|
|
412
420
|
const chunkHashMap = Object.create(null);
|
|
413
|
-
/** @type {Record<string
|
|
421
|
+
/** @type {Record<string, Record<ChunkId, string>>} */
|
|
414
422
|
const chunkContentHashMap = Object.create(null);
|
|
415
|
-
/** @type {Record<
|
|
423
|
+
/** @type {Record<ChunkId, string>} */
|
|
416
424
|
const chunkNameMap = Object.create(null);
|
|
417
425
|
|
|
418
426
|
for (const chunk of this.getAllAsyncChunks()) {
|
|
@@ -519,7 +527,7 @@ class Chunk {
|
|
|
519
527
|
}
|
|
520
528
|
|
|
521
529
|
/**
|
|
522
|
-
* @returns {
|
|
530
|
+
* @returns {SortableChunkGroups} the chunkGroups that the said chunk is referenced in
|
|
523
531
|
*/
|
|
524
532
|
get groupsIterable() {
|
|
525
533
|
this._groups.sort();
|
|
@@ -576,16 +584,19 @@ class Chunk {
|
|
|
576
584
|
}
|
|
577
585
|
|
|
578
586
|
/**
|
|
579
|
-
* @returns {
|
|
587
|
+
* @returns {Chunks} a set of all the async chunks
|
|
580
588
|
*/
|
|
581
589
|
getAllAsyncChunks() {
|
|
590
|
+
/** @type {Queue} */
|
|
582
591
|
const queue = new Set();
|
|
592
|
+
/** @type {Chunks} */
|
|
583
593
|
const chunks = new Set();
|
|
584
594
|
|
|
585
595
|
const initialChunks = intersect(
|
|
586
596
|
Array.from(this.groupsIterable, (g) => new Set(g.chunks))
|
|
587
597
|
);
|
|
588
598
|
|
|
599
|
+
/** @type {Queue} */
|
|
589
600
|
const initialQueue = new Set(this.groupsIterable);
|
|
590
601
|
|
|
591
602
|
for (const chunkGroup of initialQueue) {
|
|
@@ -613,10 +624,12 @@ class Chunk {
|
|
|
613
624
|
}
|
|
614
625
|
|
|
615
626
|
/**
|
|
616
|
-
* @returns {
|
|
627
|
+
* @returns {Chunks} a set of all the initial chunks (including itself)
|
|
617
628
|
*/
|
|
618
629
|
getAllInitialChunks() {
|
|
630
|
+
/** @type {Chunks} */
|
|
619
631
|
const chunks = new Set();
|
|
632
|
+
/** @type {Queue} */
|
|
620
633
|
const queue = new Set(this.groupsIterable);
|
|
621
634
|
for (const group of queue) {
|
|
622
635
|
if (group.isInitial()) {
|
|
@@ -628,10 +641,12 @@ class Chunk {
|
|
|
628
641
|
}
|
|
629
642
|
|
|
630
643
|
/**
|
|
631
|
-
* @returns {
|
|
644
|
+
* @returns {Chunks} a set of all the referenced chunks (including itself)
|
|
632
645
|
*/
|
|
633
646
|
getAllReferencedChunks() {
|
|
647
|
+
/** @type {Queue} */
|
|
634
648
|
const queue = new Set(this.groupsIterable);
|
|
649
|
+
/** @type {Chunks} */
|
|
635
650
|
const chunks = new Set();
|
|
636
651
|
|
|
637
652
|
for (const chunkGroup of queue) {
|
|
@@ -647,15 +662,17 @@ class Chunk {
|
|
|
647
662
|
}
|
|
648
663
|
|
|
649
664
|
/**
|
|
650
|
-
* @returns {
|
|
665
|
+
* @returns {Entrypoints} a set of all the referenced entrypoints
|
|
651
666
|
*/
|
|
652
667
|
getAllReferencedAsyncEntrypoints() {
|
|
668
|
+
/** @type {Queue} */
|
|
653
669
|
const queue = new Set(this.groupsIterable);
|
|
670
|
+
/** @type {Entrypoints} */
|
|
654
671
|
const entrypoints = new Set();
|
|
655
672
|
|
|
656
673
|
for (const chunkGroup of queue) {
|
|
657
674
|
for (const entrypoint of chunkGroup.asyncEntrypointsIterable) {
|
|
658
|
-
entrypoints.add(entrypoint);
|
|
675
|
+
entrypoints.add(/** @type {Entrypoint} */ (entrypoint));
|
|
659
676
|
}
|
|
660
677
|
for (const child of chunkGroup.childrenIterable) {
|
|
661
678
|
queue.add(child);
|
|
@@ -669,6 +686,7 @@ class Chunk {
|
|
|
669
686
|
* @returns {boolean} true, if the chunk references async chunks
|
|
670
687
|
*/
|
|
671
688
|
hasAsyncChunks() {
|
|
689
|
+
/** @type {Queue} */
|
|
672
690
|
const queue = new Set();
|
|
673
691
|
|
|
674
692
|
const initialChunks = intersect(
|
|
@@ -730,7 +748,7 @@ class Chunk {
|
|
|
730
748
|
}
|
|
731
749
|
}
|
|
732
750
|
}
|
|
733
|
-
/** @type {Record<string,
|
|
751
|
+
/** @type {Record<string, ChunkId[]>} */
|
|
734
752
|
const result = Object.create(null);
|
|
735
753
|
for (const [name, list] of lists) {
|
|
736
754
|
list.sort((a, b) => {
|
|
@@ -756,7 +774,7 @@ class Chunk {
|
|
|
756
774
|
/**
|
|
757
775
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
|
758
776
|
* @param {string} type option name
|
|
759
|
-
* @returns {{ onChunks: Chunk[], chunks:
|
|
777
|
+
* @returns {{ onChunks: Chunk[], chunks: Chunks }[] | undefined} referenced chunks for a specific type
|
|
760
778
|
*/
|
|
761
779
|
getChildrenOfTypeInOrder(chunkGraph, type) {
|
|
762
780
|
const list = [];
|
|
@@ -802,10 +820,10 @@ class Chunk {
|
|
|
802
820
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
|
803
821
|
* @param {boolean=} includeDirectChildren include direct children (by default only children of async children are included)
|
|
804
822
|
* @param {ChunkFilterPredicate=} filterFn function used to filter chunks
|
|
805
|
-
* @returns {
|
|
823
|
+
* @returns {ChunkChildIdsByOrdersMapByData} a record object of names to lists of child ids(?) by chunk id
|
|
806
824
|
*/
|
|
807
825
|
getChildIdsByOrdersMap(chunkGraph, includeDirectChildren, filterFn) {
|
|
808
|
-
/** @type {
|
|
826
|
+
/** @type {ChunkChildIdsByOrdersMapByData} */
|
|
809
827
|
const chunkMaps = Object.create(null);
|
|
810
828
|
|
|
811
829
|
/**
|
|
@@ -824,7 +842,7 @@ class Chunk {
|
|
|
824
842
|
};
|
|
825
843
|
|
|
826
844
|
if (includeDirectChildren) {
|
|
827
|
-
/** @type {
|
|
845
|
+
/** @type {Chunks} */
|
|
828
846
|
const chunks = new Set();
|
|
829
847
|
for (const chunkGroup of this.groupsIterable) {
|
|
830
848
|
for (const chunk of chunkGroup.chunks) {
|
|
@@ -852,7 +870,7 @@ class Chunk {
|
|
|
852
870
|
*/
|
|
853
871
|
hasChildByOrder(chunkGraph, type, includeDirectChildren, filterFn) {
|
|
854
872
|
if (includeDirectChildren) {
|
|
855
|
-
/** @type {
|
|
873
|
+
/** @type {Chunks} */
|
|
856
874
|
const chunks = new Set();
|
|
857
875
|
for (const chunkGroup of this.groupsIterable) {
|
|
858
876
|
for (const chunk of chunkGroup.chunks) {
|