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
package/lib/CleanPlugin.js
CHANGED
|
@@ -72,7 +72,7 @@ function getDirectories(assets) {
|
|
|
72
72
|
/**
|
|
73
73
|
* @param {string} filename asset filename
|
|
74
74
|
*/
|
|
75
|
-
const addDirectory = filename => {
|
|
75
|
+
const addDirectory = (filename) => {
|
|
76
76
|
directories.add(path.dirname(filename));
|
|
77
77
|
};
|
|
78
78
|
|
|
@@ -87,38 +87,6 @@ function getDirectories(assets) {
|
|
|
87
87
|
return directories;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
/**
|
|
91
|
-
* @param {string} a First directory path to compare
|
|
92
|
-
* @param {string} b Second directory path to compare
|
|
93
|
-
* @returns {boolean} True if both paths have the same parent directory
|
|
94
|
-
*/
|
|
95
|
-
function isEqualPath(a, b) {
|
|
96
|
-
return path.normalize(a) === path.normalize(b);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* @param {Map<string, number>|Set<string>} files Collection of files to check against
|
|
101
|
-
* @param {string} file File path to check
|
|
102
|
-
* @returns {boolean} True if the file or its parent exists in the collection
|
|
103
|
-
*/
|
|
104
|
-
function hasFile(files, file) {
|
|
105
|
-
if (files instanceof Set) {
|
|
106
|
-
for (const dir of files) {
|
|
107
|
-
if (isEqualPath(dir, file)) {
|
|
108
|
-
return true;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
if (files instanceof Map) {
|
|
113
|
-
for (const dir of files.keys()) {
|
|
114
|
-
if (isEqualPath(dir, file)) {
|
|
115
|
-
return true;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
90
|
/** @typedef {Set<string>} Diff */
|
|
123
91
|
|
|
124
92
|
/**
|
|
@@ -147,18 +115,18 @@ const getDiffToFs = (fs, outputPath, currentAssets, callback) => {
|
|
|
147
115
|
}
|
|
148
116
|
for (const entry of /** @type {string[]} */ (entries)) {
|
|
149
117
|
const file = entry;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
) {
|
|
118
|
+
// Since path.normalize("./file") === path.normalize("file"),
|
|
119
|
+
// return file directly when directory === "."
|
|
120
|
+
const filename =
|
|
121
|
+
directory && directory !== "." ? `${directory}/${file}` : file;
|
|
122
|
+
if (!directories.has(filename) && !currentAssets.has(filename)) {
|
|
155
123
|
diff.add(filename);
|
|
156
124
|
}
|
|
157
125
|
}
|
|
158
126
|
callback();
|
|
159
127
|
});
|
|
160
128
|
},
|
|
161
|
-
err => {
|
|
129
|
+
(err) => {
|
|
162
130
|
if (err) return callback(err);
|
|
163
131
|
|
|
164
132
|
callback(null, diff);
|
|
@@ -210,7 +178,7 @@ const applyDiff = (fs, outputPath, dry, logger, diff, isKept, callback) => {
|
|
|
210
178
|
/**
|
|
211
179
|
* @param {string} msg message
|
|
212
180
|
*/
|
|
213
|
-
const log = msg => {
|
|
181
|
+
const log = (msg) => {
|
|
214
182
|
if (dry) {
|
|
215
183
|
logger.info(msg);
|
|
216
184
|
} else {
|
|
@@ -219,7 +187,7 @@ const applyDiff = (fs, outputPath, dry, logger, diff, isKept, callback) => {
|
|
|
219
187
|
};
|
|
220
188
|
/** @typedef {{ type: "check" | "unlink" | "rmdir", filename: string, parent: { remaining: number, job: Job } | undefined }} Job */
|
|
221
189
|
/** @type {Job[]} */
|
|
222
|
-
const jobs = Array.from(diff.keys(), filename => ({
|
|
190
|
+
const jobs = Array.from(diff.keys(), (filename) => ({
|
|
223
191
|
type: "check",
|
|
224
192
|
filename,
|
|
225
193
|
parent: undefined
|
|
@@ -235,15 +203,15 @@ const applyDiff = (fs, outputPath, dry, logger, diff, isKept, callback) => {
|
|
|
235
203
|
* @param {Error & { code?: string }} err error
|
|
236
204
|
* @returns {void}
|
|
237
205
|
*/
|
|
238
|
-
const handleError = err => {
|
|
206
|
+
const handleError = (err) => {
|
|
239
207
|
const isAlreadyRemoved = () =>
|
|
240
|
-
new Promise(resolve => {
|
|
208
|
+
new Promise((resolve) => {
|
|
241
209
|
if (err.code === "ENOENT") {
|
|
242
210
|
resolve(true);
|
|
243
211
|
} else if (err.code === "EPERM") {
|
|
244
212
|
// https://github.com/isaacs/rimraf/blob/main/src/fix-eperm.ts#L37
|
|
245
213
|
// fs.existsSync(path) === false https://github.com/webpack/webpack/actions/runs/15493412975/job/43624272783?pr=19586
|
|
246
|
-
doStat(fs, path, err => {
|
|
214
|
+
doStat(fs, path, (err) => {
|
|
247
215
|
if (err) {
|
|
248
216
|
resolve(err.code === "ENOENT");
|
|
249
217
|
} else {
|
|
@@ -255,7 +223,7 @@ const applyDiff = (fs, outputPath, dry, logger, diff, isKept, callback) => {
|
|
|
255
223
|
}
|
|
256
224
|
});
|
|
257
225
|
|
|
258
|
-
isAlreadyRemoved().then(isRemoved => {
|
|
226
|
+
isAlreadyRemoved().then((isRemoved) => {
|
|
259
227
|
if (isRemoved) {
|
|
260
228
|
log(`${filename} was removed during cleaning by something else`);
|
|
261
229
|
handleParent();
|
|
@@ -334,7 +302,7 @@ const applyDiff = (fs, outputPath, dry, logger, diff, isKept, callback) => {
|
|
|
334
302
|
);
|
|
335
303
|
return process.nextTick(callback);
|
|
336
304
|
}
|
|
337
|
-
fs.rmdir(path, err => {
|
|
305
|
+
fs.rmdir(path, (err) => {
|
|
338
306
|
if (err) return handleError(err);
|
|
339
307
|
handleParent();
|
|
340
308
|
callback();
|
|
@@ -352,7 +320,7 @@ const applyDiff = (fs, outputPath, dry, logger, diff, isKept, callback) => {
|
|
|
352
320
|
);
|
|
353
321
|
return process.nextTick(callback);
|
|
354
322
|
}
|
|
355
|
-
fs.unlink(path, err => {
|
|
323
|
+
fs.unlink(path, (err) => {
|
|
356
324
|
if (err) return handleError(err);
|
|
357
325
|
handleParent();
|
|
358
326
|
callback();
|
|
@@ -360,7 +328,7 @@ const applyDiff = (fs, outputPath, dry, logger, diff, isKept, callback) => {
|
|
|
360
328
|
break;
|
|
361
329
|
}
|
|
362
330
|
},
|
|
363
|
-
err => {
|
|
331
|
+
(err) => {
|
|
364
332
|
if (err) return callback(err);
|
|
365
333
|
callback(undefined, keptAssets);
|
|
366
334
|
}
|
|
@@ -412,9 +380,9 @@ class CleanPlugin {
|
|
|
412
380
|
typeof keep === "function"
|
|
413
381
|
? keep
|
|
414
382
|
: typeof keep === "string"
|
|
415
|
-
? path => path.startsWith(keep)
|
|
383
|
+
? (path) => path.startsWith(keep)
|
|
416
384
|
: typeof keep === "object" && keep.test
|
|
417
|
-
? path => keep.test(path)
|
|
385
|
+
? (path) => keep.test(path)
|
|
418
386
|
: () => false;
|
|
419
387
|
|
|
420
388
|
// We assume that no external modification happens while the compiler is active
|
|
@@ -470,7 +438,7 @@ class CleanPlugin {
|
|
|
470
438
|
* @param {string} path path
|
|
471
439
|
* @returns {boolean | void} true, if needs to be kept
|
|
472
440
|
*/
|
|
473
|
-
const isKept = path => {
|
|
441
|
+
const isKept = (path) => {
|
|
474
442
|
const result = hooks.keep.call(path);
|
|
475
443
|
if (result !== undefined) return result;
|
|
476
444
|
return keepFn(path);
|
|
@@ -518,5 +486,3 @@ class CleanPlugin {
|
|
|
518
486
|
|
|
519
487
|
module.exports = CleanPlugin;
|
|
520
488
|
module.exports._getDirectories = getDirectories;
|
|
521
|
-
module.exports._hasFile = hasFile;
|
|
522
|
-
module.exports._isEqualPath = isEqualPath;
|
|
@@ -39,7 +39,7 @@ class CodeGenerationResults {
|
|
|
39
39
|
throw new Error(
|
|
40
40
|
`No code generation entry for ${module.identifier()} (existing entries: ${Array.from(
|
|
41
41
|
this.map.keys(),
|
|
42
|
-
m => m.identifier()
|
|
42
|
+
(m) => m.identifier()
|
|
43
43
|
).join(", ")})`
|
|
44
44
|
);
|
|
45
45
|
}
|
|
@@ -50,7 +50,7 @@ class CodeGenerationResults {
|
|
|
50
50
|
throw new Error(
|
|
51
51
|
`No unique code generation entry for unspecified runtime for ${module.identifier()} (existing runtimes: ${Array.from(
|
|
52
52
|
entry.keys(),
|
|
53
|
-
r => runtimeToString(r)
|
|
53
|
+
(r) => runtimeToString(r)
|
|
54
54
|
).join(", ")}).
|
|
55
55
|
Caller might not support runtime-dependent code generation (opt-out via optimization.usedExports: "global").`
|
|
56
56
|
);
|
|
@@ -66,7 +66,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|
|
66
66
|
runtime
|
|
67
67
|
)} for ${module.identifier()} (existing runtimes: ${Array.from(
|
|
68
68
|
entry.keys(),
|
|
69
|
-
r => runtimeToString(r)
|
|
69
|
+
(r) => runtimeToString(r)
|
|
70
70
|
).join(", ")})`
|
|
71
71
|
);
|
|
72
72
|
}
|
|
@@ -54,7 +54,7 @@ class CompatibilityPlugin {
|
|
|
54
54
|
* @param {CallExpression} expr call expression
|
|
55
55
|
* @returns {boolean | void} true when need to handle
|
|
56
56
|
*/
|
|
57
|
-
expr => {
|
|
57
|
+
(expr) => {
|
|
58
58
|
// support for browserify style require delegator: "require(o, !0)"
|
|
59
59
|
if (expr.arguments.length !== 2) return;
|
|
60
60
|
const second = parser.evaluateExpression(expr.arguments[1]);
|
|
@@ -90,9 +90,9 @@ class CompatibilityPlugin {
|
|
|
90
90
|
* @param {JavascriptParser} parser the parser
|
|
91
91
|
* @returns {void}
|
|
92
92
|
*/
|
|
93
|
-
const handler = parser => {
|
|
93
|
+
const handler = (parser) => {
|
|
94
94
|
// Handle nested requires
|
|
95
|
-
parser.hooks.preStatement.tap(PLUGIN_NAME, statement => {
|
|
95
|
+
parser.hooks.preStatement.tap(PLUGIN_NAME, (statement) => {
|
|
96
96
|
if (
|
|
97
97
|
statement.type === "FunctionDeclaration" &&
|
|
98
98
|
statement.id &&
|
|
@@ -118,7 +118,7 @@ class CompatibilityPlugin {
|
|
|
118
118
|
});
|
|
119
119
|
parser.hooks.pattern
|
|
120
120
|
.for(RuntimeGlobals.require)
|
|
121
|
-
.tap(PLUGIN_NAME, pattern => {
|
|
121
|
+
.tap(PLUGIN_NAME, (pattern) => {
|
|
122
122
|
const newName = `__nested_webpack_require_${
|
|
123
123
|
/** @type {Range} */ (pattern.range)[0]
|
|
124
124
|
}__`;
|
|
@@ -134,7 +134,7 @@ class CompatibilityPlugin {
|
|
|
134
134
|
});
|
|
135
135
|
parser.hooks.pattern
|
|
136
136
|
.for(RuntimeGlobals.exports)
|
|
137
|
-
.tap(PLUGIN_NAME, pattern => {
|
|
137
|
+
.tap(PLUGIN_NAME, (pattern) => {
|
|
138
138
|
parser.tagVariable(pattern.name, nestedWebpackIdentifierTag, {
|
|
139
139
|
name: "__nested_webpack_exports__",
|
|
140
140
|
declaration: {
|
|
@@ -147,7 +147,7 @@ class CompatibilityPlugin {
|
|
|
147
147
|
});
|
|
148
148
|
parser.hooks.expression
|
|
149
149
|
.for(nestedWebpackIdentifierTag)
|
|
150
|
-
.tap(PLUGIN_NAME, expr => {
|
|
150
|
+
.tap(PLUGIN_NAME, (expr) => {
|
|
151
151
|
const { name, declaration } =
|
|
152
152
|
/** @type {TagData} */
|
|
153
153
|
(parser.currentTagData);
|