webpack 5.66.0 → 5.69.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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/README.md +1 -1
- package/lib/APIPlugin.js +33 -0
- package/lib/Cache.js +1 -1
- package/lib/CacheFacade.js +2 -2
- package/lib/ChunkGraph.js +1 -2
- package/lib/CleanPlugin.js +1 -1
- package/lib/Compilation.js +14 -9
- package/lib/Compiler.js +57 -3
- package/lib/ContextModule.js +21 -17
- package/lib/DelegatedModule.js +1 -1
- package/lib/DependencyTemplates.js +1 -1
- package/lib/DllModule.js +1 -1
- package/lib/EvalDevToolModulePlugin.js +16 -1
- package/lib/EvalSourceMapDevToolPlugin.js +18 -1
- package/lib/ExportsInfo.js +4 -4
- package/lib/ExternalModule.js +1 -1
- package/lib/ExternalModuleFactoryPlugin.js +1 -1
- package/lib/FileSystemInfo.js +29 -25
- package/lib/HookWebpackError.js +1 -1
- package/lib/Module.js +1 -3
- package/lib/MultiCompiler.js +1 -1
- package/lib/MultiWatching.js +1 -1
- package/lib/NormalModule.js +6 -4
- package/lib/NormalModuleFactory.js +25 -27
- package/lib/ProgressPlugin.js +1 -1
- package/lib/RawModule.js +1 -1
- package/lib/RuntimeGlobals.js +18 -0
- package/lib/RuntimeModule.js +1 -1
- package/lib/RuntimePlugin.js +28 -3
- package/lib/RuntimeTemplate.js +1 -1
- package/lib/TemplatedPathPlugin.js +48 -23
- package/lib/Watching.js +1 -1
- package/lib/WebpackOptionsApply.js +1 -1
- package/lib/asset/AssetGenerator.js +65 -26
- package/lib/asset/AssetModulesPlugin.js +3 -0
- package/lib/asset/RawDataUrlModule.js +8 -5
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -4
- package/lib/buildChunkGraph.js +1 -1
- package/lib/cache/ResolverCachePlugin.js +1 -1
- package/lib/cli.js +44 -3
- package/lib/config/defaults.js +30 -7
- package/lib/config/normalization.js +5 -0
- package/lib/container/ContainerEntryModule.js +4 -2
- package/lib/container/FallbackModule.js +4 -4
- package/lib/container/RemoteModule.js +4 -2
- package/lib/css/CssExportsGenerator.js +139 -0
- package/lib/css/CssGenerator.js +3 -0
- package/lib/css/CssLoadingRuntimeModule.js +201 -154
- package/lib/css/CssModulesPlugin.js +22 -4
- package/lib/debug/ProfilingPlugin.js +15 -14
- package/lib/dependencies/ContextElementDependency.js +8 -2
- package/lib/dependencies/CreateScriptUrlDependency.js +12 -0
- package/lib/dependencies/ExportsInfoDependency.js +6 -0
- package/lib/dependencies/HarmonyCompatibilityDependency.js +5 -5
- package/lib/dependencies/ImportMetaPlugin.js +22 -3
- package/lib/dependencies/LoaderPlugin.js +2 -2
- package/lib/hmr/LazyCompilationPlugin.js +45 -21
- package/lib/hmr/lazyCompilationBackend.js +1 -1
- package/lib/ids/DeterministicModuleIdsPlugin.js +55 -35
- package/lib/ids/HashedModuleIdsPlugin.js +9 -12
- package/lib/ids/IdHelpers.js +24 -10
- package/lib/ids/NamedModuleIdsPlugin.js +6 -9
- package/lib/ids/NaturalModuleIdsPlugin.js +10 -13
- package/lib/ids/OccurrenceModuleIdsPlugin.js +13 -10
- package/lib/ids/SyncModuleIdsPlugin.js +140 -0
- package/lib/index.js +10 -0
- package/lib/javascript/JavascriptModulesPlugin.js +27 -2
- package/lib/javascript/StartupHelpers.js +3 -2
- package/lib/library/AssignLibraryPlugin.js +8 -2
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/optimize/ConcatenatedModule.js +11 -5
- package/lib/runtime/AsyncModuleRuntimeModule.js +25 -15
- package/lib/runtime/CreateScriptRuntimeModule.js +36 -0
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +9 -34
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +76 -0
- package/lib/schemes/HttpUriPlugin.js +32 -11
- package/lib/serialization/FileMiddleware.js +44 -9
- package/lib/sharing/ConsumeSharedModule.js +4 -2
- package/lib/sharing/ProvideSharedModule.js +4 -2
- package/lib/sharing/utils.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +112 -67
- package/lib/stats/DefaultStatsPrinterPlugin.js +88 -23
- package/lib/util/ArrayHelpers.js +18 -4
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/compileBooleanMatcher.js +1 -1
- package/lib/util/deterministicGrouping.js +1 -1
- package/lib/util/identifier.js +65 -44
- package/lib/util/nonNumericOnlyHash.js +22 -0
- package/lib/util/semver.js +17 -10
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +9 -3
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -11
- package/package.json +14 -21
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +47 -6
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- package/types.d.ts +207 -60
package/README.md
CHANGED
@@ -687,7 +687,7 @@ src="https://static.monei.net/monei-logo.svg" height="30" alt="MONEI"></a>
|
|
687
687
|
|
688
688
|
- [@google](https://github.com/google) for [Google Web Toolkit (GWT)](http://www.gwtproject.org/), which aims to compile Java to JavaScript. It features a similar [Code Splitting](http://www.gwtproject.org/doc/latest/DevGuideCodeSplitting.html) as webpack.
|
689
689
|
- [@medikoo](https://github.com/medikoo) for [modules-webmake](https://github.com/medikoo/modules-webmake), which is a similar project. webpack was born because I wanted Code Splitting for modules-webmake. Interestingly the [Code Splitting issue is still open](https://github.com/medikoo/modules-webmake/issues/7) (thanks also to @Phoscur for the discussion).
|
690
|
-
- [@substack](https://github.com/substack) for [browserify](
|
690
|
+
- [@substack](https://github.com/substack) for [browserify](https://browserify.org/), which is a similar project and source for many ideas.
|
691
691
|
- [@jrburke](https://github.com/jrburke) for [require.js](https://requirejs.org/), which is a similar project and source for many ideas.
|
692
692
|
- [@defunctzombie](https://github.com/defunctzombie) for the [browser-field spec](https://github.com/defunctzombie/package-browser-field-spec), which makes modules available for node.js, browserify and webpack.
|
693
693
|
- Every early webpack user, which contributed to webpack by writing issues or PRs. You influenced the direction...
|
package/lib/APIPlugin.js
CHANGED
@@ -201,6 +201,39 @@ class APIPlugin {
|
|
201
201
|
)
|
202
202
|
.setRange(expr.range)
|
203
203
|
);
|
204
|
+
|
205
|
+
parser.hooks.expression
|
206
|
+
.for("__webpack_module__.id")
|
207
|
+
.tap("APIPlugin", expr => {
|
208
|
+
parser.state.module.buildInfo.moduleConcatenationBailout =
|
209
|
+
"__webpack_module__.id";
|
210
|
+
const dep = new ConstDependency(
|
211
|
+
parser.state.module.moduleArgument + ".id",
|
212
|
+
expr.range,
|
213
|
+
[RuntimeGlobals.moduleId]
|
214
|
+
);
|
215
|
+
dep.loc = expr.loc;
|
216
|
+
parser.state.module.addPresentationalDependency(dep);
|
217
|
+
return true;
|
218
|
+
});
|
219
|
+
|
220
|
+
parser.hooks.expression
|
221
|
+
.for("__webpack_module__")
|
222
|
+
.tap("APIPlugin", expr => {
|
223
|
+
parser.state.module.buildInfo.moduleConcatenationBailout =
|
224
|
+
"__webpack_module__";
|
225
|
+
const dep = new ConstDependency(
|
226
|
+
parser.state.module.moduleArgument,
|
227
|
+
expr.range,
|
228
|
+
[RuntimeGlobals.module]
|
229
|
+
);
|
230
|
+
dep.loc = expr.loc;
|
231
|
+
parser.state.module.addPresentationalDependency(dep);
|
232
|
+
return true;
|
233
|
+
});
|
234
|
+
parser.hooks.evaluateTypeof
|
235
|
+
.for("__webpack_module__")
|
236
|
+
.tap("APIPlugin", evaluateToString("object"));
|
204
237
|
};
|
205
238
|
|
206
239
|
normalModuleFactory.hooks.parser
|
package/lib/Cache.js
CHANGED
package/lib/CacheFacade.js
CHANGED
@@ -19,7 +19,7 @@ const mergeEtags = require("./cache/mergeEtags");
|
|
19
19
|
/**
|
20
20
|
* @template T
|
21
21
|
* @callback CallbackCache
|
22
|
-
* @param {WebpackError=} err
|
22
|
+
* @param {(WebpackError | null)=} err
|
23
23
|
* @param {T=} result
|
24
24
|
* @returns {void}
|
25
25
|
*/
|
@@ -27,7 +27,7 @@ const mergeEtags = require("./cache/mergeEtags");
|
|
27
27
|
/**
|
28
28
|
* @template T
|
29
29
|
* @callback CallbackNormalErrorCache
|
30
|
-
* @param {Error=} err
|
30
|
+
* @param {(Error | null)=} err
|
31
31
|
* @param {T=} result
|
32
32
|
* @returns {void}
|
33
33
|
*/
|
package/lib/ChunkGraph.js
CHANGED
@@ -46,6 +46,7 @@ const compareModuleIterables = compareIterables(compareModulesByIdentifier);
|
|
46
46
|
|
47
47
|
/** @typedef {(c: Chunk, chunkGraph: ChunkGraph) => boolean} ChunkFilterPredicate */
|
48
48
|
/** @typedef {(m: Module) => boolean} ModuleFilterPredicate */
|
49
|
+
/** @typedef {[Module, Entrypoint | undefined]} EntryModuleWithChunkGroup */
|
49
50
|
|
50
51
|
/**
|
51
52
|
* @typedef {Object} ChunkSizeOptions
|
@@ -1180,8 +1181,6 @@ class ChunkGraph {
|
|
1180
1181
|
return cgc.dependentHashModules;
|
1181
1182
|
}
|
1182
1183
|
|
1183
|
-
/** @typedef {[Module, Entrypoint | undefined]} EntryModuleWithChunkGroup */
|
1184
|
-
|
1185
1184
|
/**
|
1186
1185
|
* @param {Chunk} chunk the chunk
|
1187
1186
|
* @returns {Iterable<EntryModuleWithChunkGroup>} iterable of modules (do not modify)
|
package/lib/CleanPlugin.js
CHANGED
@@ -45,7 +45,7 @@ const validate = createSchemaValidation(
|
|
45
45
|
* @param {OutputFileSystem} fs filesystem
|
46
46
|
* @param {string} outputPath output path
|
47
47
|
* @param {Set<string>} currentAssets filename of the current assets (must not start with .. or ., must only use / as path separator)
|
48
|
-
* @param {function(Error=, Set<string>=): void} callback returns the filenames of the assets that shouldn't be there
|
48
|
+
* @param {function((Error | null)=, Set<string>=): void} callback returns the filenames of the assets that shouldn't be there
|
49
49
|
* @returns {void}
|
50
50
|
*/
|
51
51
|
const getDiffToFs = (fs, outputPath, currentAssets, callback) => {
|
package/lib/Compilation.js
CHANGED
@@ -116,34 +116,34 @@ const { isSourceEqual } = require("./util/source");
|
|
116
116
|
|
117
117
|
/**
|
118
118
|
* @callback Callback
|
119
|
-
* @param {WebpackError=} err
|
119
|
+
* @param {(WebpackError | null)=} err
|
120
120
|
* @returns {void}
|
121
121
|
*/
|
122
122
|
|
123
123
|
/**
|
124
124
|
* @callback ModuleCallback
|
125
|
-
* @param {WebpackError=} err
|
125
|
+
* @param {(WebpackError | null)=} err
|
126
126
|
* @param {Module=} result
|
127
127
|
* @returns {void}
|
128
128
|
*/
|
129
129
|
|
130
130
|
/**
|
131
131
|
* @callback ModuleFactoryResultCallback
|
132
|
-
* @param {WebpackError=} err
|
132
|
+
* @param {(WebpackError | null)=} err
|
133
133
|
* @param {ModuleFactoryResult=} result
|
134
134
|
* @returns {void}
|
135
135
|
*/
|
136
136
|
|
137
137
|
/**
|
138
138
|
* @callback ModuleOrFactoryResultCallback
|
139
|
-
* @param {WebpackError=} err
|
139
|
+
* @param {(WebpackError | null)=} err
|
140
140
|
* @param {Module | ModuleFactoryResult=} result
|
141
141
|
* @returns {void}
|
142
142
|
*/
|
143
143
|
|
144
144
|
/**
|
145
145
|
* @callback ExecuteModuleCallback
|
146
|
-
* @param {WebpackError=} err
|
146
|
+
* @param {(WebpackError | null)=} err
|
147
147
|
* @param {ExecuteModuleResult=} result
|
148
148
|
* @returns {void}
|
149
149
|
*/
|
@@ -182,6 +182,7 @@ const { isSourceEqual } = require("./util/source");
|
|
182
182
|
|
183
183
|
/**
|
184
184
|
* @typedef {Object} ChunkHashContext
|
185
|
+
* @property {CodeGenerationResults} codeGenerationResults results of code generation
|
185
186
|
* @property {RuntimeTemplate} runtimeTemplate the runtime template
|
186
187
|
* @property {ModuleGraph} moduleGraph the module graph
|
187
188
|
* @property {ChunkGraph} chunkGraph the chunk graph
|
@@ -1020,7 +1021,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1020
1021
|
/** @type {Map<DepConstructor, ModuleFactory>} */
|
1021
1022
|
this.dependencyFactories = new Map();
|
1022
1023
|
/** @type {DependencyTemplates} */
|
1023
|
-
this.dependencyTemplates = new DependencyTemplates(
|
1024
|
+
this.dependencyTemplates = new DependencyTemplates(
|
1025
|
+
this.outputOptions.hashFunction
|
1026
|
+
);
|
1024
1027
|
this.childrenCounters = {};
|
1025
1028
|
/** @type {Set<number|string>} */
|
1026
1029
|
this.usedChunkIds = null;
|
@@ -3553,10 +3556,11 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3553
3556
|
}
|
3554
3557
|
|
3555
3558
|
/**
|
3559
|
+
* If `module` is passed, `loc` and `request` must also be passed.
|
3556
3560
|
* @param {string | ChunkGroupOptions} groupOptions options for the chunk group
|
3557
|
-
* @param {Module} module the module the references the chunk group
|
3558
|
-
* @param {DependencyLocation} loc the location from with the chunk group is referenced (inside of module)
|
3559
|
-
* @param {string} request the request from which the the chunk group is referenced
|
3561
|
+
* @param {Module=} module the module the references the chunk group
|
3562
|
+
* @param {DependencyLocation=} loc the location from with the chunk group is referenced (inside of module)
|
3563
|
+
* @param {string=} request the request from which the the chunk group is referenced
|
3560
3564
|
* @returns {ChunkGroup} the new or existing chunk group
|
3561
3565
|
*/
|
3562
3566
|
addChunkInGroup(groupOptions, module, loc, request) {
|
@@ -4134,6 +4138,7 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4134
4138
|
chunk.updateHash(chunkHash, chunkGraph);
|
4135
4139
|
this.hooks.chunkHash.call(chunk, chunkHash, {
|
4136
4140
|
chunkGraph,
|
4141
|
+
codeGenerationResults: this.codeGenerationResults,
|
4137
4142
|
moduleGraph: this.moduleGraph,
|
4138
4143
|
runtimeTemplate: this.runtimeTemplate
|
4139
4144
|
});
|
package/lib/Compiler.js
CHANGED
@@ -58,13 +58,13 @@ const { isSourceEqual } = require("./util/source");
|
|
58
58
|
/**
|
59
59
|
* @template T
|
60
60
|
* @callback Callback
|
61
|
-
* @param {Error=} err
|
61
|
+
* @param {(Error | null)=} err
|
62
62
|
* @param {T=} result
|
63
63
|
*/
|
64
64
|
|
65
65
|
/**
|
66
66
|
* @callback RunAsChildCallback
|
67
|
-
* @param {Error=} err
|
67
|
+
* @param {(Error | null)=} err
|
68
68
|
* @param {Chunk[]=} entries
|
69
69
|
* @param {Compilation=} compilation
|
70
70
|
*/
|
@@ -165,6 +165,11 @@ class Compiler {
|
|
165
165
|
/** @type {AsyncSeriesHook<[Compilation]>} */
|
166
166
|
afterCompile: new AsyncSeriesHook(["compilation"]),
|
167
167
|
|
168
|
+
/** @type {AsyncSeriesHook<[]>} */
|
169
|
+
readRecords: new AsyncSeriesHook([]),
|
170
|
+
/** @type {AsyncSeriesHook<[]>} */
|
171
|
+
emitRecords: new AsyncSeriesHook([]),
|
172
|
+
|
168
173
|
/** @type {AsyncSeriesHook<[Compiler]>} */
|
169
174
|
watchRun: new AsyncSeriesHook(["compiler"]),
|
170
175
|
/** @type {SyncHook<[Error]>} */
|
@@ -882,8 +887,32 @@ ${other}`);
|
|
882
887
|
* @returns {void}
|
883
888
|
*/
|
884
889
|
emitRecords(callback) {
|
885
|
-
if (
|
890
|
+
if (this.hooks.emitRecords.isUsed()) {
|
891
|
+
if (this.recordsOutputPath) {
|
892
|
+
asyncLib.parallel(
|
893
|
+
[
|
894
|
+
cb => this.hooks.emitRecords.callAsync(cb),
|
895
|
+
this._emitRecords.bind(this)
|
896
|
+
],
|
897
|
+
err => callback(err)
|
898
|
+
);
|
899
|
+
} else {
|
900
|
+
this.hooks.emitRecords.callAsync(callback);
|
901
|
+
}
|
902
|
+
} else {
|
903
|
+
if (this.recordsOutputPath) {
|
904
|
+
this._emitRecords(callback);
|
905
|
+
} else {
|
906
|
+
callback();
|
907
|
+
}
|
908
|
+
}
|
909
|
+
}
|
886
910
|
|
911
|
+
/**
|
912
|
+
* @param {Callback<void>} callback signals when the call finishes
|
913
|
+
* @returns {void}
|
914
|
+
*/
|
915
|
+
_emitRecords(callback) {
|
887
916
|
const writeFile = () => {
|
888
917
|
this.outputFileSystem.writeFile(
|
889
918
|
this.recordsOutputPath,
|
@@ -926,6 +955,31 @@ ${other}`);
|
|
926
955
|
* @returns {void}
|
927
956
|
*/
|
928
957
|
readRecords(callback) {
|
958
|
+
if (this.hooks.readRecords.isUsed()) {
|
959
|
+
if (this.recordsInputPath) {
|
960
|
+
asyncLib.parallel([
|
961
|
+
cb => this.hooks.readRecords.callAsync(cb),
|
962
|
+
this._readRecords.bind(this)
|
963
|
+
]);
|
964
|
+
} else {
|
965
|
+
this.records = {};
|
966
|
+
this.hooks.readRecords.callAsync(callback);
|
967
|
+
}
|
968
|
+
} else {
|
969
|
+
if (this.recordsInputPath) {
|
970
|
+
this._readRecords(callback);
|
971
|
+
} else {
|
972
|
+
this.records = {};
|
973
|
+
callback();
|
974
|
+
}
|
975
|
+
}
|
976
|
+
}
|
977
|
+
|
978
|
+
/**
|
979
|
+
* @param {Callback<void>} callback signals when the call finishes
|
980
|
+
* @returns {void}
|
981
|
+
*/
|
982
|
+
_readRecords(callback) {
|
929
983
|
if (!this.recordsInputPath) {
|
930
984
|
this.records = {};
|
931
985
|
return callback();
|
package/lib/ContextModule.js
CHANGED
@@ -71,7 +71,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|
71
71
|
|
72
72
|
/**
|
73
73
|
* @callback ResolveDependenciesCallback
|
74
|
-
* @param {Error=} err
|
74
|
+
* @param {(Error | null)=} err
|
75
75
|
* @param {ContextElementDependency[]=} dependencies
|
76
76
|
*/
|
77
77
|
|
@@ -149,12 +149,9 @@ class ContextModule extends Module {
|
|
149
149
|
this.resolveDependencies = undefined;
|
150
150
|
}
|
151
151
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
return regexString
|
156
|
-
.substring(1, regexString.length - 1)
|
157
|
-
.replace(/!/g, "%21");
|
152
|
+
_prettyRegExp(regexString, stripSlash = true) {
|
153
|
+
const str = (regexString + "").replace(/!/g, "%21").replace(/\|/g, "%7C");
|
154
|
+
return stripSlash ? str.substring(1, str.length - 1) : str;
|
158
155
|
}
|
159
156
|
|
160
157
|
_createIdentifier() {
|
@@ -175,13 +172,19 @@ class ContextModule extends Module {
|
|
175
172
|
identifier += `|${this.options.addon}`;
|
176
173
|
}
|
177
174
|
if (this.options.regExp) {
|
178
|
-
identifier += `|${this.options.regExp}`;
|
175
|
+
identifier += `|${this._prettyRegExp(this.options.regExp, false)}`;
|
179
176
|
}
|
180
177
|
if (this.options.include) {
|
181
|
-
identifier += `|include: ${this.
|
178
|
+
identifier += `|include: ${this._prettyRegExp(
|
179
|
+
this.options.include,
|
180
|
+
false
|
181
|
+
)}`;
|
182
182
|
}
|
183
183
|
if (this.options.exclude) {
|
184
|
-
identifier += `|exclude: ${this.
|
184
|
+
identifier += `|exclude: ${this._prettyRegExp(
|
185
|
+
this.options.exclude,
|
186
|
+
false
|
187
|
+
)}`;
|
185
188
|
}
|
186
189
|
if (this.options.referencedExports) {
|
187
190
|
identifier += `|referencedExports: ${JSON.stringify(
|
@@ -231,13 +234,13 @@ class ContextModule extends Module {
|
|
231
234
|
identifier += ` ${requestShortener.shorten(this.options.addon)}`;
|
232
235
|
}
|
233
236
|
if (this.options.regExp) {
|
234
|
-
identifier += ` ${this.
|
237
|
+
identifier += ` ${this._prettyRegExp(this.options.regExp)}`;
|
235
238
|
}
|
236
239
|
if (this.options.include) {
|
237
|
-
identifier += ` include: ${this.
|
240
|
+
identifier += ` include: ${this._prettyRegExp(this.options.include)}`;
|
238
241
|
}
|
239
242
|
if (this.options.exclude) {
|
240
|
-
identifier += ` exclude: ${this.
|
243
|
+
identifier += ` exclude: ${this._prettyRegExp(this.options.exclude)}`;
|
241
244
|
}
|
242
245
|
if (this.options.referencedExports) {
|
243
246
|
identifier += ` referencedExports: ${this.options.referencedExports
|
@@ -272,6 +275,7 @@ class ContextModule extends Module {
|
|
272
275
|
this.context,
|
273
276
|
options.associatedObjectForCache
|
274
277
|
);
|
278
|
+
if (this.layer) identifier = `(${this.layer})/${identifier}`;
|
275
279
|
if (this.options.mode) {
|
276
280
|
identifier += ` ${this.options.mode}`;
|
277
281
|
}
|
@@ -286,13 +290,13 @@ class ContextModule extends Module {
|
|
286
290
|
)}`;
|
287
291
|
}
|
288
292
|
if (this.options.regExp) {
|
289
|
-
identifier += ` ${this.
|
293
|
+
identifier += ` ${this._prettyRegExp(this.options.regExp)}`;
|
290
294
|
}
|
291
295
|
if (this.options.include) {
|
292
|
-
identifier += ` include: ${this.
|
296
|
+
identifier += ` include: ${this._prettyRegExp(this.options.include)}`;
|
293
297
|
}
|
294
298
|
if (this.options.exclude) {
|
295
|
-
identifier += ` exclude: ${this.
|
299
|
+
identifier += ` exclude: ${this._prettyRegExp(this.options.exclude)}`;
|
296
300
|
}
|
297
301
|
if (this.options.referencedExports) {
|
298
302
|
identifier += ` referencedExports: ${this.options.referencedExports
|
@@ -312,7 +316,7 @@ class ContextModule extends Module {
|
|
312
316
|
|
313
317
|
/**
|
314
318
|
* @param {NeedBuildContext} context context info
|
315
|
-
* @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
319
|
+
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
316
320
|
* @returns {void}
|
317
321
|
*/
|
318
322
|
needBuild({ fileSystemInfo }, callback) {
|
package/lib/DelegatedModule.js
CHANGED
@@ -91,7 +91,7 @@ class DelegatedModule extends Module {
|
|
91
91
|
|
92
92
|
/**
|
93
93
|
* @param {NeedBuildContext} context context info
|
94
|
-
* @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
94
|
+
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
95
95
|
* @returns {void}
|
96
96
|
*/
|
97
97
|
needBuild(context, callback) {
|
@@ -57,7 +57,7 @@ class DependencyTemplates {
|
|
57
57
|
}
|
58
58
|
|
59
59
|
clone() {
|
60
|
-
const newInstance = new DependencyTemplates();
|
60
|
+
const newInstance = new DependencyTemplates(this._hashFunction);
|
61
61
|
newInstance._map = new Map(this._map);
|
62
62
|
newInstance._hash = this._hash;
|
63
63
|
return newInstance;
|
package/lib/DllModule.js
CHANGED
@@ -96,7 +96,7 @@ class DllModule extends Module {
|
|
96
96
|
|
97
97
|
/**
|
98
98
|
* @param {NeedBuildContext} context context info
|
99
|
-
* @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
99
|
+
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
100
100
|
* @returns {void}
|
101
101
|
*/
|
102
102
|
needBuild(context, callback) {
|
@@ -8,6 +8,7 @@
|
|
8
8
|
const { ConcatSource, RawSource } = require("webpack-sources");
|
9
9
|
const ExternalModule = require("./ExternalModule");
|
10
10
|
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
|
11
|
+
const RuntimeGlobals = require("./RuntimeGlobals");
|
11
12
|
const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin");
|
12
13
|
|
13
14
|
/** @typedef {import("webpack-sources").Source} Source */
|
@@ -77,7 +78,13 @@ class EvalDevToolModulePlugin {
|
|
77
78
|
.replace(/^\//, "")
|
78
79
|
);
|
79
80
|
const result = new RawSource(
|
80
|
-
`eval(${
|
81
|
+
`eval(${
|
82
|
+
compilation.outputOptions.trustedTypes
|
83
|
+
? `${RuntimeGlobals.createScript}(${JSON.stringify(
|
84
|
+
content + footer
|
85
|
+
)})`
|
86
|
+
: JSON.stringify(content + footer)
|
87
|
+
});`
|
81
88
|
);
|
82
89
|
cache.set(source, result);
|
83
90
|
return result;
|
@@ -95,6 +102,14 @@ class EvalDevToolModulePlugin {
|
|
95
102
|
hash.update("EvalDevToolModulePlugin");
|
96
103
|
hash.update("2");
|
97
104
|
});
|
105
|
+
if (compilation.outputOptions.trustedTypes) {
|
106
|
+
compilation.hooks.additionalModuleRuntimeRequirements.tap(
|
107
|
+
"EvalDevToolModulePlugin",
|
108
|
+
(module, set, context) => {
|
109
|
+
set.add(RuntimeGlobals.createScript);
|
110
|
+
}
|
111
|
+
);
|
112
|
+
}
|
98
113
|
});
|
99
114
|
}
|
100
115
|
}
|
@@ -8,6 +8,7 @@
|
|
8
8
|
const { ConcatSource, RawSource } = require("webpack-sources");
|
9
9
|
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
|
10
10
|
const NormalModule = require("./NormalModule");
|
11
|
+
const RuntimeGlobals = require("./RuntimeGlobals");
|
11
12
|
const SourceMapDevToolModuleOptionsPlugin = require("./SourceMapDevToolModuleOptionsPlugin");
|
12
13
|
const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin");
|
13
14
|
const ConcatenatedModule = require("./optimize/ConcatenatedModule");
|
@@ -165,7 +166,15 @@ class EvalSourceMapDevToolPlugin {
|
|
165
166
|
) + `\n//# sourceURL=webpack-internal:///${moduleId}\n`; // workaround for chrome bug
|
166
167
|
|
167
168
|
return result(
|
168
|
-
new RawSource(
|
169
|
+
new RawSource(
|
170
|
+
`eval(${
|
171
|
+
compilation.outputOptions.trustedTypes
|
172
|
+
? `${RuntimeGlobals.createScript}(${JSON.stringify(
|
173
|
+
content + footer
|
174
|
+
)})`
|
175
|
+
: JSON.stringify(content + footer)
|
176
|
+
});`
|
177
|
+
)
|
169
178
|
);
|
170
179
|
}
|
171
180
|
);
|
@@ -181,6 +190,14 @@ class EvalSourceMapDevToolPlugin {
|
|
181
190
|
hash.update("EvalSourceMapDevToolPlugin");
|
182
191
|
hash.update("2");
|
183
192
|
});
|
193
|
+
if (compilation.outputOptions.trustedTypes) {
|
194
|
+
compilation.hooks.additionalModuleRuntimeRequirements.tap(
|
195
|
+
"EvalSourceMapDevToolPlugin",
|
196
|
+
(module, set, context) => {
|
197
|
+
set.add(RuntimeGlobals.createScript);
|
198
|
+
}
|
199
|
+
);
|
200
|
+
}
|
184
201
|
}
|
185
202
|
);
|
186
203
|
}
|
package/lib/ExportsInfo.js
CHANGED
@@ -291,15 +291,15 @@ class ExportsInfo {
|
|
291
291
|
}
|
292
292
|
}
|
293
293
|
for (const exportInfo of this._exports.values()) {
|
294
|
+
if (!canMangle && exportInfo.canMangleProvide !== false) {
|
295
|
+
exportInfo.canMangleProvide = false;
|
296
|
+
changed = true;
|
297
|
+
}
|
294
298
|
if (excludeExports && excludeExports.has(exportInfo.name)) continue;
|
295
299
|
if (exportInfo.provided !== true && exportInfo.provided !== null) {
|
296
300
|
exportInfo.provided = null;
|
297
301
|
changed = true;
|
298
302
|
}
|
299
|
-
if (!canMangle && exportInfo.canMangleProvide !== false) {
|
300
|
-
exportInfo.canMangleProvide = false;
|
301
|
-
changed = true;
|
302
|
-
}
|
303
303
|
if (targetKey) {
|
304
304
|
exportInfo.setTarget(targetKey, targetModule, [exportInfo.name], -1);
|
305
305
|
}
|
package/lib/ExternalModule.js
CHANGED
@@ -432,7 +432,7 @@ class ExternalModule extends Module {
|
|
432
432
|
|
433
433
|
/**
|
434
434
|
* @param {NeedBuildContext} context context info
|
435
|
-
* @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
435
|
+
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
436
436
|
* @returns {void}
|
437
437
|
*/
|
438
438
|
needBuild(context, callback) {
|
@@ -117,7 +117,7 @@ class ExternalModuleFactoryPlugin {
|
|
117
117
|
|
118
118
|
/**
|
119
119
|
* @param {Externals} externals externals config
|
120
|
-
* @param {function(Error=, ExternalModule=): void} callback callback
|
120
|
+
* @param {function((Error | null)=, ExternalModule=): void} callback callback
|
121
121
|
* @returns {void}
|
122
122
|
*/
|
123
123
|
const handleExternals = (externals, callback) => {
|