webpack 5.99.5 → 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/README.md +1 -1
- package/lib/APIPlugin.js +2 -2
- package/lib/AutomaticPrefetchPlugin.js +21 -22
- package/lib/BannerPlugin.js +31 -35
- package/lib/Cache.js +1 -1
- package/lib/Chunk.js +12 -9
- package/lib/CleanPlugin.js +5 -3
- package/lib/Compilation.js +45 -35
- package/lib/Compiler.js +6 -4
- package/lib/ContextExclusionPlugin.js +4 -2
- package/lib/ContextModule.js +2 -1
- 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/HotModuleReplacementPlugin.js +3 -3
- 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 +29 -14
- package/lib/ModuleFilenameHelpers.js +1 -1
- package/lib/ModuleGraph.js +15 -10
- package/lib/ModuleInfoHeaderPlugin.js +11 -12
- package/lib/MultiCompiler.js +5 -3
- package/lib/NoEmitOnErrorsPlugin.js +5 -3
- package/lib/NormalModule.js +6 -2
- package/lib/NormalModuleReplacementPlugin.js +33 -36
- package/lib/PlatformPlugin.js +3 -1
- package/lib/PrefetchPlugin.js +5 -3
- package/lib/ProgressPlugin.js +23 -26
- package/lib/RecordIdsPlugin.js +73 -103
- package/lib/RuntimePlugin.js +34 -32
- package/lib/SourceMapDevToolPlugin.js +8 -6
- package/lib/Template.js +1 -1
- 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 +22 -5
- package/lib/async-modules/InferAsyncModulesPlugin.js +25 -26
- package/lib/buildChunkGraph.js +7 -2
- package/lib/cache/IdleFileCachePlugin.js +12 -13
- package/lib/cache/MemoryCachePlugin.js +2 -1
- package/lib/cache/MemoryWithGcCachePlugin.js +10 -7
- package/lib/cache/PackFileCacheStrategy.js +13 -21
- package/lib/cache/ResolverCachePlugin.js +22 -22
- package/lib/cli.js +8 -4
- package/lib/config/defaults.js +2 -2
- package/lib/config/normalization.js +9 -3
- package/lib/config/target.js +6 -6
- 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/css/CssParser.js +1 -1
- package/lib/debug/ProfilingPlugin.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +1 -1
- package/lib/dependencies/CssIcssImportDependency.js +3 -2
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +9 -15
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +2 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +1 -1
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +15 -15
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +4 -2
- package/lib/dependencies/JsonExportsDependency.js +1 -1
- package/lib/dependencies/LoaderPlugin.js +5 -3
- package/lib/dependencies/LocalModulesHelpers.js +1 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +46 -46
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +94 -100
- package/lib/dependencies/RequireResolveDependency.js +1 -1
- package/lib/dependencies/WorkerPlugin.js +2 -2
- package/lib/esm/ModuleChunkLoadingPlugin.js +76 -57
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +11 -9
- 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/DeterministicChunkIdsPlugin.js +1 -1
- package/lib/ids/DeterministicModuleIdsPlugin.js +48 -49
- package/lib/ids/HashedModuleIdsPlugin.js +4 -2
- package/lib/ids/NamedChunkIdsPlugin.js +6 -4
- package/lib/ids/NamedModuleIdsPlugin.js +6 -4
- 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/index.js +1 -1
- package/lib/javascript/BasicEvaluatedExpression.js +2 -2
- package/lib/javascript/JavascriptParser.js +670 -688
- package/lib/library/EnableLibraryPlugin.js +15 -2
- package/lib/library/ModuleLibraryPlugin.js +66 -43
- package/lib/logging/createConsoleLogger.js +0 -1
- package/lib/node/CommonJsChunkLoadingPlugin.js +71 -75
- package/lib/node/NodeEnvironmentPlugin.js +3 -1
- package/lib/node/NodeTemplatePlugin.js +2 -2
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +2 -2
- package/lib/node/ReadFileCompileWasmPlugin.js +3 -3
- package/lib/optimize/AggressiveMergingPlugin.js +1 -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 +9 -6
- package/lib/performance/SizeLimitsPlugin.js +3 -1
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +61 -62
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +3 -4
- 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/BinaryMiddleware.js +22 -38
- package/lib/serialization/ErrorObjectSerializer.js +7 -2
- package/lib/serialization/FileMiddleware.js +29 -33
- package/lib/serialization/ObjectMiddleware.js +42 -30
- package/lib/serialization/Serializer.js +29 -18
- package/lib/serialization/SerializerMiddleware.js +105 -72
- package/lib/serialization/SingleItemMiddleware.js +4 -5
- package/lib/sharing/ProvideSharedPlugin.js +6 -4
- package/lib/stats/DefaultStatsFactoryPlugin.js +128 -57
- package/lib/stats/DefaultStatsPresetPlugin.js +25 -20
- package/lib/stats/DefaultStatsPrinterPlugin.js +486 -334
- package/lib/stats/StatsFactory.js +47 -10
- package/lib/stats/StatsPrinter.js +52 -31
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/TupleQueue.js +9 -7
- package/lib/util/TupleSet.js +37 -18
- package/lib/util/WeakTupleMap.js +50 -37
- package/lib/util/cleverMerge.js +2 -2
- package/lib/util/comparators.js +1 -1
- package/lib/util/concatenate.js +4 -2
- package/lib/util/createHash.js +1 -1
- package/lib/util/fs.js +1 -1
- package/lib/util/makeSerializable.js +1 -1
- package/lib/util/runtime.js +1 -0
- package/lib/util/serialization.js +50 -42
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +1 -1
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +55 -57
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -1
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +1 -1
- package/lib/web/FetchCompileWasmPlugin.js +2 -2
- package/lib/web/JsonpChunkLoadingPlugin.js +73 -74
- package/lib/webpack.js +1 -1
- 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 +273 -128
@@ -14,6 +14,8 @@ const { join } = require("./util/fs");
|
|
14
14
|
|
15
15
|
/** @typedef {Record<string, string>} NewContentCreateContextMap */
|
16
16
|
|
17
|
+
const PLUGIN_NAME = "ContextReplacementPlugin";
|
18
|
+
|
17
19
|
class ContextReplacementPlugin {
|
18
20
|
/**
|
19
21
|
* @param {RegExp} resourceRegExp A regular expression that determines which files will be selected
|
@@ -95,8 +97,8 @@ class ContextReplacementPlugin {
|
|
95
97
|
const newContentRegExp = this.newContentRegExp;
|
96
98
|
const newContentCreateContextMap = this.newContentCreateContextMap;
|
97
99
|
|
98
|
-
compiler.hooks.contextModuleFactory.tap(
|
99
|
-
cmf.hooks.beforeResolve.tap(
|
100
|
+
compiler.hooks.contextModuleFactory.tap(PLUGIN_NAME, cmf => {
|
101
|
+
cmf.hooks.beforeResolve.tap(PLUGIN_NAME, result => {
|
100
102
|
if (!result) return;
|
101
103
|
if (resourceRegExp.test(result.request)) {
|
102
104
|
if (newContentResource !== undefined) {
|
@@ -118,7 +120,7 @@ class ContextReplacementPlugin {
|
|
118
120
|
}
|
119
121
|
return result;
|
120
122
|
});
|
121
|
-
cmf.hooks.afterResolve.tap(
|
123
|
+
cmf.hooks.afterResolve.tap(PLUGIN_NAME, result => {
|
122
124
|
if (!result) return;
|
123
125
|
if (resourceRegExp.test(result.resource)) {
|
124
126
|
if (newContentResource !== undefined) {
|
package/lib/DelegatedPlugin.js
CHANGED
@@ -11,6 +11,8 @@ const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDepende
|
|
11
11
|
/** @typedef {import("./Compiler")} Compiler */
|
12
12
|
/** @typedef {import("./DelegatedModuleFactoryPlugin").Options} Options */
|
13
13
|
|
14
|
+
const PLUGIN_NAME = "DelegatedPlugin";
|
15
|
+
|
14
16
|
class DelegatedPlugin {
|
15
17
|
/**
|
16
18
|
* @param {Options} options options
|
@@ -26,7 +28,7 @@ class DelegatedPlugin {
|
|
26
28
|
*/
|
27
29
|
apply(compiler) {
|
28
30
|
compiler.hooks.compilation.tap(
|
29
|
-
|
31
|
+
PLUGIN_NAME,
|
30
32
|
(compilation, { normalModuleFactory }) => {
|
31
33
|
compilation.dependencyFactories.set(
|
32
34
|
DelegatedSourceDependency,
|
@@ -35,7 +37,7 @@ class DelegatedPlugin {
|
|
35
37
|
}
|
36
38
|
);
|
37
39
|
|
38
|
-
compiler.hooks.compile.tap(
|
40
|
+
compiler.hooks.compile.tap(PLUGIN_NAME, ({ normalModuleFactory }) => {
|
39
41
|
new DelegatedModuleFactoryPlugin({
|
40
42
|
associatedObjectForCache: compiler.root,
|
41
43
|
...this.options
|
package/lib/DllEntryPlugin.js
CHANGED
@@ -13,6 +13,8 @@ const EntryDependency = require("./dependencies/EntryDependency");
|
|
13
13
|
/** @typedef {string[]} Entries */
|
14
14
|
/** @typedef {{ name: string, filename: TODO }} Options */
|
15
15
|
|
16
|
+
const PLUGIN_NAME = "DllEntryPlugin";
|
17
|
+
|
16
18
|
class DllEntryPlugin {
|
17
19
|
/**
|
18
20
|
* @param {string} context context
|
@@ -32,7 +34,7 @@ class DllEntryPlugin {
|
|
32
34
|
*/
|
33
35
|
apply(compiler) {
|
34
36
|
compiler.hooks.compilation.tap(
|
35
|
-
|
37
|
+
PLUGIN_NAME,
|
36
38
|
(compilation, { normalModuleFactory }) => {
|
37
39
|
const dllModuleFactory = new DllModuleFactory();
|
38
40
|
compilation.dependencyFactories.set(
|
@@ -45,7 +47,7 @@ class DllEntryPlugin {
|
|
45
47
|
);
|
46
48
|
}
|
47
49
|
);
|
48
|
-
compiler.hooks.make.tapAsync(
|
50
|
+
compiler.hooks.make.tapAsync(PLUGIN_NAME, (compilation, callback) => {
|
49
51
|
compilation.addEntry(
|
50
52
|
this.context,
|
51
53
|
new DllEntryDependency(
|
package/lib/DllPlugin.js
CHANGED
@@ -24,6 +24,8 @@ const validate = createSchemaValidation(
|
|
24
24
|
}
|
25
25
|
);
|
26
26
|
|
27
|
+
const PLUGIN_NAME = "DllPlugin";
|
28
|
+
|
27
29
|
class DllPlugin {
|
28
30
|
/**
|
29
31
|
* @param {DllPluginOptions} options options object
|
@@ -42,7 +44,7 @@ class DllPlugin {
|
|
42
44
|
* @returns {void}
|
43
45
|
*/
|
44
46
|
apply(compiler) {
|
45
|
-
compiler.hooks.entryOption.tap(
|
47
|
+
compiler.hooks.entryOption.tap(PLUGIN_NAME, (context, entry) => {
|
46
48
|
if (typeof entry !== "function") {
|
47
49
|
for (const name of Object.keys(entry)) {
|
48
50
|
/** @type {Options} */
|
@@ -55,14 +57,14 @@ class DllPlugin {
|
|
55
57
|
}
|
56
58
|
} else {
|
57
59
|
throw new Error(
|
58
|
-
|
60
|
+
`${PLUGIN_NAME} doesn't support dynamic entry (function) yet`
|
59
61
|
);
|
60
62
|
}
|
61
63
|
return true;
|
62
64
|
});
|
63
65
|
new LibManifestPlugin(this.options).apply(compiler);
|
64
66
|
if (!this.options.entryOnly) {
|
65
|
-
new FlagAllModulesAsUsedPlugin(
|
67
|
+
new FlagAllModulesAsUsedPlugin(PLUGIN_NAME).apply(compiler);
|
66
68
|
}
|
67
69
|
}
|
68
70
|
}
|
@@ -32,6 +32,8 @@ const validate = createSchemaValidation(
|
|
32
32
|
|
33
33
|
/** @typedef {{ path: string, data: DllReferencePluginOptionsManifest | undefined, error: Error | undefined }} CompilationDataItem */
|
34
34
|
|
35
|
+
const PLUGIN_NAME = "DllReferencePlugin";
|
36
|
+
|
35
37
|
class DllReferencePlugin {
|
36
38
|
/**
|
37
39
|
* @param {DllReferencePluginOptions} options options object
|
@@ -50,7 +52,7 @@ class DllReferencePlugin {
|
|
50
52
|
*/
|
51
53
|
apply(compiler) {
|
52
54
|
compiler.hooks.compilation.tap(
|
53
|
-
|
55
|
+
PLUGIN_NAME,
|
54
56
|
(compilation, { normalModuleFactory }) => {
|
55
57
|
compilation.dependencyFactories.set(
|
56
58
|
DelegatedSourceDependency,
|
@@ -59,51 +61,48 @@ class DllReferencePlugin {
|
|
59
61
|
}
|
60
62
|
);
|
61
63
|
|
62
|
-
compiler.hooks.beforeCompile.tapAsync(
|
63
|
-
"
|
64
|
-
|
65
|
-
if (
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
});
|
99
|
-
return;
|
100
|
-
}
|
64
|
+
compiler.hooks.beforeCompile.tapAsync(PLUGIN_NAME, (params, callback) => {
|
65
|
+
if ("manifest" in this.options) {
|
66
|
+
const manifest = this.options.manifest;
|
67
|
+
if (typeof manifest === "string") {
|
68
|
+
/** @type {InputFileSystem} */
|
69
|
+
(compiler.inputFileSystem).readFile(manifest, (err, result) => {
|
70
|
+
if (err) return callback(err);
|
71
|
+
/** @type {CompilationDataItem} */
|
72
|
+
const data = {
|
73
|
+
path: manifest,
|
74
|
+
data: undefined,
|
75
|
+
error: undefined
|
76
|
+
};
|
77
|
+
// Catch errors parsing the manifest so that blank
|
78
|
+
// or malformed manifest files don't kill the process.
|
79
|
+
try {
|
80
|
+
data.data = parseJson(
|
81
|
+
/** @type {Buffer} */ (result).toString("utf-8")
|
82
|
+
);
|
83
|
+
} catch (parseErr) {
|
84
|
+
// Store the error in the params so that it can
|
85
|
+
// be added as a compilation error later on.
|
86
|
+
const manifestPath = makePathsRelative(
|
87
|
+
/** @type {string} */ (compiler.options.context),
|
88
|
+
manifest,
|
89
|
+
compiler.root
|
90
|
+
);
|
91
|
+
data.error = new DllManifestError(
|
92
|
+
manifestPath,
|
93
|
+
/** @type {Error} */ (parseErr).message
|
94
|
+
);
|
95
|
+
}
|
96
|
+
this._compilationData.set(params, data);
|
97
|
+
return callback();
|
98
|
+
});
|
99
|
+
return;
|
101
100
|
}
|
102
|
-
return callback();
|
103
101
|
}
|
104
|
-
|
102
|
+
return callback();
|
103
|
+
});
|
105
104
|
|
106
|
-
compiler.hooks.compile.tap(
|
105
|
+
compiler.hooks.compile.tap(PLUGIN_NAME, params => {
|
107
106
|
let name = this.options.name;
|
108
107
|
let sourceType = this.options.sourceType;
|
109
108
|
let resolvedContent =
|
@@ -154,27 +153,24 @@ class DllReferencePlugin {
|
|
154
153
|
}).apply(normalModuleFactory);
|
155
154
|
});
|
156
155
|
|
157
|
-
compiler.hooks.compilation.tap(
|
158
|
-
"
|
159
|
-
|
160
|
-
if (
|
161
|
-
const
|
162
|
-
|
163
|
-
|
164
|
-
|
156
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation, params) => {
|
157
|
+
if ("manifest" in this.options) {
|
158
|
+
const manifest = this.options.manifest;
|
159
|
+
if (typeof manifest === "string") {
|
160
|
+
const data = /** @type {CompilationDataItem} */ (
|
161
|
+
this._compilationData.get(params)
|
162
|
+
);
|
163
|
+
// If there was an error parsing the manifest file, add the
|
164
|
+
// error as a compilation error to make the compilation fail.
|
165
|
+
if (data.error) {
|
166
|
+
compilation.errors.push(
|
167
|
+
/** @type {DllManifestError} */ (data.error)
|
165
168
|
);
|
166
|
-
// If there was an error parsing the manifest file, add the
|
167
|
-
// error as a compilation error to make the compilation fail.
|
168
|
-
if (data.error) {
|
169
|
-
compilation.errors.push(
|
170
|
-
/** @type {DllManifestError} */ (data.error)
|
171
|
-
);
|
172
|
-
}
|
173
|
-
compilation.fileDependencies.add(manifest);
|
174
169
|
}
|
170
|
+
compilation.fileDependencies.add(manifest);
|
175
171
|
}
|
176
172
|
}
|
177
|
-
);
|
173
|
+
});
|
178
174
|
}
|
179
175
|
}
|
180
176
|
|
@@ -15,6 +15,8 @@ const EntryDependency = require("./dependencies/EntryDependency");
|
|
15
15
|
/** @typedef {import("../declarations/WebpackOptions").EntryStaticNormalized} EntryStatic */
|
16
16
|
/** @typedef {import("./Compiler")} Compiler */
|
17
17
|
|
18
|
+
const PLUGIN_NAME = "DynamicEntryPlugin";
|
19
|
+
|
18
20
|
class DynamicEntryPlugin {
|
19
21
|
/**
|
20
22
|
* @param {string} context the context path
|
@@ -32,7 +34,7 @@ class DynamicEntryPlugin {
|
|
32
34
|
*/
|
33
35
|
apply(compiler) {
|
34
36
|
compiler.hooks.compilation.tap(
|
35
|
-
|
37
|
+
PLUGIN_NAME,
|
36
38
|
(compilation, { normalModuleFactory }) => {
|
37
39
|
compilation.dependencyFactories.set(
|
38
40
|
EntryDependency,
|
@@ -41,7 +43,7 @@ class DynamicEntryPlugin {
|
|
41
43
|
}
|
42
44
|
);
|
43
45
|
|
44
|
-
compiler.hooks.make.tapPromise(
|
46
|
+
compiler.hooks.make.tapPromise(PLUGIN_NAME, compilation =>
|
45
47
|
Promise.resolve(this.entry())
|
46
48
|
.then(entry => {
|
47
49
|
const promises = [];
|
package/lib/EntryOptionPlugin.js
CHANGED
@@ -10,13 +10,15 @@
|
|
10
10
|
/** @typedef {import("./Compiler")} Compiler */
|
11
11
|
/** @typedef {import("./Entrypoint").EntryOptions} EntryOptions */
|
12
12
|
|
13
|
+
const PLUGIN_NAME = "EntryOptionPlugin";
|
14
|
+
|
13
15
|
class EntryOptionPlugin {
|
14
16
|
/**
|
15
17
|
* @param {Compiler} compiler the compiler instance one is tapping into
|
16
18
|
* @returns {void}
|
17
19
|
*/
|
18
20
|
apply(compiler) {
|
19
|
-
compiler.hooks.entryOption.tap(
|
21
|
+
compiler.hooks.entryOption.tap(PLUGIN_NAME, (context, entry) => {
|
20
22
|
EntryOptionPlugin.applyEntryOption(compiler, context, entry);
|
21
23
|
return true;
|
22
24
|
});
|
package/lib/EntryPlugin.js
CHANGED
@@ -10,6 +10,8 @@ const EntryDependency = require("./dependencies/EntryDependency");
|
|
10
10
|
/** @typedef {import("./Compiler")} Compiler */
|
11
11
|
/** @typedef {import("./Entrypoint").EntryOptions} EntryOptions */
|
12
12
|
|
13
|
+
const PLUGIN_NAME = "EntryPlugin";
|
14
|
+
|
13
15
|
class EntryPlugin {
|
14
16
|
/**
|
15
17
|
* An entry plugin which will handle creation of the EntryDependency
|
@@ -30,7 +32,7 @@ class EntryPlugin {
|
|
30
32
|
*/
|
31
33
|
apply(compiler) {
|
32
34
|
compiler.hooks.compilation.tap(
|
33
|
-
|
35
|
+
PLUGIN_NAME,
|
34
36
|
(compilation, { normalModuleFactory }) => {
|
35
37
|
compilation.dependencyFactories.set(
|
36
38
|
EntryDependency,
|
@@ -42,7 +44,7 @@ class EntryPlugin {
|
|
42
44
|
const { entry, options, context } = this;
|
43
45
|
const dep = EntryPlugin.createDependency(entry, options);
|
44
46
|
|
45
|
-
compiler.hooks.make.tapAsync(
|
47
|
+
compiler.hooks.make.tapAsync(PLUGIN_NAME, (compilation, callback) => {
|
46
48
|
compilation.addEntry(context, dep, options, err => {
|
47
49
|
callback(err);
|
48
50
|
});
|
package/lib/EnvironmentPlugin.js
CHANGED
@@ -11,6 +11,8 @@ const WebpackError = require("./WebpackError");
|
|
11
11
|
/** @typedef {import("./Compiler")} Compiler */
|
12
12
|
/** @typedef {import("./DefinePlugin").CodeValue} CodeValue */
|
13
13
|
|
14
|
+
const PLUGIN_NAME = "EnvironmentPlugin";
|
15
|
+
|
14
16
|
class EnvironmentPlugin {
|
15
17
|
/**
|
16
18
|
* @param {(string | string[] | Record<string, EXPECTED_ANY>)[]} keys keys
|
@@ -46,9 +48,9 @@ class EnvironmentPlugin {
|
|
46
48
|
: this.defaultValues[key];
|
47
49
|
|
48
50
|
if (value === undefined) {
|
49
|
-
compiler.hooks.thisCompilation.tap(
|
51
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
50
52
|
const error = new WebpackError(
|
51
|
-
|
53
|
+
`${PLUGIN_NAME} - ${key} environment variable is undefined.\n\n` +
|
52
54
|
"You can pass an object with default values to suppress this warning.\n" +
|
53
55
|
"See https://webpack.js.org/plugins/environment-plugin for example."
|
54
56
|
);
|
@@ -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
|
}
|