webpack 5.64.3 → 5.67.0
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/Cache.js +1 -1
- package/lib/CacheFacade.js +4 -11
- package/lib/Chunk.js +2 -0
- package/lib/CleanPlugin.js +1 -1
- package/lib/Compilation.js +91 -47
- package/lib/Compiler.js +57 -3
- package/lib/ContextModule.js +21 -17
- package/lib/DelegatedModule.js +1 -1
- package/lib/Dependency.js +10 -0
- package/lib/DependencyTemplate.js +9 -0
- 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/ExternalModule.js +94 -54
- package/lib/ExternalModuleFactoryPlugin.js +1 -1
- package/lib/FileSystemInfo.js +29 -25
- package/lib/Generator.js +2 -0
- package/lib/HookWebpackError.js +1 -1
- package/lib/Module.js +25 -2
- package/lib/ModuleFilenameHelpers.js +5 -1
- package/lib/MultiCompiler.js +1 -1
- package/lib/MultiWatching.js +1 -1
- package/lib/NormalModule.js +9 -5
- package/lib/RawModule.js +1 -1
- package/lib/RuntimeGlobals.js +29 -1
- package/lib/RuntimeModule.js +1 -1
- package/lib/RuntimePlugin.js +50 -0
- package/lib/RuntimeTemplate.js +113 -2
- package/lib/Template.js +2 -1
- package/lib/WatchIgnorePlugin.js +14 -1
- package/lib/Watching.js +33 -19
- package/lib/WebpackOptionsApply.js +43 -2
- package/lib/asset/AssetGenerator.js +71 -30
- package/lib/asset/AssetModulesPlugin.js +3 -0
- package/lib/asset/RawDataUrlModule.js +148 -0
- package/lib/cache/ResolverCachePlugin.js +1 -1
- package/lib/cli.js +44 -3
- package/lib/config/browserslistTargetHandler.js +38 -1
- package/lib/config/defaults.js +79 -6
- package/lib/config/normalization.js +5 -0
- package/lib/config/target.js +10 -0
- package/lib/container/ContainerEntryModule.js +8 -5
- 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 +109 -0
- package/lib/css/CssLoadingRuntimeModule.js +447 -0
- package/lib/css/CssModulesPlugin.js +461 -0
- package/lib/css/CssParser.js +618 -0
- package/lib/css/walkCssTokens.js +659 -0
- package/lib/debug/ProfilingPlugin.js +12 -10
- package/lib/dependencies/CreateScriptUrlDependency.js +12 -0
- package/lib/dependencies/CssExportDependency.js +85 -0
- package/lib/dependencies/CssImportDependency.js +75 -0
- package/lib/dependencies/CssLocalIdentifierDependency.js +119 -0
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +101 -0
- package/lib/dependencies/CssUrlDependency.js +132 -0
- package/lib/dependencies/LoaderPlugin.js +2 -2
- package/lib/dependencies/URLDependency.js +3 -8
- package/lib/esm/ModuleChunkFormatPlugin.js +74 -49
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -1
- package/lib/hmr/LazyCompilationPlugin.js +45 -21
- package/lib/hmr/lazyCompilationBackend.js +4 -2
- 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 +8 -0
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +2 -2
- package/lib/javascript/ChunkHelpers.js +33 -0
- package/lib/javascript/JavascriptGenerator.js +1 -0
- package/lib/javascript/JavascriptParser.js +16 -8
- package/lib/javascript/StartupHelpers.js +4 -28
- package/lib/library/AssignLibraryPlugin.js +31 -13
- package/lib/library/EnableLibraryPlugin.js +11 -0
- package/lib/node/NodeWatchFileSystem.js +85 -31
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +1 -1
- package/lib/node/RequireChunkLoadingRuntimeModule.js +1 -1
- package/lib/optimize/ConcatenatedModule.js +11 -5
- 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 +8 -8
- package/lib/sharing/ConsumeSharedModule.js +8 -2
- package/lib/sharing/ConsumeSharedRuntimeModule.js +25 -4
- 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 +89 -24
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/extractUrlAndGlobal.js +3 -0
- package/lib/util/fs.js +10 -0
- package/lib/util/hash/xxhash64.js +2 -2
- package/lib/util/internalSerializables.js +11 -0
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +3 -3
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -11
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +3 -2
- package/package.json +5 -12
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +100 -1
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.json +2 -1
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +3 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssGeneratorOptions.check.js +6 -0
- package/schemas/plugins/css/CssGeneratorOptions.json +3 -0
- package/schemas/plugins/css/CssParserOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssParserOptions.json +3 -0
- package/types.d.ts +305 -58
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/Cache.js
CHANGED
package/lib/CacheFacade.js
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
const { forEachBail } = require("enhanced-resolve");
|
8
9
|
const asyncLib = require("neo-async");
|
9
10
|
const getLazyHashedEtag = require("./cache/getLazyHashedEtag");
|
10
11
|
const mergeEtags = require("./cache/mergeEtags");
|
@@ -18,7 +19,7 @@ const mergeEtags = require("./cache/mergeEtags");
|
|
18
19
|
/**
|
19
20
|
* @template T
|
20
21
|
* @callback CallbackCache
|
21
|
-
* @param {WebpackError=} err
|
22
|
+
* @param {(WebpackError | null)=} err
|
22
23
|
* @param {T=} result
|
23
24
|
* @returns {void}
|
24
25
|
*/
|
@@ -26,7 +27,7 @@ const mergeEtags = require("./cache/mergeEtags");
|
|
26
27
|
/**
|
27
28
|
* @template T
|
28
29
|
* @callback CallbackNormalErrorCache
|
29
|
-
* @param {Error=} err
|
30
|
+
* @param {(Error | null)=} err
|
30
31
|
* @param {T=} result
|
31
32
|
* @returns {void}
|
32
33
|
*/
|
@@ -46,15 +47,7 @@ class MultiItemCache {
|
|
46
47
|
* @returns {void}
|
47
48
|
*/
|
48
49
|
get(callback) {
|
49
|
-
|
50
|
-
this._items[i].get((err, result) => {
|
51
|
-
if (err) return callback(err);
|
52
|
-
if (result !== undefined) return callback(null, result);
|
53
|
-
if (++i >= this._items.length) return callback();
|
54
|
-
next(i);
|
55
|
-
});
|
56
|
-
};
|
57
|
-
next(0);
|
50
|
+
forEachBail(this._items, (item, callback) => item.get(callback), callback);
|
58
51
|
}
|
59
52
|
|
60
53
|
/**
|
package/lib/Chunk.js
CHANGED
@@ -80,6 +80,8 @@ class Chunk {
|
|
80
80
|
this.preventIntegration = false;
|
81
81
|
/** @type {(string | function(PathData, AssetInfo=): string)?} */
|
82
82
|
this.filenameTemplate = undefined;
|
83
|
+
/** @type {(string | function(PathData, AssetInfo=): string)?} */
|
84
|
+
this.cssFilenameTemplate = undefined;
|
83
85
|
/** @private @type {SortableSet<ChunkGroup>} */
|
84
86
|
this._groups = new SortableSet(undefined, compareChunkGroupsByIndex);
|
85
87
|
/** @type {RuntimeSpec} */
|
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
|
*/
|
@@ -1020,7 +1020,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1020
1020
|
/** @type {Map<DepConstructor, ModuleFactory>} */
|
1021
1021
|
this.dependencyFactories = new Map();
|
1022
1022
|
/** @type {DependencyTemplates} */
|
1023
|
-
this.dependencyTemplates = new DependencyTemplates(
|
1023
|
+
this.dependencyTemplates = new DependencyTemplates(
|
1024
|
+
this.outputOptions.hashFunction
|
1025
|
+
);
|
1024
1026
|
this.childrenCounters = {};
|
1025
1027
|
/** @type {Set<number|string>} */
|
1026
1028
|
this.usedChunkIds = null;
|
@@ -3193,47 +3195,87 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3193
3195
|
this;
|
3194
3196
|
const results = this.codeGenerationResults;
|
3195
3197
|
const errors = [];
|
3196
|
-
|
3197
|
-
|
3198
|
-
|
3199
|
-
|
3200
|
-
|
3201
|
-
|
3202
|
-
|
3203
|
-
|
3204
|
-
|
3205
|
-
|
3206
|
-
|
3207
|
-
|
3208
|
-
|
3209
|
-
|
3210
|
-
|
3211
|
-
|
3212
|
-
|
3213
|
-
|
3214
|
-
|
3198
|
+
/** @type {Set<Module> | undefined} */
|
3199
|
+
let notCodeGeneratedModules = undefined;
|
3200
|
+
const runIteration = () => {
|
3201
|
+
let delayedJobs = [];
|
3202
|
+
let delayedModules = new Set();
|
3203
|
+
asyncLib.eachLimit(
|
3204
|
+
jobs,
|
3205
|
+
this.options.parallelism,
|
3206
|
+
(job, callback) => {
|
3207
|
+
const { module } = job;
|
3208
|
+
const { codeGenerationDependencies } = module;
|
3209
|
+
if (codeGenerationDependencies !== undefined) {
|
3210
|
+
if (
|
3211
|
+
notCodeGeneratedModules === undefined ||
|
3212
|
+
codeGenerationDependencies.some(dep => {
|
3213
|
+
const referencedModule = moduleGraph.getModule(dep);
|
3214
|
+
return notCodeGeneratedModules.has(referencedModule);
|
3215
|
+
})
|
3216
|
+
) {
|
3217
|
+
delayedJobs.push(job);
|
3218
|
+
delayedModules.add(module);
|
3219
|
+
return callback();
|
3220
|
+
}
|
3215
3221
|
}
|
3216
|
-
|
3217
|
-
|
3218
|
-
|
3219
|
-
|
3220
|
-
|
3221
|
-
|
3222
|
-
|
3222
|
+
const { hash, runtime, runtimes } = job;
|
3223
|
+
this._codeGenerationModule(
|
3224
|
+
module,
|
3225
|
+
runtime,
|
3226
|
+
runtimes,
|
3227
|
+
hash,
|
3228
|
+
dependencyTemplates,
|
3229
|
+
chunkGraph,
|
3230
|
+
moduleGraph,
|
3231
|
+
runtimeTemplate,
|
3232
|
+
errors,
|
3233
|
+
results,
|
3234
|
+
(err, codeGenerated) => {
|
3235
|
+
if (codeGenerated) statModulesGenerated++;
|
3236
|
+
else statModulesFromCache++;
|
3237
|
+
callback(err);
|
3238
|
+
}
|
3223
3239
|
);
|
3224
|
-
|
3225
|
-
|
3240
|
+
},
|
3241
|
+
err => {
|
3242
|
+
if (err) return callback(err);
|
3243
|
+
if (delayedJobs.length > 0) {
|
3244
|
+
if (delayedJobs.length === jobs.length) {
|
3245
|
+
return callback(
|
3246
|
+
new Error(
|
3247
|
+
`Unable to make progress during code generation because of circular code generation dependency: ${Array.from(
|
3248
|
+
delayedModules,
|
3249
|
+
m => m.identifier()
|
3250
|
+
).join(", ")}`
|
3251
|
+
)
|
3252
|
+
);
|
3253
|
+
}
|
3254
|
+
jobs = delayedJobs;
|
3255
|
+
delayedJobs = [];
|
3256
|
+
notCodeGeneratedModules = delayedModules;
|
3257
|
+
delayedModules = new Set();
|
3258
|
+
return runIteration();
|
3259
|
+
}
|
3260
|
+
if (errors.length > 0) {
|
3261
|
+
errors.sort(
|
3262
|
+
compareSelect(err => err.module, compareModulesByIdentifier)
|
3263
|
+
);
|
3264
|
+
for (const error of errors) {
|
3265
|
+
this.errors.push(error);
|
3266
|
+
}
|
3226
3267
|
}
|
3268
|
+
this.logger.log(
|
3269
|
+
`${Math.round(
|
3270
|
+
(100 * statModulesGenerated) /
|
3271
|
+
(statModulesGenerated + statModulesFromCache)
|
3272
|
+
)}% code generated (${statModulesGenerated} generated, ${statModulesFromCache} from cache)`
|
3273
|
+
);
|
3274
|
+
callback();
|
3227
3275
|
}
|
3228
|
-
|
3229
|
-
|
3230
|
-
|
3231
|
-
(statModulesGenerated + statModulesFromCache)
|
3232
|
-
)}% code generated (${statModulesGenerated} generated, ${statModulesFromCache} from cache)`
|
3233
|
-
);
|
3234
|
-
callback();
|
3235
|
-
}
|
3236
|
-
);
|
3276
|
+
);
|
3277
|
+
};
|
3278
|
+
runIteration();
|
3237
3279
|
}
|
3238
3280
|
|
3239
3281
|
/**
|
@@ -3283,7 +3325,8 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3283
3325
|
moduleGraph,
|
3284
3326
|
dependencyTemplates,
|
3285
3327
|
runtimeTemplate,
|
3286
|
-
runtime
|
3328
|
+
runtime,
|
3329
|
+
codeGenerationResults: results
|
3287
3330
|
});
|
3288
3331
|
} catch (err) {
|
3289
3332
|
errors.push(new CodeGenerationError(module, err));
|
@@ -3512,10 +3555,11 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3512
3555
|
}
|
3513
3556
|
|
3514
3557
|
/**
|
3558
|
+
* If `module` is passed, `loc` and `request` must also be passed.
|
3515
3559
|
* @param {string | ChunkGroupOptions} groupOptions options for the chunk group
|
3516
|
-
* @param {Module} module the module the references the chunk group
|
3517
|
-
* @param {DependencyLocation} loc the location from with the chunk group is referenced (inside of module)
|
3518
|
-
* @param {string} request the request from which the the chunk group is referenced
|
3560
|
+
* @param {Module=} module the module the references the chunk group
|
3561
|
+
* @param {DependencyLocation=} loc the location from with the chunk group is referenced (inside of module)
|
3562
|
+
* @param {string=} request the request from which the the chunk group is referenced
|
3519
3563
|
* @returns {ChunkGroup} the new or existing chunk group
|
3520
3564
|
*/
|
3521
3565
|
addChunkInGroup(groupOptions, module, loc, request) {
|
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) {
|
package/lib/Dependency.js
CHANGED
@@ -172,6 +172,16 @@ class Dependency {
|
|
172
172
|
this._loc = loc;
|
173
173
|
}
|
174
174
|
|
175
|
+
setLoc(startLine, startColumn, endLine, endColumn) {
|
176
|
+
this._locSL = startLine;
|
177
|
+
this._locSC = startColumn;
|
178
|
+
this._locEL = endLine;
|
179
|
+
this._locEC = endColumn;
|
180
|
+
this._locI = undefined;
|
181
|
+
this._locN = undefined;
|
182
|
+
this._loc = undefined;
|
183
|
+
}
|
184
|
+
|
175
185
|
/**
|
176
186
|
* @returns {string | null} an identifier to merge equal requests
|
177
187
|
*/
|
@@ -7,6 +7,7 @@
|
|
7
7
|
|
8
8
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
9
9
|
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
10
|
+
/** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */
|
10
11
|
/** @typedef {import("./ConcatenationScope")} ConcatenationScope */
|
11
12
|
/** @typedef {import("./Dependency")} Dependency */
|
12
13
|
/** @typedef {import("./Dependency").RuntimeSpec} RuntimeSpec */
|
@@ -28,8 +29,16 @@
|
|
28
29
|
* @property {RuntimeSpec} runtime current runtimes, for which code is generated
|
29
30
|
* @property {InitFragment<GenerateContext>[]} initFragments mutable array of init fragments for the current module
|
30
31
|
* @property {ConcatenationScope=} concatenationScope when in a concatenated module, information about other concatenated modules
|
32
|
+
* @property {CodeGenerationResults} codeGenerationResults the code generation results
|
31
33
|
*/
|
32
34
|
|
35
|
+
/**
|
36
|
+
* @typedef {Object} CssDependencyTemplateContextExtras
|
37
|
+
* @property {Map<string, string>} cssExports the css exports
|
38
|
+
*/
|
39
|
+
|
40
|
+
/** @typedef {DependencyTemplateContext & CssDependencyTemplateContextExtras} CssDependencyTemplateContext */
|
41
|
+
|
33
42
|
class DependencyTemplate {
|
34
43
|
/* istanbul ignore next */
|
35
44
|
/**
|
@@ -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
|
}
|