webpack 5.100.2 → 5.101.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -10
- package/bin/webpack.js +7 -7
- package/lib/APIPlugin.js +12 -14
- package/lib/AutomaticPrefetchPlugin.js +2 -2
- package/lib/BannerPlugin.js +4 -4
- package/lib/Cache.js +1 -1
- package/lib/CacheFacade.js +7 -7
- package/lib/CaseSensitiveModulesWarning.js +2 -2
- package/lib/Chunk.js +3 -3
- package/lib/ChunkGraph.js +21 -18
- package/lib/ChunkGroup.js +4 -4
- package/lib/CleanPlugin.js +19 -53
- package/lib/CodeGenerationResults.js +3 -3
- package/lib/CompatibilityPlugin.js +6 -6
- package/lib/Compilation.js +126 -113
- package/lib/Compiler.js +37 -37
- package/lib/ConcatenationScope.js +39 -1
- package/lib/ConstPlugin.js +11 -11
- package/lib/ContextExclusionPlugin.js +3 -3
- package/lib/ContextModule.js +12 -11
- package/lib/ContextModuleFactory.js +11 -11
- package/lib/ContextReplacementPlugin.js +5 -5
- package/lib/DefinePlugin.js +24 -22
- package/lib/DelegatedModuleFactoryPlugin.js +1 -1
- package/lib/DllEntryPlugin.js +1 -1
- package/lib/DllReferencePlugin.js +1 -1
- package/lib/DynamicEntryPlugin.js +3 -3
- package/lib/EntryPlugin.js +1 -1
- package/lib/EnvironmentPlugin.js +1 -1
- package/lib/ErrorHelpers.js +2 -2
- package/lib/EvalDevToolModulePlugin.js +2 -2
- package/lib/EvalSourceMapDevToolPlugin.js +5 -5
- package/lib/ExportsInfo.js +9 -9
- package/lib/ExportsInfoApiPlugin.js +2 -2
- package/lib/ExternalModule.js +163 -48
- package/lib/ExternalModuleFactoryPlugin.js +2 -2
- package/lib/ExternalsPlugin.js +45 -0
- package/lib/FileSystemInfo.js +64 -61
- package/lib/FlagAllModulesAsUsedPlugin.js +2 -2
- package/lib/FlagDependencyExportsPlugin.js +7 -7
- package/lib/FlagDependencyUsagePlugin.js +4 -4
- package/lib/FlagEntryExportAsUsedPlugin.js +1 -1
- package/lib/HotModuleReplacementPlugin.js +27 -27
- package/lib/IgnorePlugin.js +3 -3
- package/lib/IgnoreWarningsPlugin.js +4 -4
- package/lib/InitFragment.js +6 -0
- package/lib/InvalidDependenciesModuleWarning.js +1 -1
- package/lib/JavascriptMetaInfoPlugin.js +1 -1
- package/lib/LibManifestPlugin.js +2 -2
- package/lib/LoaderOptionsPlugin.js +1 -1
- package/lib/LoaderTargetPlugin.js +2 -2
- package/lib/MainTemplate.js +1 -1
- package/lib/Module.js +1 -1
- package/lib/ModuleFilenameHelpers.js +3 -3
- package/lib/ModuleGraph.js +9 -5
- package/lib/ModuleInfoHeaderPlugin.js +3 -3
- package/lib/ModuleParseError.js +5 -3
- package/lib/MultiCompiler.js +29 -24
- package/lib/MultiStats.js +18 -13
- package/lib/MultiWatching.js +1 -1
- package/lib/NoEmitOnErrorsPlugin.js +2 -2
- package/lib/NodeStuffPlugin.js +27 -15
- package/lib/NormalModule.js +23 -23
- package/lib/NormalModuleFactory.js +23 -21
- package/lib/NormalModuleReplacementPlugin.js +3 -3
- package/lib/PrefetchPlugin.js +1 -1
- package/lib/ProgressPlugin.js +11 -11
- package/lib/ProvidePlugin.js +2 -2
- package/lib/RecordIdsPlugin.js +3 -3
- package/lib/ResolverFactory.js +3 -3
- package/lib/RuntimeGlobals.js +20 -0
- package/lib/RuntimePlugin.js +16 -16
- package/lib/RuntimeTemplate.js +35 -26
- package/lib/SizeFormatHelpers.js +1 -1
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +4 -4
- package/lib/SourceMapDevToolPlugin.js +9 -9
- package/lib/Stats.js +2 -2
- package/lib/Template.js +1 -1
- package/lib/TemplatedPathPlugin.js +2 -2
- package/lib/UseStrictPlugin.js +1 -1
- package/lib/WarnCaseSensitiveModulesPlugin.js +1 -1
- package/lib/WarnDeprecatedOptionPlugin.js +1 -1
- package/lib/WarnNoModeSetPlugin.js +1 -1
- package/lib/WatchIgnorePlugin.js +2 -2
- package/lib/Watching.js +12 -12
- package/lib/WebpackIsIncludedPlugin.js +2 -2
- package/lib/WebpackOptionsApply.js +3 -3
- package/lib/asset/AssetGenerator.js +1 -1
- package/lib/asset/AssetModulesPlugin.js +6 -6
- package/lib/async-modules/AsyncModuleHelpers.js +1 -1
- package/lib/async-modules/AwaitDependenciesInitFragment.js +36 -24
- package/lib/async-modules/InferAsyncModulesPlugin.js +3 -3
- package/lib/buildChunkGraph.js +5 -5
- package/lib/cache/AddBuildDependenciesPlugin.js +1 -1
- package/lib/cache/IdleFileCachePlugin.js +5 -5
- package/lib/cache/PackFileCacheStrategy.js +20 -20
- package/lib/cache/ResolverCachePlugin.js +4 -4
- package/lib/cli.js +196 -14
- package/lib/config/browserslistTargetHandler.js +6 -6
- package/lib/config/defaults.js +23 -14
- package/lib/config/normalization.js +41 -38
- package/lib/config/target.js +4 -4
- package/lib/container/ContainerEntryModule.js +3 -3
- package/lib/container/ContainerPlugin.js +3 -3
- package/lib/container/ContainerReferencePlugin.js +3 -3
- package/lib/container/FallbackModule.js +1 -1
- package/lib/container/HoistContainerReferencesPlugin.js +7 -7
- package/lib/container/options.js +4 -4
- package/lib/css/CssGenerator.js +5 -3
- package/lib/css/CssLoadingRuntimeModule.js +1 -1
- package/lib/css/CssModulesPlugin.js +25 -22
- package/lib/css/CssParser.js +5 -5
- package/lib/css/walkCssTokens.js +9 -9
- package/lib/debug/ProfilingPlugin.js +5 -5
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +4 -4
- package/lib/dependencies/AMDPlugin.js +3 -3
- package/lib/dependencies/AMDRequireArrayDependency.js +1 -1
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +3 -3
- package/lib/dependencies/CommonJsExportRequireDependency.js +2 -2
- package/lib/dependencies/CommonJsExportsParserPlugin.js +12 -10
- package/lib/dependencies/CommonJsImportsParserPlugin.js +21 -19
- package/lib/dependencies/CommonJsPlugin.js +2 -2
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +3 -3
- package/lib/dependencies/CssIcssExportDependency.js +2 -2
- package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssUrlDependency.js +4 -4
- package/lib/dependencies/DynamicExports.js +5 -5
- package/lib/dependencies/HarmonyAcceptDependency.js +39 -5
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +2 -2
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +17 -13
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +7 -8
- package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
- package/lib/dependencies/HarmonyExports.js +1 -1
- package/lib/dependencies/HarmonyImportDependency.js +28 -9
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +56 -48
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -5
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +3 -4
- package/lib/dependencies/HarmonyModulesPlugin.js +2 -8
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +1 -1
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +4 -4
- package/lib/dependencies/ImportMetaPlugin.js +7 -7
- package/lib/dependencies/ImportParserPlugin.js +4 -4
- package/lib/dependencies/JsonExportsDependency.js +1 -1
- package/lib/dependencies/LoaderPlugin.js +4 -4
- package/lib/dependencies/ProvidedDependency.js +2 -2
- package/lib/dependencies/PureExpressionDependency.js +1 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -1
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +3 -3
- package/lib/dependencies/SystemPlugin.js +3 -3
- package/lib/dependencies/WorkerPlugin.js +5 -5
- package/lib/dependencies/getFunctionExpression.js +1 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +5 -5
- package/lib/esm/ModuleChunkLoadingPlugin.js +2 -2
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +15 -11
- package/lib/formatLocation.js +2 -2
- package/lib/hmr/HotModuleReplacement.runtime.js +39 -27
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +43 -32
- package/lib/hmr/JavascriptHotModuleReplacementHelper.js +1 -1
- package/lib/hmr/LazyCompilationPlugin.js +6 -6
- package/lib/hmr/lazyCompilationBackend.js +6 -6
- package/lib/ids/ChunkModuleIdRangePlugin.js +4 -4
- package/lib/ids/DeterministicChunkIdsPlugin.js +5 -4
- package/lib/ids/DeterministicModuleIdsPlugin.js +2 -2
- package/lib/ids/HashedModuleIdsPlugin.js +1 -1
- package/lib/ids/IdHelpers.js +9 -9
- package/lib/ids/NamedChunkIdsPlugin.js +5 -5
- package/lib/ids/NamedModuleIdsPlugin.js +2 -2
- package/lib/ids/NaturalChunkIdsPlugin.js +2 -2
- package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +2 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +4 -4
- package/lib/ids/SyncModuleIdsPlugin.js +4 -4
- package/lib/index.js +10 -6
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +1 -1
- package/lib/javascript/BasicEvaluatedExpression.js +3 -3
- package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
- package/lib/javascript/EnableChunkLoadingPlugin.js +1 -1
- package/lib/javascript/JavascriptGenerator.js +1 -1
- package/lib/javascript/JavascriptModulesPlugin.js +16 -16
- package/lib/javascript/JavascriptParser.js +80 -78
- package/lib/javascript/JavascriptParserHelpers.js +3 -3
- package/lib/javascript/StartupHelpers.js +2 -2
- package/lib/json/JsonGenerator.js +2 -2
- package/lib/json/JsonModulesPlugin.js +2 -2
- package/lib/library/AbstractLibraryPlugin.js +3 -3
- package/lib/library/AmdLibraryPlugin.js +3 -3
- package/lib/library/AssignLibraryPlugin.js +2 -2
- package/lib/library/EnableLibraryPlugin.js +2 -2
- package/lib/library/ModuleLibraryPlugin.js +7 -2
- package/lib/library/SystemLibraryPlugin.js +6 -4
- package/lib/library/UmdLibraryPlugin.js +14 -14
- package/lib/logging/createConsoleLogger.js +4 -4
- package/lib/logging/runtime.js +3 -3
- package/lib/logging/truncateArgs.js +4 -4
- package/lib/node/CommonJsChunkLoadingPlugin.js +2 -2
- package/lib/node/NodeEnvironmentPlugin.js +1 -1
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +16 -14
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +7 -7
- package/lib/node/ReadFileCompileWasmPlugin.js +7 -7
- package/lib/node/RequireChunkLoadingRuntimeModule.js +6 -4
- package/lib/node/nodeConsole.js +2 -2
- package/lib/optimize/AggressiveMergingPlugin.js +2 -2
- package/lib/optimize/AggressiveSplittingPlugin.js +10 -10
- package/lib/optimize/ConcatenatedModule.js +161 -52
- package/lib/optimize/EnsureChunkConditionsPlugin.js +2 -2
- package/lib/optimize/FlagIncludedChunksPlugin.js +2 -2
- package/lib/optimize/InnerGraph.js +5 -5
- package/lib/optimize/InnerGraphPlugin.js +14 -12
- package/lib/optimize/LimitChunkCountPlugin.js +5 -5
- package/lib/optimize/MangleExportsPlugin.js +5 -5
- package/lib/optimize/MergeDuplicateChunksPlugin.js +2 -2
- package/lib/optimize/MinChunkSizePlugin.js +3 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +45 -38
- package/lib/optimize/RealContentHashPlugin.js +23 -23
- package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -2
- package/lib/optimize/RemoveParentModulesPlugin.js +3 -3
- package/lib/optimize/RuntimeChunkPlugin.js +2 -2
- package/lib/optimize/SideEffectsFlagPlugin.js +5 -5
- package/lib/optimize/SplitChunksPlugin.js +20 -20
- package/lib/performance/AssetsOverSizeLimitWarning.js +1 -1
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +2 -2
- package/lib/performance/SizeLimitsPlugin.js +4 -4
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +1 -1
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +3 -3
- package/lib/rules/BasicMatcherRulePlugin.js +1 -1
- package/lib/rules/RuleSetCompiler.js +10 -10
- package/lib/rules/UseEffectRulePlugin.js +2 -2
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +15 -15
- package/lib/runtime/GetMainFilenameRuntimeModule.js +1 -1
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -1
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -1
- package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -2
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +3 -3
- package/lib/schemes/DataUriPlugin.js +3 -3
- package/lib/schemes/FileUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +40 -36
- package/lib/schemes/VirtualUrlPlugin.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +11 -11
- package/lib/serialization/FileMiddleware.js +17 -17
- package/lib/serialization/ObjectMiddleware.js +8 -8
- package/lib/serialization/Serializer.js +2 -2
- package/lib/serialization/SerializerMiddleware.js +2 -2
- package/lib/sharing/ConsumeSharedPlugin.js +4 -4
- package/lib/sharing/ProvideSharedPlugin.js +4 -4
- package/lib/sharing/SharePlugin.js +1 -1
- package/lib/sharing/resolveMatchedConfigs.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +85 -80
- package/lib/stats/DefaultStatsPresetPlugin.js +15 -15
- package/lib/stats/DefaultStatsPrinterPlugin.js +87 -87
- package/lib/stats/StatsFactory.js +7 -7
- package/lib/stats/StatsPrinter.js +9 -9
- package/lib/url/URLParserPlugin.js +5 -5
- package/lib/util/AsyncQueue.js +4 -4
- package/lib/util/IterableHelpers.js +2 -2
- package/lib/util/LazyBucketSortedSet.js +3 -3
- package/lib/util/SetHelpers.js +2 -2
- package/lib/util/StackedCacheMap.js +1 -1
- package/lib/util/StackedMap.js +1 -1
- package/lib/util/TupleSet.js +1 -1
- package/lib/util/WeakTupleMap.js +1 -1
- package/lib/util/cleverMerge.js +8 -8
- package/lib/util/comparators.js +10 -10
- package/lib/util/compileBooleanMatcher.js +20 -20
- package/lib/util/concatenate.js +3 -3
- package/lib/util/conventions.js +4 -4
- package/lib/util/create-schema-validation.js +1 -1
- package/lib/util/createHash.js +1 -1
- package/lib/util/deprecation.js +4 -4
- package/lib/util/deterministicGrouping.js +7 -7
- package/lib/util/findGraphRoots.js +1 -1
- package/lib/util/fs.js +3 -3
- package/lib/util/identifier.js +14 -14
- package/lib/util/magicComment.js +5 -1
- package/lib/util/memoize.js +1 -1
- package/lib/util/processAsyncTree.js +2 -2
- package/lib/util/propertyName.js +1 -1
- package/lib/util/removeBOM.js +1 -1
- package/lib/util/runtime.js +6 -6
- package/lib/util/semver.js +16 -16
- package/lib/util/serialization.js +5 -5
- package/lib/util/smartGrouping.js +1 -1
- package/lib/validateSchema.js +2 -2
- package/lib/wasm/EnableWasmLoadingPlugin.js +1 -1
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +1 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +4 -4
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +13 -9
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +2 -2
- package/lib/wasm-sync/WebAssemblyGenerator.js +14 -14
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +4 -2
- package/lib/wasm-sync/WebAssemblyParser.js +2 -2
- package/lib/web/FetchCompileAsyncWasmPlugin.js +4 -4
- package/lib/web/FetchCompileWasmPlugin.js +4 -4
- package/lib/web/JsonpChunkLoadingPlugin.js +2 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
- package/lib/webpack.js +17 -12
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +2 -2
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +13 -13
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +4 -0
- package/types.d.ts +151 -44
|
@@ -118,7 +118,7 @@ const ALLOWED_MEMBER_TYPES_ALL = 0b11;
|
|
|
118
118
|
const LEGACY_ASSERT_ATTRIBUTES = Symbol("assert");
|
|
119
119
|
|
|
120
120
|
/** @type {(BaseParser: typeof AcornParser) => typeof AcornParser} */
|
|
121
|
-
const importAssertions = Parser =>
|
|
121
|
+
const importAssertions = (Parser) =>
|
|
122
122
|
class extends Parser {
|
|
123
123
|
/**
|
|
124
124
|
* @this {InstanceType<AcornParser>}
|
|
@@ -189,7 +189,7 @@ let parser = AcornParser.extend(importAssertions);
|
|
|
189
189
|
* @param {ImportDeclaration | ExportNamedDeclaration | ExportAllDeclaration | ImportExpression} node node with assertions
|
|
190
190
|
* @returns {ImportAttributes | undefined} import attributes
|
|
191
191
|
*/
|
|
192
|
-
const getImportAttributes = node => {
|
|
192
|
+
const getImportAttributes = (node) => {
|
|
193
193
|
if (node.type === "ImportExpression") {
|
|
194
194
|
if (
|
|
195
195
|
node.options &&
|
|
@@ -361,7 +361,7 @@ const objectAndMembersToName = (object, membersReversed) => {
|
|
|
361
361
|
* @param {Expression | SpreadElement | Super} expression expression
|
|
362
362
|
* @returns {string | "this" | undefined} name or variable info
|
|
363
363
|
*/
|
|
364
|
-
const getRootName = expression => {
|
|
364
|
+
const getRootName = (expression) => {
|
|
365
365
|
switch (expression.type) {
|
|
366
366
|
case "Identifier":
|
|
367
367
|
return expression.name;
|
|
@@ -607,7 +607,7 @@ class JavascriptParser extends Parser {
|
|
|
607
607
|
}
|
|
608
608
|
|
|
609
609
|
_initializeEvaluating() {
|
|
610
|
-
this.hooks.evaluate.for("Literal").tap(CLASS_NAME, _expr => {
|
|
610
|
+
this.hooks.evaluate.for("Literal").tap(CLASS_NAME, (_expr) => {
|
|
611
611
|
const expr = /** @type {Literal} */ (_expr);
|
|
612
612
|
|
|
613
613
|
switch (typeof expr.value) {
|
|
@@ -639,7 +639,7 @@ class JavascriptParser extends Parser {
|
|
|
639
639
|
.setRange(/** @type {Range} */ (expr.range));
|
|
640
640
|
}
|
|
641
641
|
});
|
|
642
|
-
this.hooks.evaluate.for("NewExpression").tap(CLASS_NAME, _expr => {
|
|
642
|
+
this.hooks.evaluate.for("NewExpression").tap(CLASS_NAME, (_expr) => {
|
|
643
643
|
const expr = /** @type {NewExpression} */ (_expr);
|
|
644
644
|
const callee = expr.callee;
|
|
645
645
|
if (callee.type !== "Identifier") return;
|
|
@@ -704,7 +704,7 @@ class JavascriptParser extends Parser {
|
|
|
704
704
|
.setRegExp(flags ? new RegExp(regExp, flags) : new RegExp(regExp))
|
|
705
705
|
.setRange(/** @type {Range} */ (expr.range));
|
|
706
706
|
});
|
|
707
|
-
this.hooks.evaluate.for("LogicalExpression").tap(CLASS_NAME, _expr => {
|
|
707
|
+
this.hooks.evaluate.for("LogicalExpression").tap(CLASS_NAME, (_expr) => {
|
|
708
708
|
const expr = /** @type {LogicalExpression} */ (_expr);
|
|
709
709
|
|
|
710
710
|
const left = this.evaluateExpression(expr.left);
|
|
@@ -822,7 +822,7 @@ class JavascriptParser extends Parser {
|
|
|
822
822
|
}
|
|
823
823
|
};
|
|
824
824
|
|
|
825
|
-
this.hooks.evaluate.for("BinaryExpression").tap(CLASS_NAME, _expr => {
|
|
825
|
+
this.hooks.evaluate.for("BinaryExpression").tap(CLASS_NAME, (_expr) => {
|
|
826
826
|
const expr = /** @type {BinaryExpression} */ (_expr);
|
|
827
827
|
|
|
828
828
|
/**
|
|
@@ -831,7 +831,7 @@ class JavascriptParser extends Parser {
|
|
|
831
831
|
* @param {(leftOperand: T, rightOperand: T) => boolean | number | bigint | string} operandHandler the handler for the operation (e.g. (a, b) => a + b)
|
|
832
832
|
* @returns {BasicEvaluatedExpression | undefined} the evaluated expression
|
|
833
833
|
*/
|
|
834
|
-
const handleConstOperation = operandHandler => {
|
|
834
|
+
const handleConstOperation = (operandHandler) => {
|
|
835
835
|
const left = this.evaluateExpression(expr.left);
|
|
836
836
|
if (!left.isCompileTimeValue()) return;
|
|
837
837
|
|
|
@@ -871,7 +871,7 @@ class JavascriptParser extends Parser {
|
|
|
871
871
|
* @param {BasicEvaluatedExpression[]} parts parts
|
|
872
872
|
* @returns {string} value
|
|
873
873
|
*/
|
|
874
|
-
const getPrefix = parts => {
|
|
874
|
+
const getPrefix = (parts) => {
|
|
875
875
|
let value = "";
|
|
876
876
|
for (const p of parts) {
|
|
877
877
|
const v = p.asString();
|
|
@@ -884,7 +884,7 @@ class JavascriptParser extends Parser {
|
|
|
884
884
|
* @param {BasicEvaluatedExpression[]} parts parts
|
|
885
885
|
* @returns {string} value
|
|
886
886
|
*/
|
|
887
|
-
const getSuffix = parts => {
|
|
887
|
+
const getSuffix = (parts) => {
|
|
888
888
|
let value = "";
|
|
889
889
|
for (let i = parts.length - 1; i >= 0; i--) {
|
|
890
890
|
const v = parts[i].asString();
|
|
@@ -927,7 +927,7 @@ class JavascriptParser extends Parser {
|
|
|
927
927
|
* @param {boolean} eql true for "===" and false for "!=="
|
|
928
928
|
* @returns {BasicEvaluatedExpression | undefined} the evaluated expression
|
|
929
929
|
*/
|
|
930
|
-
const handleStrictEqualityComparison = eql => {
|
|
930
|
+
const handleStrictEqualityComparison = (eql) => {
|
|
931
931
|
const left = this.evaluateExpression(expr.left);
|
|
932
932
|
const right = this.evaluateExpression(expr.right);
|
|
933
933
|
const res = new BasicEvaluatedExpression();
|
|
@@ -989,7 +989,7 @@ class JavascriptParser extends Parser {
|
|
|
989
989
|
* @param {boolean} eql true for "==" and false for "!="
|
|
990
990
|
* @returns {BasicEvaluatedExpression | undefined} the evaluated expression
|
|
991
991
|
*/
|
|
992
|
-
const handleAbstractEqualityComparison = eql => {
|
|
992
|
+
const handleAbstractEqualityComparison = (eql) => {
|
|
993
993
|
const left = this.evaluateExpression(expr.left);
|
|
994
994
|
const right = this.evaluateExpression(expr.right);
|
|
995
995
|
const res = new BasicEvaluatedExpression();
|
|
@@ -1225,7 +1225,7 @@ class JavascriptParser extends Parser {
|
|
|
1225
1225
|
return handleConstOperation((l, r) => l >= r);
|
|
1226
1226
|
}
|
|
1227
1227
|
});
|
|
1228
|
-
this.hooks.evaluate.for("UnaryExpression").tap(CLASS_NAME, _expr => {
|
|
1228
|
+
this.hooks.evaluate.for("UnaryExpression").tap(CLASS_NAME, (_expr) => {
|
|
1229
1229
|
const expr = /** @type {UnaryExpression} */ (_expr);
|
|
1230
1230
|
|
|
1231
1231
|
/**
|
|
@@ -1234,7 +1234,7 @@ class JavascriptParser extends Parser {
|
|
|
1234
1234
|
* @param {(operand: T) => boolean | number | bigint | string} operandHandler handler for the operand
|
|
1235
1235
|
* @returns {BasicEvaluatedExpression | undefined} evaluated expression
|
|
1236
1236
|
*/
|
|
1237
|
-
const handleConstOperation = operandHandler => {
|
|
1237
|
+
const handleConstOperation = (operandHandler) => {
|
|
1238
1238
|
const argument = this.evaluateExpression(expr.argument);
|
|
1239
1239
|
if (!argument.isCompileTimeValue()) return;
|
|
1240
1240
|
const result = operandHandler(
|
|
@@ -1341,22 +1341,22 @@ class JavascriptParser extends Parser {
|
|
|
1341
1341
|
.setSideEffects(argument.couldHaveSideEffects())
|
|
1342
1342
|
.setRange(/** @type {Range} */ (expr.range));
|
|
1343
1343
|
} else if (expr.operator === "~") {
|
|
1344
|
-
return handleConstOperation(v => ~v);
|
|
1344
|
+
return handleConstOperation((v) => ~v);
|
|
1345
1345
|
} else if (expr.operator === "+") {
|
|
1346
1346
|
// eslint-disable-next-line no-implicit-coercion
|
|
1347
|
-
return handleConstOperation(v => +v);
|
|
1347
|
+
return handleConstOperation((v) => +v);
|
|
1348
1348
|
} else if (expr.operator === "-") {
|
|
1349
|
-
return handleConstOperation(v => -v);
|
|
1349
|
+
return handleConstOperation((v) => -v);
|
|
1350
1350
|
}
|
|
1351
1351
|
});
|
|
1352
1352
|
this.hooks.evaluateTypeof
|
|
1353
1353
|
.for("undefined")
|
|
1354
|
-
.tap(CLASS_NAME, expr =>
|
|
1354
|
+
.tap(CLASS_NAME, (expr) =>
|
|
1355
1355
|
new BasicEvaluatedExpression()
|
|
1356
1356
|
.setString("undefined")
|
|
1357
1357
|
.setRange(/** @type {Range} */ (expr.range))
|
|
1358
1358
|
);
|
|
1359
|
-
this.hooks.evaluate.for("Identifier").tap(CLASS_NAME, expr => {
|
|
1359
|
+
this.hooks.evaluate.for("Identifier").tap(CLASS_NAME, (expr) => {
|
|
1360
1360
|
if (/** @type {Identifier} */ (expr).name === "undefined") {
|
|
1361
1361
|
return new BasicEvaluatedExpression()
|
|
1362
1362
|
.setUndefined()
|
|
@@ -1373,7 +1373,7 @@ class JavascriptParser extends Parser {
|
|
|
1373
1373
|
let cachedExpression;
|
|
1374
1374
|
/** @type {GetInfoResult | undefined} */
|
|
1375
1375
|
let cachedInfo;
|
|
1376
|
-
this.hooks.evaluate.for(exprType).tap(CLASS_NAME, expr => {
|
|
1376
|
+
this.hooks.evaluate.for(exprType).tap(CLASS_NAME, (expr) => {
|
|
1377
1377
|
const expression =
|
|
1378
1378
|
/** @type {Identifier | ThisExpression | MemberExpression} */ (expr);
|
|
1379
1379
|
|
|
@@ -1382,12 +1382,12 @@ class JavascriptParser extends Parser {
|
|
|
1382
1382
|
return this.callHooksForInfoWithFallback(
|
|
1383
1383
|
this.hooks.evaluateIdentifier,
|
|
1384
1384
|
info.name,
|
|
1385
|
-
_name => {
|
|
1385
|
+
(_name) => {
|
|
1386
1386
|
cachedExpression = expression;
|
|
1387
1387
|
cachedInfo = info;
|
|
1388
1388
|
return undefined;
|
|
1389
1389
|
},
|
|
1390
|
-
name => {
|
|
1390
|
+
(name) => {
|
|
1391
1391
|
const hook = this.hooks.evaluateDefinedIdentifier.get(name);
|
|
1392
1392
|
if (hook !== undefined) {
|
|
1393
1393
|
return hook.call(expression);
|
|
@@ -1399,7 +1399,7 @@ class JavascriptParser extends Parser {
|
|
|
1399
1399
|
});
|
|
1400
1400
|
this.hooks.evaluate
|
|
1401
1401
|
.for(exprType)
|
|
1402
|
-
.tap({ name: CLASS_NAME, stage: 100 }, expr => {
|
|
1402
|
+
.tap({ name: CLASS_NAME, stage: 100 }, (expr) => {
|
|
1403
1403
|
const expression =
|
|
1404
1404
|
/** @type {Identifier | ThisExpression | MemberExpression} */
|
|
1405
1405
|
(expr);
|
|
@@ -1422,7 +1422,7 @@ class JavascriptParser extends Parser {
|
|
|
1422
1422
|
cachedExpression = cachedInfo = undefined;
|
|
1423
1423
|
});
|
|
1424
1424
|
};
|
|
1425
|
-
tapEvaluateWithVariableInfo("Identifier", expr => {
|
|
1425
|
+
tapEvaluateWithVariableInfo("Identifier", (expr) => {
|
|
1426
1426
|
const info = this.getVariableInfo(/** @type {Identifier} */ (expr).name);
|
|
1427
1427
|
if (
|
|
1428
1428
|
typeof info === "string" ||
|
|
@@ -1437,7 +1437,7 @@ class JavascriptParser extends Parser {
|
|
|
1437
1437
|
};
|
|
1438
1438
|
}
|
|
1439
1439
|
});
|
|
1440
|
-
tapEvaluateWithVariableInfo("ThisExpression", _expr => {
|
|
1440
|
+
tapEvaluateWithVariableInfo("ThisExpression", (_expr) => {
|
|
1441
1441
|
const info = this.getVariableInfo("this");
|
|
1442
1442
|
if (
|
|
1443
1443
|
typeof info === "string" ||
|
|
@@ -1452,7 +1452,7 @@ class JavascriptParser extends Parser {
|
|
|
1452
1452
|
};
|
|
1453
1453
|
}
|
|
1454
1454
|
});
|
|
1455
|
-
this.hooks.evaluate.for("MetaProperty").tap(CLASS_NAME, expr => {
|
|
1455
|
+
this.hooks.evaluate.for("MetaProperty").tap(CLASS_NAME, (expr) => {
|
|
1456
1456
|
const metaProperty = /** @type {MetaProperty} */ (expr);
|
|
1457
1457
|
|
|
1458
1458
|
return this.callHooksForName(
|
|
@@ -1462,14 +1462,14 @@ class JavascriptParser extends Parser {
|
|
|
1462
1462
|
metaProperty
|
|
1463
1463
|
);
|
|
1464
1464
|
});
|
|
1465
|
-
tapEvaluateWithVariableInfo("MemberExpression", expr =>
|
|
1465
|
+
tapEvaluateWithVariableInfo("MemberExpression", (expr) =>
|
|
1466
1466
|
this.getMemberExpressionInfo(
|
|
1467
1467
|
/** @type {MemberExpression} */ (expr),
|
|
1468
1468
|
ALLOWED_MEMBER_TYPES_EXPRESSION
|
|
1469
1469
|
)
|
|
1470
1470
|
);
|
|
1471
1471
|
|
|
1472
|
-
this.hooks.evaluate.for("CallExpression").tap(CLASS_NAME, _expr => {
|
|
1472
|
+
this.hooks.evaluate.for("CallExpression").tap(CLASS_NAME, (_expr) => {
|
|
1473
1473
|
const expr = /** @type {CallExpression} */ (_expr);
|
|
1474
1474
|
if (
|
|
1475
1475
|
expr.callee.type === "MemberExpression" &&
|
|
@@ -1641,7 +1641,7 @@ class JavascriptParser extends Parser {
|
|
|
1641
1641
|
};
|
|
1642
1642
|
};
|
|
1643
1643
|
|
|
1644
|
-
this.hooks.evaluate.for("TemplateLiteral").tap(CLASS_NAME, _node => {
|
|
1644
|
+
this.hooks.evaluate.for("TemplateLiteral").tap(CLASS_NAME, (_node) => {
|
|
1645
1645
|
const node = /** @type {TemplateLiteral} */ (_node);
|
|
1646
1646
|
|
|
1647
1647
|
const { quasis, parts } = getSimplifiedTemplateResult("cooked", node);
|
|
@@ -1654,7 +1654,7 @@ class JavascriptParser extends Parser {
|
|
|
1654
1654
|
});
|
|
1655
1655
|
this.hooks.evaluate
|
|
1656
1656
|
.for("TaggedTemplateExpression")
|
|
1657
|
-
.tap(CLASS_NAME, _node => {
|
|
1657
|
+
.tap(CLASS_NAME, (_node) => {
|
|
1658
1658
|
const node = /** @type {TaggedTemplateExpression} */ (_node);
|
|
1659
1659
|
const tag = this.evaluateExpression(node.tag);
|
|
1660
1660
|
|
|
@@ -1767,44 +1767,46 @@ class JavascriptParser extends Parser {
|
|
|
1767
1767
|
.setSideEffects(param.couldHaveSideEffects())
|
|
1768
1768
|
.setRange(/** @type {Range} */ (expr.range));
|
|
1769
1769
|
});
|
|
1770
|
-
this.hooks.evaluate
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
res
|
|
1782
|
-
|
|
1783
|
-
|
|
1770
|
+
this.hooks.evaluate
|
|
1771
|
+
.for("ConditionalExpression")
|
|
1772
|
+
.tap(CLASS_NAME, (_expr) => {
|
|
1773
|
+
const expr = /** @type {ConditionalExpression} */ (_expr);
|
|
1774
|
+
|
|
1775
|
+
const condition = this.evaluateExpression(expr.test);
|
|
1776
|
+
const conditionValue = condition.asBool();
|
|
1777
|
+
let res;
|
|
1778
|
+
if (conditionValue === undefined) {
|
|
1779
|
+
const consequent = this.evaluateExpression(expr.consequent);
|
|
1780
|
+
const alternate = this.evaluateExpression(expr.alternate);
|
|
1781
|
+
res = new BasicEvaluatedExpression();
|
|
1782
|
+
if (consequent.isConditional()) {
|
|
1783
|
+
res.setOptions(
|
|
1784
|
+
/** @type {BasicEvaluatedExpression[]} */ (consequent.options)
|
|
1785
|
+
);
|
|
1786
|
+
} else {
|
|
1787
|
+
res.setOptions([consequent]);
|
|
1788
|
+
}
|
|
1789
|
+
if (alternate.isConditional()) {
|
|
1790
|
+
res.addOptions(
|
|
1791
|
+
/** @type {BasicEvaluatedExpression[]} */ (alternate.options)
|
|
1792
|
+
);
|
|
1793
|
+
} else {
|
|
1794
|
+
res.addOptions([alternate]);
|
|
1795
|
+
}
|
|
1784
1796
|
} else {
|
|
1785
|
-
res.
|
|
1786
|
-
|
|
1787
|
-
if (alternate.isConditional()) {
|
|
1788
|
-
res.addOptions(
|
|
1789
|
-
/** @type {BasicEvaluatedExpression[]} */ (alternate.options)
|
|
1797
|
+
res = this.evaluateExpression(
|
|
1798
|
+
conditionValue ? expr.consequent : expr.alternate
|
|
1790
1799
|
);
|
|
1791
|
-
|
|
1792
|
-
res.addOptions([alternate]);
|
|
1800
|
+
if (condition.couldHaveSideEffects()) res.setSideEffects();
|
|
1793
1801
|
}
|
|
1794
|
-
|
|
1795
|
-
res
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
if (condition.couldHaveSideEffects()) res.setSideEffects();
|
|
1799
|
-
}
|
|
1800
|
-
res.setRange(/** @type {Range} */ (expr.range));
|
|
1801
|
-
return res;
|
|
1802
|
-
});
|
|
1803
|
-
this.hooks.evaluate.for("ArrayExpression").tap(CLASS_NAME, _expr => {
|
|
1802
|
+
res.setRange(/** @type {Range} */ (expr.range));
|
|
1803
|
+
return res;
|
|
1804
|
+
});
|
|
1805
|
+
this.hooks.evaluate.for("ArrayExpression").tap(CLASS_NAME, (_expr) => {
|
|
1804
1806
|
const expr = /** @type {ArrayExpression} */ (_expr);
|
|
1805
1807
|
|
|
1806
1808
|
const items = expr.elements.map(
|
|
1807
|
-
element =>
|
|
1809
|
+
(element) =>
|
|
1808
1810
|
element !== null &&
|
|
1809
1811
|
element.type !== "SpreadElement" &&
|
|
1810
1812
|
this.evaluateExpression(element)
|
|
@@ -1814,7 +1816,7 @@ class JavascriptParser extends Parser {
|
|
|
1814
1816
|
.setItems(/** @type {BasicEvaluatedExpression[]} */ (items))
|
|
1815
1817
|
.setRange(/** @type {Range} */ (expr.range));
|
|
1816
1818
|
});
|
|
1817
|
-
this.hooks.evaluate.for("ChainExpression").tap(CLASS_NAME, _expr => {
|
|
1819
|
+
this.hooks.evaluate.for("ChainExpression").tap(CLASS_NAME, (_expr) => {
|
|
1818
1820
|
const expr = /** @type {ChainExpression} */ (_expr);
|
|
1819
1821
|
/** @type {Expression[]} */
|
|
1820
1822
|
const optionalExpressionsStack = [];
|
|
@@ -2680,7 +2682,7 @@ class JavascriptParser extends Parser {
|
|
|
2680
2682
|
this.prevStatement = prev;
|
|
2681
2683
|
this.blockPreWalkStatement(statement.declaration);
|
|
2682
2684
|
let index = 0;
|
|
2683
|
-
this.enterDeclaration(statement.declaration, def => {
|
|
2685
|
+
this.enterDeclaration(statement.declaration, (def) => {
|
|
2684
2686
|
this.hooks.exportSpecifier.call(statement, def, def, index++);
|
|
2685
2687
|
});
|
|
2686
2688
|
}
|
|
@@ -3061,7 +3063,7 @@ class JavascriptParser extends Parser {
|
|
|
3061
3063
|
this.inBlockScope(() => {
|
|
3062
3064
|
// Error binding is optional in catch clause since ECMAScript 2019
|
|
3063
3065
|
if (catchClause.param !== null) {
|
|
3064
|
-
this.enterPattern(catchClause.param, ident => {
|
|
3066
|
+
this.enterPattern(catchClause.param, (ident) => {
|
|
3065
3067
|
this.defineVariable(ident);
|
|
3066
3068
|
});
|
|
3067
3069
|
this.walkPattern(catchClause.param);
|
|
@@ -3620,7 +3622,7 @@ class JavascriptParser extends Parser {
|
|
|
3620
3622
|
* @param {Expression | SpreadElement} argOrThis arg or this
|
|
3621
3623
|
* @returns {string | VariableInfo | undefined} var info
|
|
3622
3624
|
*/
|
|
3623
|
-
const getVarInfo = argOrThis => {
|
|
3625
|
+
const getVarInfo = (argOrThis) => {
|
|
3624
3626
|
const renameIdentifier = this.getRenameIdentifier(argOrThis);
|
|
3625
3627
|
if (
|
|
3626
3628
|
renameIdentifier &&
|
|
@@ -3702,8 +3704,8 @@ class JavascriptParser extends Parser {
|
|
|
3702
3704
|
* @param {FunctionExpression | ArrowFunctionExpression} fn function
|
|
3703
3705
|
* @returns {boolean} true when simple function
|
|
3704
3706
|
*/
|
|
3705
|
-
const isSimpleFunction = fn =>
|
|
3706
|
-
fn.params.every(p => p.type === "Identifier");
|
|
3707
|
+
const isSimpleFunction = (fn) =>
|
|
3708
|
+
fn.params.every((p) => p.type === "Identifier");
|
|
3707
3709
|
if (
|
|
3708
3710
|
expression.callee.type === "MemberExpression" &&
|
|
3709
3711
|
expression.callee.object.type.endsWith("FunctionExpression") &&
|
|
@@ -3976,7 +3978,7 @@ class JavascriptParser extends Parser {
|
|
|
3976
3978
|
hookMap,
|
|
3977
3979
|
members.length === 0 ? exprName.rootInfo : exprName.name,
|
|
3978
3980
|
fallback &&
|
|
3979
|
-
(name => fallback(name, exprName.rootInfo, exprName.getMembers)),
|
|
3981
|
+
((name) => fallback(name, exprName.rootInfo, exprName.getMembers)),
|
|
3980
3982
|
defined && (() => defined(exprName.name)),
|
|
3981
3983
|
...args
|
|
3982
3984
|
);
|
|
@@ -4110,7 +4112,7 @@ class JavascriptParser extends Parser {
|
|
|
4110
4112
|
|
|
4111
4113
|
this.undefineVariable("this");
|
|
4112
4114
|
|
|
4113
|
-
this.enterPatterns(params, ident => {
|
|
4115
|
+
this.enterPatterns(params, (ident) => {
|
|
4114
4116
|
this.defineVariable(ident);
|
|
4115
4117
|
});
|
|
4116
4118
|
|
|
@@ -4142,7 +4144,7 @@ class JavascriptParser extends Parser {
|
|
|
4142
4144
|
this.undefineVariable("this");
|
|
4143
4145
|
}
|
|
4144
4146
|
|
|
4145
|
-
this.enterPatterns(params, ident => {
|
|
4147
|
+
this.enterPatterns(params, (ident) => {
|
|
4146
4148
|
this.defineVariable(ident);
|
|
4147
4149
|
});
|
|
4148
4150
|
|
|
@@ -4174,7 +4176,7 @@ class JavascriptParser extends Parser {
|
|
|
4174
4176
|
this.undefineVariable("this");
|
|
4175
4177
|
}
|
|
4176
4178
|
|
|
4177
|
-
this.enterPatterns(params, ident => {
|
|
4179
|
+
this.enterPatterns(params, (ident) => {
|
|
4178
4180
|
this.defineVariable(ident);
|
|
4179
4181
|
});
|
|
4180
4182
|
|
|
@@ -4513,7 +4515,7 @@ class JavascriptParser extends Parser {
|
|
|
4513
4515
|
ast = JavascriptParser._parse(source, {
|
|
4514
4516
|
sourceType: this.sourceType,
|
|
4515
4517
|
onComment: comments,
|
|
4516
|
-
onInsertedSemicolon: pos => semicolons.add(pos)
|
|
4518
|
+
onInsertedSemicolon: (pos) => semicolons.add(pos)
|
|
4517
4519
|
});
|
|
4518
4520
|
}
|
|
4519
4521
|
|
|
@@ -4596,7 +4598,7 @@ class JavascriptParser extends Parser {
|
|
|
4596
4598
|
return false;
|
|
4597
4599
|
}
|
|
4598
4600
|
const items = expr.body.body;
|
|
4599
|
-
return items.every(item => {
|
|
4601
|
+
return items.every((item) => {
|
|
4600
4602
|
if (item.type === "StaticBlock") {
|
|
4601
4603
|
return false;
|
|
4602
4604
|
}
|
|
@@ -4649,7 +4651,7 @@ class JavascriptParser extends Parser {
|
|
|
4649
4651
|
return true;
|
|
4650
4652
|
|
|
4651
4653
|
case "VariableDeclaration":
|
|
4652
|
-
return expr.declarations.every(decl =>
|
|
4654
|
+
return expr.declarations.every((decl) =>
|
|
4653
4655
|
this.isPure(decl.init, /** @type {Range} */ (decl.range)[0])
|
|
4654
4656
|
);
|
|
4655
4657
|
|
|
@@ -4673,7 +4675,7 @@ class JavascriptParser extends Parser {
|
|
|
4673
4675
|
);
|
|
4674
4676
|
|
|
4675
4677
|
case "SequenceExpression":
|
|
4676
|
-
return expr.expressions.every(expr => {
|
|
4678
|
+
return expr.expressions.every((expr) => {
|
|
4677
4679
|
const pureFlag = this.isPure(expr, commentsStartPos);
|
|
4678
4680
|
commentsStartPos = /** @type {Range} */ (expr.range)[1];
|
|
4679
4681
|
return pureFlag;
|
|
@@ -4686,13 +4688,13 @@ class JavascriptParser extends Parser {
|
|
|
4686
4688
|
commentsStartPos,
|
|
4687
4689
|
/** @type {Range} */ (expr.range)[0]
|
|
4688
4690
|
]).some(
|
|
4689
|
-
comment =>
|
|
4691
|
+
(comment) =>
|
|
4690
4692
|
comment.type === "Block" &&
|
|
4691
4693
|
/^\s*(#|@)__PURE__\s*$/.test(comment.value)
|
|
4692
4694
|
);
|
|
4693
4695
|
if (!pureFlag) return false;
|
|
4694
4696
|
commentsStartPos = /** @type {Range} */ (expr.callee.range)[1];
|
|
4695
|
-
return expr.arguments.every(arg => {
|
|
4697
|
+
return expr.arguments.every((arg) => {
|
|
4696
4698
|
if (arg.type === "SpreadElement") return false;
|
|
4697
4699
|
const pureFlag = this.isPure(arg, commentsStartPos);
|
|
4698
4700
|
commentsStartPos = /** @type {Range} */ (arg.range)[1];
|
|
@@ -21,7 +21,7 @@ module.exports.approve = () => true;
|
|
|
21
21
|
* @param {boolean} value the boolean value
|
|
22
22
|
* @returns {(expression: Expression) => BasicEvaluatedExpression} plugin function
|
|
23
23
|
*/
|
|
24
|
-
module.exports.evaluateToBoolean = value =>
|
|
24
|
+
module.exports.evaluateToBoolean = (value) =>
|
|
25
25
|
function booleanExpression(expr) {
|
|
26
26
|
return new BasicEvaluatedExpression()
|
|
27
27
|
.setBoolean(value)
|
|
@@ -65,7 +65,7 @@ module.exports.evaluateToIdentifier = (
|
|
|
65
65
|
* @param {number} value the number value
|
|
66
66
|
* @returns {(expression: Expression) => BasicEvaluatedExpression} plugin function
|
|
67
67
|
*/
|
|
68
|
-
module.exports.evaluateToNumber = value =>
|
|
68
|
+
module.exports.evaluateToNumber = (value) =>
|
|
69
69
|
function stringExpression(expr) {
|
|
70
70
|
return new BasicEvaluatedExpression()
|
|
71
71
|
.setNumber(value)
|
|
@@ -76,7 +76,7 @@ module.exports.evaluateToNumber = value =>
|
|
|
76
76
|
* @param {string} value the string value
|
|
77
77
|
* @returns {(expression: Expression) => BasicEvaluatedExpression} plugin function
|
|
78
78
|
*/
|
|
79
|
-
module.exports.evaluateToString = value =>
|
|
79
|
+
module.exports.evaluateToString = (value) =>
|
|
80
80
|
function stringExpression(expr) {
|
|
81
81
|
return new BasicEvaluatedExpression()
|
|
82
82
|
.setString(value)
|
|
@@ -54,7 +54,7 @@ module.exports.generateEntryStartup = (
|
|
|
54
54
|
* @param {ModuleId} id id
|
|
55
55
|
* @returns {string} fn to execute
|
|
56
56
|
*/
|
|
57
|
-
const runModule = id => `__webpack_exec__(${JSON.stringify(id)})`;
|
|
57
|
+
const runModule = (id) => `__webpack_exec__(${JSON.stringify(id)})`;
|
|
58
58
|
/**
|
|
59
59
|
* @param {Chunks} chunks chunks
|
|
60
60
|
* @param {ModuleIds} moduleIds module ids
|
|
@@ -74,7 +74,7 @@ module.exports.generateEntryStartup = (
|
|
|
74
74
|
passive
|
|
75
75
|
? RuntimeGlobals.onChunksLoaded
|
|
76
76
|
: RuntimeGlobals.startupEntrypoint
|
|
77
|
-
}(0, ${JSON.stringify(Array.from(chunks, c => c.id))}, ${fn});`
|
|
77
|
+
}(0, ${JSON.stringify(Array.from(chunks, (c) => c.id))}, ${fn});`
|
|
78
78
|
);
|
|
79
79
|
if (final && passive) {
|
|
80
80
|
runtime.push(`${EXPORT_PREFIX}${RuntimeGlobals.onChunksLoaded}();`);
|
|
@@ -29,13 +29,13 @@ const RuntimeGlobals = require("../RuntimeGlobals");
|
|
|
29
29
|
* @param {JsonValue} data Raw JSON data
|
|
30
30
|
* @returns {undefined|string} stringified data
|
|
31
31
|
*/
|
|
32
|
-
const stringifySafe = data => {
|
|
32
|
+
const stringifySafe = (data) => {
|
|
33
33
|
const stringified = JSON.stringify(data);
|
|
34
34
|
if (!stringified) {
|
|
35
35
|
return; // Invalid JSON
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
return stringified.replace(/\u2028|\u2029/g, str =>
|
|
38
|
+
return stringified.replace(/\u2028|\u2029/g, (str) =>
|
|
39
39
|
str === "\u2029" ? "\\u2029" : "\\u2028"
|
|
40
40
|
); // invalid in JavaScript but valid JSON
|
|
41
41
|
};
|
|
@@ -51,13 +51,13 @@ class JsonModulesPlugin {
|
|
|
51
51
|
(compilation, { normalModuleFactory }) => {
|
|
52
52
|
normalModuleFactory.hooks.createParser
|
|
53
53
|
.for(JSON_MODULE_TYPE)
|
|
54
|
-
.tap(PLUGIN_NAME, parserOptions => {
|
|
54
|
+
.tap(PLUGIN_NAME, (parserOptions) => {
|
|
55
55
|
validate(parserOptions);
|
|
56
56
|
return new JsonParser(parserOptions);
|
|
57
57
|
});
|
|
58
58
|
normalModuleFactory.hooks.createGenerator
|
|
59
59
|
.for(JSON_MODULE_TYPE)
|
|
60
|
-
.tap(PLUGIN_NAME, generatorOptions => {
|
|
60
|
+
.tap(PLUGIN_NAME, (generatorOptions) => {
|
|
61
61
|
validateGenerator(generatorOptions);
|
|
62
62
|
return new JsonGenerator(generatorOptions);
|
|
63
63
|
});
|
|
@@ -58,7 +58,7 @@ class AbstractLibraryPlugin {
|
|
|
58
58
|
*/
|
|
59
59
|
apply(compiler) {
|
|
60
60
|
const { _pluginName } = this;
|
|
61
|
-
compiler.hooks.thisCompilation.tap(_pluginName, compilation => {
|
|
61
|
+
compiler.hooks.thisCompilation.tap(_pluginName, (compilation) => {
|
|
62
62
|
compilation.hooks.finishModules.tap(
|
|
63
63
|
{ name: _pluginName, stage: 10 },
|
|
64
64
|
() => {
|
|
@@ -95,7 +95,7 @@ class AbstractLibraryPlugin {
|
|
|
95
95
|
* @param {Chunk} chunk chunk
|
|
96
96
|
* @returns {T | false} options for the chunk
|
|
97
97
|
*/
|
|
98
|
-
const getOptionsForChunk = chunk => {
|
|
98
|
+
const getOptionsForChunk = (chunk) => {
|
|
99
99
|
if (compilation.chunkGraph.getNumberOfEntryModules(chunk) === 0) {
|
|
100
100
|
return false;
|
|
101
101
|
}
|
|
@@ -162,7 +162,7 @@ class AbstractLibraryPlugin {
|
|
|
162
162
|
this.strictRuntimeBailout !==
|
|
163
163
|
AbstractLibraryPlugin.prototype.strictRuntimeBailout
|
|
164
164
|
) {
|
|
165
|
-
hooks.strictRuntimeBailout.tap(_pluginName, renderContext => {
|
|
165
|
+
hooks.strictRuntimeBailout.tap(_pluginName, (renderContext) => {
|
|
166
166
|
const options = getOptionsForChunk(renderContext.chunk);
|
|
167
167
|
if (options === false) return;
|
|
168
168
|
return this.strictRuntimeBailout(renderContext, {
|
|
@@ -85,13 +85,13 @@ class AmdLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
85
85
|
const modules = chunkGraph
|
|
86
86
|
.getChunkModules(chunk)
|
|
87
87
|
.filter(
|
|
88
|
-
m =>
|
|
88
|
+
(m) =>
|
|
89
89
|
m instanceof ExternalModule &&
|
|
90
90
|
(m.externalType === "amd" || m.externalType === "amd-require")
|
|
91
91
|
);
|
|
92
92
|
const externals = /** @type {ExternalModule[]} */ (modules);
|
|
93
93
|
const externalsDepsArray = JSON.stringify(
|
|
94
|
-
externals.map(m =>
|
|
94
|
+
externals.map((m) =>
|
|
95
95
|
typeof m.request === "object" && !Array.isArray(m.request)
|
|
96
96
|
? m.request.amd
|
|
97
97
|
: m.request
|
|
@@ -99,7 +99,7 @@ class AmdLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
99
99
|
);
|
|
100
100
|
const externalsArguments = externals
|
|
101
101
|
.map(
|
|
102
|
-
m =>
|
|
102
|
+
(m) =>
|
|
103
103
|
`__WEBPACK_EXTERNAL_MODULE_${Template.toIdentifier(
|
|
104
104
|
`${chunkGraph.getModuleId(m)}`
|
|
105
105
|
)}__`
|
|
@@ -35,7 +35,7 @@ const IDENTIFIER_REGEX =
|
|
|
35
35
|
* @param {string} name name to be validated
|
|
36
36
|
* @returns {boolean} true, when valid
|
|
37
37
|
*/
|
|
38
|
-
const isNameValid = name =>
|
|
38
|
+
const isNameValid = (name) =>
|
|
39
39
|
!KEYWORD_REGEX.test(name) && IDENTIFIER_REGEX.test(name);
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -197,7 +197,7 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
197
197
|
...(Array.isArray(options.name) ? options.name : [options.name])
|
|
198
198
|
]
|
|
199
199
|
: prefix;
|
|
200
|
-
return fullName.map(n =>
|
|
200
|
+
return fullName.map((n) =>
|
|
201
201
|
compilation.getPath(n, {
|
|
202
202
|
chunk
|
|
203
203
|
})
|
|
@@ -21,7 +21,7 @@ const enabledTypes = new WeakMap();
|
|
|
21
21
|
* @param {Compiler} compiler the compiler instance
|
|
22
22
|
* @returns {Set<LibraryType>} enabled types
|
|
23
23
|
*/
|
|
24
|
-
const getEnabledTypes = compiler => {
|
|
24
|
+
const getEnabledTypes = (compiler) => {
|
|
25
25
|
let set = enabledTypes.get(compiler);
|
|
26
26
|
if (set === undefined) {
|
|
27
27
|
set = new Set();
|
|
@@ -243,7 +243,7 @@ class EnableLibraryPlugin {
|
|
|
243
243
|
apply(compiler) {
|
|
244
244
|
compiler.hooks.thisCompilation.tap(
|
|
245
245
|
"WarnFalseIifeUmdPlugin",
|
|
246
|
-
compilation => {
|
|
246
|
+
(compilation) => {
|
|
247
247
|
const FalseIIFEUmdWarning = require("../FalseIIFEUmdWarning");
|
|
248
248
|
|
|
249
249
|
compilation.warnings.push(new FalseIIFEUmdWarning());
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
const { ConcatSource } = require("webpack-sources");
|
|
9
9
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
10
10
|
const Template = require("../Template");
|
|
11
|
+
const JavascriptModulesPlugin = require("../javascript/JavascriptModulesPlugin");
|
|
11
12
|
const ConcatenatedModule = require("../optimize/ConcatenatedModule");
|
|
12
13
|
const propertyAccess = require("../util/propertyAccess");
|
|
13
14
|
const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
|
|
@@ -64,10 +65,14 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
64
65
|
apply(compiler) {
|
|
65
66
|
super.apply(compiler);
|
|
66
67
|
|
|
67
|
-
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
|
68
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
68
69
|
const { exportsDefinitions } =
|
|
69
70
|
ConcatenatedModule.getCompilationHooks(compilation);
|
|
70
71
|
exportsDefinitions.tap(PLUGIN_NAME, (definitions, module) => {
|
|
72
|
+
const bailout = JavascriptModulesPlugin.getCompilationHooks(
|
|
73
|
+
compilation
|
|
74
|
+
).inlineInRuntimeBailout.call(module, {});
|
|
75
|
+
if (bailout) return false;
|
|
71
76
|
// If we have connections not all modules were concatenated, so we need the wrapper
|
|
72
77
|
const connections =
|
|
73
78
|
compilation.moduleGraph.getIncomingConnections(module);
|
|
@@ -159,7 +164,7 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|
|
159
164
|
|
|
160
165
|
let shouldContinue = false;
|
|
161
166
|
|
|
162
|
-
const reexport = exportInfo.findTarget(moduleGraph, _m => true);
|
|
167
|
+
const reexport = exportInfo.findTarget(moduleGraph, (_m) => true);
|
|
163
168
|
|
|
164
169
|
if (reexport) {
|
|
165
170
|
const exp = moduleGraph.getExportsInfo(reexport.module);
|