webpack 5.99.6 → 5.99.7
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/lib/AutomaticPrefetchPlugin.js +21 -22
- package/lib/BannerPlugin.js +31 -35
- package/lib/CleanPlugin.js +5 -3
- package/lib/Compilation.js +9 -8
- package/lib/Compiler.js +2 -1
- package/lib/ContextExclusionPlugin.js +4 -2
- package/lib/ContextReplacementPlugin.js +5 -3
- package/lib/DelegatedPlugin.js +4 -2
- package/lib/DllEntryPlugin.js +4 -2
- package/lib/DllPlugin.js +5 -3
- package/lib/DllReferencePlugin.js +56 -60
- package/lib/DynamicEntryPlugin.js +4 -2
- package/lib/EntryOptionPlugin.js +3 -1
- package/lib/EntryPlugin.js +4 -2
- package/lib/EnvironmentPlugin.js +4 -2
- package/lib/EvalDevToolModulePlugin.js +9 -7
- package/lib/EvalSourceMapDevToolPlugin.js +137 -138
- package/lib/ExternalsPlugin.js +3 -1
- package/lib/FlagDependencyExportsPlugin.js +2 -1
- package/lib/IgnorePlugin.js +6 -4
- package/lib/IgnoreWarningsPlugin.js +4 -2
- package/lib/LibManifestPlugin.js +3 -4
- package/lib/LoaderOptionsPlugin.js +4 -2
- package/lib/LoaderTargetPlugin.js +4 -2
- package/lib/Module.js +19 -12
- package/lib/ModuleInfoHeaderPlugin.js +11 -12
- package/lib/MultiCompiler.js +5 -3
- package/lib/NoEmitOnErrorsPlugin.js +5 -3
- package/lib/NormalModule.js +5 -1
- package/lib/NormalModuleReplacementPlugin.js +33 -36
- package/lib/PlatformPlugin.js +3 -1
- package/lib/PrefetchPlugin.js +4 -2
- package/lib/ProgressPlugin.js +23 -26
- package/lib/RecordIdsPlugin.js +72 -102
- package/lib/RuntimePlugin.js +34 -32
- package/lib/SourceMapDevToolPlugin.js +7 -5
- package/lib/WarnCaseSensitiveModulesPlugin.js +36 -37
- package/lib/WarnNoModeSetPlugin.js +3 -1
- package/lib/WatchIgnorePlugin.js +3 -1
- package/lib/WebpackError.js +11 -3
- package/lib/WebpackOptionsApply.js +5 -3
- package/lib/async-modules/InferAsyncModulesPlugin.js +25 -26
- package/lib/cache/IdleFileCachePlugin.js +11 -12
- package/lib/cache/MemoryWithGcCachePlugin.js +7 -5
- package/lib/cache/ResolverCachePlugin.js +8 -6
- package/lib/cli.js +5 -1
- package/lib/config/normalization.js +9 -3
- package/lib/container/ContainerReferencePlugin.js +24 -26
- package/lib/container/ModuleFederationPlugin.js +2 -1
- package/lib/css/CssGenerator.js +1 -1
- package/lib/css/CssModulesPlugin.js +6 -4
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +9 -15
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +15 -15
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +4 -2
- package/lib/dependencies/LoaderPlugin.js +5 -3
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +46 -46
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +94 -100
- package/lib/esm/ModuleChunkLoadingPlugin.js +72 -73
- package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +0 -1
- package/lib/hmr/LazyCompilationPlugin.js +17 -18
- package/lib/ids/ChunkModuleIdRangePlugin.js +6 -6
- package/lib/ids/DeterministicModuleIdsPlugin.js +47 -48
- package/lib/ids/HashedModuleIdsPlugin.js +4 -2
- package/lib/ids/NamedChunkIdsPlugin.js +4 -2
- package/lib/ids/NamedModuleIdsPlugin.js +4 -2
- package/lib/ids/NaturalChunkIdsPlugin.js +4 -2
- package/lib/ids/NaturalModuleIdsPlugin.js +4 -2
- package/lib/ids/OccurrenceChunkIdsPlugin.js +4 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +4 -2
- package/lib/javascript/JavascriptParser.js +634 -656
- package/lib/library/ModuleLibraryPlugin.js +60 -42
- package/lib/node/CommonJsChunkLoadingPlugin.js +69 -73
- package/lib/node/NodeEnvironmentPlugin.js +3 -1
- package/lib/optimize/AggressiveSplittingPlugin.js +224 -232
- package/lib/optimize/ConcatenatedModule.js +12 -15
- package/lib/optimize/FlagIncludedChunksPlugin.js +92 -97
- package/lib/optimize/LimitChunkCountPlugin.js +4 -2
- package/lib/optimize/MangleExportsPlugin.js +15 -16
- package/lib/optimize/MinChunkSizePlugin.js +4 -2
- package/lib/optimize/ModuleConcatenationPlugin.js +4 -2
- package/lib/optimize/RealContentHashPlugin.js +4 -2
- package/lib/optimize/RemoveEmptyChunksPlugin.js +5 -3
- package/lib/optimize/RemoveParentModulesPlugin.js +4 -2
- package/lib/optimize/RuntimeChunkPlugin.js +17 -18
- package/lib/optimize/SplitChunksPlugin.js +7 -5
- package/lib/performance/SizeLimitsPlugin.js +3 -1
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +61 -62
- package/lib/runtime/StartupChunkDependenciesPlugin.js +39 -42
- package/lib/schemes/DataUriPlugin.js +5 -3
- package/lib/schemes/FileUriPlugin.js +5 -3
- package/lib/schemes/HttpUriPlugin.js +32 -39
- package/lib/serialization/AggregateErrorSerializer.js +42 -0
- package/lib/serialization/ErrorObjectSerializer.js +7 -2
- package/lib/serialization/ObjectMiddleware.js +13 -0
- package/lib/sharing/ProvideSharedPlugin.js +6 -4
- package/lib/stats/DefaultStatsFactoryPlugin.js +89 -33
- package/lib/stats/DefaultStatsPresetPlugin.js +25 -20
- package/lib/stats/DefaultStatsPrinterPlugin.js +306 -341
- package/lib/util/concatenate.js +4 -2
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +55 -57
- package/lib/web/JsonpChunkLoadingPlugin.js +73 -74
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +77 -78
- package/package.json +4 -3
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +24 -2
- package/types.d.ts +148 -55
@@ -35,6 +35,8 @@ const devtoolWarning = new RawSource(`/*
|
|
35
35
|
* @property {OutputOptions["devtoolModuleFilenameTemplate"]=} moduleFilenameTemplate module filename template
|
36
36
|
*/
|
37
37
|
|
38
|
+
const PLUGIN_NAME = "EvalDevToolModulePlugin";
|
39
|
+
|
38
40
|
class EvalDevToolModulePlugin {
|
39
41
|
/**
|
40
42
|
* @param {EvalDevToolModulePluginOptions=} options options
|
@@ -53,10 +55,10 @@ class EvalDevToolModulePlugin {
|
|
53
55
|
* @returns {void}
|
54
56
|
*/
|
55
57
|
apply(compiler) {
|
56
|
-
compiler.hooks.compilation.tap(
|
58
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
57
59
|
const hooks = JavascriptModulesPlugin.getCompilationHooks(compilation);
|
58
60
|
hooks.renderModuleContent.tap(
|
59
|
-
|
61
|
+
PLUGIN_NAME,
|
60
62
|
(source, module, { chunk, runtimeTemplate, chunkGraph }) => {
|
61
63
|
const cacheEntry = cache.get(source);
|
62
64
|
if (cacheEntry !== undefined) return cacheEntry;
|
@@ -103,20 +105,20 @@ class EvalDevToolModulePlugin {
|
|
103
105
|
}
|
104
106
|
);
|
105
107
|
hooks.inlineInRuntimeBailout.tap(
|
106
|
-
|
108
|
+
PLUGIN_NAME,
|
107
109
|
() => "the eval devtool is used."
|
108
110
|
);
|
109
111
|
hooks.render.tap(
|
110
|
-
|
112
|
+
PLUGIN_NAME,
|
111
113
|
source => new ConcatSource(devtoolWarning, source)
|
112
114
|
);
|
113
|
-
hooks.chunkHash.tap(
|
114
|
-
hash.update(
|
115
|
+
hooks.chunkHash.tap(PLUGIN_NAME, (chunk, hash) => {
|
116
|
+
hash.update(PLUGIN_NAME);
|
115
117
|
hash.update("2");
|
116
118
|
});
|
117
119
|
if (compilation.outputOptions.trustedTypes) {
|
118
120
|
compilation.hooks.additionalModuleRuntimeRequirements.tap(
|
119
|
-
|
121
|
+
PLUGIN_NAME,
|
120
122
|
(module, set, context) => {
|
121
123
|
set.add(RuntimeGlobals.createScript);
|
122
124
|
}
|
@@ -35,6 +35,8 @@ const devtoolWarning = new RawSource(`/*
|
|
35
35
|
*/
|
36
36
|
`);
|
37
37
|
|
38
|
+
const PLUGIN_NAME = "EvalSourceMapDevToolPlugin";
|
39
|
+
|
38
40
|
class EvalSourceMapDevToolPlugin {
|
39
41
|
/**
|
40
42
|
* @param {SourceMapDevToolPluginOptions|string} inputOptions Options object
|
@@ -67,160 +69,157 @@ class EvalSourceMapDevToolPlugin {
|
|
67
69
|
*/
|
68
70
|
apply(compiler) {
|
69
71
|
const options = this.options;
|
70
|
-
compiler.hooks.compilation.tap(
|
71
|
-
|
72
|
-
compilation
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
(
|
82
|
-
|
83
|
-
|
84
|
-
return cachedSource;
|
85
|
-
}
|
72
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
73
|
+
const hooks = JavascriptModulesPlugin.getCompilationHooks(compilation);
|
74
|
+
new SourceMapDevToolModuleOptionsPlugin(options).apply(compilation);
|
75
|
+
const matchModule = ModuleFilenameHelpers.matchObject.bind(
|
76
|
+
ModuleFilenameHelpers,
|
77
|
+
options
|
78
|
+
);
|
79
|
+
hooks.renderModuleContent.tap(
|
80
|
+
PLUGIN_NAME,
|
81
|
+
(source, m, { chunk, runtimeTemplate, chunkGraph }) => {
|
82
|
+
const cachedSource = cache.get(source);
|
83
|
+
if (cachedSource !== undefined) {
|
84
|
+
return cachedSource;
|
85
|
+
}
|
86
86
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
87
|
+
/**
|
88
|
+
* @param {Source} r result
|
89
|
+
* @returns {Source} result
|
90
|
+
*/
|
91
|
+
const result = r => {
|
92
|
+
cache.set(source, r);
|
93
|
+
return r;
|
94
|
+
};
|
95
|
+
|
96
|
+
if (m instanceof NormalModule) {
|
97
|
+
const module = /** @type {NormalModule} */ (m);
|
98
|
+
if (!matchModule(module.resource)) {
|
99
|
+
return result(source);
|
100
|
+
}
|
101
|
+
} else if (m instanceof ConcatenatedModule) {
|
102
|
+
const concatModule = /** @type {ConcatenatedModule} */ (m);
|
103
|
+
if (concatModule.rootModule instanceof NormalModule) {
|
104
|
+
const module = /** @type {NormalModule} */ (
|
105
|
+
concatModule.rootModule
|
106
|
+
);
|
98
107
|
if (!matchModule(module.resource)) {
|
99
108
|
return result(source);
|
100
109
|
}
|
101
|
-
} else if (m instanceof ConcatenatedModule) {
|
102
|
-
const concatModule = /** @type {ConcatenatedModule} */ (m);
|
103
|
-
if (concatModule.rootModule instanceof NormalModule) {
|
104
|
-
const module = /** @type {NormalModule} */ (
|
105
|
-
concatModule.rootModule
|
106
|
-
);
|
107
|
-
if (!matchModule(module.resource)) {
|
108
|
-
return result(source);
|
109
|
-
}
|
110
|
-
} else {
|
111
|
-
return result(source);
|
112
|
-
}
|
113
110
|
} else {
|
114
111
|
return result(source);
|
115
112
|
}
|
113
|
+
} else {
|
114
|
+
return result(source);
|
115
|
+
}
|
116
116
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
117
|
+
const namespace = compilation.getPath(this.namespace, {
|
118
|
+
chunk
|
119
|
+
});
|
120
|
+
/** @type {SourceMap} */
|
121
|
+
let sourceMap;
|
122
|
+
let content;
|
123
|
+
if (source.sourceAndMap) {
|
124
|
+
const sourceAndMap = source.sourceAndMap(options);
|
125
|
+
sourceMap = /** @type {SourceMap} */ (sourceAndMap.map);
|
126
|
+
content = sourceAndMap.source;
|
127
|
+
} else {
|
128
|
+
sourceMap = /** @type {SourceMap} */ (source.map(options));
|
129
|
+
content = source.source();
|
130
|
+
}
|
131
|
+
if (!sourceMap) {
|
132
|
+
return result(source);
|
133
|
+
}
|
134
134
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
}
|
157
|
-
)
|
158
|
-
);
|
159
|
-
moduleFilenames = ModuleFilenameHelpers.replaceDuplicates(
|
160
|
-
moduleFilenames,
|
161
|
-
(filename, i, n) => {
|
162
|
-
for (let j = 0; j < n; j++) filename += "*";
|
163
|
-
return filename;
|
135
|
+
// Clone (flat) the sourcemap to ensure that the mutations below do not persist.
|
136
|
+
sourceMap = { ...sourceMap };
|
137
|
+
const context = /** @type {string} */ (compiler.options.context);
|
138
|
+
const root = compiler.root;
|
139
|
+
const modules = sourceMap.sources.map(source => {
|
140
|
+
if (!source.startsWith("webpack://")) return source;
|
141
|
+
source = makePathsAbsolute(context, source.slice(10), root);
|
142
|
+
const module = compilation.findModule(source);
|
143
|
+
return module || source;
|
144
|
+
});
|
145
|
+
let moduleFilenames = modules.map(module =>
|
146
|
+
ModuleFilenameHelpers.createFilename(
|
147
|
+
module,
|
148
|
+
{
|
149
|
+
moduleFilenameTemplate: this.moduleFilenameTemplate,
|
150
|
+
namespace
|
151
|
+
},
|
152
|
+
{
|
153
|
+
requestShortener: runtimeTemplate.requestShortener,
|
154
|
+
chunkGraph,
|
155
|
+
hashFunction: compilation.outputOptions.hashFunction
|
164
156
|
}
|
165
|
-
)
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
/** @type {ModuleId} */
|
173
|
-
(chunkGraph.getModuleId(m));
|
174
|
-
sourceMap.file =
|
175
|
-
typeof moduleId === "number" ? `${moduleId}.js` : moduleId;
|
176
|
-
|
177
|
-
if (options.debugIds) {
|
178
|
-
sourceMap.debugId = generateDebugId(content, sourceMap.file);
|
157
|
+
)
|
158
|
+
);
|
159
|
+
moduleFilenames = ModuleFilenameHelpers.replaceDuplicates(
|
160
|
+
moduleFilenames,
|
161
|
+
(filename, i, n) => {
|
162
|
+
for (let j = 0; j < n; j++) filename += "*";
|
163
|
+
return filename;
|
179
164
|
}
|
165
|
+
);
|
166
|
+
sourceMap.sources = moduleFilenames;
|
167
|
+
if (options.noSources) {
|
168
|
+
sourceMap.sourcesContent = undefined;
|
169
|
+
}
|
170
|
+
sourceMap.sourceRoot = options.sourceRoot || "";
|
171
|
+
const moduleId =
|
172
|
+
/** @type {ModuleId} */
|
173
|
+
(chunkGraph.getModuleId(m));
|
174
|
+
sourceMap.file =
|
175
|
+
typeof moduleId === "number" ? `${moduleId}.js` : moduleId;
|
180
176
|
|
181
|
-
|
182
|
-
|
183
|
-
`data:application/json;charset=utf-8;base64,${Buffer.from(
|
184
|
-
JSON.stringify(sourceMap),
|
185
|
-
"utf8"
|
186
|
-
).toString("base64")}`
|
187
|
-
)}\n//# sourceURL=webpack-internal:///${moduleId}\n`; // workaround for chrome bug
|
188
|
-
|
189
|
-
return result(
|
190
|
-
new RawSource(
|
191
|
-
`eval(${
|
192
|
-
compilation.outputOptions.trustedTypes
|
193
|
-
? `${RuntimeGlobals.createScript}(${JSON.stringify(
|
194
|
-
content + footer
|
195
|
-
)})`
|
196
|
-
: JSON.stringify(content + footer)
|
197
|
-
});`
|
198
|
-
)
|
199
|
-
);
|
177
|
+
if (options.debugIds) {
|
178
|
+
sourceMap.debugId = generateDebugId(content, sourceMap.file);
|
200
179
|
}
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
180
|
+
|
181
|
+
const footer = `${this.sourceMapComment.replace(
|
182
|
+
/\[url\]/g,
|
183
|
+
`data:application/json;charset=utf-8;base64,${Buffer.from(
|
184
|
+
JSON.stringify(sourceMap),
|
185
|
+
"utf8"
|
186
|
+
).toString("base64")}`
|
187
|
+
)}\n//# sourceURL=webpack-internal:///${moduleId}\n`; // workaround for chrome bug
|
188
|
+
|
189
|
+
return result(
|
190
|
+
new RawSource(
|
191
|
+
`eval(${
|
192
|
+
compilation.outputOptions.trustedTypes
|
193
|
+
? `${RuntimeGlobals.createScript}(${JSON.stringify(
|
194
|
+
content + footer
|
195
|
+
)})`
|
196
|
+
: JSON.stringify(content + footer)
|
197
|
+
});`
|
198
|
+
)
|
220
199
|
);
|
221
200
|
}
|
201
|
+
);
|
202
|
+
hooks.inlineInRuntimeBailout.tap(
|
203
|
+
"EvalDevToolModulePlugin",
|
204
|
+
() => "the eval-source-map devtool is used."
|
205
|
+
);
|
206
|
+
hooks.render.tap(
|
207
|
+
PLUGIN_NAME,
|
208
|
+
source => new ConcatSource(devtoolWarning, source)
|
209
|
+
);
|
210
|
+
hooks.chunkHash.tap(PLUGIN_NAME, (chunk, hash) => {
|
211
|
+
hash.update(PLUGIN_NAME);
|
212
|
+
hash.update("2");
|
213
|
+
});
|
214
|
+
if (compilation.outputOptions.trustedTypes) {
|
215
|
+
compilation.hooks.additionalModuleRuntimeRequirements.tap(
|
216
|
+
PLUGIN_NAME,
|
217
|
+
(module, set, context) => {
|
218
|
+
set.add(RuntimeGlobals.createScript);
|
219
|
+
}
|
220
|
+
);
|
222
221
|
}
|
223
|
-
);
|
222
|
+
});
|
224
223
|
}
|
225
224
|
}
|
226
225
|
|
package/lib/ExternalsPlugin.js
CHANGED
@@ -10,6 +10,8 @@ const ExternalModuleFactoryPlugin = require("./ExternalModuleFactoryPlugin");
|
|
10
10
|
/** @typedef {import("../declarations/WebpackOptions").Externals} Externals */
|
11
11
|
/** @typedef {import("./Compiler")} Compiler */
|
12
12
|
|
13
|
+
const PLUGIN_NAME = "ExternalsPlugin";
|
14
|
+
|
13
15
|
class ExternalsPlugin {
|
14
16
|
/**
|
15
17
|
* @param {string | undefined} type default external type
|
@@ -26,7 +28,7 @@ class ExternalsPlugin {
|
|
26
28
|
* @returns {void}
|
27
29
|
*/
|
28
30
|
apply(compiler) {
|
29
|
-
compiler.hooks.compile.tap(
|
31
|
+
compiler.hooks.compile.tap(PLUGIN_NAME, ({ normalModuleFactory }) => {
|
30
32
|
new ExternalModuleFactoryPlugin(this.type, this.externals).apply(
|
31
33
|
normalModuleFactory
|
32
34
|
);
|
package/lib/IgnorePlugin.js
CHANGED
@@ -22,6 +22,8 @@ const validate = createSchemaValidation(
|
|
22
22
|
}
|
23
23
|
);
|
24
24
|
|
25
|
+
const PLUGIN_NAME = "IgnorePlugin";
|
26
|
+
|
25
27
|
class IgnorePlugin {
|
26
28
|
/**
|
27
29
|
* @param {IgnorePluginOptions} options IgnorePlugin options
|
@@ -69,8 +71,8 @@ class IgnorePlugin {
|
|
69
71
|
* @returns {void}
|
70
72
|
*/
|
71
73
|
apply(compiler) {
|
72
|
-
compiler.hooks.normalModuleFactory.tap(
|
73
|
-
nmf.hooks.beforeResolve.tap(
|
74
|
+
compiler.hooks.normalModuleFactory.tap(PLUGIN_NAME, nmf => {
|
75
|
+
nmf.hooks.beforeResolve.tap(PLUGIN_NAME, resolveData => {
|
74
76
|
const result = this.checkIgnore(resolveData);
|
75
77
|
|
76
78
|
if (
|
@@ -88,8 +90,8 @@ class IgnorePlugin {
|
|
88
90
|
return result;
|
89
91
|
});
|
90
92
|
});
|
91
|
-
compiler.hooks.contextModuleFactory.tap(
|
92
|
-
cmf.hooks.beforeResolve.tap(
|
93
|
+
compiler.hooks.contextModuleFactory.tap(PLUGIN_NAME, cmf => {
|
94
|
+
cmf.hooks.beforeResolve.tap(PLUGIN_NAME, this.checkIgnore);
|
93
95
|
});
|
94
96
|
}
|
95
97
|
}
|
@@ -8,6 +8,8 @@
|
|
8
8
|
/** @typedef {import("../declarations/WebpackOptions").IgnoreWarningsNormalized} IgnoreWarningsNormalized */
|
9
9
|
/** @typedef {import("./Compiler")} Compiler */
|
10
10
|
|
11
|
+
const PLUGIN_NAME = "IgnoreWarningsPlugin";
|
12
|
+
|
11
13
|
class IgnoreWarningsPlugin {
|
12
14
|
/**
|
13
15
|
* @param {IgnoreWarningsNormalized} ignoreWarnings conditions to ignore warnings
|
@@ -22,8 +24,8 @@ class IgnoreWarningsPlugin {
|
|
22
24
|
* @returns {void}
|
23
25
|
*/
|
24
26
|
apply(compiler) {
|
25
|
-
compiler.hooks.compilation.tap(
|
26
|
-
compilation.hooks.processWarnings.tap(
|
27
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
28
|
+
compilation.hooks.processWarnings.tap(PLUGIN_NAME, warnings =>
|
27
29
|
warnings.filter(
|
28
30
|
warning =>
|
29
31
|
!this._ignoreWarnings.some(ignore => ignore(warning, compilation))
|
package/lib/LibManifestPlugin.js
CHANGED
@@ -33,6 +33,8 @@ const { dirname, mkdirp } = require("./util/fs");
|
|
33
33
|
* @property {string=} type Type of the dll bundle (external type, use value of 'output.libraryTarget').
|
34
34
|
*/
|
35
35
|
|
36
|
+
const PLUGIN_NAME = "LibManifestPlugin";
|
37
|
+
|
36
38
|
class LibManifestPlugin {
|
37
39
|
/**
|
38
40
|
* @param {LibManifestPluginOptions} options the options
|
@@ -48,10 +50,7 @@ class LibManifestPlugin {
|
|
48
50
|
*/
|
49
51
|
apply(compiler) {
|
50
52
|
compiler.hooks.emit.tapAsync(
|
51
|
-
{
|
52
|
-
name: "LibManifestPlugin",
|
53
|
-
stage: 110
|
54
|
-
},
|
53
|
+
{ name: PLUGIN_NAME, stage: 110 },
|
55
54
|
(compilation, callback) => {
|
56
55
|
const moduleGraph = compilation.moduleGraph;
|
57
56
|
// store used paths to detect issue and output an error. #18200
|
@@ -28,6 +28,8 @@ const validate = createSchemaValidation(
|
|
28
28
|
}
|
29
29
|
);
|
30
30
|
|
31
|
+
const PLUGIN_NAME = "LoaderOptionsPlugin";
|
32
|
+
|
31
33
|
class LoaderOptionsPlugin {
|
32
34
|
/**
|
33
35
|
* @param {LoaderOptionsPluginOptions & MatchObject} options options object
|
@@ -55,9 +57,9 @@ class LoaderOptionsPlugin {
|
|
55
57
|
*/
|
56
58
|
apply(compiler) {
|
57
59
|
const options = this.options;
|
58
|
-
compiler.hooks.compilation.tap(
|
60
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
59
61
|
NormalModule.getCompilationHooks(compilation).loader.tap(
|
60
|
-
|
62
|
+
PLUGIN_NAME,
|
61
63
|
(context, module) => {
|
62
64
|
const resource = module.resource;
|
63
65
|
if (!resource) return;
|
@@ -9,6 +9,8 @@ const NormalModule = require("./NormalModule");
|
|
9
9
|
|
10
10
|
/** @typedef {import("./Compiler")} Compiler */
|
11
11
|
|
12
|
+
const PLUGIN_NAME = "LoaderTargetPlugin";
|
13
|
+
|
12
14
|
class LoaderTargetPlugin {
|
13
15
|
/**
|
14
16
|
* @param {string} target the target
|
@@ -23,9 +25,9 @@ class LoaderTargetPlugin {
|
|
23
25
|
* @returns {void}
|
24
26
|
*/
|
25
27
|
apply(compiler) {
|
26
|
-
compiler.hooks.compilation.tap(
|
28
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
27
29
|
NormalModule.getCompilationHooks(compilation).loader.tap(
|
28
|
-
|
30
|
+
PLUGIN_NAME,
|
29
31
|
loaderContext => {
|
30
32
|
loaderContext.target = this.target;
|
31
33
|
}
|
package/lib/Module.js
CHANGED
@@ -28,6 +28,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|
28
28
|
/** @typedef {import("./ConcatenationScope")} ConcatenationScope */
|
29
29
|
/** @typedef {import("./Dependency")} Dependency */
|
30
30
|
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
|
31
|
+
/** @typedef {import("./DependencyTemplate").CssData} CssData */
|
31
32
|
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
|
32
33
|
/** @typedef {import("./ExportsInfo").UsageStateType} UsageStateType */
|
33
34
|
/** @typedef {import("./FileSystemInfo")} FileSystemInfo */
|
@@ -120,19 +121,25 @@ const makeSerializable = require("./util/makeSerializable");
|
|
120
121
|
* @typedef {object} KnownBuildInfo
|
121
122
|
* @property {boolean=} cacheable
|
122
123
|
* @property {boolean=} parsed
|
123
|
-
* @property {string=} moduleArgument
|
124
|
-
* @property {string=} exportsArgument
|
125
124
|
* @property {boolean=} strict
|
126
|
-
* @property {string=}
|
127
|
-
* @property {
|
128
|
-
* @property {
|
129
|
-
* @property {
|
130
|
-
* @property {
|
131
|
-
* @property {
|
132
|
-
* @property {
|
133
|
-
* @property {
|
134
|
-
* @property {
|
135
|
-
* @property {
|
125
|
+
* @property {string=} moduleArgument using in AMD
|
126
|
+
* @property {string=} exportsArgument using in AMD
|
127
|
+
* @property {string=} moduleConcatenationBailout using in CommonJs
|
128
|
+
* @property {boolean=} needCreateRequire using in APIPlugin
|
129
|
+
* @property {string=} resourceIntegrity using in HttpUriPlugin
|
130
|
+
* @property {LazySet<string>=} fileDependencies using in NormalModule
|
131
|
+
* @property {LazySet<string>=} contextDependencies using in NormalModule
|
132
|
+
* @property {LazySet<string>=} missingDependencies using in NormalModule
|
133
|
+
* @property {LazySet<string>=} buildDependencies using in NormalModule
|
134
|
+
* @property {ValueCacheVersions=} valueDependencies using in NormalModule
|
135
|
+
* @property {Record<string, Source>=} assets using in NormalModule
|
136
|
+
* @property {string=} hash using in NormalModule
|
137
|
+
* @property {(Snapshot | null)=} snapshot using in ContextModule
|
138
|
+
* @property {string=} fullContentHash for assets modules
|
139
|
+
* @property {string=} filename for assets modules
|
140
|
+
* @property {Map<string, AssetInfo | undefined>=} assetsInfo for assets modules
|
141
|
+
* @property {boolean=} dataUrl for assets modules
|
142
|
+
* @property {CssData=} cssData for css modules
|
136
143
|
*/
|
137
144
|
|
138
145
|
/** @typedef {Map<string, string | Set<string>>} ValueCacheVersions */
|
@@ -149,6 +149,8 @@ const printExportsInfoToSource = (
|
|
149
149
|
/** @type {WeakMap<RequestShortener, WeakMap<Module, { header: RawSource | undefined, full: WeakMap<Source, CachedSource> }>>} */
|
150
150
|
const caches = new WeakMap();
|
151
151
|
|
152
|
+
const PLUGIN_NAME = "ModuleInfoHeaderPlugin";
|
153
|
+
|
152
154
|
class ModuleInfoHeaderPlugin {
|
153
155
|
/**
|
154
156
|
* @param {boolean=} verbose add more information like exports, runtime requirements and bailouts
|
@@ -163,11 +165,11 @@ class ModuleInfoHeaderPlugin {
|
|
163
165
|
*/
|
164
166
|
apply(compiler) {
|
165
167
|
const { _verbose: verbose } = this;
|
166
|
-
compiler.hooks.compilation.tap(
|
168
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
167
169
|
const javascriptHooks =
|
168
170
|
JavascriptModulesPlugin.getCompilationHooks(compilation);
|
169
171
|
javascriptHooks.renderModulePackage.tap(
|
170
|
-
|
172
|
+
PLUGIN_NAME,
|
171
173
|
(
|
172
174
|
moduleSource,
|
173
175
|
module,
|
@@ -246,16 +248,13 @@ class ModuleInfoHeaderPlugin {
|
|
246
248
|
return cachedSource;
|
247
249
|
}
|
248
250
|
);
|
249
|
-
javascriptHooks.chunkHash.tap(
|
250
|
-
|
251
|
-
(
|
252
|
-
|
253
|
-
hash.update("1");
|
254
|
-
}
|
255
|
-
);
|
251
|
+
javascriptHooks.chunkHash.tap(PLUGIN_NAME, (_chunk, hash) => {
|
252
|
+
hash.update(PLUGIN_NAME);
|
253
|
+
hash.update("1");
|
254
|
+
});
|
256
255
|
const cssHooks = CssModulesPlugin.getCompilationHooks(compilation);
|
257
256
|
cssHooks.renderModulePackage.tap(
|
258
|
-
|
257
|
+
PLUGIN_NAME,
|
259
258
|
(moduleSource, module, { runtimeTemplate }) => {
|
260
259
|
const { requestShortener } = runtimeTemplate;
|
261
260
|
let cacheEntry;
|
@@ -291,8 +290,8 @@ class ModuleInfoHeaderPlugin {
|
|
291
290
|
return cachedSource;
|
292
291
|
}
|
293
292
|
);
|
294
|
-
cssHooks.chunkHash.tap(
|
295
|
-
hash.update(
|
293
|
+
cssHooks.chunkHash.tap(PLUGIN_NAME, (_chunk, hash) => {
|
294
|
+
hash.update(PLUGIN_NAME);
|
296
295
|
hash.update("1");
|
297
296
|
});
|
298
297
|
});
|
package/lib/MultiCompiler.js
CHANGED
@@ -44,6 +44,8 @@ const ArrayQueue = require("./util/ArrayQueue");
|
|
44
44
|
* @property {number=} parallelism how many Compilers are allows to run at the same time in parallel
|
45
45
|
*/
|
46
46
|
|
47
|
+
const CLASS_NAME = "MultiCompiler";
|
48
|
+
|
47
49
|
module.exports = class MultiCompiler {
|
48
50
|
/**
|
49
51
|
* @param {Compiler[] | Record<string, Compiler>} compilers child compilers
|
@@ -92,7 +94,7 @@ module.exports = class MultiCompiler {
|
|
92
94
|
const compilerIndex = index;
|
93
95
|
let compilerDone = false;
|
94
96
|
// eslint-disable-next-line no-loop-func
|
95
|
-
compiler.hooks.done.tap(
|
97
|
+
compiler.hooks.done.tap(CLASS_NAME, stats => {
|
96
98
|
if (!compilerDone) {
|
97
99
|
compilerDone = true;
|
98
100
|
doneCompilers++;
|
@@ -105,7 +107,7 @@ module.exports = class MultiCompiler {
|
|
105
107
|
}
|
106
108
|
});
|
107
109
|
// eslint-disable-next-line no-loop-func
|
108
|
-
compiler.hooks.invalid.tap(
|
110
|
+
compiler.hooks.invalid.tap(CLASS_NAME, () => {
|
109
111
|
if (compilerDone) {
|
110
112
|
compilerDone = false;
|
111
113
|
doneCompilers--;
|
@@ -122,7 +124,7 @@ module.exports = class MultiCompiler {
|
|
122
124
|
* @param {WebpackError} warning warning
|
123
125
|
*/
|
124
126
|
const addWarning = (compiler, warning) => {
|
125
|
-
compiler.hooks.thisCompilation.tap(
|
127
|
+
compiler.hooks.thisCompilation.tap(CLASS_NAME, compilation => {
|
126
128
|
compilation.warnings.push(warning);
|
127
129
|
});
|
128
130
|
};
|
@@ -7,6 +7,8 @@
|
|
7
7
|
|
8
8
|
/** @typedef {import("./Compiler")} Compiler */
|
9
9
|
|
10
|
+
const PLUGIN_NAME = "NoEmitOnErrorsPlugin";
|
11
|
+
|
10
12
|
class NoEmitOnErrorsPlugin {
|
11
13
|
/**
|
12
14
|
* Apply the plugin
|
@@ -14,11 +16,11 @@ class NoEmitOnErrorsPlugin {
|
|
14
16
|
* @returns {void}
|
15
17
|
*/
|
16
18
|
apply(compiler) {
|
17
|
-
compiler.hooks.shouldEmit.tap(
|
19
|
+
compiler.hooks.shouldEmit.tap(PLUGIN_NAME, compilation => {
|
18
20
|
if (compilation.getStats().hasErrors()) return false;
|
19
21
|
});
|
20
|
-
compiler.hooks.compilation.tap(
|
21
|
-
compilation.hooks.shouldRecord.tap(
|
22
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
23
|
+
compilation.hooks.shouldRecord.tap(PLUGIN_NAME, () => {
|
22
24
|
if (compilation.getStats().hasErrors()) return false;
|
23
25
|
});
|
24
26
|
});
|