webpack 5.99.9 → 5.100.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/bin/webpack.js +8 -2
- package/hot/log.js +15 -15
- package/hot/poll.js +1 -0
- package/lib/APIPlugin.js +3 -3
- package/lib/AbstractMethodError.js +1 -0
- package/lib/AutomaticPrefetchPlugin.js +1 -0
- package/lib/BannerPlugin.js +1 -1
- package/lib/CaseSensitiveModulesWarning.js +4 -4
- package/lib/Chunk.js +6 -6
- package/lib/ChunkGraph.js +37 -31
- package/lib/ChunkGroup.js +4 -4
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +94 -17
- package/lib/CodeGenerationResults.js +1 -1
- package/lib/CompatibilityPlugin.js +5 -2
- package/lib/Compilation.js +67 -45
- package/lib/Compiler.js +46 -16
- package/lib/ConcatenationScope.js +15 -6
- package/lib/ConstPlugin.js +5 -3
- package/lib/ContextModule.js +16 -12
- package/lib/ContextModuleFactory.js +4 -3
- package/lib/ContextReplacementPlugin.js +4 -2
- package/lib/CssModule.js +2 -2
- package/lib/DefinePlugin.js +111 -3
- package/lib/DelegatedModuleFactoryPlugin.js +18 -18
- package/lib/Dependency.js +11 -4
- package/lib/DependencyTemplate.js +1 -0
- package/lib/DllEntryPlugin.js +3 -1
- package/lib/DllPlugin.js +4 -3
- package/lib/DllReferencePlugin.js +2 -2
- package/lib/DynamicEntryPlugin.js +1 -1
- package/lib/EntryOptionPlugin.js +5 -0
- package/lib/ErrorHelpers.js +4 -4
- package/lib/EvalDevToolModulePlugin.js +3 -3
- package/lib/EvalSourceMapDevToolPlugin.js +7 -7
- package/lib/ExportsInfo.js +48 -39
- package/lib/ExternalModule.js +15 -11
- package/lib/ExternalModuleFactoryPlugin.js +5 -2
- package/lib/FileSystemInfo.js +51 -36
- package/lib/FlagDependencyExportsPlugin.js +14 -7
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/Generator.js +14 -1
- package/lib/HookWebpackError.js +1 -0
- package/lib/HotModuleReplacementPlugin.js +77 -50
- package/lib/IgnorePlugin.js +5 -2
- package/lib/InvalidDependenciesModuleWarning.js +1 -1
- package/lib/JavascriptMetaInfoPlugin.js +0 -1
- package/lib/LibManifestPlugin.js +4 -2
- package/lib/LoaderOptionsPlugin.js +6 -4
- package/lib/MainTemplate.js +2 -2
- package/lib/Module.js +21 -6
- package/lib/ModuleFactory.js +1 -0
- package/lib/ModuleGraph.js +24 -2
- package/lib/ModuleGraphConnection.js +5 -5
- package/lib/ModuleInfoHeaderPlugin.js +2 -1
- package/lib/ModuleParseError.js +1 -0
- package/lib/ModuleSourceTypesConstants.js +12 -12
- package/lib/ModuleTemplate.js +1 -1
- package/lib/ModuleTypeConstants.js +21 -21
- package/lib/MultiCompiler.js +6 -6
- package/lib/NormalModule.js +31 -44
- package/lib/NormalModuleFactory.js +34 -20
- package/lib/NormalModuleReplacementPlugin.js +1 -1
- package/lib/NullFactory.js +1 -0
- package/lib/OptimizationStages.js +1 -1
- package/lib/Parser.js +1 -0
- package/lib/ProgressPlugin.js +12 -5
- package/lib/ProvidePlugin.js +5 -1
- package/lib/RawModule.js +14 -0
- package/lib/RecordIdsPlugin.js +3 -3
- package/lib/RuntimeGlobals.js +175 -155
- package/lib/RuntimeModule.js +1 -0
- package/lib/RuntimePlugin.js +33 -7
- package/lib/RuntimeTemplate.js +111 -11
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +15 -25
- package/lib/SourceMapDevToolPlugin.js +19 -17
- package/lib/Template.js +2 -2
- package/lib/TemplatedPathPlugin.js +1 -1
- package/lib/WarnDeprecatedOptionPlugin.js +7 -8
- package/lib/WatchIgnorePlugin.js +4 -3
- package/lib/WebpackIsIncludedPlugin.js +2 -1
- package/lib/WebpackOptionsApply.js +115 -27
- package/lib/asset/AssetGenerator.js +15 -11
- package/lib/asset/AssetModulesPlugin.js +19 -17
- package/lib/asset/AssetSourceGenerator.js +4 -4
- package/lib/asset/RawDataUrlModule.js +4 -2
- package/lib/async-modules/AwaitDependenciesInitFragment.js +1 -1
- package/lib/buildChunkGraph.js +6 -3
- package/lib/cache/AddBuildDependenciesPlugin.js +5 -6
- package/lib/cache/IdleFileCachePlugin.js +7 -4
- package/lib/cache/MemoryCachePlugin.js +1 -0
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +26 -20
- package/lib/cache/ResolverCachePlugin.js +16 -8
- package/lib/cli.js +15 -10
- package/lib/config/browserslistTargetHandler.js +3 -3
- package/lib/config/defaults.js +25 -17
- package/lib/config/normalization.js +2 -1
- package/lib/config/target.js +6 -5
- package/lib/container/ContainerPlugin.js +1 -1
- package/lib/container/ContainerReferencePlugin.js +1 -1
- package/lib/container/FallbackModule.js +2 -1
- package/lib/container/HoistContainerReferencesPlugin.js +1 -1
- package/lib/container/ModuleFederationPlugin.js +2 -2
- package/lib/container/RemoteModule.js +1 -1
- package/lib/css/CssGenerator.js +9 -6
- package/lib/css/CssModulesPlugin.js +44 -31
- package/lib/css/CssParser.js +6 -4
- package/lib/css/walkCssTokens.js +33 -37
- package/lib/debug/ProfilingPlugin.js +6 -6
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -8
- package/lib/dependencies/AMDPlugin.js +12 -8
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +28 -26
- package/lib/dependencies/CachedConstDependency.js +1 -5
- package/lib/dependencies/CommonJsExportRequireDependency.js +6 -4
- package/lib/dependencies/CommonJsExportsParserPlugin.js +22 -25
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -9
- package/lib/dependencies/CommonJsImportsParserPlugin.js +100 -114
- package/lib/dependencies/CommonJsPlugin.js +15 -16
- package/lib/dependencies/ContextDependencyHelpers.js +2 -1
- package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -0
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +1 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/DynamicExports.js +9 -9
- package/lib/dependencies/ExportsInfoDependency.js +1 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +122 -101
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +95 -19
- package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
- package/lib/dependencies/HarmonyImportDependency.js +11 -5
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +238 -162
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +20 -9
- package/lib/dependencies/HarmonyModulesPlugin.js +23 -12
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
- package/lib/dependencies/ImportMetaContextPlugin.js +2 -1
- package/lib/dependencies/ImportMetaPlugin.js +2 -2
- package/lib/dependencies/ImportParserPlugin.js +40 -9
- package/lib/dependencies/ImportPlugin.js +3 -1
- package/lib/dependencies/LoaderPlugin.js +1 -0
- package/lib/dependencies/ModuleDependency.js +3 -1
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +1 -0
- package/lib/dependencies/RequireContextPlugin.js +3 -1
- package/lib/dependencies/RequireEnsurePlugin.js +6 -6
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +33 -34
- package/lib/dependencies/RequireIncludePlugin.js +1 -0
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/URLContextDependency.js +65 -0
- package/lib/dependencies/URLPlugin.js +17 -157
- package/lib/dependencies/WorkerPlugin.js +23 -10
- package/lib/dependencies/processExportInfo.js +2 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +269 -185
- package/lib/esm/ModuleChunkLoadingPlugin.js +39 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +70 -3
- package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
- package/lib/hmr/JavascriptHotModuleReplacementHelper.js +37 -0
- package/lib/hmr/LazyCompilationPlugin.js +4 -2
- package/lib/hmr/lazyCompilationBackend.js +4 -2
- package/lib/ids/ChunkModuleIdRangePlugin.js +6 -3
- package/lib/ids/DeterministicChunkIdsPlugin.js +30 -35
- package/lib/ids/DeterministicModuleIdsPlugin.js +4 -3
- package/lib/ids/HashedModuleIdsPlugin.js +5 -4
- package/lib/ids/IdHelpers.js +21 -17
- package/lib/ids/NamedChunkIdsPlugin.js +5 -5
- package/lib/ids/NamedModuleIdsPlugin.js +4 -4
- package/lib/ids/NaturalChunkIdsPlugin.js +2 -1
- package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +3 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +1 -1
- package/lib/ids/SyncModuleIdsPlugin.js +1 -1
- package/lib/index.js +13 -3
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +113 -119
- package/lib/javascript/BasicEvaluatedExpression.js +2 -1
- package/lib/javascript/ChunkHelpers.js +1 -0
- package/lib/javascript/CommonJsChunkFormatPlugin.js +121 -136
- package/lib/javascript/EnableChunkLoadingPlugin.js +6 -3
- package/lib/javascript/JavascriptGenerator.js +14 -2
- package/lib/javascript/JavascriptModulesPlugin.js +68 -27
- package/lib/javascript/JavascriptParser.js +117 -76
- package/lib/javascript/JavascriptParserHelpers.js +41 -41
- package/lib/javascript/StartupHelpers.js +17 -17
- package/lib/json/JsonGenerator.js +4 -2
- package/lib/json/JsonModulesPlugin.js +2 -2
- package/lib/json/JsonParser.js +1 -1
- package/lib/library/AbstractLibraryPlugin.js +6 -2
- package/lib/library/AssignLibraryPlugin.js +21 -6
- package/lib/library/EnableLibraryPlugin.js +23 -3
- package/lib/library/UmdLibraryPlugin.js +15 -6
- package/lib/logging/createConsoleLogger.js +3 -3
- package/lib/logging/runtime.js +9 -9
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +4 -22
- package/lib/node/RequireChunkLoadingRuntimeModule.js +4 -22
- package/lib/node/nodeConsole.js +4 -2
- package/lib/optimize/AggressiveMergingPlugin.js +45 -46
- package/lib/optimize/AggressiveSplittingPlugin.js +13 -12
- package/lib/optimize/ConcatenatedModule.js +227 -57
- package/lib/optimize/EnsureChunkConditionsPlugin.js +58 -58
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -1
- package/lib/optimize/InnerGraph.js +115 -112
- package/lib/optimize/InnerGraphPlugin.js +2 -2
- package/lib/optimize/LimitChunkCountPlugin.js +4 -2
- package/lib/optimize/MangleExportsPlugin.js +4 -3
- package/lib/optimize/MergeDuplicateChunksPlugin.js +80 -81
- package/lib/optimize/MinChunkSizePlugin.js +6 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +31 -22
- package/lib/optimize/RealContentHashPlugin.js +26 -20
- package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -1
- package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -2
- package/lib/optimize/SplitChunksPlugin.js +16 -13
- package/lib/rules/BasicEffectRulePlugin.js +4 -2
- package/lib/rules/BasicMatcherRulePlugin.js +3 -1
- package/lib/rules/ObjectMatcherRulePlugin.js +3 -1
- package/lib/rules/RuleSetCompiler.js +19 -5
- package/lib/rules/UseEffectRulePlugin.js +17 -9
- package/lib/runtime/AsyncModuleRuntimeModule.js +64 -9
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +1 -1
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +214 -0
- package/lib/runtime/RuntimeIdRuntimeModule.js +2 -1
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +8 -7
- package/lib/schemes/FileUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +27 -19
- package/lib/schemes/VirtualUrlPlugin.js +222 -0
- package/lib/serialization/AggregateErrorSerializer.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +5 -4
- package/lib/serialization/FileMiddleware.js +7 -4
- package/lib/serialization/ObjectMiddleware.js +14 -8
- package/lib/serialization/Serializer.js +5 -3
- package/lib/serialization/SerializerMiddleware.js +2 -0
- package/lib/sharing/ConsumeSharedModule.js +1 -1
- package/lib/sharing/ConsumeSharedPlugin.js +3 -3
- package/lib/sharing/ConsumeSharedRuntimeModule.js +2 -2
- package/lib/sharing/ProvideSharedModule.js +1 -1
- package/lib/sharing/ProvideSharedPlugin.js +3 -2
- package/lib/sharing/SharePlugin.js +2 -1
- package/lib/sharing/ShareRuntimeModule.js +3 -5
- package/lib/sharing/utils.js +34 -34
- package/lib/stats/DefaultStatsFactoryPlugin.js +49 -46
- package/lib/stats/DefaultStatsPresetPlugin.js +13 -13
- package/lib/stats/DefaultStatsPrinterPlugin.js +15 -9
- package/lib/stats/StatsFactory.js +6 -3
- package/lib/stats/StatsPrinter.js +6 -7
- package/lib/url/URLParserPlugin.js +266 -0
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/Hash.js +2 -0
- package/lib/util/IterableHelpers.js +1 -1
- package/lib/util/LazyBucketSortedSet.js +2 -1
- package/lib/util/LazySet.js +11 -6
- package/lib/util/ParallelismFactorCalculator.js +1 -1
- package/lib/util/SetHelpers.js +3 -3
- package/lib/util/SortableSet.js +2 -2
- package/lib/util/StackedCacheMap.js +3 -1
- package/lib/util/StackedMap.js +2 -2
- package/lib/util/StringXor.js +1 -0
- package/lib/util/TupleSet.js +1 -0
- package/lib/util/URLAbsoluteSpecifier.js +1 -1
- package/lib/util/cleverMerge.js +95 -58
- package/lib/util/comparators.js +154 -127
- package/lib/util/compileBooleanMatcher.js +8 -3
- package/lib/util/concatenate.js +8 -7
- package/lib/util/conventions.js +72 -73
- package/lib/util/create-schema-validation.js +2 -1
- package/lib/util/createHash.js +10 -4
- package/lib/util/deprecation.js +69 -66
- package/lib/util/deterministicGrouping.js +4 -2
- package/lib/util/extractUrlAndGlobal.js +1 -1
- package/lib/util/findGraphRoots.js +2 -2
- package/lib/util/fs.js +30 -23
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/wasm-hash.js +4 -2
- package/lib/util/identifier.js +13 -12
- package/lib/util/internalSerializables.js +2 -0
- package/lib/util/magicComment.js +5 -5
- package/lib/util/processAsyncTree.js +1 -1
- package/lib/util/propertyAccess.js +1 -1
- package/lib/util/propertyName.js +1 -1
- package/lib/util/registerExternalSerializer.js +1 -2
- package/lib/util/removeBOM.js +1 -1
- package/lib/util/runtime.js +29 -21
- package/lib/util/semver.js +1 -1
- package/lib/util/serialization.js +3 -0
- package/lib/util/source.js +3 -2
- package/lib/validateSchema.js +1 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +6 -3
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +46 -49
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
- package/lib/wasm-sync/WebAssemblyGenerator.js +2 -3
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +3 -2
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +3 -0
- package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -22
- package/lib/webpack.js +4 -5
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -24
- package/lib/webworker/WebWorkerTemplatePlugin.js +1 -0
- package/package.json +119 -113
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +17 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.d.ts +7 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +6 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +77 -0
- package/types.d.ts +1243 -409
package/lib/css/walkCssTokens.js
CHANGED
|
@@ -320,6 +320,7 @@ const consumeAStringToken = (input, pos, callbacks) => {
|
|
|
320
320
|
const isNonASCIICodePoint = (cc, q) =>
|
|
321
321
|
// Simplify
|
|
322
322
|
cc > 0x80;
|
|
323
|
+
|
|
323
324
|
/**
|
|
324
325
|
* @param {number} cc char code
|
|
325
326
|
* @returns {boolean} is letter
|
|
@@ -716,12 +717,12 @@ const consumeRightParenthesis = (input, pos, callbacks) => {
|
|
|
716
717
|
};
|
|
717
718
|
|
|
718
719
|
/** @type {CharHandler} */
|
|
719
|
-
const consumeLeftSquareBracket = (input, pos,
|
|
720
|
+
const consumeLeftSquareBracket = (input, pos, _callbacks) =>
|
|
720
721
|
// Return a <]-token>.
|
|
721
722
|
pos;
|
|
722
723
|
|
|
723
724
|
/** @type {CharHandler} */
|
|
724
|
-
const consumeRightSquareBracket = (input, pos,
|
|
725
|
+
const consumeRightSquareBracket = (input, pos, _callbacks) =>
|
|
725
726
|
// Return a <]-token>.
|
|
726
727
|
pos;
|
|
727
728
|
|
|
@@ -1196,14 +1197,12 @@ module.exports = (input, pos = 0, callbacks = {}) => {
|
|
|
1196
1197
|
return pos;
|
|
1197
1198
|
};
|
|
1198
1199
|
|
|
1199
|
-
module.exports.isIdentStartCodePoint = isIdentStartCodePoint;
|
|
1200
|
-
|
|
1201
1200
|
/**
|
|
1202
1201
|
* @param {string} input input
|
|
1203
1202
|
* @param {number} pos position
|
|
1204
1203
|
* @returns {number} position after comments
|
|
1205
1204
|
*/
|
|
1206
|
-
|
|
1205
|
+
const eatComments = (input, pos) => {
|
|
1207
1206
|
for (;;) {
|
|
1208
1207
|
const originalPos = pos;
|
|
1209
1208
|
pos = consumeComments(input, pos, {});
|
|
@@ -1220,7 +1219,7 @@ module.exports.eatComments = (input, pos) => {
|
|
|
1220
1219
|
* @param {number} pos position
|
|
1221
1220
|
* @returns {number} position after whitespace
|
|
1222
1221
|
*/
|
|
1223
|
-
|
|
1222
|
+
const eatWhitespace = (input, pos) => {
|
|
1224
1223
|
while (_isWhiteSpace(input.charCodeAt(pos))) {
|
|
1225
1224
|
pos++;
|
|
1226
1225
|
}
|
|
@@ -1233,7 +1232,7 @@ module.exports.eatWhitespace = (input, pos) => {
|
|
|
1233
1232
|
* @param {number} pos position
|
|
1234
1233
|
* @returns {number} position after whitespace and comments
|
|
1235
1234
|
*/
|
|
1236
|
-
|
|
1235
|
+
const eatWhitespaceAndComments = (input, pos) => {
|
|
1237
1236
|
for (;;) {
|
|
1238
1237
|
const originalPos = pos;
|
|
1239
1238
|
pos = consumeComments(input, pos, {});
|
|
@@ -1248,29 +1247,12 @@ module.exports.eatWhitespaceAndComments = (input, pos) => {
|
|
|
1248
1247
|
return pos;
|
|
1249
1248
|
};
|
|
1250
1249
|
|
|
1251
|
-
/**
|
|
1252
|
-
* @param {string} input input
|
|
1253
|
-
* @param {number} pos position
|
|
1254
|
-
* @returns {number} position after whitespace and comments
|
|
1255
|
-
*/
|
|
1256
|
-
module.exports.eatComments = (input, pos) => {
|
|
1257
|
-
for (;;) {
|
|
1258
|
-
const originalPos = pos;
|
|
1259
|
-
pos = consumeComments(input, pos, {});
|
|
1260
|
-
if (originalPos === pos) {
|
|
1261
|
-
break;
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
|
|
1265
|
-
return pos;
|
|
1266
|
-
};
|
|
1267
|
-
|
|
1268
1250
|
/**
|
|
1269
1251
|
* @param {string} input input
|
|
1270
1252
|
* @param {number} pos position
|
|
1271
1253
|
* @returns {number} position after whitespace
|
|
1272
1254
|
*/
|
|
1273
|
-
|
|
1255
|
+
const eatWhiteLine = (input, pos) => {
|
|
1274
1256
|
for (;;) {
|
|
1275
1257
|
const cc = input.charCodeAt(pos);
|
|
1276
1258
|
if (_isSpace(cc)) {
|
|
@@ -1290,8 +1272,8 @@ module.exports.eatWhiteLine = (input, pos) => {
|
|
|
1290
1272
|
* @param {number} pos position
|
|
1291
1273
|
* @returns {[number, number] | undefined} positions of ident sequence
|
|
1292
1274
|
*/
|
|
1293
|
-
|
|
1294
|
-
pos =
|
|
1275
|
+
const skipCommentsAndEatIdentSequence = (input, pos) => {
|
|
1276
|
+
pos = eatComments(input, pos);
|
|
1295
1277
|
|
|
1296
1278
|
const start = pos;
|
|
1297
1279
|
|
|
@@ -1315,8 +1297,8 @@ module.exports.skipCommentsAndEatIdentSequence = (input, pos) => {
|
|
|
1315
1297
|
* @param {number} pos position
|
|
1316
1298
|
* @returns {[number, number] | undefined} positions of ident sequence
|
|
1317
1299
|
*/
|
|
1318
|
-
|
|
1319
|
-
pos =
|
|
1300
|
+
const eatString = (input, pos) => {
|
|
1301
|
+
pos = eatWhitespaceAndComments(input, pos);
|
|
1320
1302
|
|
|
1321
1303
|
const start = pos;
|
|
1322
1304
|
|
|
@@ -1336,7 +1318,7 @@ module.exports.eatString = (input, pos) => {
|
|
|
1336
1318
|
* @param {CssTokenCallbacks} cbs callbacks
|
|
1337
1319
|
* @returns {[number, number][]} positions of ident sequence
|
|
1338
1320
|
*/
|
|
1339
|
-
|
|
1321
|
+
const eatImageSetStrings = (input, pos, cbs) => {
|
|
1340
1322
|
/** @type {[number, number][]} */
|
|
1341
1323
|
const result = [];
|
|
1342
1324
|
|
|
@@ -1406,10 +1388,10 @@ module.exports.eatImageSetStrings = (input, pos, cbs) => {
|
|
|
1406
1388
|
* @param {CssTokenCallbacks} cbs callbacks
|
|
1407
1389
|
* @returns {[[number, number, number, number] | undefined, [number, number] | undefined, [number, number] | undefined, [number, number] | undefined]} positions of top level tokens
|
|
1408
1390
|
*/
|
|
1409
|
-
|
|
1391
|
+
const eatImportTokens = (input, pos, cbs) => {
|
|
1410
1392
|
const result =
|
|
1411
1393
|
/** @type {[[number, number, number, number] | undefined, [number, number] | undefined, [number, number] | undefined, [number, number] | undefined]} */
|
|
1412
|
-
(
|
|
1394
|
+
(Array.from({ length: 4 }));
|
|
1413
1395
|
|
|
1414
1396
|
/** @type {0 | 1 | 2 | undefined} */
|
|
1415
1397
|
let scope;
|
|
@@ -1548,8 +1530,8 @@ module.exports.eatImportTokens = (input, pos, cbs) => {
|
|
|
1548
1530
|
* @param {number} pos position
|
|
1549
1531
|
* @returns {[number, number] | undefined} positions of ident sequence
|
|
1550
1532
|
*/
|
|
1551
|
-
|
|
1552
|
-
pos =
|
|
1533
|
+
const eatIdentSequence = (input, pos) => {
|
|
1534
|
+
pos = eatWhitespaceAndComments(input, pos);
|
|
1553
1535
|
|
|
1554
1536
|
const start = pos;
|
|
1555
1537
|
|
|
@@ -1573,8 +1555,8 @@ module.exports.eatIdentSequence = (input, pos) => {
|
|
|
1573
1555
|
* @param {number} pos position
|
|
1574
1556
|
* @returns {[number, number, boolean] | undefined} positions of ident sequence or string
|
|
1575
1557
|
*/
|
|
1576
|
-
|
|
1577
|
-
pos =
|
|
1558
|
+
const eatIdentSequenceOrString = (input, pos) => {
|
|
1559
|
+
pos = eatWhitespaceAndComments(input, pos);
|
|
1578
1560
|
|
|
1579
1561
|
const start = pos;
|
|
1580
1562
|
|
|
@@ -1602,7 +1584,7 @@ module.exports.eatIdentSequenceOrString = (input, pos) => {
|
|
|
1602
1584
|
* @param {string} chars characters
|
|
1603
1585
|
* @returns {(input: string, pos: number) => number} function to eat characters
|
|
1604
1586
|
*/
|
|
1605
|
-
|
|
1587
|
+
const eatUntil = chars => {
|
|
1606
1588
|
const charCodes = Array.from({ length: chars.length }, (_, i) =>
|
|
1607
1589
|
chars.charCodeAt(i)
|
|
1608
1590
|
);
|
|
@@ -1625,3 +1607,17 @@ module.exports.eatUntil = chars => {
|
|
|
1625
1607
|
}
|
|
1626
1608
|
};
|
|
1627
1609
|
};
|
|
1610
|
+
|
|
1611
|
+
module.exports.eatComments = eatComments;
|
|
1612
|
+
module.exports.eatIdentSequence = eatIdentSequence;
|
|
1613
|
+
module.exports.eatIdentSequenceOrString = eatIdentSequenceOrString;
|
|
1614
|
+
module.exports.eatImageSetStrings = eatImageSetStrings;
|
|
1615
|
+
module.exports.eatImportTokens = eatImportTokens;
|
|
1616
|
+
module.exports.eatString = eatString;
|
|
1617
|
+
module.exports.eatUntil = eatUntil;
|
|
1618
|
+
module.exports.eatWhiteLine = eatWhiteLine;
|
|
1619
|
+
module.exports.eatWhitespace = eatWhitespace;
|
|
1620
|
+
module.exports.eatWhitespaceAndComments = eatWhitespaceAndComments;
|
|
1621
|
+
module.exports.isIdentStartCodePoint = isIdentStartCodePoint;
|
|
1622
|
+
module.exports.skipCommentsAndEatIdentSequence =
|
|
1623
|
+
skipCommentsAndEatIdentSequence;
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
const { Tracer } = require("chrome-trace-event");
|
|
8
8
|
const {
|
|
9
|
-
JAVASCRIPT_MODULES,
|
|
10
9
|
CSS_MODULES,
|
|
11
|
-
|
|
12
|
-
JSON_MODULE_TYPE
|
|
10
|
+
JAVASCRIPT_MODULES,
|
|
11
|
+
JSON_MODULE_TYPE,
|
|
12
|
+
WEBASSEMBLY_MODULES
|
|
13
13
|
} = require("../ModuleTypeConstants");
|
|
14
14
|
const createSchemaValidation = require("../util/create-schema-validation");
|
|
15
15
|
const { dirname, mkdirpSync } = require("../util/fs");
|
|
@@ -27,7 +27,7 @@ const { dirname, mkdirpSync } = require("../util/fs");
|
|
|
27
27
|
/** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */
|
|
28
28
|
|
|
29
29
|
const validate = createSchemaValidation(
|
|
30
|
-
require("../../schemas/plugins/debug/ProfilingPlugin.check
|
|
30
|
+
require("../../schemas/plugins/debug/ProfilingPlugin.check"),
|
|
31
31
|
() => require("../../schemas/plugins/debug/ProfilingPlugin.json"),
|
|
32
32
|
{
|
|
33
33
|
name: "Profiling Plugin",
|
|
@@ -378,7 +378,7 @@ const interceptAllParserHooks = (moduleFactory, tracer) => {
|
|
|
378
378
|
for (const moduleType of moduleTypes) {
|
|
379
379
|
moduleFactory.hooks.parser
|
|
380
380
|
.for(moduleType)
|
|
381
|
-
.tap(PLUGIN_NAME, (parser,
|
|
381
|
+
.tap(PLUGIN_NAME, (parser, _parserOpts) => {
|
|
382
382
|
interceptAllHooksFor(parser, tracer, "Parser");
|
|
383
383
|
});
|
|
384
384
|
}
|
|
@@ -399,7 +399,7 @@ const interceptAllGeneratorHooks = (moduleFactory, tracer) => {
|
|
|
399
399
|
for (const moduleType of moduleTypes) {
|
|
400
400
|
moduleFactory.hooks.generator
|
|
401
401
|
.for(moduleType)
|
|
402
|
-
.tap(PLUGIN_NAME, (parser,
|
|
402
|
+
.tap(PLUGIN_NAME, (parser, _parserOpts) => {
|
|
403
403
|
interceptAllHooksFor(parser, tracer, "Generator");
|
|
404
404
|
});
|
|
405
405
|
}
|
|
@@ -68,6 +68,8 @@ const isCallable = expr => {
|
|
|
68
68
|
return false;
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
+
const PLUGIN_NAME = "AMDDefineDependencyParserPlugin";
|
|
72
|
+
|
|
71
73
|
class AMDDefineDependencyParserPlugin {
|
|
72
74
|
/**
|
|
73
75
|
* @param {JavascriptParserOptions} options parserOptions
|
|
@@ -83,10 +85,7 @@ class AMDDefineDependencyParserPlugin {
|
|
|
83
85
|
apply(parser) {
|
|
84
86
|
parser.hooks.call
|
|
85
87
|
.for("define")
|
|
86
|
-
.tap(
|
|
87
|
-
"AMDDefineDependencyParserPlugin",
|
|
88
|
-
this.processCallDefine.bind(this, parser)
|
|
89
|
-
);
|
|
88
|
+
.tap(PLUGIN_NAME, this.processCallDefine.bind(this, parser));
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
/**
|
|
@@ -106,10 +105,11 @@ class AMDDefineDependencyParserPlugin {
|
|
|
106
105
|
["require", "module", "exports"].includes(
|
|
107
106
|
/** @type {string} */ (item.string)
|
|
108
107
|
)
|
|
109
|
-
)
|
|
110
|
-
identifiers[/** @type {number} */ (idx)] =
|
|
111
|
-
|
|
112
|
-
|
|
108
|
+
) {
|
|
109
|
+
identifiers[/** @type {number} */ (idx)] =
|
|
110
|
+
/** @type {string} */
|
|
111
|
+
(item.string);
|
|
112
|
+
}
|
|
113
113
|
const result = this.processItem(parser, expr, item, namedModule);
|
|
114
114
|
if (result === undefined) {
|
|
115
115
|
this.processContext(parser, expr, item);
|
|
@@ -42,7 +42,7 @@ const UnsupportedDependency = require("./UnsupportedDependency");
|
|
|
42
42
|
|
|
43
43
|
const PLUGIN_NAME = "AMDPlugin";
|
|
44
44
|
|
|
45
|
-
/** @typedef {
|
|
45
|
+
/** @typedef {Exclude<Amd, false>} AmdOptions */
|
|
46
46
|
|
|
47
47
|
class AMDPlugin {
|
|
48
48
|
/**
|
|
@@ -119,13 +119,13 @@ class AMDPlugin {
|
|
|
119
119
|
|
|
120
120
|
compilation.hooks.runtimeRequirementInTree
|
|
121
121
|
.for(RuntimeGlobals.amdDefine)
|
|
122
|
-
.tap(PLUGIN_NAME, (chunk,
|
|
122
|
+
.tap(PLUGIN_NAME, (chunk, _set) => {
|
|
123
123
|
compilation.addRuntimeModule(chunk, new AMDDefineRuntimeModule());
|
|
124
124
|
});
|
|
125
125
|
|
|
126
126
|
compilation.hooks.runtimeRequirementInTree
|
|
127
127
|
.for(RuntimeGlobals.amdOptions)
|
|
128
|
-
.tap(PLUGIN_NAME, (chunk,
|
|
128
|
+
.tap(PLUGIN_NAME, (chunk, _set) => {
|
|
129
129
|
compilation.addRuntimeModule(
|
|
130
130
|
chunk,
|
|
131
131
|
new AMDOptionsRuntimeModule(amdOptions)
|
|
@@ -143,7 +143,7 @@ class AMDPlugin {
|
|
|
143
143
|
/**
|
|
144
144
|
* @param {string} optionExpr option expression
|
|
145
145
|
* @param {string} rootName root name
|
|
146
|
-
* @param {() =>
|
|
146
|
+
* @param {() => string[]} getMembers callback
|
|
147
147
|
*/
|
|
148
148
|
const tapOptionsHooks = (optionExpr, rootName, getMembers) => {
|
|
149
149
|
parser.hooks.expression
|
|
@@ -156,9 +156,13 @@ class AMDPlugin {
|
|
|
156
156
|
);
|
|
157
157
|
parser.hooks.evaluateIdentifier
|
|
158
158
|
.for(optionExpr)
|
|
159
|
-
.tap(
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
.tap(PLUGIN_NAME, expr =>
|
|
160
|
+
evaluateToIdentifier(
|
|
161
|
+
optionExpr,
|
|
162
|
+
rootName,
|
|
163
|
+
getMembers,
|
|
164
|
+
true
|
|
165
|
+
)(expr)
|
|
162
166
|
);
|
|
163
167
|
parser.hooks.evaluateTypeof
|
|
164
168
|
.for(optionExpr)
|
|
@@ -176,7 +180,7 @@ class AMDPlugin {
|
|
|
176
180
|
);
|
|
177
181
|
new AMDDefineDependencyParserPlugin(parserOptions).apply(parser);
|
|
178
182
|
|
|
179
|
-
tapOptionsHooks("define.amd", "define", () => "amd");
|
|
183
|
+
tapOptionsHooks("define.amd", "define", () => ["amd"]);
|
|
180
184
|
tapOptionsHooks("require.amd", "require", () => ["amd"]);
|
|
181
185
|
tapOptionsHooks(
|
|
182
186
|
"__webpack_amd_options__",
|
|
@@ -31,6 +31,8 @@ const getFunctionExpression = require("./getFunctionExpression");
|
|
|
31
31
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
|
32
32
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
33
33
|
|
|
34
|
+
const PLUGIN_NAME = "AMDRequireDependenciesBlockParserPlugin";
|
|
35
|
+
|
|
34
36
|
class AMDRequireDependenciesBlockParserPlugin {
|
|
35
37
|
/**
|
|
36
38
|
* @param {JavascriptParserOptions} options parserOptions
|
|
@@ -80,10 +82,7 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
80
82
|
apply(parser) {
|
|
81
83
|
parser.hooks.call
|
|
82
84
|
.for("require")
|
|
83
|
-
.tap(
|
|
84
|
-
"AMDRequireDependenciesBlockParserPlugin",
|
|
85
|
-
this.processCallRequire.bind(this, parser)
|
|
86
|
-
);
|
|
85
|
+
.tap(PLUGIN_NAME, this.processCallRequire.bind(this, parser));
|
|
87
86
|
}
|
|
88
87
|
|
|
89
88
|
/**
|
|
@@ -126,7 +125,8 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
126
125
|
}
|
|
127
126
|
const dep = this.newRequireArrayDependency(
|
|
128
127
|
deps,
|
|
129
|
-
/** @type {Range} */
|
|
128
|
+
/** @type {Range} */
|
|
129
|
+
(param.range)
|
|
130
130
|
);
|
|
131
131
|
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
|
132
132
|
dep.optional = Boolean(parser.scope.inTry);
|
|
@@ -158,41 +158,37 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
158
158
|
if (param.string === "require") {
|
|
159
159
|
dep = new ConstDependency(
|
|
160
160
|
RuntimeGlobals.require,
|
|
161
|
-
/** @type {
|
|
162
|
-
(param.
|
|
161
|
+
/** @type {Range} */
|
|
162
|
+
(param.range),
|
|
163
163
|
[RuntimeGlobals.require]
|
|
164
164
|
);
|
|
165
165
|
} else if (param.string === "module") {
|
|
166
166
|
dep = new ConstDependency(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
(parser.state.module.buildInfo).moduleArgument
|
|
171
|
-
),
|
|
172
|
-
/** @type {Range} */ (param.range),
|
|
167
|
+
parser.state.module.moduleArgument,
|
|
168
|
+
/** @type {Range} */
|
|
169
|
+
(param.range),
|
|
173
170
|
[RuntimeGlobals.module]
|
|
174
171
|
);
|
|
175
172
|
} else if (param.string === "exports") {
|
|
176
173
|
dep = new ConstDependency(
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
(parser.state.module.buildInfo).exportsArgument
|
|
181
|
-
),
|
|
182
|
-
/** @type {Range} */ (param.range),
|
|
174
|
+
parser.state.module.exportsArgument,
|
|
175
|
+
/** @type {Range} */
|
|
176
|
+
(param.range),
|
|
183
177
|
[RuntimeGlobals.exports]
|
|
184
178
|
);
|
|
185
179
|
} else if (
|
|
186
180
|
(localModule = getLocalModule(
|
|
187
181
|
parser.state,
|
|
188
|
-
/** @type {string} */
|
|
182
|
+
/** @type {string} */
|
|
183
|
+
(param.string)
|
|
189
184
|
))
|
|
190
185
|
) {
|
|
191
186
|
localModule.flagUsed();
|
|
192
187
|
dep = new LocalModuleDependency(localModule, param.range, false);
|
|
193
188
|
} else {
|
|
194
189
|
dep = this.newRequireItemDependency(
|
|
195
|
-
/** @type {string} */
|
|
190
|
+
/** @type {string} */
|
|
191
|
+
(param.string),
|
|
196
192
|
param.range
|
|
197
193
|
);
|
|
198
194
|
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
|
@@ -308,13 +304,15 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
308
304
|
result = this.processArray(
|
|
309
305
|
parser,
|
|
310
306
|
expr,
|
|
311
|
-
/** @type {BasicEvaluatedExpression} */
|
|
307
|
+
/** @type {BasicEvaluatedExpression} */
|
|
308
|
+
(param)
|
|
312
309
|
);
|
|
313
310
|
});
|
|
314
311
|
parser.state.current = old;
|
|
315
312
|
if (!result) return;
|
|
316
313
|
parser.state.current.addBlock(
|
|
317
|
-
/** @type {AMDRequireDependenciesBlock} */
|
|
314
|
+
/** @type {AMDRequireDependenciesBlock} */
|
|
315
|
+
(depBlock)
|
|
318
316
|
);
|
|
319
317
|
return true;
|
|
320
318
|
}
|
|
@@ -325,13 +323,15 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
325
323
|
result = this.processArray(
|
|
326
324
|
parser,
|
|
327
325
|
expr,
|
|
328
|
-
/** @type {BasicEvaluatedExpression} */
|
|
326
|
+
/** @type {BasicEvaluatedExpression} */
|
|
327
|
+
(param)
|
|
329
328
|
);
|
|
330
329
|
});
|
|
331
330
|
if (!result) {
|
|
332
331
|
const dep = new UnsupportedDependency(
|
|
333
332
|
"unsupported",
|
|
334
|
-
/** @type {Range} */
|
|
333
|
+
/** @type {Range} */
|
|
334
|
+
(expr.range)
|
|
335
335
|
);
|
|
336
336
|
old.addPresentationalDependency(dep);
|
|
337
337
|
if (parser.state.module) {
|
|
@@ -340,7 +340,8 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
340
340
|
`Cannot statically analyse 'require(…, …)' in line ${
|
|
341
341
|
/** @type {SourceLocation} */ (expr.loc).start.line
|
|
342
342
|
}`,
|
|
343
|
-
/** @type {DependencyLocation} */
|
|
343
|
+
/** @type {DependencyLocation} */
|
|
344
|
+
(expr.loc)
|
|
344
345
|
)
|
|
345
346
|
);
|
|
346
347
|
}
|
|
@@ -415,4 +416,5 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
415
416
|
return new AMDRequireArrayDependency(depsArray, range);
|
|
416
417
|
}
|
|
417
418
|
}
|
|
419
|
+
|
|
418
420
|
module.exports = AMDRequireDependenciesBlockParserPlugin;
|
|
@@ -99,11 +99,7 @@ CachedConstDependency.Template = class CachedConstDependencyTemplate extends (
|
|
|
99
99
|
* @param {DependencyTemplateContext} templateContext the context object
|
|
100
100
|
* @returns {void}
|
|
101
101
|
*/
|
|
102
|
-
apply(
|
|
103
|
-
dependency,
|
|
104
|
-
source,
|
|
105
|
-
{ runtimeTemplate, dependencyTemplates, initFragments }
|
|
106
|
-
) {
|
|
102
|
+
apply(dependency, source, { initFragments }) {
|
|
107
103
|
const dep = /** @type {CachedConstDependency} */ (dependency);
|
|
108
104
|
|
|
109
105
|
initFragments.push(
|
|
@@ -126,7 +126,7 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|
|
126
126
|
processExportInfo(
|
|
127
127
|
runtime,
|
|
128
128
|
referencedExports,
|
|
129
|
-
ids
|
|
129
|
+
[...ids, exportInfo.name],
|
|
130
130
|
exportInfo,
|
|
131
131
|
false
|
|
132
132
|
);
|
|
@@ -193,7 +193,7 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|
|
193
193
|
name => ({
|
|
194
194
|
name,
|
|
195
195
|
from,
|
|
196
|
-
export: ids
|
|
196
|
+
export: [...ids, name],
|
|
197
197
|
canMangle: !(name in EMPTY_OBJECT) && false
|
|
198
198
|
})
|
|
199
199
|
),
|
|
@@ -223,14 +223,16 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|
|
223
223
|
/** @type {ExportsInfo | undefined} */
|
|
224
224
|
let importedExportsInfo = moduleGraph.getExportsInfo(importedModule);
|
|
225
225
|
const ids = this.getIds(moduleGraph);
|
|
226
|
-
if (ids.length > 0)
|
|
226
|
+
if (ids.length > 0) {
|
|
227
227
|
importedExportsInfo = importedExportsInfo.getNestedExportsInfo(ids);
|
|
228
|
+
}
|
|
228
229
|
/** @type {ExportsInfo | undefined} */
|
|
229
230
|
let exportsInfo = moduleGraph.getExportsInfo(
|
|
230
231
|
/** @type {Module} */ (moduleGraph.getParentModule(this))
|
|
231
232
|
);
|
|
232
|
-
if (this.names.length > 0)
|
|
233
|
+
if (this.names.length > 0) {
|
|
233
234
|
exportsInfo = exportsInfo.getNestedExportsInfo(this.names);
|
|
235
|
+
}
|
|
234
236
|
|
|
235
237
|
const noExtraExports =
|
|
236
238
|
importedExportsInfo &&
|
|
@@ -125,6 +125,8 @@ const parseRequireCall = (parser, expr) => {
|
|
|
125
125
|
return { argument: argValue, ids: ids.reverse() };
|
|
126
126
|
};
|
|
127
127
|
|
|
128
|
+
const PLUGIN_NAME = "CommonJsExportsParserPlugin";
|
|
129
|
+
|
|
128
130
|
class CommonJsExportsParserPlugin {
|
|
129
131
|
/**
|
|
130
132
|
* @param {ModuleGraph} moduleGraph module graph
|
|
@@ -177,10 +179,10 @@ class CommonJsExportsParserPlugin {
|
|
|
177
179
|
// metadata //
|
|
178
180
|
parser.hooks.evaluateTypeof
|
|
179
181
|
.for("module")
|
|
180
|
-
.tap(
|
|
182
|
+
.tap(PLUGIN_NAME, evaluateToString("object"));
|
|
181
183
|
parser.hooks.evaluateTypeof
|
|
182
184
|
.for("exports")
|
|
183
|
-
.tap(
|
|
185
|
+
.tap(PLUGIN_NAME, evaluateToString("object"));
|
|
184
186
|
|
|
185
187
|
// exporting //
|
|
186
188
|
|
|
@@ -239,24 +241,24 @@ class CommonJsExportsParserPlugin {
|
|
|
239
241
|
};
|
|
240
242
|
parser.hooks.assignMemberChain
|
|
241
243
|
.for("exports")
|
|
242
|
-
.tap(
|
|
244
|
+
.tap(PLUGIN_NAME, (expr, members) =>
|
|
243
245
|
handleAssignExport(expr, "exports", members)
|
|
244
246
|
);
|
|
245
247
|
parser.hooks.assignMemberChain
|
|
246
248
|
.for("this")
|
|
247
|
-
.tap(
|
|
249
|
+
.tap(PLUGIN_NAME, (expr, members) => {
|
|
248
250
|
if (!parser.scope.topLevelScope) return;
|
|
249
251
|
return handleAssignExport(expr, "this", members);
|
|
250
252
|
});
|
|
251
253
|
parser.hooks.assignMemberChain
|
|
252
254
|
.for("module")
|
|
253
|
-
.tap(
|
|
255
|
+
.tap(PLUGIN_NAME, (expr, members) => {
|
|
254
256
|
if (members[0] !== "exports") return;
|
|
255
257
|
return handleAssignExport(expr, "module.exports", members.slice(1));
|
|
256
258
|
});
|
|
257
259
|
parser.hooks.call
|
|
258
260
|
.for("Object.defineProperty")
|
|
259
|
-
.tap(
|
|
261
|
+
.tap(PLUGIN_NAME, expression => {
|
|
260
262
|
const expr = /** @type {CallExpression} */ (expression);
|
|
261
263
|
if (!parser.isStatementLevelExpression(expr)) return;
|
|
262
264
|
if (expr.arguments.length !== 3) return;
|
|
@@ -338,22 +340,20 @@ class CommonJsExportsParserPlugin {
|
|
|
338
340
|
};
|
|
339
341
|
parser.hooks.callMemberChain
|
|
340
342
|
.for("exports")
|
|
341
|
-
.tap(
|
|
343
|
+
.tap(PLUGIN_NAME, (expr, members) =>
|
|
342
344
|
handleAccessExport(expr.callee, "exports", members, expr)
|
|
343
345
|
);
|
|
344
346
|
parser.hooks.expressionMemberChain
|
|
345
347
|
.for("exports")
|
|
346
|
-
.tap(
|
|
348
|
+
.tap(PLUGIN_NAME, (expr, members) =>
|
|
347
349
|
handleAccessExport(expr, "exports", members)
|
|
348
350
|
);
|
|
349
351
|
parser.hooks.expression
|
|
350
352
|
.for("exports")
|
|
351
|
-
.tap(
|
|
352
|
-
handleAccessExport(expr, "exports", [])
|
|
353
|
-
);
|
|
353
|
+
.tap(PLUGIN_NAME, expr => handleAccessExport(expr, "exports", []));
|
|
354
354
|
parser.hooks.callMemberChain
|
|
355
355
|
.for("module")
|
|
356
|
-
.tap(
|
|
356
|
+
.tap(PLUGIN_NAME, (expr, members) => {
|
|
357
357
|
if (members[0] !== "exports") return;
|
|
358
358
|
return handleAccessExport(
|
|
359
359
|
expr.callee,
|
|
@@ -364,36 +364,32 @@ class CommonJsExportsParserPlugin {
|
|
|
364
364
|
});
|
|
365
365
|
parser.hooks.expressionMemberChain
|
|
366
366
|
.for("module")
|
|
367
|
-
.tap(
|
|
367
|
+
.tap(PLUGIN_NAME, (expr, members) => {
|
|
368
368
|
if (members[0] !== "exports") return;
|
|
369
369
|
return handleAccessExport(expr, "module.exports", members.slice(1));
|
|
370
370
|
});
|
|
371
371
|
parser.hooks.expression
|
|
372
372
|
.for("module.exports")
|
|
373
|
-
.tap(
|
|
374
|
-
handleAccessExport(expr, "module.exports", [])
|
|
375
|
-
);
|
|
373
|
+
.tap(PLUGIN_NAME, expr => handleAccessExport(expr, "module.exports", []));
|
|
376
374
|
parser.hooks.callMemberChain
|
|
377
375
|
.for("this")
|
|
378
|
-
.tap(
|
|
376
|
+
.tap(PLUGIN_NAME, (expr, members) => {
|
|
379
377
|
if (!parser.scope.topLevelScope) return;
|
|
380
378
|
return handleAccessExport(expr.callee, "this", members, expr);
|
|
381
379
|
});
|
|
382
380
|
parser.hooks.expressionMemberChain
|
|
383
381
|
.for("this")
|
|
384
|
-
.tap(
|
|
382
|
+
.tap(PLUGIN_NAME, (expr, members) => {
|
|
385
383
|
if (!parser.scope.topLevelScope) return;
|
|
386
384
|
return handleAccessExport(expr, "this", members);
|
|
387
385
|
});
|
|
388
|
-
parser.hooks.expression
|
|
389
|
-
.
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
return handleAccessExport(expr, "this", []);
|
|
393
|
-
});
|
|
386
|
+
parser.hooks.expression.for("this").tap(PLUGIN_NAME, expr => {
|
|
387
|
+
if (!parser.scope.topLevelScope) return;
|
|
388
|
+
return handleAccessExport(expr, "this", []);
|
|
389
|
+
});
|
|
394
390
|
|
|
395
391
|
// Bailouts //
|
|
396
|
-
parser.hooks.expression.for("module").tap(
|
|
392
|
+
parser.hooks.expression.for("module").tap(PLUGIN_NAME, expr => {
|
|
397
393
|
bailout();
|
|
398
394
|
const isHarmony = HarmonyExports.isEnabled(parser.state);
|
|
399
395
|
const dep = new ModuleDecoratorDependency(
|
|
@@ -408,4 +404,5 @@ class CommonJsExportsParserPlugin {
|
|
|
408
404
|
});
|
|
409
405
|
}
|
|
410
406
|
}
|
|
407
|
+
|
|
411
408
|
module.exports = CommonJsExportsParserPlugin;
|
|
@@ -107,15 +107,7 @@ CommonJsFullRequireDependency.Template = class CommonJsFullRequireDependencyTemp
|
|
|
107
107
|
apply(
|
|
108
108
|
dependency,
|
|
109
109
|
source,
|
|
110
|
-
{
|
|
111
|
-
module,
|
|
112
|
-
runtimeTemplate,
|
|
113
|
-
moduleGraph,
|
|
114
|
-
chunkGraph,
|
|
115
|
-
runtimeRequirements,
|
|
116
|
-
runtime,
|
|
117
|
-
initFragments
|
|
118
|
-
}
|
|
110
|
+
{ runtimeTemplate, moduleGraph, chunkGraph, runtimeRequirements, runtime }
|
|
119
111
|
) {
|
|
120
112
|
const dep = /** @type {CommonJsFullRequireDependency} */ (dependency);
|
|
121
113
|
if (!dep.range) return;
|