webpack 5.101.3 → 5.102.1
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 +37 -27
- package/lib/ChunkGroup.js +8 -10
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +3 -3
- package/lib/CodeGenerationResults.js +3 -2
- package/lib/CompatibilityPlugin.js +29 -12
- package/lib/Compilation.js +209 -196
- package/lib/Compiler.js +36 -35
- package/lib/ConcatenationScope.js +6 -1
- package/lib/ConditionalInitFragment.js +1 -1
- package/lib/ConstPlugin.js +6 -5
- package/lib/ContextExclusionPlugin.js +0 -1
- package/lib/ContextModule.js +25 -21
- package/lib/ContextModuleFactory.js +30 -11
- package/lib/ContextReplacementPlugin.js +38 -15
- package/lib/DefinePlugin.js +5 -9
- package/lib/DelegatedModule.js +7 -11
- package/lib/DependenciesBlock.js +0 -2
- package/lib/Dependency.js +9 -11
- package/lib/DependencyTemplates.js +2 -4
- 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 +105 -90
- 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 +42 -25
- 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 +146 -89
- package/lib/NormalModuleFactory.js +132 -42
- 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 +22 -12
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -2
- package/lib/SourceMapDevToolPlugin.js +11 -18
- 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 +167 -0
- package/lib/asset/AssetBytesParser.js +37 -0
- package/lib/asset/AssetGenerator.js +22 -37
- 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/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/cache/getLazyHashedEtag.js +1 -1
- package/lib/config/browserslistTargetHandler.js +77 -76
- package/lib/config/defaults.js +162 -23
- package/lib/config/normalization.js +18 -3
- package/lib/config/target.js +1 -1
- 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 +13 -19
- package/lib/css/CssParser.js +3 -3
- package/lib/css/walkCssTokens.js +2 -2
- 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 +4 -7
- 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 +33 -14
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +20 -23
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +0 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -31
- package/lib/dependencies/HarmonyModulesPlugin.js +3 -3
- package/lib/dependencies/ImportContextDependency.js +13 -0
- 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 +3 -2
- package/lib/dependencies/ImportParserPlugin.js +288 -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 +4 -12
- 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/HashedModuleIdsPlugin.js +5 -7
- package/lib/ids/IdHelpers.js +1 -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 +46 -24
- package/lib/javascript/JavascriptParser.js +120 -55
- 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 +15 -6
- 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/RealContentHashPlugin.js +5 -3
- 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/FileMiddleware.js +1 -1
- package/lib/serialization/NullPrototypeObjectSerializer.js +5 -3
- package/lib/serialization/ObjectMiddleware.js +31 -20
- 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 +179 -95
- 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/Hash.js +35 -5
- 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 +1 -2
- package/lib/util/createHash.js +85 -15
- 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/hash/BatchedHash.js +47 -8
- package/lib/util/hash/wasm-hash.js +53 -13
- 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 -10
- 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 -13
- 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 +21 -21
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +93 -96
- 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/ids/HashedModuleIdsPlugin.check.d.ts +7 -0
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +6 -0
- package/schemas/plugins/{HashedModuleIdsPlugin.json → ids/HashedModuleIdsPlugin.json} +15 -2
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
- package/types.d.ts +1699 -706
- package/SECURITY.md +0 -9
- package/schemas/plugins/HashedModuleIdsPlugin.check.d.ts +0 -7
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +0 -6
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
const Hash = require("../Hash");
|
|
9
9
|
const MAX_SHORT_STRING = require("./wasm-hash").MAX_SHORT_STRING;
|
|
10
10
|
|
|
11
|
+
/** @typedef {import("../../../declarations/WebpackOptions").HashDigest} Encoding */
|
|
12
|
+
|
|
11
13
|
class BatchedHash extends Hash {
|
|
12
14
|
/**
|
|
13
15
|
* @param {Hash} hash hash
|
|
@@ -21,9 +23,22 @@ class BatchedHash extends Hash {
|
|
|
21
23
|
|
|
22
24
|
/**
|
|
23
25
|
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
|
24
|
-
* @
|
|
25
|
-
* @param {string
|
|
26
|
-
* @returns {
|
|
26
|
+
* @overload
|
|
27
|
+
* @param {string | Buffer} data data
|
|
28
|
+
* @returns {Hash} updated hash
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
|
32
|
+
* @overload
|
|
33
|
+
* @param {string} data data
|
|
34
|
+
* @param {Encoding} inputEncoding data encoding
|
|
35
|
+
* @returns {Hash} updated hash
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
|
39
|
+
* @param {string | Buffer} data data
|
|
40
|
+
* @param {Encoding=} inputEncoding data encoding
|
|
41
|
+
* @returns {Hash} updated hash
|
|
27
42
|
*/
|
|
28
43
|
update(data, inputEncoding) {
|
|
29
44
|
if (this.string !== undefined) {
|
|
@@ -35,7 +50,11 @@ class BatchedHash extends Hash {
|
|
|
35
50
|
this.string += data;
|
|
36
51
|
return this;
|
|
37
52
|
}
|
|
38
|
-
|
|
53
|
+
if (this.encoding) {
|
|
54
|
+
this.hash.update(this.string, this.encoding);
|
|
55
|
+
} else {
|
|
56
|
+
this.hash.update(this.string);
|
|
57
|
+
}
|
|
39
58
|
this.string = undefined;
|
|
40
59
|
}
|
|
41
60
|
if (typeof data === "string") {
|
|
@@ -46,8 +65,10 @@ class BatchedHash extends Hash {
|
|
|
46
65
|
) {
|
|
47
66
|
this.string = data;
|
|
48
67
|
this.encoding = inputEncoding;
|
|
49
|
-
} else {
|
|
68
|
+
} else if (inputEncoding) {
|
|
50
69
|
this.hash.update(data, inputEncoding);
|
|
70
|
+
} else {
|
|
71
|
+
this.hash.update(data);
|
|
51
72
|
}
|
|
52
73
|
} else {
|
|
53
74
|
this.hash.update(data);
|
|
@@ -57,12 +78,30 @@ class BatchedHash extends Hash {
|
|
|
57
78
|
|
|
58
79
|
/**
|
|
59
80
|
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
|
60
|
-
* @
|
|
61
|
-
* @returns {
|
|
81
|
+
* @overload
|
|
82
|
+
* @returns {Buffer} digest
|
|
83
|
+
*/
|
|
84
|
+
/**
|
|
85
|
+
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
|
86
|
+
* @overload
|
|
87
|
+
* @param {Encoding} encoding encoding of the return value
|
|
88
|
+
* @returns {string} digest
|
|
89
|
+
*/
|
|
90
|
+
/**
|
|
91
|
+
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
|
92
|
+
* @param {Encoding=} encoding encoding of the return value
|
|
93
|
+
* @returns {string | Buffer} digest
|
|
62
94
|
*/
|
|
63
95
|
digest(encoding) {
|
|
64
96
|
if (this.string !== undefined) {
|
|
65
|
-
|
|
97
|
+
if (this.encoding) {
|
|
98
|
+
this.hash.update(this.string, this.encoding);
|
|
99
|
+
} else {
|
|
100
|
+
this.hash.update(this.string);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (!encoding) {
|
|
104
|
+
return this.hash.digest();
|
|
66
105
|
}
|
|
67
106
|
return this.hash.digest(encoding);
|
|
68
107
|
}
|
|
@@ -5,13 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
+
const Hash = require("../Hash");
|
|
9
|
+
|
|
8
10
|
// 65536 is the size of a wasm memory page
|
|
9
11
|
// 64 is the maximum chunk size for every possible wasm hash implementation
|
|
10
12
|
// 4 is the maximum number of bytes per char for string encoding (max is utf-8)
|
|
11
13
|
// ~3 makes sure that it's always a block of 4 chars, so avoid partially encoded bytes for base64
|
|
12
14
|
const MAX_SHORT_STRING = Math.floor((65536 - 64) / 4) & ~3;
|
|
13
15
|
|
|
14
|
-
class WasmHash {
|
|
16
|
+
class WasmHash extends Hash {
|
|
15
17
|
/**
|
|
16
18
|
* @param {WebAssembly.Instance} instance wasm instance
|
|
17
19
|
* @param {WebAssembly.Instance[]} instancesPool pool of instances
|
|
@@ -19,6 +21,8 @@ class WasmHash {
|
|
|
19
21
|
* @param {number} digestSize size of digest returned by wasm
|
|
20
22
|
*/
|
|
21
23
|
constructor(instance, instancesPool, chunkSize, digestSize) {
|
|
24
|
+
super();
|
|
25
|
+
|
|
22
26
|
const exports = /** @type {EXPECTED_ANY} */ (instance.exports);
|
|
23
27
|
exports.init();
|
|
24
28
|
this.exports = exports;
|
|
@@ -35,17 +39,39 @@ class WasmHash {
|
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
/**
|
|
38
|
-
*
|
|
39
|
-
* @
|
|
40
|
-
* @
|
|
42
|
+
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
|
43
|
+
* @overload
|
|
44
|
+
* @param {string | Buffer} data data
|
|
45
|
+
* @returns {Hash} updated hash
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
|
49
|
+
* @overload
|
|
50
|
+
* @param {string} data data
|
|
51
|
+
* @param {string=} inputEncoding data encoding
|
|
52
|
+
* @returns {this} updated hash
|
|
41
53
|
*/
|
|
42
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
|
56
|
+
* @param {string | Buffer} data data
|
|
57
|
+
* @param {string=} inputEncoding data encoding
|
|
58
|
+
* @returns {this} updated hash
|
|
59
|
+
*/
|
|
60
|
+
update(data, inputEncoding) {
|
|
43
61
|
if (typeof data === "string") {
|
|
44
62
|
while (data.length > MAX_SHORT_STRING) {
|
|
45
|
-
this._updateWithShortString(
|
|
63
|
+
this._updateWithShortString(
|
|
64
|
+
data.slice(0, MAX_SHORT_STRING),
|
|
65
|
+
/** @type {NodeJS.BufferEncoding} */
|
|
66
|
+
(inputEncoding)
|
|
67
|
+
);
|
|
46
68
|
data = data.slice(MAX_SHORT_STRING);
|
|
47
69
|
}
|
|
48
|
-
this._updateWithShortString(
|
|
70
|
+
this._updateWithShortString(
|
|
71
|
+
data,
|
|
72
|
+
/** @type {NodeJS.BufferEncoding} */
|
|
73
|
+
(inputEncoding)
|
|
74
|
+
);
|
|
49
75
|
return this;
|
|
50
76
|
}
|
|
51
77
|
this._updateWithBuffer(data);
|
|
@@ -136,17 +162,31 @@ class WasmHash {
|
|
|
136
162
|
}
|
|
137
163
|
|
|
138
164
|
/**
|
|
139
|
-
* @
|
|
140
|
-
* @
|
|
165
|
+
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
|
166
|
+
* @overload
|
|
167
|
+
* @returns {Buffer} digest
|
|
168
|
+
*/
|
|
169
|
+
/**
|
|
170
|
+
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
|
171
|
+
* @overload
|
|
172
|
+
* @param {string=} encoding encoding of the return value
|
|
173
|
+
* @returns {string} digest
|
|
174
|
+
*/
|
|
175
|
+
/**
|
|
176
|
+
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
|
177
|
+
* @param {string=} encoding encoding of the return value
|
|
178
|
+
* @returns {string | Buffer} digest
|
|
141
179
|
*/
|
|
142
|
-
digest(
|
|
180
|
+
digest(encoding) {
|
|
143
181
|
const { exports, buffered, mem, digestSize } = this;
|
|
144
182
|
exports.final(buffered);
|
|
145
183
|
this.instancesPool.push(this);
|
|
146
184
|
const hex = mem.toString("latin1", 0, digestSize);
|
|
147
|
-
if (
|
|
148
|
-
if (
|
|
149
|
-
return Buffer.from(hex, "hex").toString(
|
|
185
|
+
if (encoding === "hex") return hex;
|
|
186
|
+
if (encoding === "binary" || !encoding) return Buffer.from(hex, "hex");
|
|
187
|
+
return Buffer.from(hex, "hex").toString(
|
|
188
|
+
/** @type {NodeJS.BufferEncoding} */ (encoding)
|
|
189
|
+
);
|
|
150
190
|
}
|
|
151
191
|
}
|
|
152
192
|
|
package/lib/util/semver.js
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
9
|
-
/** @typedef {string | number
|
|
9
|
+
/** @typedef {string | number} VersionValue */
|
|
10
|
+
/** @typedef {VersionValue | undefined} SemVerRangeItem */
|
|
10
11
|
/** @typedef {(SemVerRangeItem | SemVerRangeItem[])[]} SemVerRange */
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -16,12 +17,12 @@
|
|
|
16
17
|
const parseVersion = (str) => {
|
|
17
18
|
/**
|
|
18
19
|
* @param {str} str str
|
|
19
|
-
* @returns {
|
|
20
|
+
* @returns {VersionValue[]} result
|
|
20
21
|
*/
|
|
21
22
|
var splitAndConvert = function (str) {
|
|
22
23
|
return str.split(".").map(function (item) {
|
|
23
24
|
// eslint-disable-next-line eqeqeq
|
|
24
|
-
return +item == /** @type {
|
|
25
|
+
return +item == /** @type {string | number} */ (item) ? +item : item;
|
|
25
26
|
});
|
|
26
27
|
};
|
|
27
28
|
|
|
@@ -29,7 +30,7 @@ const parseVersion = (str) => {
|
|
|
29
30
|
/** @type {RegExpExecArray} */
|
|
30
31
|
(/^([^-+]+)?(?:-([^+]+))?(?:\+(.+))?$/.exec(str));
|
|
31
32
|
|
|
32
|
-
/** @type {(
|
|
33
|
+
/** @type {(VersionValue | undefined | [])[]} */
|
|
33
34
|
var ver = match[1] ? splitAndConvert(match[1]) : [];
|
|
34
35
|
|
|
35
36
|
if (match[2]) {
|
|
@@ -103,7 +104,7 @@ module.exports.versionLt = versionLt;
|
|
|
103
104
|
module.exports.parseRange = (str) => {
|
|
104
105
|
/**
|
|
105
106
|
* @param {string} str str
|
|
106
|
-
* @returns {
|
|
107
|
+
* @returns {VersionValue[]} result
|
|
107
108
|
*/
|
|
108
109
|
const splitAndConvert = (str) => {
|
|
109
110
|
return str
|
|
@@ -429,7 +430,7 @@ const satisfy = (range, version) => {
|
|
|
429
430
|
/** @type {"s" | "n" | "u" | ""} */
|
|
430
431
|
(j < range.length ? (typeof range[j])[0] : "");
|
|
431
432
|
|
|
432
|
-
/** @type {
|
|
433
|
+
/** @type {VersionValue | undefined} */
|
|
433
434
|
var versionValue;
|
|
434
435
|
/** @type {"n" | "s" | "u" | "o" | undefined} */
|
|
435
436
|
var versionType;
|
|
@@ -470,8 +471,8 @@ const satisfy = (range, version) => {
|
|
|
470
471
|
// Handles "cmp" cases
|
|
471
472
|
if (
|
|
472
473
|
negated
|
|
473
|
-
? versionValue > /** @type {
|
|
474
|
-
: versionValue < /** @type {
|
|
474
|
+
? versionValue > /** @type {VersionValue[]} */ (range)[j]
|
|
475
|
+
: versionValue < /** @type {VersionValue[]} */ (range)[j]
|
|
475
476
|
) {
|
|
476
477
|
return false;
|
|
477
478
|
}
|
|
@@ -13,42 +13,53 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* @template
|
|
17
|
-
* @template
|
|
16
|
+
* @template I
|
|
17
|
+
* @template G
|
|
18
18
|
* @typedef {object} GroupConfig
|
|
19
|
-
* @property {(item:
|
|
20
|
-
* @property {(
|
|
21
|
-
* @property {(
|
|
19
|
+
* @property {(item: I) => string[] | undefined} getKeys
|
|
20
|
+
* @property {(name: string, items: I[]) => GroupOptions=} getOptions
|
|
21
|
+
* @property {(key: string, children: I[], items: I[]) => G} createGroup
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* @template
|
|
26
|
-
* @template
|
|
25
|
+
* @template I
|
|
26
|
+
* @template G
|
|
27
|
+
* @typedef {{ config: GroupConfig<I, G>, name: string, alreadyGrouped: boolean, items: Items<I, G> | undefined }} Group
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @template I, G
|
|
32
|
+
* @typedef {Set<Group<I, G>>} Groups
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @template I
|
|
37
|
+
* @template G
|
|
27
38
|
* @typedef {object} ItemWithGroups
|
|
28
|
-
* @property {
|
|
29
|
-
* @property {
|
|
39
|
+
* @property {I} item
|
|
40
|
+
* @property {Groups<I, G>} groups
|
|
30
41
|
*/
|
|
31
42
|
|
|
32
43
|
/**
|
|
33
|
-
* @template T
|
|
34
|
-
* @
|
|
35
|
-
* @typedef {{ config: GroupConfig<T, R>, name: string, alreadyGrouped: boolean, items: Set<ItemWithGroups<T, R>> | undefined }} Group
|
|
44
|
+
* @template T, G
|
|
45
|
+
* @typedef {Set<ItemWithGroups<T, G>>} Items
|
|
36
46
|
*/
|
|
37
47
|
|
|
38
48
|
/**
|
|
39
|
-
* @template
|
|
49
|
+
* @template I
|
|
50
|
+
* @template G
|
|
40
51
|
* @template R
|
|
41
|
-
* @param {
|
|
42
|
-
* @param {GroupConfig<
|
|
43
|
-
* @returns {(
|
|
52
|
+
* @param {I[]} items the list of items
|
|
53
|
+
* @param {GroupConfig<I, G>[]} groupConfigs configuration
|
|
54
|
+
* @returns {(I | G)[]} grouped items
|
|
44
55
|
*/
|
|
45
56
|
const smartGrouping = (items, groupConfigs) => {
|
|
46
|
-
/** @type {
|
|
57
|
+
/** @type {Items<I, G>} */
|
|
47
58
|
const itemsWithGroups = new Set();
|
|
48
|
-
/** @type {Map<string, Group<
|
|
59
|
+
/** @type {Map<string, Group<I, G>>} */
|
|
49
60
|
const allGroups = new Map();
|
|
50
61
|
for (const item of items) {
|
|
51
|
-
/** @type {
|
|
62
|
+
/** @type {Groups<I, G>} */
|
|
52
63
|
const groups = new Set();
|
|
53
64
|
for (let i = 0; i < groupConfigs.length; i++) {
|
|
54
65
|
const groupConfig = groupConfigs[i];
|
|
@@ -77,9 +88,10 @@ const smartGrouping = (items, groupConfigs) => {
|
|
|
77
88
|
groups
|
|
78
89
|
});
|
|
79
90
|
}
|
|
91
|
+
|
|
80
92
|
/**
|
|
81
|
-
* @param {
|
|
82
|
-
* @returns {(
|
|
93
|
+
* @param {Items<I, G>} itemsWithGroups input items with groups
|
|
94
|
+
* @returns {(I | G)[]} groups items
|
|
83
95
|
*/
|
|
84
96
|
const runGrouping = (itemsWithGroups) => {
|
|
85
97
|
const totalSize = itemsWithGroups.size;
|
|
@@ -94,7 +106,7 @@ const smartGrouping = (items, groupConfigs) => {
|
|
|
94
106
|
}
|
|
95
107
|
}
|
|
96
108
|
}
|
|
97
|
-
/** @type {Map<Group<
|
|
109
|
+
/** @type {Map<Group<I, G>, { items: Items<I, G>, options: GroupOptions | false | undefined, used: boolean }>} */
|
|
98
110
|
const groupMap = new Map();
|
|
99
111
|
for (const group of allGroups.values()) {
|
|
100
112
|
if (group.items) {
|
|
@@ -107,13 +119,15 @@ const smartGrouping = (items, groupConfigs) => {
|
|
|
107
119
|
});
|
|
108
120
|
}
|
|
109
121
|
}
|
|
110
|
-
/** @type {(
|
|
122
|
+
/** @type {(I | G)[]} */
|
|
111
123
|
const results = [];
|
|
112
124
|
for (;;) {
|
|
113
|
-
/** @type {Group<
|
|
125
|
+
/** @type {Group<I, G> | undefined} */
|
|
114
126
|
let bestGroup;
|
|
115
127
|
let bestGroupSize = -1;
|
|
128
|
+
/** @type {Items<I, G> | undefined} */
|
|
116
129
|
let bestGroupItems;
|
|
130
|
+
/** @type {GroupOptions | false | undefined} */
|
|
117
131
|
let bestGroupOptions;
|
|
118
132
|
for (const [group, state] of groupMap) {
|
|
119
133
|
const { items, used } = state;
|
|
@@ -192,8 +206,9 @@ const smartGrouping = (items, groupConfigs) => {
|
|
|
192
206
|
bestGroup.alreadyGrouped = true;
|
|
193
207
|
const children = groupChildren ? runGrouping(items) : allItems;
|
|
194
208
|
bestGroup.alreadyGrouped = false;
|
|
195
|
-
|
|
196
|
-
|
|
209
|
+
results.push(
|
|
210
|
+
groupConfig.createGroup(key, /** @type {I[]} */ (children), allItems)
|
|
211
|
+
);
|
|
197
212
|
}
|
|
198
213
|
for (const { item } of itemsWithGroups) {
|
|
199
214
|
results.push(item);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
/** @typedef {import("../javascript/JavascriptParser").DestructuringAssignmentProperties} DestructuringAssignmentProperties */
|
|
9
|
+
/** @typedef {import("../javascript/JavascriptParser").DestructuringAssignmentProperty} DestructuringAssignmentProperty */
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Deep first traverse the properties of a destructuring assignment.
|
|
13
|
+
* @param {DestructuringAssignmentProperties} properties destructuring assignment properties
|
|
14
|
+
* @param {((stack: DestructuringAssignmentProperty[]) => void) | undefined=} onLeftNode on left node callback
|
|
15
|
+
* @param {((stack: DestructuringAssignmentProperty[]) => void) | undefined=} enterNode enter node callback
|
|
16
|
+
* @param {((stack: DestructuringAssignmentProperty[]) => void) | undefined=} exitNode exit node callback
|
|
17
|
+
* @param {DestructuringAssignmentProperty[] | undefined=} stack stack of the walking nodes
|
|
18
|
+
*/
|
|
19
|
+
function traverseDestructuringAssignmentProperties(
|
|
20
|
+
properties,
|
|
21
|
+
onLeftNode,
|
|
22
|
+
enterNode,
|
|
23
|
+
exitNode,
|
|
24
|
+
stack = []
|
|
25
|
+
) {
|
|
26
|
+
for (const property of properties) {
|
|
27
|
+
stack.push(property);
|
|
28
|
+
if (enterNode) enterNode(stack);
|
|
29
|
+
if (property.pattern) {
|
|
30
|
+
traverseDestructuringAssignmentProperties(
|
|
31
|
+
property.pattern,
|
|
32
|
+
onLeftNode,
|
|
33
|
+
enterNode,
|
|
34
|
+
exitNode,
|
|
35
|
+
stack
|
|
36
|
+
);
|
|
37
|
+
} else if (onLeftNode) {
|
|
38
|
+
onLeftNode(stack);
|
|
39
|
+
}
|
|
40
|
+
if (exitNode) exitNode(stack);
|
|
41
|
+
stack.pop();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = traverseDestructuringAssignmentProperties;
|
|
@@ -5,16 +5,17 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
/** @typedef {import("../../declarations/WebpackOptions").LibraryOptions} LibraryOptions */
|
|
9
8
|
/** @typedef {import("../../declarations/WebpackOptions").WasmLoadingType} WasmLoadingType */
|
|
10
9
|
/** @typedef {import("../Compiler")} Compiler */
|
|
11
10
|
|
|
11
|
+
/** @typedef {Set<WasmLoadingType>} WasmLoadingTypes */
|
|
12
|
+
|
|
12
13
|
/** @type {WeakMap<Compiler, Set<WasmLoadingType>>} */
|
|
13
14
|
const enabledTypes = new WeakMap();
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* @param {Compiler} compiler compiler instance
|
|
17
|
-
* @returns {
|
|
18
|
+
* @returns {WasmLoadingTypes} enabled types
|
|
18
19
|
*/
|
|
19
20
|
const getEnabledTypes = (compiler) => {
|
|
20
21
|
let set = enabledTypes.get(compiler);
|
|
@@ -76,7 +76,11 @@ class AsyncWasmLoadingRuntimeModule extends RuntimeModule {
|
|
|
76
76
|
)})`
|
|
77
77
|
];
|
|
78
78
|
const getStreaming = () => {
|
|
79
|
-
|
|
79
|
+
/**
|
|
80
|
+
* @param {string[]} text text
|
|
81
|
+
* @returns {string} merged text
|
|
82
|
+
*/
|
|
83
|
+
const concat = (...text) => text.join("");
|
|
80
84
|
return [
|
|
81
85
|
this.generateBeforeLoadBinaryCode
|
|
82
86
|
? this.generateBeforeLoadBinaryCode(wasmModuleSrcPath)
|
|
@@ -14,27 +14,16 @@ const Template = require("../Template");
|
|
|
14
14
|
const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
|
|
15
15
|
|
|
16
16
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
17
|
-
/** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} OutputOptions */
|
|
18
|
-
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */
|
|
19
17
|
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
|
20
18
|
/** @typedef {import("../Module")} Module */
|
|
21
19
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
|
22
20
|
/** @typedef {import("../NormalModule")} NormalModule */
|
|
23
|
-
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
24
21
|
|
|
25
22
|
/**
|
|
26
23
|
* @typedef {{ request: string, importVar: string }} ImportObjRequestItem
|
|
27
24
|
*/
|
|
28
25
|
|
|
29
26
|
class AsyncWebAssemblyJavascriptGenerator extends Generator {
|
|
30
|
-
/**
|
|
31
|
-
* @param {OutputOptions["webassemblyModuleFilename"]} filenameTemplate template for the WebAssembly module filename
|
|
32
|
-
*/
|
|
33
|
-
constructor(filenameTemplate) {
|
|
34
|
-
super();
|
|
35
|
-
this.filenameTemplate = filenameTemplate;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
27
|
/**
|
|
39
28
|
* @param {NormalModule} module fresh module
|
|
40
29
|
* @returns {SourceTypes} available types (do not mutate)
|
|
@@ -69,7 +58,7 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
|
|
|
69
58
|
runtimeRequirements.add(RuntimeGlobals.moduleId);
|
|
70
59
|
runtimeRequirements.add(RuntimeGlobals.exports);
|
|
71
60
|
runtimeRequirements.add(RuntimeGlobals.instantiateWasm);
|
|
72
|
-
/** @type {InitFragment<
|
|
61
|
+
/** @type {InitFragment<GenerateContext>[]} */
|
|
73
62
|
const initFragments = [];
|
|
74
63
|
/** @type {Map<Module, ImportObjRequestItem>} */
|
|
75
64
|
const depModules = new Map();
|
|
@@ -93,7 +82,7 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
|
|
|
93
82
|
}
|
|
94
83
|
}
|
|
95
84
|
|
|
96
|
-
/** @type {
|
|
85
|
+
/** @type {string[]} */
|
|
97
86
|
const promises = [];
|
|
98
87
|
|
|
99
88
|
const importStatements = Array.from(
|
|
@@ -15,7 +15,6 @@ const { compareModulesByIdOrIdentifier } = require("../util/comparators");
|
|
|
15
15
|
const memoize = require("../util/memoize");
|
|
16
16
|
|
|
17
17
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
18
|
-
/** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} OutputOptions */
|
|
19
18
|
/** @typedef {import("../Chunk")} Chunk */
|
|
20
19
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
21
20
|
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
|
@@ -24,8 +23,6 @@ const memoize = require("../util/memoize");
|
|
|
24
23
|
/** @typedef {import("../Module")} Module */
|
|
25
24
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
26
25
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
27
|
-
/** @typedef {import("../Template").RenderManifestEntry} RenderManifestEntry */
|
|
28
|
-
/** @typedef {import("../Template").RenderManifestOptions} RenderManifestOptions */
|
|
29
26
|
/** @typedef {import("../WebpackError")} WebpackError */
|
|
30
27
|
|
|
31
28
|
const getAsyncWebAssemblyGenerator = memoize(() =>
|
|
@@ -126,9 +123,7 @@ class AsyncWebAssemblyModulesPlugin {
|
|
|
126
123
|
const AsyncWebAssemblyGenerator = getAsyncWebAssemblyGenerator();
|
|
127
124
|
|
|
128
125
|
return Generator.byType({
|
|
129
|
-
javascript: new AsyncWebAssemblyJavascriptGenerator(
|
|
130
|
-
compilation.outputOptions.webassemblyModuleFilename
|
|
131
|
-
),
|
|
126
|
+
javascript: new AsyncWebAssemblyJavascriptGenerator(),
|
|
132
127
|
webassembly: new AsyncWebAssemblyGenerator(this.options)
|
|
133
128
|
});
|
|
134
129
|
});
|
|
@@ -147,9 +142,7 @@ class AsyncWebAssemblyModulesPlugin {
|
|
|
147
142
|
compareModulesByIdOrIdentifier(chunkGraph)
|
|
148
143
|
)) {
|
|
149
144
|
if (module.type === WEBASSEMBLY_MODULE_TYPE_ASYNC) {
|
|
150
|
-
const filenameTemplate =
|
|
151
|
-
/** @type {NonNullable<OutputOptions["webassemblyModuleFilename"]>} */
|
|
152
|
-
(outputOptions.webassemblyModuleFilename);
|
|
145
|
+
const filenameTemplate = outputOptions.webassemblyModuleFilename;
|
|
153
146
|
|
|
154
147
|
result.push({
|
|
155
148
|
render: () =>
|
|
@@ -26,15 +26,6 @@ const decoderOpts = {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
class WebAssemblyParser extends Parser {
|
|
29
|
-
/**
|
|
30
|
-
* @param {{}=} options parser options
|
|
31
|
-
*/
|
|
32
|
-
constructor(options) {
|
|
33
|
-
super();
|
|
34
|
-
this.hooks = Object.freeze({});
|
|
35
|
-
this.options = options;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
29
|
/**
|
|
39
30
|
* @param {string | Buffer | PreparsedAst} source the source to parse
|
|
40
31
|
* @param {ParserState} state the parser state
|
|
@@ -60,8 +51,9 @@ class WebAssemblyParser extends Parser {
|
|
|
60
51
|
// parse it
|
|
61
52
|
const program = decode(source, decoderOpts);
|
|
62
53
|
const module = program.body[0];
|
|
63
|
-
/** @type {
|
|
54
|
+
/** @type {string[]} */
|
|
64
55
|
const exports = [];
|
|
56
|
+
|
|
65
57
|
t.traverse(module, {
|
|
66
58
|
ModuleExport({ node }) {
|
|
67
59
|
exports.push(node.name);
|
|
@@ -46,12 +46,14 @@ const getAllWasmModules = (moduleGraph, chunkGraph, chunk) => {
|
|
|
46
46
|
return array;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
+
/** @typedef {string[]} Declarations */
|
|
50
|
+
|
|
49
51
|
/**
|
|
50
52
|
* generates the import object function for a module
|
|
51
53
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
|
52
54
|
* @param {Module} module the module
|
|
53
55
|
* @param {boolean | undefined} mangle mangle imports
|
|
54
|
-
* @param {
|
|
56
|
+
* @param {Declarations} declarations array where declarations are pushed to
|
|
55
57
|
* @param {RuntimeSpec} runtime the runtime
|
|
56
58
|
* @returns {string} source code
|
|
57
59
|
*/
|
|
@@ -63,7 +65,7 @@ const generateImportObject = (
|
|
|
63
65
|
runtime
|
|
64
66
|
) => {
|
|
65
67
|
const moduleGraph = chunkGraph.moduleGraph;
|
|
66
|
-
/** @type {Map<string,
|
|
68
|
+
/** @type {Map<string, ModuleId>} */
|
|
67
69
|
const waitForInstances = new Map();
|
|
68
70
|
const properties = [];
|
|
69
71
|
const usedWasmDependencies = WebAssemblyUtils.getUsedDependencies(
|
|
@@ -146,7 +148,7 @@ const generateImportObject = (
|
|
|
146
148
|
"};"
|
|
147
149
|
];
|
|
148
150
|
} else {
|
|
149
|
-
/** @type {Map<string,
|
|
151
|
+
/** @type {Map<string, { name: string, value: string }[]>} */
|
|
150
152
|
const propertiesByModule = new Map();
|
|
151
153
|
for (const p of properties) {
|
|
152
154
|
let list = propertiesByModule.get(p.module);
|
|
@@ -253,7 +255,7 @@ class WasmChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
253
255
|
const chunk = /** @type {Chunk} */ (this.chunk);
|
|
254
256
|
const wasmModules = getAllWasmModules(moduleGraph, chunkGraph, chunk);
|
|
255
257
|
const { mangleImports } = this;
|
|
256
|
-
/** @type {
|
|
258
|
+
/** @type {Declarations} */
|
|
257
259
|
const declarations = [];
|
|
258
260
|
const importObjects = wasmModules.map((module) =>
|
|
259
261
|
generateImportObject(
|
|
@@ -16,13 +16,11 @@ const WebAssemblyExportImportedDependency = require("../dependencies/WebAssembly
|
|
|
16
16
|
const WebAssemblyUtils = require("./WebAssemblyUtils");
|
|
17
17
|
|
|
18
18
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
19
|
-
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */
|
|
20
19
|
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
|
21
20
|
/** @typedef {import("../Module")} Module */
|
|
22
21
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
|
23
22
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
24
23
|
/** @typedef {import("../NormalModule")} NormalModule */
|
|
25
|
-
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
26
24
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
27
25
|
/** @typedef {import("./WebAssemblyUtils").UsedWasmDependency} UsedWasmDependency */
|
|
28
26
|
/** @typedef {import("@webassemblyjs/ast").Instruction} Instruction */
|
|
@@ -175,7 +173,7 @@ const createDefaultInitForGlobal = (globalType) => {
|
|
|
175
173
|
*/
|
|
176
174
|
const rewriteImportedGlobals = (state) => (bin) => {
|
|
177
175
|
const additionalInitCode = state.additionalInitCode;
|
|
178
|
-
/** @type {
|
|
176
|
+
/** @type {t.Global[]} */
|
|
179
177
|
const newGlobals = [];
|
|
180
178
|
|
|
181
179
|
bin = editWithAST(state.ast, bin, {
|
|
@@ -17,13 +17,10 @@ const WebAssemblyExportImportedDependency = require("../dependencies/WebAssembly
|
|
|
17
17
|
const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
|
|
18
18
|
|
|
19
19
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
20
|
-
/** @typedef {import("../Dependency")} Dependency */
|
|
21
|
-
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */
|
|
22
20
|
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
|
23
21
|
/** @typedef {import("../Module")} Module */
|
|
24
22
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
|
25
23
|
/** @typedef {import("../NormalModule")} NormalModule */
|
|
26
|
-
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
27
24
|
|
|
28
25
|
class WebAssemblyJavascriptGenerator extends Generator {
|
|
29
26
|
/**
|
|
@@ -56,7 +53,7 @@ class WebAssemblyJavascriptGenerator extends Generator {
|
|
|
56
53
|
runtimeRequirements,
|
|
57
54
|
runtime
|
|
58
55
|
} = generateContext;
|
|
59
|
-
/** @type {InitFragment<
|
|
56
|
+
/** @type {InitFragment<GenerateContext>[]} */
|
|
60
57
|
const initFragments = [];
|
|
61
58
|
|
|
62
59
|
const exportsInfo = moduleGraph.getExportsInfo(module);
|