webpack 5.100.1 → 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 +127 -114
- 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 +86 -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 +28 -24
- 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 +42 -44
- 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 +10 -3
- package/lib/asset/AssetGenerator.js +3 -3
- package/lib/asset/AssetModulesPlugin.js +6 -6
- package/lib/async-modules/AsyncModuleHelpers.js +50 -0
- 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 -23
- 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 +59 -75
- 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 +90 -83
- 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 +22 -6
- 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 +86 -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 +107 -8
- 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 +186 -54
package/lib/css/walkCssTokens.js
CHANGED
|
@@ -98,7 +98,7 @@ const consumeSpace = (input, pos, _callbacks) => {
|
|
|
98
98
|
* @param {number} cc char code
|
|
99
99
|
* @returns {boolean} true, if cc is a newline
|
|
100
100
|
*/
|
|
101
|
-
const _isNewline = cc =>
|
|
101
|
+
const _isNewline = (cc) =>
|
|
102
102
|
cc === CC_LINE_FEED || cc === CC_CARRIAGE_RETURN || cc === CC_FORM_FEED;
|
|
103
103
|
|
|
104
104
|
/**
|
|
@@ -119,13 +119,13 @@ const consumeExtraNewline = (cc, input, pos) => {
|
|
|
119
119
|
* @param {number} cc char code
|
|
120
120
|
* @returns {boolean} true, if cc is a space (U+0009 CHARACTER TABULATION or U+0020 SPACE)
|
|
121
121
|
*/
|
|
122
|
-
const _isSpace = cc => cc === CC_TAB || cc === CC_SPACE;
|
|
122
|
+
const _isSpace = (cc) => cc === CC_TAB || cc === CC_SPACE;
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* @param {number} cc char code
|
|
126
126
|
* @returns {boolean} true, if cc is a whitespace
|
|
127
127
|
*/
|
|
128
|
-
const _isWhiteSpace = cc => _isNewline(cc) || _isSpace(cc);
|
|
128
|
+
const _isWhiteSpace = (cc) => _isNewline(cc) || _isSpace(cc);
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
131
|
* ident-start code point
|
|
@@ -134,7 +134,7 @@ const _isWhiteSpace = cc => _isNewline(cc) || _isSpace(cc);
|
|
|
134
134
|
* @param {number} cc char code
|
|
135
135
|
* @returns {boolean} true, if cc is a start code point of an identifier
|
|
136
136
|
*/
|
|
137
|
-
const isIdentStartCodePoint = cc =>
|
|
137
|
+
const isIdentStartCodePoint = (cc) =>
|
|
138
138
|
(cc >= CC_LOWER_A && cc <= CC_LOWER_Z) ||
|
|
139
139
|
(cc >= CC_UPPER_A && cc <= CC_UPPER_Z) ||
|
|
140
140
|
cc === CC_LOW_LINE ||
|
|
@@ -189,7 +189,7 @@ const consumeComments = (input, pos, callbacks) => {
|
|
|
189
189
|
* @param {number} cc char code
|
|
190
190
|
* @returns {boolean} true, if cc is a hex digit
|
|
191
191
|
*/
|
|
192
|
-
const _isHexDigit = cc =>
|
|
192
|
+
const _isHexDigit = (cc) =>
|
|
193
193
|
_isDigit(cc) ||
|
|
194
194
|
(cc >= CC_UPPER_A && cc <= CC_UPPER_F) ||
|
|
195
195
|
(cc >= CC_LOWER_A && cc <= CC_LOWER_F);
|
|
@@ -325,7 +325,7 @@ const isNonASCIICodePoint = (cc, q) =>
|
|
|
325
325
|
* @param {number} cc char code
|
|
326
326
|
* @returns {boolean} is letter
|
|
327
327
|
*/
|
|
328
|
-
const isLetter = cc =>
|
|
328
|
+
const isLetter = (cc) =>
|
|
329
329
|
(cc >= CC_LOWER_A && cc <= CC_LOWER_Z) ||
|
|
330
330
|
(cc >= CC_UPPER_A && cc <= CC_UPPER_Z);
|
|
331
331
|
|
|
@@ -348,7 +348,7 @@ const _isIdentCodePoint = (cc, q) =>
|
|
|
348
348
|
* @param {number} cc char code
|
|
349
349
|
* @returns {boolean} is digit
|
|
350
350
|
*/
|
|
351
|
-
const _isDigit = cc => cc >= CC_0 && cc <= CC_9;
|
|
351
|
+
const _isDigit = (cc) => cc >= CC_0 && cc <= CC_9;
|
|
352
352
|
|
|
353
353
|
/**
|
|
354
354
|
* @param {string} input input
|
|
@@ -799,7 +799,7 @@ const _consumeAnIdentSequence = (input, pos) => {
|
|
|
799
799
|
* @param {number} cc char code
|
|
800
800
|
* @returns {boolean} true, when cc is the non-printable code point, otherwise false
|
|
801
801
|
*/
|
|
802
|
-
const _isNonPrintableCodePoint = cc =>
|
|
802
|
+
const _isNonPrintableCodePoint = (cc) =>
|
|
803
803
|
(cc >= 0x00 && cc <= 0x08) ||
|
|
804
804
|
cc === 0x0b ||
|
|
805
805
|
(cc >= 0x0e && cc <= 0x1f) ||
|
|
@@ -1584,7 +1584,7 @@ const eatIdentSequenceOrString = (input, pos) => {
|
|
|
1584
1584
|
* @param {string} chars characters
|
|
1585
1585
|
* @returns {(input: string, pos: number) => number} function to eat characters
|
|
1586
1586
|
*/
|
|
1587
|
-
const eatUntil = chars => {
|
|
1587
|
+
const eatUntil = (chars) => {
|
|
1588
1588
|
const charCodes = Array.from({ length: chars.length }, (_, i) =>
|
|
1589
1589
|
chars.charCodeAt(i)
|
|
1590
1590
|
);
|
|
@@ -203,7 +203,7 @@ const createTrace = (fs, outputPath) => {
|
|
|
203
203
|
trace,
|
|
204
204
|
counter,
|
|
205
205
|
profiler,
|
|
206
|
-
end: callback => {
|
|
206
|
+
end: (callback) => {
|
|
207
207
|
trace.push("]");
|
|
208
208
|
// Wait until the write stream finishes.
|
|
209
209
|
fsStream.on("close", () => {
|
|
@@ -288,7 +288,7 @@ class ProfilingPlugin {
|
|
|
288
288
|
},
|
|
289
289
|
(stats, callback) => {
|
|
290
290
|
if (compiler.watchMode) return callback();
|
|
291
|
-
tracer.profiler.stopProfiling().then(parsedResults => {
|
|
291
|
+
tracer.profiler.stopProfiling().then((parsedResults) => {
|
|
292
292
|
if (parsedResults === undefined) {
|
|
293
293
|
tracer.profiler.destroy();
|
|
294
294
|
tracer.end(callback);
|
|
@@ -443,12 +443,12 @@ const interceptAllCssModulesPluginHooks = (compilation, tracer) => {
|
|
|
443
443
|
* @param {Trace} tracer tracer
|
|
444
444
|
* @returns {(hookName: string) => TODO} interceptor
|
|
445
445
|
*/
|
|
446
|
-
const makeInterceptorFor = (instance, tracer) => hookName => ({
|
|
446
|
+
const makeInterceptorFor = (instance, tracer) => (hookName) => ({
|
|
447
447
|
/**
|
|
448
448
|
* @param {FullTap} tapInfo tap info
|
|
449
449
|
* @returns {FullTap} modified full tap
|
|
450
450
|
*/
|
|
451
|
-
register: tapInfo => {
|
|
451
|
+
register: (tapInfo) => {
|
|
452
452
|
const { name, type, fn: internalFn } = tapInfo;
|
|
453
453
|
const newFn =
|
|
454
454
|
// Don't tap our own hooks to ensure stream can close cleanly
|
|
@@ -487,7 +487,7 @@ const makeNewProfiledTapFn = (hookName, tracer, { name, type, fn }) => {
|
|
|
487
487
|
const promise =
|
|
488
488
|
/** @type {Promise<(...args: EXPECTED_ANY[]) => EXPECTED_ANY>} */
|
|
489
489
|
(fn(...args));
|
|
490
|
-
return promise.then(r => {
|
|
490
|
+
return promise.then((r) => {
|
|
491
491
|
tracer.trace.end({
|
|
492
492
|
name,
|
|
493
493
|
id,
|
|
@@ -36,7 +36,7 @@ const { addLocalModule, getLocalModule } = require("./LocalModulesHelpers");
|
|
|
36
36
|
* @param {Expression | SpreadElement} expr expression
|
|
37
37
|
* @returns {expr is CallExpression} true if it's a bound function expression
|
|
38
38
|
*/
|
|
39
|
-
const isBoundFunctionExpression = expr => {
|
|
39
|
+
const isBoundFunctionExpression = (expr) => {
|
|
40
40
|
if (expr.type !== "CallExpression") return false;
|
|
41
41
|
if (expr.callee.type !== "MemberExpression") return false;
|
|
42
42
|
if (expr.callee.computed) return false;
|
|
@@ -52,7 +52,7 @@ const isBoundFunctionExpression = expr => {
|
|
|
52
52
|
* @param {Expression | SpreadElement} expr expression
|
|
53
53
|
* @returns {expr is FunctionExpression | ArrowFunctionExpression} true when unbound function expression
|
|
54
54
|
*/
|
|
55
|
-
const isUnboundFunctionExpression = expr => {
|
|
55
|
+
const isUnboundFunctionExpression = (expr) => {
|
|
56
56
|
if (expr.type === "FunctionExpression") return true;
|
|
57
57
|
if (expr.type === "ArrowFunctionExpression") return true;
|
|
58
58
|
return false;
|
|
@@ -62,7 +62,7 @@ const isUnboundFunctionExpression = expr => {
|
|
|
62
62
|
* @param {Expression | SpreadElement} expr expression
|
|
63
63
|
* @returns {expr is FunctionExpression | ArrowFunctionExpression | CallExpression} true when callable
|
|
64
64
|
*/
|
|
65
|
-
const isCallable = expr => {
|
|
65
|
+
const isCallable = (expr) => {
|
|
66
66
|
if (isUnboundFunctionExpression(expr)) return true;
|
|
67
67
|
if (isBoundFunctionExpression(expr)) return true;
|
|
68
68
|
return false;
|
|
@@ -410,7 +410,7 @@ class AMDDefineDependencyParserPlugin {
|
|
|
410
410
|
parser.inScope(
|
|
411
411
|
/** @type {Identifier[]} */
|
|
412
412
|
(object.params).filter(
|
|
413
|
-
i => !["require", "module", "exports"].includes(i.name)
|
|
413
|
+
(i) => !["require", "module", "exports"].includes(i.name)
|
|
414
414
|
),
|
|
415
415
|
() => {
|
|
416
416
|
for (const [name, varInfo] of fnRenames) {
|
|
@@ -156,7 +156,7 @@ class AMDPlugin {
|
|
|
156
156
|
);
|
|
157
157
|
parser.hooks.evaluateIdentifier
|
|
158
158
|
.for(optionExpr)
|
|
159
|
-
.tap(PLUGIN_NAME, expr =>
|
|
159
|
+
.tap(PLUGIN_NAME, (expr) =>
|
|
160
160
|
evaluateToIdentifier(
|
|
161
161
|
optionExpr,
|
|
162
162
|
rootName,
|
|
@@ -188,7 +188,7 @@ class AMDPlugin {
|
|
|
188
188
|
() => []
|
|
189
189
|
);
|
|
190
190
|
|
|
191
|
-
parser.hooks.expression.for("define").tap(PLUGIN_NAME, expr => {
|
|
191
|
+
parser.hooks.expression.for("define").tap(PLUGIN_NAME, (expr) => {
|
|
192
192
|
const dep = new ConstDependency(
|
|
193
193
|
RuntimeGlobals.amdDefine,
|
|
194
194
|
/** @type {Range} */ (expr.range),
|
|
@@ -208,7 +208,7 @@ class AMDPlugin {
|
|
|
208
208
|
.for("define")
|
|
209
209
|
.tap(PLUGIN_NAME, evaluateToString("function"));
|
|
210
210
|
parser.hooks.canRename.for("define").tap(PLUGIN_NAME, approve);
|
|
211
|
-
parser.hooks.rename.for("define").tap(PLUGIN_NAME, expr => {
|
|
211
|
+
parser.hooks.rename.for("define").tap(PLUGIN_NAME, (expr) => {
|
|
212
212
|
const dep = new ConstDependency(
|
|
213
213
|
RuntimeGlobals.amdDefine,
|
|
214
214
|
/** @type {Range} */ (expr.range),
|
|
@@ -89,7 +89,7 @@ AMDRequireArrayDependency.Template = class AMDRequireArrayDependencyTemplate ext
|
|
|
89
89
|
* @returns {string} content
|
|
90
90
|
*/
|
|
91
91
|
getContent(dep, templateContext) {
|
|
92
|
-
const requires = dep.depsArray.map(dependency =>
|
|
92
|
+
const requires = dep.depsArray.map((dependency) =>
|
|
93
93
|
this.contentForDependency(dependency, templateContext)
|
|
94
94
|
);
|
|
95
95
|
return `[${requires.join(", ")}]`;
|
|
@@ -52,7 +52,7 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
52
52
|
if (fnData) {
|
|
53
53
|
parser.inScope(
|
|
54
54
|
fnData.fn.params.filter(
|
|
55
|
-
i =>
|
|
55
|
+
(i) =>
|
|
56
56
|
!["require", "module", "exports"].includes(
|
|
57
57
|
/** @type {Identifier} */ (i).name
|
|
58
58
|
)
|
|
@@ -236,7 +236,7 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
236
236
|
if (param.isArray()) {
|
|
237
237
|
const result =
|
|
238
238
|
/** @type {BasicEvaluatedExpression[]} */
|
|
239
|
-
(param.items).map(item => this.processItemForRequestString(item));
|
|
239
|
+
(param.items).map((item) => this.processItemForRequestString(item));
|
|
240
240
|
if (result.every(Boolean)) return result.join(" ");
|
|
241
241
|
} else if (param.isConstArray()) {
|
|
242
242
|
return /** @type {string[]} */ (param.array).join(" ");
|
|
@@ -251,7 +251,7 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
|
251
251
|
if (param.isConditional()) {
|
|
252
252
|
const result =
|
|
253
253
|
/** @type {BasicEvaluatedExpression[]} */
|
|
254
|
-
(param.options).map(item => this.processItemForRequestString(item));
|
|
254
|
+
(param.options).map((item) => this.processItemForRequestString(item));
|
|
255
255
|
if (result.every(Boolean)) return result.join("|");
|
|
256
256
|
} else if (param.isString()) {
|
|
257
257
|
return param.string;
|
|
@@ -131,7 +131,7 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|
|
131
131
|
false
|
|
132
132
|
);
|
|
133
133
|
}
|
|
134
|
-
return referencedExports.map(name => ({
|
|
134
|
+
return referencedExports.map((name) => ({
|
|
135
135
|
name,
|
|
136
136
|
canMangle: false
|
|
137
137
|
}));
|
|
@@ -190,7 +190,7 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|
|
190
190
|
exports: Array.from(
|
|
191
191
|
/** @type {Set<string>} */
|
|
192
192
|
(reexportInfo.exports),
|
|
193
|
-
name => ({
|
|
193
|
+
(name) => ({
|
|
194
194
|
name,
|
|
195
195
|
from,
|
|
196
196
|
export: [...ids, name],
|
|
@@ -47,7 +47,7 @@ const ModuleDecoratorDependency = require("./ModuleDecoratorDependency");
|
|
|
47
47
|
* @param {Expression} expr expression
|
|
48
48
|
* @returns {Expression | undefined} returns the value of property descriptor
|
|
49
49
|
*/
|
|
50
|
-
const getValueOfPropertyDescription = expr => {
|
|
50
|
+
const getValueOfPropertyDescription = (expr) => {
|
|
51
51
|
if (expr.type !== "ObjectExpression") return;
|
|
52
52
|
for (const property of expr.properties) {
|
|
53
53
|
if (property.type === "SpreadElement" || property.computed) continue;
|
|
@@ -64,7 +64,7 @@ const getValueOfPropertyDescription = expr => {
|
|
|
64
64
|
* @param {Expression} expr expression being checked
|
|
65
65
|
* @returns {boolean} true, when the expression is a truthy literal
|
|
66
66
|
*/
|
|
67
|
-
const isTruthyLiteral = expr => {
|
|
67
|
+
const isTruthyLiteral = (expr) => {
|
|
68
68
|
switch (expr.type) {
|
|
69
69
|
case "Literal":
|
|
70
70
|
return Boolean(expr.value);
|
|
@@ -81,7 +81,7 @@ const isTruthyLiteral = expr => {
|
|
|
81
81
|
* @param {Expression} expr expression being checked
|
|
82
82
|
* @returns {boolean} true, when the expression is a falsy literal
|
|
83
83
|
*/
|
|
84
|
-
const isFalsyLiteral = expr => {
|
|
84
|
+
const isFalsyLiteral = (expr) => {
|
|
85
85
|
switch (expr.type) {
|
|
86
86
|
case "Literal":
|
|
87
87
|
return !expr.value;
|
|
@@ -163,14 +163,14 @@ class CommonJsExportsParserPlugin {
|
|
|
163
163
|
/**
|
|
164
164
|
* @param {string=} reason reason
|
|
165
165
|
*/
|
|
166
|
-
const bailout = reason => {
|
|
166
|
+
const bailout = (reason) => {
|
|
167
167
|
DynamicExports.bailout(parser.state);
|
|
168
168
|
if (reason) bailoutHint(reason);
|
|
169
169
|
};
|
|
170
170
|
/**
|
|
171
171
|
* @param {string} reason reason
|
|
172
172
|
*/
|
|
173
|
-
const bailoutHint = reason => {
|
|
173
|
+
const bailoutHint = (reason) => {
|
|
174
174
|
this.moduleGraph
|
|
175
175
|
.getOptimizationBailout(parser.state.module)
|
|
176
176
|
.push(`CommonJS bailout: ${reason}`);
|
|
@@ -258,7 +258,7 @@ class CommonJsExportsParserPlugin {
|
|
|
258
258
|
});
|
|
259
259
|
parser.hooks.call
|
|
260
260
|
.for("Object.defineProperty")
|
|
261
|
-
.tap(PLUGIN_NAME, expression => {
|
|
261
|
+
.tap(PLUGIN_NAME, (expression) => {
|
|
262
262
|
const expr = /** @type {CallExpression} */ (expression);
|
|
263
263
|
if (!parser.isStatementLevelExpression(expr)) return;
|
|
264
264
|
if (expr.arguments.length !== 3) return;
|
|
@@ -350,7 +350,7 @@ class CommonJsExportsParserPlugin {
|
|
|
350
350
|
);
|
|
351
351
|
parser.hooks.expression
|
|
352
352
|
.for("exports")
|
|
353
|
-
.tap(PLUGIN_NAME, expr => handleAccessExport(expr, "exports", []));
|
|
353
|
+
.tap(PLUGIN_NAME, (expr) => handleAccessExport(expr, "exports", []));
|
|
354
354
|
parser.hooks.callMemberChain
|
|
355
355
|
.for("module")
|
|
356
356
|
.tap(PLUGIN_NAME, (expr, members) => {
|
|
@@ -370,7 +370,9 @@ class CommonJsExportsParserPlugin {
|
|
|
370
370
|
});
|
|
371
371
|
parser.hooks.expression
|
|
372
372
|
.for("module.exports")
|
|
373
|
-
.tap(PLUGIN_NAME, expr =>
|
|
373
|
+
.tap(PLUGIN_NAME, (expr) =>
|
|
374
|
+
handleAccessExport(expr, "module.exports", [])
|
|
375
|
+
);
|
|
374
376
|
parser.hooks.callMemberChain
|
|
375
377
|
.for("this")
|
|
376
378
|
.tap(PLUGIN_NAME, (expr, members) => {
|
|
@@ -383,13 +385,13 @@ class CommonJsExportsParserPlugin {
|
|
|
383
385
|
if (!parser.scope.topLevelScope) return;
|
|
384
386
|
return handleAccessExport(expr, "this", members);
|
|
385
387
|
});
|
|
386
|
-
parser.hooks.expression.for("this").tap(PLUGIN_NAME, expr => {
|
|
388
|
+
parser.hooks.expression.for("this").tap(PLUGIN_NAME, (expr) => {
|
|
387
389
|
if (!parser.scope.topLevelScope) return;
|
|
388
390
|
return handleAccessExport(expr, "this", []);
|
|
389
391
|
});
|
|
390
392
|
|
|
391
393
|
// Bailouts //
|
|
392
|
-
parser.hooks.expression.for("module").tap(PLUGIN_NAME, expr => {
|
|
394
|
+
parser.hooks.expression.for("module").tap(PLUGIN_NAME, (expr) => {
|
|
393
395
|
bailout();
|
|
394
396
|
const isHarmony = HarmonyExports.isEnabled(parser.state);
|
|
395
397
|
const dep = new ModuleDecoratorDependency(
|
|
@@ -91,7 +91,7 @@ class CommonJsImportsParserPlugin {
|
|
|
91
91
|
/**
|
|
92
92
|
* @param {string | symbol} tag tag
|
|
93
93
|
*/
|
|
94
|
-
const tapRequireExpressionTag = tag => {
|
|
94
|
+
const tapRequireExpressionTag = (tag) => {
|
|
95
95
|
parser.hooks.typeof
|
|
96
96
|
.for(tag)
|
|
97
97
|
.tap(
|
|
@@ -108,7 +108,7 @@ class CommonJsImportsParserPlugin {
|
|
|
108
108
|
// #endregion
|
|
109
109
|
|
|
110
110
|
// Weird stuff //
|
|
111
|
-
parser.hooks.assign.for("require").tap(PLUGIN_NAME, expr => {
|
|
111
|
+
parser.hooks.assign.for("require").tap(PLUGIN_NAME, (expr) => {
|
|
112
112
|
// to not leak to global "require", we need to define a local require here.
|
|
113
113
|
const dep = new ConstDependency("var require;", 0);
|
|
114
114
|
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
|
@@ -160,7 +160,7 @@ class CommonJsImportsParserPlugin {
|
|
|
160
160
|
* @param {Expression} expr expression
|
|
161
161
|
* @returns {boolean} true when set undefined
|
|
162
162
|
*/
|
|
163
|
-
const defineUndefined = expr => {
|
|
163
|
+
const defineUndefined = (expr) => {
|
|
164
164
|
// To avoid "not defined" error, replace the value with undefined
|
|
165
165
|
const dep = new ConstDependency(
|
|
166
166
|
"undefined",
|
|
@@ -193,7 +193,7 @@ class CommonJsImportsParserPlugin {
|
|
|
193
193
|
* @param {Expression} expr expression
|
|
194
194
|
* @returns {boolean} true when handled
|
|
195
195
|
*/
|
|
196
|
-
const requireAsExpressionHandler = expr => {
|
|
196
|
+
const requireAsExpressionHandler = (expr) => {
|
|
197
197
|
const dep = new CommonJsRequireContextDependency(
|
|
198
198
|
{
|
|
199
199
|
request: /** @type {string} */ (options.unknownContextRequest),
|
|
@@ -267,7 +267,7 @@ class CommonJsImportsParserPlugin {
|
|
|
267
267
|
* @param {boolean} callNew true, when require is called with new
|
|
268
268
|
* @returns {(expr: CallExpression | NewExpression) => (boolean | void)} handler
|
|
269
269
|
*/
|
|
270
|
-
const createRequireHandler = callNew => expr => {
|
|
270
|
+
const createRequireHandler = (callNew) => (expr) => {
|
|
271
271
|
if (options.commonjsMagicComments) {
|
|
272
272
|
const { options: requireOptions, errors: commentErrors } =
|
|
273
273
|
parser.parseCommentOptions(/** @type {Range} */ (expr.range));
|
|
@@ -567,10 +567,10 @@ class CommonJsImportsParserPlugin {
|
|
|
567
567
|
|
|
568
568
|
parser.hooks.call
|
|
569
569
|
.for("require.resolve")
|
|
570
|
-
.tap(PLUGIN_NAME, expr => processResolve(expr, false));
|
|
570
|
+
.tap(PLUGIN_NAME, (expr) => processResolve(expr, false));
|
|
571
571
|
parser.hooks.call
|
|
572
572
|
.for("require.resolveWeak")
|
|
573
|
-
.tap(PLUGIN_NAME, expr => processResolve(expr, true));
|
|
573
|
+
.tap(PLUGIN_NAME, (expr) => processResolve(expr, true));
|
|
574
574
|
// #endregion
|
|
575
575
|
|
|
576
576
|
// #region Create require
|
|
@@ -607,7 +607,7 @@ class CommonJsImportsParserPlugin {
|
|
|
607
607
|
tapRequireExpressionTag(createRequireSpecifierTag);
|
|
608
608
|
parser.hooks.evaluateCallExpression
|
|
609
609
|
.for(createRequireSpecifierTag)
|
|
610
|
-
.tap(PLUGIN_NAME, expr => {
|
|
610
|
+
.tap(PLUGIN_NAME, (expr) => {
|
|
611
611
|
const context = parseCreateRequireArguments(expr);
|
|
612
612
|
if (context === undefined) return;
|
|
613
613
|
const ident = parser.evaluatedVariable({
|
|
@@ -648,7 +648,7 @@ class CommonJsImportsParserPlugin {
|
|
|
648
648
|
* @param {CallExpression} expr call expression
|
|
649
649
|
* @returns {string | void} context
|
|
650
650
|
*/
|
|
651
|
-
const parseCreateRequireArguments = expr => {
|
|
651
|
+
const parseCreateRequireArguments = (expr) => {
|
|
652
652
|
const args = expr.arguments;
|
|
653
653
|
if (args.length !== 1) {
|
|
654
654
|
const err = new WebpackError(
|
|
@@ -715,7 +715,7 @@ class CommonJsImportsParserPlugin {
|
|
|
715
715
|
return true;
|
|
716
716
|
}
|
|
717
717
|
);
|
|
718
|
-
parser.hooks.preDeclarator.tap(PLUGIN_NAME, declarator => {
|
|
718
|
+
parser.hooks.preDeclarator.tap(PLUGIN_NAME, (declarator) => {
|
|
719
719
|
if (
|
|
720
720
|
declarator.id.type !== "Identifier" ||
|
|
721
721
|
!declarator.init ||
|
|
@@ -784,15 +784,17 @@ class CommonJsImportsParserPlugin {
|
|
|
784
784
|
return processResolve(expr, false);
|
|
785
785
|
}
|
|
786
786
|
});
|
|
787
|
-
parser.hooks.call
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
787
|
+
parser.hooks.call
|
|
788
|
+
.for(createRequireSpecifierTag)
|
|
789
|
+
.tap(PLUGIN_NAME, (expr) => {
|
|
790
|
+
const clearDep = new ConstDependency(
|
|
791
|
+
"/* createRequire() */ undefined",
|
|
792
|
+
/** @type {Range} */ (expr.range)
|
|
793
|
+
);
|
|
794
|
+
clearDep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
|
795
|
+
parser.state.module.addPresentationalDependency(clearDep);
|
|
796
|
+
return true;
|
|
797
|
+
});
|
|
796
798
|
// #endregion
|
|
797
799
|
}
|
|
798
800
|
}
|
|
@@ -200,7 +200,7 @@ class CommonJsPlugin {
|
|
|
200
200
|
);
|
|
201
201
|
parser.hooks.expression
|
|
202
202
|
.for(RuntimeGlobals.moduleLoaded)
|
|
203
|
-
.tap(PLUGIN_NAME, expr => {
|
|
203
|
+
.tap(PLUGIN_NAME, (expr) => {
|
|
204
204
|
/** @type {BuildInfo} */
|
|
205
205
|
(parser.state.module.buildInfo).moduleConcatenationBailout =
|
|
206
206
|
RuntimeGlobals.moduleLoaded;
|
|
@@ -214,7 +214,7 @@ class CommonJsPlugin {
|
|
|
214
214
|
|
|
215
215
|
parser.hooks.expression
|
|
216
216
|
.for(RuntimeGlobals.moduleId)
|
|
217
|
-
.tap(PLUGIN_NAME, expr => {
|
|
217
|
+
.tap(PLUGIN_NAME, (expr) => {
|
|
218
218
|
/** @type {BuildInfo} */
|
|
219
219
|
(parser.state.module.buildInfo).moduleConcatenationBailout =
|
|
220
220
|
RuntimeGlobals.moduleId;
|
|
@@ -27,7 +27,7 @@ const getCriticalDependencyWarning = memoize(() =>
|
|
|
27
27
|
* @param {RegExp | null | undefined} r regexp
|
|
28
28
|
* @returns {string} stringified regexp
|
|
29
29
|
*/
|
|
30
|
-
const regExpToString = r => (r ? String(r) : "");
|
|
30
|
+
const regExpToString = (r) => (r ? String(r) : "");
|
|
31
31
|
|
|
32
32
|
class ContextDependency extends Dependency {
|
|
33
33
|
/**
|
|
@@ -22,13 +22,13 @@ const { parseResource } = require("../util/identifier");
|
|
|
22
22
|
* @param {string} str String to quote
|
|
23
23
|
* @returns {string} Escaped string
|
|
24
24
|
*/
|
|
25
|
-
const quoteMeta = str => str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&");
|
|
25
|
+
const quoteMeta = (str) => str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&");
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* @param {string} prefix prefix
|
|
29
29
|
* @returns {{prefix: string, context: string}} result
|
|
30
30
|
*/
|
|
31
|
-
const splitContextFromPrefix = prefix => {
|
|
31
|
+
const splitContextFromPrefix = (prefix) => {
|
|
32
32
|
const idx = prefix.lastIndexOf("/");
|
|
33
33
|
let context = ".";
|
|
34
34
|
if (idx >= 0) {
|
|
@@ -87,7 +87,7 @@ module.exports.create = (
|
|
|
87
87
|
/** @type {RegExp} */ (options.wrappedContextRegExp).source +
|
|
88
88
|
innerQuasis
|
|
89
89
|
.map(
|
|
90
|
-
q =>
|
|
90
|
+
(q) =>
|
|
91
91
|
quoteMeta(/** @type {string} */ (q.string)) +
|
|
92
92
|
/** @type {RegExp} */ (options.wrappedContextRegExp).source
|
|
93
93
|
)
|
|
@@ -65,7 +65,7 @@ class CssIcssExportDependency extends NullDependency {
|
|
|
65
65
|
(generator.convention)
|
|
66
66
|
);
|
|
67
67
|
return {
|
|
68
|
-
exports: names.map(name => ({
|
|
68
|
+
exports: names.map((name) => ({
|
|
69
69
|
name,
|
|
70
70
|
canMangle: true
|
|
71
71
|
})),
|
|
@@ -139,7 +139,7 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
|
|
139
139
|
/** @type {string[]} */
|
|
140
140
|
(
|
|
141
141
|
names
|
|
142
|
-
.map(name =>
|
|
142
|
+
.map((name) =>
|
|
143
143
|
moduleGraph.getExportInfo(module, name).getUsedName(name, runtime)
|
|
144
144
|
)
|
|
145
145
|
.filter(Boolean)
|
|
@@ -127,7 +127,7 @@ class CssLocalIdentifierDependency extends NullDependency {
|
|
|
127
127
|
/** @type {CssGeneratorExportsConvention} */ (generator.convention)
|
|
128
128
|
);
|
|
129
129
|
return {
|
|
130
|
-
exports: names.map(name => ({
|
|
130
|
+
exports: names.map((name) => ({
|
|
131
131
|
name,
|
|
132
132
|
canMangle: true
|
|
133
133
|
})),
|
|
@@ -225,7 +225,7 @@ CssLocalIdentifierDependency.Template = class CssLocalIdentifierDependencyTempla
|
|
|
225
225
|
/** @type {string[]} */
|
|
226
226
|
(
|
|
227
227
|
names
|
|
228
|
-
.map(name =>
|
|
228
|
+
.map((name) =>
|
|
229
229
|
moduleGraph.getExportInfo(module, name).getUsedName(name, runtime)
|
|
230
230
|
)
|
|
231
231
|
.filter(Boolean)
|
|
@@ -82,7 +82,7 @@ class CssUrlDependency extends ModuleDependency {
|
|
|
82
82
|
* @param {string} str string
|
|
83
83
|
* @returns {string} string in quotes if needed
|
|
84
84
|
*/
|
|
85
|
-
const cssEscapeString = str => {
|
|
85
|
+
const cssEscapeString = (str) => {
|
|
86
86
|
let countWhiteOrBracket = 0;
|
|
87
87
|
let countQuotation = 0;
|
|
88
88
|
let countApostrophe = 0;
|
|
@@ -105,11 +105,11 @@ const cssEscapeString = str => {
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
if (countWhiteOrBracket < 2) {
|
|
108
|
-
return str.replace(/[\n\t ()'"\\]/g, m => `\\${m}`);
|
|
108
|
+
return str.replace(/[\n\t ()'"\\]/g, (m) => `\\${m}`);
|
|
109
109
|
} else if (countQuotation <= countApostrophe) {
|
|
110
|
-
return `"${str.replace(/[\n"\\]/g, m => `\\${m}`)}"`;
|
|
110
|
+
return `"${str.replace(/[\n"\\]/g, (m) => `\\${m}`)}"`;
|
|
111
111
|
}
|
|
112
|
-
return `'${str.replace(/[\n'\\]/g, m => `\\${m}`)}'`;
|
|
112
|
+
return `'${str.replace(/[\n'\\]/g, (m) => `\\${m}`)}'`;
|
|
113
113
|
};
|
|
114
114
|
|
|
115
115
|
CssUrlDependency.Template = class CssUrlDependencyTemplate extends (
|
|
@@ -15,7 +15,7 @@ const parserStateExportsState = new WeakMap();
|
|
|
15
15
|
* @param {ParserState} parserState parser state
|
|
16
16
|
* @returns {void}
|
|
17
17
|
*/
|
|
18
|
-
module.exports.bailout = parserState => {
|
|
18
|
+
module.exports.bailout = (parserState) => {
|
|
19
19
|
const value = parserStateExportsState.get(parserState);
|
|
20
20
|
parserStateExportsState.set(parserState, false);
|
|
21
21
|
if (value === true) {
|
|
@@ -29,7 +29,7 @@ module.exports.bailout = parserState => {
|
|
|
29
29
|
* @param {ParserState} parserState parser state
|
|
30
30
|
* @returns {void}
|
|
31
31
|
*/
|
|
32
|
-
module.exports.enable = parserState => {
|
|
32
|
+
module.exports.enable = (parserState) => {
|
|
33
33
|
const value = parserStateExportsState.get(parserState);
|
|
34
34
|
if (value === false) return;
|
|
35
35
|
parserStateExportsState.set(parserState, true);
|
|
@@ -44,7 +44,7 @@ module.exports.enable = parserState => {
|
|
|
44
44
|
* @param {ParserState} parserState parser state
|
|
45
45
|
* @returns {boolean} true, when enabled
|
|
46
46
|
*/
|
|
47
|
-
module.exports.isEnabled = parserState => {
|
|
47
|
+
module.exports.isEnabled = (parserState) => {
|
|
48
48
|
const value = parserStateExportsState.get(parserState);
|
|
49
49
|
return value === true;
|
|
50
50
|
};
|
|
@@ -53,7 +53,7 @@ module.exports.isEnabled = parserState => {
|
|
|
53
53
|
* @param {ParserState} parserState parser state
|
|
54
54
|
* @returns {void}
|
|
55
55
|
*/
|
|
56
|
-
module.exports.setDynamic = parserState => {
|
|
56
|
+
module.exports.setDynamic = (parserState) => {
|
|
57
57
|
const value = parserStateExportsState.get(parserState);
|
|
58
58
|
if (value !== true) return;
|
|
59
59
|
/** @type {BuildMeta} */
|
|
@@ -64,7 +64,7 @@ module.exports.setDynamic = parserState => {
|
|
|
64
64
|
* @param {ParserState} parserState parser state
|
|
65
65
|
* @returns {void}
|
|
66
66
|
*/
|
|
67
|
-
module.exports.setFlagged = parserState => {
|
|
67
|
+
module.exports.setFlagged = (parserState) => {
|
|
68
68
|
const value = parserStateExportsState.get(parserState);
|
|
69
69
|
if (value !== true) return;
|
|
70
70
|
const buildMeta = /** @type {BuildMeta} */ (parserState.module.buildMeta);
|