webpack 5.100.2 → 5.101.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +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 +63 -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 +168 -116
- 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/Dependency.js +2 -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 +3 -2
- package/lib/ModuleFilenameHelpers.js +3 -3
- package/lib/ModuleGraph.js +23 -38
- package/lib/ModuleInfoHeaderPlugin.js +3 -3
- package/lib/ModuleParseError.js +5 -3
- package/lib/ModuleTemplate.js +3 -2
- 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 -14
- 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 +91 -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 +7 -2
- package/lib/dependencies/LoaderPlugin.js +4 -4
- package/lib/dependencies/ModuleDependency.js +2 -1
- 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/ExportWebpackRequireRuntimeModule.js +8 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +35 -69
- package/lib/esm/ModuleChunkLoadingPlugin.js +3 -6
- 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 +18 -6
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +1 -1
- package/lib/javascript/BasicEvaluatedExpression.js +3 -3
- package/lib/javascript/ChunkFormatHelpers.js +70 -0
- package/lib/javascript/CommonJsChunkFormatPlugin.js +10 -21
- package/lib/javascript/EnableChunkLoadingPlugin.js +1 -1
- package/lib/javascript/JavascriptGenerator.js +1 -1
- package/lib/javascript/JavascriptModulesPlugin.js +108 -54
- 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 +30 -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 +49 -31
- 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 +13 -6
- 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 +186 -77
- 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 +19 -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 +18 -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 +4 -4
- 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 +16 -17
- 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 +16 -16
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +4 -0
- package/types.d.ts +275 -64
|
@@ -57,7 +57,7 @@ const nestedConfig = (value, fn) =>
|
|
|
57
57
|
* @param {T|undefined} value value or not
|
|
58
58
|
* @returns {T} result value
|
|
59
59
|
*/
|
|
60
|
-
const cloneObject = value => /** @type {T} */ ({ ...value });
|
|
60
|
+
const cloneObject = (value) => /** @type {T} */ ({ ...value });
|
|
61
61
|
/**
|
|
62
62
|
* @template T
|
|
63
63
|
* @template R
|
|
@@ -124,13 +124,13 @@ const keyedNestedConfig = (value, fn, customKeys) => {
|
|
|
124
124
|
* @param {WebpackOptions} config input config
|
|
125
125
|
* @returns {WebpackOptionsNormalized} normalized options
|
|
126
126
|
*/
|
|
127
|
-
const getNormalizedWebpackOptions = config => ({
|
|
127
|
+
const getNormalizedWebpackOptions = (config) => ({
|
|
128
128
|
amd: config.amd,
|
|
129
129
|
bail: config.bail,
|
|
130
130
|
cache:
|
|
131
131
|
/** @type {NonNullable<CacheOptions>} */
|
|
132
132
|
(
|
|
133
|
-
optionalNestedConfig(config.cache, cache => {
|
|
133
|
+
optionalNestedConfig(config.cache, (cache) => {
|
|
134
134
|
if (cache === false) return false;
|
|
135
135
|
if (cache === true) {
|
|
136
136
|
return {
|
|
@@ -173,7 +173,7 @@ const getNormalizedWebpackOptions = config => ({
|
|
|
173
173
|
),
|
|
174
174
|
context: config.context,
|
|
175
175
|
dependencies: config.dependencies,
|
|
176
|
-
devServer: optionalNestedConfig(config.devServer, devServer => {
|
|
176
|
+
devServer: optionalNestedConfig(config.devServer, (devServer) => {
|
|
177
177
|
if (devServer === false) return false;
|
|
178
178
|
return { ...devServer };
|
|
179
179
|
}),
|
|
@@ -183,25 +183,25 @@ const getNormalizedWebpackOptions = config => ({
|
|
|
183
183
|
? { main: {} }
|
|
184
184
|
: typeof config.entry === "function"
|
|
185
185
|
? (
|
|
186
|
-
fn => () =>
|
|
186
|
+
(fn) => () =>
|
|
187
187
|
Promise.resolve().then(fn).then(getNormalizedEntryStatic)
|
|
188
188
|
)(config.entry)
|
|
189
189
|
: getNormalizedEntryStatic(config.entry),
|
|
190
|
-
experiments: nestedConfig(config.experiments, experiments => ({
|
|
190
|
+
experiments: nestedConfig(config.experiments, (experiments) => ({
|
|
191
191
|
...experiments,
|
|
192
|
-
buildHttp: optionalNestedConfig(experiments.buildHttp, options =>
|
|
192
|
+
buildHttp: optionalNestedConfig(experiments.buildHttp, (options) =>
|
|
193
193
|
Array.isArray(options) ? { allowedUris: options } : options
|
|
194
194
|
),
|
|
195
195
|
lazyCompilation: optionalNestedConfig(
|
|
196
196
|
experiments.lazyCompilation,
|
|
197
|
-
options => (options === true ? {} : options)
|
|
197
|
+
(options) => (options === true ? {} : options)
|
|
198
198
|
)
|
|
199
199
|
})),
|
|
200
200
|
externals: /** @type {NonNullable<Externals>} */ (config.externals),
|
|
201
201
|
externalsPresets: cloneObject(config.externalsPresets),
|
|
202
202
|
externalsType: config.externalsType,
|
|
203
203
|
ignoreWarnings: config.ignoreWarnings
|
|
204
|
-
? config.ignoreWarnings.map(ignore => {
|
|
204
|
+
? config.ignoreWarnings.map((ignore) => {
|
|
205
205
|
if (typeof ignore === "function") return ignore;
|
|
206
206
|
const i = ignore instanceof RegExp ? { message: ignore } : ignore;
|
|
207
207
|
return (warning, { requestShortener }) => {
|
|
@@ -236,11 +236,11 @@ const getNormalizedWebpackOptions = config => ({
|
|
|
236
236
|
module:
|
|
237
237
|
/** @type {ModuleOptionsNormalized} */
|
|
238
238
|
(
|
|
239
|
-
nestedConfig(config.module, module => ({
|
|
239
|
+
nestedConfig(config.module, (module) => ({
|
|
240
240
|
noParse: module.noParse,
|
|
241
241
|
unsafeCache: module.unsafeCache,
|
|
242
242
|
parser: keyedNestedConfig(module.parser, cloneObject, {
|
|
243
|
-
javascript: parserOptions => ({
|
|
243
|
+
javascript: (parserOptions) => ({
|
|
244
244
|
unknownContextRequest: module.unknownContextRequest,
|
|
245
245
|
unknownContextRegExp: module.unknownContextRegExp,
|
|
246
246
|
unknownContextRecursive: module.unknownContextRecursive,
|
|
@@ -259,26 +259,26 @@ const getNormalizedWebpackOptions = config => ({
|
|
|
259
259
|
})
|
|
260
260
|
}),
|
|
261
261
|
generator: cloneObject(module.generator),
|
|
262
|
-
defaultRules: optionalNestedArray(module.defaultRules, r => [...r]),
|
|
263
|
-
rules: nestedArray(module.rules, r => [...r])
|
|
262
|
+
defaultRules: optionalNestedArray(module.defaultRules, (r) => [...r]),
|
|
263
|
+
rules: nestedArray(module.rules, (r) => [...r])
|
|
264
264
|
}))
|
|
265
265
|
),
|
|
266
266
|
name: config.name,
|
|
267
267
|
node: nestedConfig(
|
|
268
268
|
config.node,
|
|
269
|
-
node =>
|
|
269
|
+
(node) =>
|
|
270
270
|
node && {
|
|
271
271
|
...node
|
|
272
272
|
}
|
|
273
273
|
),
|
|
274
|
-
optimization: nestedConfig(config.optimization, optimization => ({
|
|
274
|
+
optimization: nestedConfig(config.optimization, (optimization) => ({
|
|
275
275
|
...optimization,
|
|
276
276
|
runtimeChunk: getNormalizedOptimizationRuntimeChunk(
|
|
277
277
|
optimization.runtimeChunk
|
|
278
278
|
),
|
|
279
279
|
splitChunks: nestedConfig(
|
|
280
280
|
optimization.splitChunks,
|
|
281
|
-
splitChunks =>
|
|
281
|
+
(splitChunks) =>
|
|
282
282
|
splitChunks && {
|
|
283
283
|
...splitChunks,
|
|
284
284
|
defaultSizeTypes: splitChunks.defaultSizeTypes
|
|
@@ -295,7 +295,7 @@ const getNormalizedWebpackOptions = config => ({
|
|
|
295
295
|
)
|
|
296
296
|
: optimization.emitOnErrors
|
|
297
297
|
})),
|
|
298
|
-
output: nestedConfig(config.output, output => {
|
|
298
|
+
output: nestedConfig(config.output, (output) => {
|
|
299
299
|
const { library } = output;
|
|
300
300
|
const libraryAsName = /** @type {LibraryName} */ (library);
|
|
301
301
|
const libraryBase =
|
|
@@ -384,13 +384,16 @@ const getNormalizedWebpackOptions = config => ({
|
|
|
384
384
|
sourcePrefix: output.sourcePrefix,
|
|
385
385
|
strictModuleErrorHandling: output.strictModuleErrorHandling,
|
|
386
386
|
strictModuleExceptionHandling: output.strictModuleExceptionHandling,
|
|
387
|
-
trustedTypes: optionalNestedConfig(
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
387
|
+
trustedTypes: optionalNestedConfig(
|
|
388
|
+
output.trustedTypes,
|
|
389
|
+
(trustedTypes) => {
|
|
390
|
+
if (trustedTypes === true) return {};
|
|
391
|
+
if (typeof trustedTypes === "string") {
|
|
392
|
+
return { policyName: trustedTypes };
|
|
393
|
+
}
|
|
394
|
+
return { ...trustedTypes };
|
|
391
395
|
}
|
|
392
|
-
|
|
393
|
-
}),
|
|
396
|
+
),
|
|
394
397
|
uniqueName: output.uniqueName,
|
|
395
398
|
wasmLoading: output.wasmLoading,
|
|
396
399
|
webassemblyModuleFilename: output.webassemblyModuleFilename,
|
|
@@ -401,13 +404,13 @@ const getNormalizedWebpackOptions = config => ({
|
|
|
401
404
|
return result;
|
|
402
405
|
}),
|
|
403
406
|
parallelism: config.parallelism,
|
|
404
|
-
performance: optionalNestedConfig(config.performance, performance => {
|
|
407
|
+
performance: optionalNestedConfig(config.performance, (performance) => {
|
|
405
408
|
if (performance === false) return false;
|
|
406
409
|
return {
|
|
407
410
|
...performance
|
|
408
411
|
};
|
|
409
412
|
}),
|
|
410
|
-
plugins: /** @type {Plugins} */ (nestedArray(config.plugins, p => [...p])),
|
|
413
|
+
plugins: /** @type {Plugins} */ (nestedArray(config.plugins, (p) => [...p])),
|
|
411
414
|
profile: config.profile,
|
|
412
415
|
recordsInputPath:
|
|
413
416
|
config.recordsInputPath !== undefined
|
|
@@ -417,39 +420,39 @@ const getNormalizedWebpackOptions = config => ({
|
|
|
417
420
|
config.recordsOutputPath !== undefined
|
|
418
421
|
? config.recordsOutputPath
|
|
419
422
|
: config.recordsPath,
|
|
420
|
-
resolve: nestedConfig(config.resolve, resolve => ({
|
|
423
|
+
resolve: nestedConfig(config.resolve, (resolve) => ({
|
|
421
424
|
...resolve,
|
|
422
425
|
byDependency: keyedNestedConfig(resolve.byDependency, cloneObject)
|
|
423
426
|
})),
|
|
424
427
|
resolveLoader: cloneObject(config.resolveLoader),
|
|
425
|
-
snapshot: nestedConfig(config.snapshot, snapshot => ({
|
|
428
|
+
snapshot: nestedConfig(config.snapshot, (snapshot) => ({
|
|
426
429
|
resolveBuildDependencies: optionalNestedConfig(
|
|
427
430
|
snapshot.resolveBuildDependencies,
|
|
428
|
-
resolveBuildDependencies => ({
|
|
431
|
+
(resolveBuildDependencies) => ({
|
|
429
432
|
timestamp: resolveBuildDependencies.timestamp,
|
|
430
433
|
hash: resolveBuildDependencies.hash
|
|
431
434
|
})
|
|
432
435
|
),
|
|
433
436
|
buildDependencies: optionalNestedConfig(
|
|
434
437
|
snapshot.buildDependencies,
|
|
435
|
-
buildDependencies => ({
|
|
438
|
+
(buildDependencies) => ({
|
|
436
439
|
timestamp: buildDependencies.timestamp,
|
|
437
440
|
hash: buildDependencies.hash
|
|
438
441
|
})
|
|
439
442
|
),
|
|
440
|
-
resolve: optionalNestedConfig(snapshot.resolve, resolve => ({
|
|
443
|
+
resolve: optionalNestedConfig(snapshot.resolve, (resolve) => ({
|
|
441
444
|
timestamp: resolve.timestamp,
|
|
442
445
|
hash: resolve.hash
|
|
443
446
|
})),
|
|
444
|
-
module: optionalNestedConfig(snapshot.module, module => ({
|
|
447
|
+
module: optionalNestedConfig(snapshot.module, (module) => ({
|
|
445
448
|
timestamp: module.timestamp,
|
|
446
449
|
hash: module.hash
|
|
447
450
|
})),
|
|
448
|
-
immutablePaths: optionalNestedArray(snapshot.immutablePaths, p => [...p]),
|
|
449
|
-
managedPaths: optionalNestedArray(snapshot.managedPaths, p => [...p]),
|
|
450
|
-
unmanagedPaths: optionalNestedArray(snapshot.unmanagedPaths, p => [...p])
|
|
451
|
+
immutablePaths: optionalNestedArray(snapshot.immutablePaths, (p) => [...p]),
|
|
452
|
+
managedPaths: optionalNestedArray(snapshot.managedPaths, (p) => [...p]),
|
|
453
|
+
unmanagedPaths: optionalNestedArray(snapshot.unmanagedPaths, (p) => [...p])
|
|
451
454
|
})),
|
|
452
|
-
stats: nestedConfig(config.stats, stats => {
|
|
455
|
+
stats: nestedConfig(config.stats, (stats) => {
|
|
453
456
|
if (stats === false) {
|
|
454
457
|
return {
|
|
455
458
|
preset: "none"
|
|
@@ -478,7 +481,7 @@ const getNormalizedWebpackOptions = config => ({
|
|
|
478
481
|
* @param {EntryStatic} entry static entry options
|
|
479
482
|
* @returns {EntryStaticNormalized} normalized static entry options
|
|
480
483
|
*/
|
|
481
|
-
const getNormalizedEntryStatic = entry => {
|
|
484
|
+
const getNormalizedEntryStatic = (entry) => {
|
|
482
485
|
if (typeof entry === "string") {
|
|
483
486
|
return {
|
|
484
487
|
main: {
|
|
@@ -540,7 +543,7 @@ const getNormalizedEntryStatic = entry => {
|
|
|
540
543
|
* @param {OptimizationRuntimeChunk=} runtimeChunk runtimeChunk option
|
|
541
544
|
* @returns {OptimizationRuntimeChunkNormalized=} normalized runtimeChunk option
|
|
542
545
|
*/
|
|
543
|
-
const getNormalizedOptimizationRuntimeChunk = runtimeChunk => {
|
|
546
|
+
const getNormalizedOptimizationRuntimeChunk = (runtimeChunk) => {
|
|
544
547
|
if (runtimeChunk === undefined) return;
|
|
545
548
|
if (runtimeChunk === false) return false;
|
|
546
549
|
if (runtimeChunk === "single") {
|
|
@@ -550,7 +553,7 @@ const getNormalizedOptimizationRuntimeChunk = runtimeChunk => {
|
|
|
550
553
|
}
|
|
551
554
|
if (runtimeChunk === true || runtimeChunk === "multiple") {
|
|
552
555
|
return {
|
|
553
|
-
name: entrypoint => `runtime~${entrypoint.name}`
|
|
556
|
+
name: (entrypoint) => `runtime~${entrypoint.name}`
|
|
554
557
|
};
|
|
555
558
|
}
|
|
556
559
|
const { name } = runtimeChunk;
|
package/lib/config/target.js
CHANGED
|
@@ -15,7 +15,7 @@ const getBrowserslistTargetHandler = memoize(() =>
|
|
|
15
15
|
* @param {string} context the context directory
|
|
16
16
|
* @returns {string} default target
|
|
17
17
|
*/
|
|
18
|
-
const getDefaultTarget = context => {
|
|
18
|
+
const getDefaultTarget = (context) => {
|
|
19
19
|
const browsers = getBrowserslistTargetHandler().load(null, context);
|
|
20
20
|
return browsers ? "browserslist" : "web";
|
|
21
21
|
};
|
|
@@ -287,7 +287,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
287
287
|
"esX",
|
|
288
288
|
"EcmaScript in this version. Examples: es2020, es5.",
|
|
289
289
|
/^es(\d+)$/,
|
|
290
|
-
version => {
|
|
290
|
+
(version) => {
|
|
291
291
|
let v = Number(version);
|
|
292
292
|
if (v < 1000) v += 2009;
|
|
293
293
|
return {
|
|
@@ -333,7 +333,7 @@ const getTargetProperties = (target, context) => {
|
|
|
333
333
|
* @param {TargetProperties[]} targetProperties array of target properties
|
|
334
334
|
* @returns {TargetProperties} merged target properties
|
|
335
335
|
*/
|
|
336
|
-
const mergeTargetProperties = targetProperties => {
|
|
336
|
+
const mergeTargetProperties = (targetProperties) => {
|
|
337
337
|
/** @type {Set<keyof TargetProperties>} */
|
|
338
338
|
const keys = new Set();
|
|
339
339
|
for (const tp of targetProperties) {
|
|
@@ -371,7 +371,7 @@ const mergeTargetProperties = targetProperties => {
|
|
|
371
371
|
* @returns {TargetProperties} target properties
|
|
372
372
|
*/
|
|
373
373
|
const getTargetsProperties = (targets, context) =>
|
|
374
|
-
mergeTargetProperties(targets.map(t => getTargetProperties(t, context)));
|
|
374
|
+
mergeTargetProperties(targets.map((t) => getTargetProperties(t, context)));
|
|
375
375
|
|
|
376
376
|
module.exports.getDefaultTarget = getDefaultTarget;
|
|
377
377
|
module.exports.getTargetProperties = getTargetProperties;
|
|
@@ -159,7 +159,7 @@ class ContainerEntryModule extends Module {
|
|
|
159
159
|
for (const block of this.blocks) {
|
|
160
160
|
const { dependencies } = block;
|
|
161
161
|
|
|
162
|
-
const modules = dependencies.map(dependency => {
|
|
162
|
+
const modules = dependencies.map((dependency) => {
|
|
163
163
|
const dep = /** @type {ContainerExposedDependency} */ (dependency);
|
|
164
164
|
return {
|
|
165
165
|
name: dep.exposedName,
|
|
@@ -170,9 +170,9 @@ class ContainerEntryModule extends Module {
|
|
|
170
170
|
|
|
171
171
|
let str;
|
|
172
172
|
|
|
173
|
-
if (modules.some(m => !m.module)) {
|
|
173
|
+
if (modules.some((m) => !m.module)) {
|
|
174
174
|
str = runtimeTemplate.throwMissingModuleErrorBlock({
|
|
175
|
-
request: modules.map(m => m.request).join(", ")
|
|
175
|
+
request: modules.map((m) => m.request).join(", ")
|
|
176
176
|
});
|
|
177
177
|
} else {
|
|
178
178
|
str = `return ${runtimeTemplate.blockPromise({
|
|
@@ -51,11 +51,11 @@ class ContainerPlugin {
|
|
|
51
51
|
exposes: /** @type {ExposesList} */ (
|
|
52
52
|
parseOptions(
|
|
53
53
|
options.exposes,
|
|
54
|
-
item => ({
|
|
54
|
+
(item) => ({
|
|
55
55
|
import: Array.isArray(item) ? item : [item],
|
|
56
56
|
name: undefined
|
|
57
57
|
}),
|
|
58
|
-
item => ({
|
|
58
|
+
(item) => ({
|
|
59
59
|
import: Array.isArray(item.import) ? item.import : [item.import],
|
|
60
60
|
name: item.name || undefined
|
|
61
61
|
})
|
|
@@ -91,7 +91,7 @@ class ContainerPlugin {
|
|
|
91
91
|
runtime,
|
|
92
92
|
library
|
|
93
93
|
},
|
|
94
|
-
error => {
|
|
94
|
+
(error) => {
|
|
95
95
|
if (error) return callback(error);
|
|
96
96
|
hooks.addContainerEntryDependency.call(dep);
|
|
97
97
|
callback();
|
|
@@ -43,11 +43,11 @@ class ContainerReferencePlugin {
|
|
|
43
43
|
this._remoteType = options.remoteType;
|
|
44
44
|
this._remotes = parseOptions(
|
|
45
45
|
options.remotes,
|
|
46
|
-
item => ({
|
|
46
|
+
(item) => ({
|
|
47
47
|
external: Array.isArray(item) ? item : [item],
|
|
48
48
|
shareScope: options.shareScope || "default"
|
|
49
49
|
}),
|
|
50
|
-
item => ({
|
|
50
|
+
(item) => ({
|
|
51
51
|
external: Array.isArray(item.external)
|
|
52
52
|
? item.external
|
|
53
53
|
: [item.external],
|
|
@@ -97,7 +97,7 @@ class ContainerReferencePlugin {
|
|
|
97
97
|
new FallbackModuleFactory()
|
|
98
98
|
);
|
|
99
99
|
|
|
100
|
-
normalModuleFactory.hooks.factorize.tap(PLUGIN_NAME, data => {
|
|
100
|
+
normalModuleFactory.hooks.factorize.tap(PLUGIN_NAME, (data) => {
|
|
101
101
|
if (!data.request.includes("!")) {
|
|
102
102
|
for (const [key, config] of remotes) {
|
|
103
103
|
if (
|
|
@@ -131,7 +131,7 @@ class FallbackModule extends Module {
|
|
|
131
131
|
* @returns {CodeGenerationResult} result
|
|
132
132
|
*/
|
|
133
133
|
codeGeneration({ runtimeTemplate, moduleGraph, chunkGraph }) {
|
|
134
|
-
const ids = this.dependencies.map(dep =>
|
|
134
|
+
const ids = this.dependencies.map((dep) =>
|
|
135
135
|
chunkGraph.getModuleId(/** @type {Module} */ (moduleGraph.getModule(dep)))
|
|
136
136
|
);
|
|
137
137
|
const code = Template.asString([
|
|
@@ -31,19 +31,19 @@ class HoistContainerReferences {
|
|
|
31
31
|
* @param {Compiler} compiler The webpack compiler instance.
|
|
32
32
|
*/
|
|
33
33
|
apply(compiler) {
|
|
34
|
-
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
|
34
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
35
35
|
const hooks =
|
|
36
36
|
getModuleFederationPlugin().getCompilationHooks(compilation);
|
|
37
37
|
const depsToTrace = new Set();
|
|
38
38
|
const entryExternalsToHoist = new Set();
|
|
39
|
-
hooks.addContainerEntryDependency.tap(PLUGIN_NAME, dep => {
|
|
39
|
+
hooks.addContainerEntryDependency.tap(PLUGIN_NAME, (dep) => {
|
|
40
40
|
depsToTrace.add(dep);
|
|
41
41
|
});
|
|
42
|
-
hooks.addFederationRuntimeDependency.tap(PLUGIN_NAME, dep => {
|
|
42
|
+
hooks.addFederationRuntimeDependency.tap(PLUGIN_NAME, (dep) => {
|
|
43
43
|
depsToTrace.add(dep);
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
compilation.hooks.addEntry.tap(PLUGIN_NAME, entryDep => {
|
|
46
|
+
compilation.hooks.addEntry.tap(PLUGIN_NAME, (entryDep) => {
|
|
47
47
|
if (entryDep.type === "entry") {
|
|
48
48
|
entryExternalsToHoist.add(entryDep);
|
|
49
49
|
}
|
|
@@ -56,7 +56,7 @@ class HoistContainerReferences {
|
|
|
56
56
|
// advanced stage is where SplitChunksPlugin runs.
|
|
57
57
|
stage: STAGE_ADVANCED + 1
|
|
58
58
|
},
|
|
59
|
-
_chunks => {
|
|
59
|
+
(_chunks) => {
|
|
60
60
|
this.hoistModulesInChunks(
|
|
61
61
|
compilation,
|
|
62
62
|
depsToTrace,
|
|
@@ -92,7 +92,7 @@ class HoistContainerReferences {
|
|
|
92
92
|
const runtimes = new Set();
|
|
93
93
|
|
|
94
94
|
for (const runtimeSpec of containerRuntimes) {
|
|
95
|
-
forEachRuntime(runtimeSpec, runtimeKey => {
|
|
95
|
+
forEachRuntime(runtimeSpec, (runtimeKey) => {
|
|
96
96
|
if (runtimeKey) {
|
|
97
97
|
runtimes.add(runtimeKey);
|
|
98
98
|
}
|
|
@@ -139,7 +139,7 @@ class HoistContainerReferences {
|
|
|
139
139
|
const runtimes = new Set();
|
|
140
140
|
|
|
141
141
|
for (const runtimeSpec of containerRuntimes) {
|
|
142
|
-
forEachRuntime(runtimeSpec, runtimeKey => {
|
|
142
|
+
forEachRuntime(runtimeSpec, (runtimeKey) => {
|
|
143
143
|
if (runtimeKey) {
|
|
144
144
|
runtimes.add(runtimeKey);
|
|
145
145
|
}
|
package/lib/container/options.js
CHANGED
|
@@ -28,7 +28,7 @@ const process = (options, normalizeSimple, normalizeOptions, fn) => {
|
|
|
28
28
|
/**
|
|
29
29
|
* @param {(string | Item<T>)[]} items items
|
|
30
30
|
*/
|
|
31
|
-
const array = items => {
|
|
31
|
+
const array = (items) => {
|
|
32
32
|
for (const item of items) {
|
|
33
33
|
if (typeof item === "string") {
|
|
34
34
|
fn(item, normalizeSimple(item, item));
|
|
@@ -42,7 +42,7 @@ const process = (options, normalizeSimple, normalizeOptions, fn) => {
|
|
|
42
42
|
/**
|
|
43
43
|
* @param {Item<T>} obj an object
|
|
44
44
|
*/
|
|
45
|
-
const object = obj => {
|
|
45
|
+
const object = (obj) => {
|
|
46
46
|
for (const [key, value] of Object.entries(obj)) {
|
|
47
47
|
if (typeof value === "string" || Array.isArray(value)) {
|
|
48
48
|
fn(key, normalizeSimple(value, key));
|
|
@@ -90,8 +90,8 @@ const scope = (scope, options) => {
|
|
|
90
90
|
const obj = {};
|
|
91
91
|
process(
|
|
92
92
|
options,
|
|
93
|
-
item => /** @type {string | string[] | T} */ (item),
|
|
94
|
-
item => /** @type {string | string[] | T} */ (item),
|
|
93
|
+
(item) => /** @type {string | string[] | T} */ (item),
|
|
94
|
+
(item) => /** @type {string | string[] | T} */ (item),
|
|
95
95
|
(key, value) => {
|
|
96
96
|
obj[
|
|
97
97
|
key.startsWith("./") ? `${scope}${key.slice(1)}` : `${scope}/${key}`
|
package/lib/css/CssGenerator.js
CHANGED
|
@@ -18,6 +18,7 @@ const {
|
|
|
18
18
|
} = require("../ModuleSourceTypesConstants");
|
|
19
19
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
20
20
|
const Template = require("../Template");
|
|
21
|
+
const memoize = require("../util/memoize");
|
|
21
22
|
|
|
22
23
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
23
24
|
/** @typedef {import("../../declarations/WebpackOptions").CssAutoGeneratorOptions} CssAutoGeneratorOptions */
|
|
@@ -37,6 +38,8 @@ const Template = require("../Template");
|
|
|
37
38
|
/** @typedef {import("../NormalModule")} NormalModule */
|
|
38
39
|
/** @typedef {import("../util/Hash")} Hash */
|
|
39
40
|
|
|
41
|
+
const getPropertyName = memoize(() => require("../util/propertyName"));
|
|
42
|
+
|
|
40
43
|
class CssGenerator extends Generator {
|
|
41
44
|
/**
|
|
42
45
|
* @param {CssAutoGeneratorOptions | CssGlobalGeneratorOptions | CssModuleGeneratorOptions} options options
|
|
@@ -119,7 +122,7 @@ class CssGenerator extends Generator {
|
|
|
119
122
|
/**
|
|
120
123
|
* @param {Dependency} dependency dependency
|
|
121
124
|
*/
|
|
122
|
-
const handleDependency = dependency => {
|
|
125
|
+
const handleDependency = (dependency) => {
|
|
123
126
|
const constructor =
|
|
124
127
|
/** @type {new (...args: EXPECTED_ANY[]) => Dependency} */
|
|
125
128
|
(dependency.constructor);
|
|
@@ -147,6 +150,7 @@ class CssGenerator extends Generator {
|
|
|
147
150
|
if (generateContext.concatenationScope) {
|
|
148
151
|
const source = new ConcatSource();
|
|
149
152
|
const usedIdentifiers = new Set();
|
|
153
|
+
const { RESERVED_IDENTIFIER } = getPropertyName();
|
|
150
154
|
for (const [name, v] of cssData.exports) {
|
|
151
155
|
const usedName = generateContext.moduleGraph
|
|
152
156
|
.getExportInfo(module, name)
|
|
@@ -156,8 +160,6 @@ class CssGenerator extends Generator {
|
|
|
156
160
|
}
|
|
157
161
|
let identifier = Template.toIdentifier(usedName);
|
|
158
162
|
|
|
159
|
-
const { RESERVED_IDENTIFIER } = require("../util/propertyName");
|
|
160
|
-
|
|
161
163
|
if (RESERVED_IDENTIFIER.has(identifier)) {
|
|
162
164
|
identifier = `_${identifier}`;
|
|
163
165
|
}
|
|
@@ -181,7 +181,7 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
|
|
181
181
|
stateExpression ? `${stateExpression} = ${stateExpression} || ` : ""
|
|
182
182
|
}{`,
|
|
183
183
|
Template.indent(
|
|
184
|
-
Array.from(initialChunkIds, id => `${JSON.stringify(id)}: 0`).join(
|
|
184
|
+
Array.from(initialChunkIds, (id) => `${JSON.stringify(id)}: 0`).join(
|
|
185
185
|
",\n"
|
|
186
186
|
)
|
|
187
187
|
),
|
|
@@ -98,7 +98,7 @@ const getCssLoadingRuntimeModule = memoize(() =>
|
|
|
98
98
|
* @param {string} name name
|
|
99
99
|
* @returns {{ oneOf: [{ $ref: string }], definitions: import("../../schemas/WebpackOptions.json")["definitions"] }} schema
|
|
100
100
|
*/
|
|
101
|
-
const getSchema = name => {
|
|
101
|
+
const getSchema = (name) => {
|
|
102
102
|
const { definitions } = require("../../schemas/WebpackOptions.json");
|
|
103
103
|
|
|
104
104
|
return {
|
|
@@ -264,7 +264,7 @@ class CssModulesPlugin {
|
|
|
264
264
|
]) {
|
|
265
265
|
normalModuleFactory.hooks.createParser
|
|
266
266
|
.for(type)
|
|
267
|
-
.tap(PLUGIN_NAME, parserOptions => {
|
|
267
|
+
.tap(PLUGIN_NAME, (parserOptions) => {
|
|
268
268
|
validateParserOptions[type](parserOptions);
|
|
269
269
|
const { url, import: importOption, namedExports } = parserOptions;
|
|
270
270
|
|
|
@@ -300,7 +300,7 @@ class CssModulesPlugin {
|
|
|
300
300
|
});
|
|
301
301
|
normalModuleFactory.hooks.createGenerator
|
|
302
302
|
.for(type)
|
|
303
|
-
.tap(PLUGIN_NAME, generatorOptions => {
|
|
303
|
+
.tap(PLUGIN_NAME, (generatorOptions) => {
|
|
304
304
|
validateGeneratorOptions[type](generatorOptions);
|
|
305
305
|
|
|
306
306
|
return new CssGenerator(
|
|
@@ -442,7 +442,7 @@ class CssModulesPlugin {
|
|
|
442
442
|
compilation.hooks.chunkHash.tap(PLUGIN_NAME, (chunk, hash, context) => {
|
|
443
443
|
hooks.chunkHash.call(chunk, hash, context);
|
|
444
444
|
});
|
|
445
|
-
compilation.hooks.contentHash.tap(PLUGIN_NAME, chunk => {
|
|
445
|
+
compilation.hooks.contentHash.tap(PLUGIN_NAME, (chunk) => {
|
|
446
446
|
const {
|
|
447
447
|
chunkGraph,
|
|
448
448
|
codeGenerationResults,
|
|
@@ -533,7 +533,7 @@ class CssModulesPlugin {
|
|
|
533
533
|
* @param {Chunk} chunk the chunk
|
|
534
534
|
* @returns {boolean} true, when enabled
|
|
535
535
|
*/
|
|
536
|
-
const isEnabledForChunk = chunk => {
|
|
536
|
+
const isEnabledForChunk = (chunk) => {
|
|
537
537
|
const options = chunk.getEntryOptions();
|
|
538
538
|
const chunkLoading =
|
|
539
539
|
options && options.chunkLoading !== undefined
|
|
@@ -566,7 +566,7 @@ class CssModulesPlugin {
|
|
|
566
566
|
if (
|
|
567
567
|
!chunkGraph.hasModuleInGraph(
|
|
568
568
|
chunk,
|
|
569
|
-
m =>
|
|
569
|
+
(m) =>
|
|
570
570
|
m.type === CSS_MODULE_TYPE ||
|
|
571
571
|
m.type === CSS_MODULE_TYPE_GLOBAL ||
|
|
572
572
|
m.type === CSS_MODULE_TYPE_MODULE ||
|
|
@@ -587,7 +587,7 @@ class CssModulesPlugin {
|
|
|
587
587
|
if (
|
|
588
588
|
!chunkGraph.hasModuleInGraph(
|
|
589
589
|
chunk,
|
|
590
|
-
m =>
|
|
590
|
+
(m) =>
|
|
591
591
|
m.type === CSS_MODULE_TYPE ||
|
|
592
592
|
m.type === CSS_MODULE_TYPE_GLOBAL ||
|
|
593
593
|
m.type === CSS_MODULE_TYPE_MODULE ||
|
|
@@ -617,21 +617,24 @@ class CssModulesPlugin {
|
|
|
617
617
|
|
|
618
618
|
// Get ordered list of modules per chunk group
|
|
619
619
|
// Lists are in reverse order to allow to use Array.pop()
|
|
620
|
-
const modulesByChunkGroup = Array.from(
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
(
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
620
|
+
const modulesByChunkGroup = Array.from(
|
|
621
|
+
chunk.groupsIterable,
|
|
622
|
+
(chunkGroup) => {
|
|
623
|
+
const sortedModules = modulesList
|
|
624
|
+
.map((module) => ({
|
|
625
|
+
module,
|
|
626
|
+
index: chunkGroup.getModulePostOrderIndex(module)
|
|
627
|
+
}))
|
|
628
|
+
.filter((item) => item.index !== undefined)
|
|
629
|
+
.sort(
|
|
630
|
+
(a, b) =>
|
|
631
|
+
/** @type {number} */ (b.index) - /** @type {number} */ (a.index)
|
|
632
|
+
)
|
|
633
|
+
.map((item) => item.module);
|
|
634
|
+
|
|
635
|
+
return { list: sortedModules, set: new Set(sortedModules) };
|
|
636
|
+
}
|
|
637
|
+
);
|
|
635
638
|
|
|
636
639
|
if (modulesByChunkGroup.length === 1) {
|
|
637
640
|
return modulesByChunkGroup[0].list.reverse();
|
package/lib/css/CssParser.js
CHANGED
|
@@ -76,7 +76,7 @@ const normalizeUrl = (str, isString) => {
|
|
|
76
76
|
// Remove unnecessary spaces from `url(" img.png ")`
|
|
77
77
|
.replace(TRIM_WHITE_SPACES, "")
|
|
78
78
|
// Unescape
|
|
79
|
-
.replace(UNESCAPE, match => {
|
|
79
|
+
.replace(UNESCAPE, (match) => {
|
|
80
80
|
if (match.length > 2) {
|
|
81
81
|
return String.fromCharCode(Number.parseInt(match.slice(1).trim(), 16));
|
|
82
82
|
}
|
|
@@ -108,7 +108,7 @@ const regexExcessiveSpaces =
|
|
|
108
108
|
* @param {string} str string
|
|
109
109
|
* @returns {string} escaped identifier
|
|
110
110
|
*/
|
|
111
|
-
const escapeIdentifier = str => {
|
|
111
|
+
const escapeIdentifier = (str) => {
|
|
112
112
|
let output = "";
|
|
113
113
|
let counter = 0;
|
|
114
114
|
|
|
@@ -161,7 +161,7 @@ const CONTAINS_ESCAPE = /\\/;
|
|
|
161
161
|
* @param {string} str string
|
|
162
162
|
* @returns {[string, number] | undefined} hex
|
|
163
163
|
*/
|
|
164
|
-
const gobbleHex = str => {
|
|
164
|
+
const gobbleHex = (str) => {
|
|
165
165
|
const lower = str.toLowerCase();
|
|
166
166
|
let hex = "";
|
|
167
167
|
let spaceTerminated = false;
|
|
@@ -198,7 +198,7 @@ const gobbleHex = str => {
|
|
|
198
198
|
* @param {string} str string
|
|
199
199
|
* @returns {string} unescaped string
|
|
200
200
|
*/
|
|
201
|
-
const unescapeIdentifier = str => {
|
|
201
|
+
const unescapeIdentifier = (str) => {
|
|
202
202
|
const needToProcess = CONTAINS_ESCAPE.test(str);
|
|
203
203
|
if (!needToProcess) return str;
|
|
204
204
|
let ret = "";
|
|
@@ -646,7 +646,7 @@ class CssParser extends Parser {
|
|
|
646
646
|
/**
|
|
647
647
|
* @param {string} input input
|
|
648
648
|
*/
|
|
649
|
-
const processDeclarationValueDone = input => {
|
|
649
|
+
const processDeclarationValueDone = (input) => {
|
|
650
650
|
if (inAnimationProperty && lastIdentifier) {
|
|
651
651
|
const { line: sl, column: sc } = locConverter.get(lastIdentifier[0]);
|
|
652
652
|
const { line: el, column: ec } = locConverter.get(lastIdentifier[1]);
|