webpack 5.72.0 → 5.74.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 +16 -9
- package/lib/Compilation.js +5 -1
- package/lib/Compiler.js +1 -1
- package/lib/DllReferencePlugin.js +1 -1
- package/lib/FileSystemInfo.js +35 -14
- package/lib/NodeStuffPlugin.js +3 -3
- package/lib/NormalModule.js +1 -1
- package/lib/RuntimePlugin.js +7 -0
- package/lib/config/defaults.js +12 -4
- package/lib/container/ModuleFederationPlugin.js +2 -0
- package/lib/css/CssLoadingRuntimeModule.js +9 -7
- package/lib/dependencies/CommonJsImportsParserPlugin.js +342 -61
- package/lib/dependencies/CommonJsRequireContextDependency.js +2 -2
- package/lib/dependencies/CommonJsRequireDependency.js +2 -1
- package/lib/dependencies/ContextDependency.js +15 -2
- package/lib/dependencies/ContextDependencyHelpers.js +18 -5
- package/lib/dependencies/ContextElementDependency.js +0 -16
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +35 -3
- package/lib/dependencies/ImportParserPlugin.js +31 -25
- package/lib/dependencies/JsonExportsDependency.js +17 -21
- package/lib/dependencies/LoaderDependency.js +13 -0
- package/lib/dependencies/LoaderImportDependency.js +13 -0
- package/lib/dependencies/ModuleDependency.js +11 -1
- package/lib/dependencies/ProvidedDependency.js +31 -8
- package/lib/dependencies/RequireResolveContextDependency.js +2 -2
- package/lib/dependencies/RequireResolveDependency.js +2 -1
- package/lib/dependencies/URLPlugin.js +21 -0
- package/lib/index.js +4 -0
- package/lib/javascript/JavascriptParser.js +47 -21
- package/lib/json/JsonData.js +8 -0
- package/lib/json/JsonParser.js +4 -6
- package/lib/optimize/ConcatenatedModule.js +40 -17
- package/lib/optimize/ModuleConcatenationPlugin.js +1 -1
- package/lib/runtime/AsyncModuleRuntimeModule.js +32 -58
- package/lib/runtime/LoadScriptRuntimeModule.js +9 -7
- package/lib/runtime/NonceRuntimeModule.js +24 -0
- package/lib/sharing/ProvideSharedPlugin.js +1 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +11 -9
- package/package.json +6 -5
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +60 -0
- package/types.d.ts +94 -4
package/README.md
CHANGED
@@ -15,8 +15,8 @@
|
|
15
15
|
[![PR's welcome][prs]][prs-url]
|
16
16
|
|
17
17
|
<br>
|
18
|
-
<a href="https://
|
19
|
-
<img src="https://api.dependabot.com/badges/compatibility_score?dependency-name=webpack&package-manager=npm_and_yarn&version
|
18
|
+
<a href="https://docs.github.com/en/code-security/dependabot/dependabot-security-updates/about-dependabot-security-updates#about-compatibility-scores">
|
19
|
+
<img src="https://api.dependabot.com/badges/compatibility_score?dependency-name=webpack&package-manager=npm_and_yarn&previous-version=5.72.1&new-version=5.73.0">
|
20
20
|
</a>
|
21
21
|
<a href="https://npmcharts.com/compare/webpack?minimal=true">
|
22
22
|
<img src="https://img.shields.io/npm/dm/webpack.svg">
|
@@ -110,6 +110,7 @@ within webpack itself use this plugin interface. This makes webpack very
|
|
110
110
|
| [mini-css-extract-plugin][mini-css] | ![mini-css-npm] | ![mini-css-size] | Extracts CSS into separate files. It creates a CSS file per JS file which contains CSS. |
|
111
111
|
| [compression-webpack-plugin][compression] | ![compression-npm] | ![compression-size] | Prepares compressed versions of assets to serve them with Content-Encoding |
|
112
112
|
| [html-webpack-plugin][html-plugin] | ![html-plugin-npm] | ![html-plugin-size] | Simplifies creation of HTML files (`index.html`) to serve your bundles |
|
113
|
+
| [pug-plugin][pug-plugin] | ![pug-plugin-npm] | ![pug-plugin-size] | Renders Pug files to HTML, extracts JS and CSS from sources specified directly in Pug. |
|
113
114
|
|
114
115
|
[common-npm]: https://img.shields.io/npm/v/webpack.svg
|
115
116
|
[mini-css]: https://github.com/webpack-contrib/mini-css-extract-plugin
|
@@ -124,6 +125,9 @@ within webpack itself use this plugin interface. This makes webpack very
|
|
124
125
|
[html-plugin]: https://github.com/jantimon/html-webpack-plugin
|
125
126
|
[html-plugin-npm]: https://img.shields.io/npm/v/html-webpack-plugin.svg
|
126
127
|
[html-plugin-size]: https://packagephobia.com/badge?p=html-webpack-plugin
|
128
|
+
[pug-plugin]: https://github.com/webdiscus/pug-plugin
|
129
|
+
[pug-plugin-npm]: https://img.shields.io/npm/v/pug-plugin.svg
|
130
|
+
[pug-plugin-size]: https://packagephobia.com/badge?p=pug-plugin
|
127
131
|
|
128
132
|
### [Loaders](https://webpack.js.org/loaders/)
|
129
133
|
|
@@ -170,18 +174,21 @@ or are automatically applied via regex from your webpack configuration.
|
|
170
174
|
|
171
175
|
#### Templating
|
172
176
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
177
|
+
| Name | Status | Install Size | Description |
|
178
|
+
| :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------: | :--------------: | :-------------------------------------------------------------------------------------- |
|
179
|
+
| <a href="https://github.com/webpack-contrib/html-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/html5.svg"></a> | ![html-npm] | ![html-size] | Exports HTML as string, requires references to static resources |
|
180
|
+
| <a href="https://github.com/pugjs/pug-loader"><img width="48" height="48" src="https://cdn.rawgit.com/pugjs/pug-logo/master/SVG/pug-final-logo-_-colour-128.svg"></a> | ![pug-npm] | ![pug-size] | Loads Pug templates and returns a function |
|
181
|
+
| <a href="https://github.com/webdiscus/pug-loader"><img width="48" height="48" src="https://cdn.rawgit.com/pugjs/pug-logo/master/SVG/pug-final-logo-_-colour-128.svg"></a> | ![pug3-npm] | ![pug3-size] | Compiles Pug to a function or HTML string, useful for use with Vue, React, Angular |
|
182
|
+
| <a href="https://github.com/peerigon/markdown-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/markdown.svg"></a> | ![md-npm] | ![md-size] | Compiles Markdown to HTML |
|
183
|
+
| <a href="https://github.com/posthtml/posthtml-loader"><img width="48" height="48" src="https://posthtml.github.io/posthtml/logo.svg"></a> | ![posthtml-npm] | ![posthtml-size] | Loads and transforms a HTML file using [PostHTML](https://github.com/posthtml/posthtml) |
|
184
|
+
| <a href="https://github.com/pcardune/handlebars-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/handlebars-1.svg"></a> | ![hbs-npm] | ![hbs-size] | Compiles Handlebars to HTML |
|
180
185
|
|
181
186
|
[html-npm]: https://img.shields.io/npm/v/html-loader.svg
|
182
187
|
[html-size]: https://packagephobia.com/badge?p=html-loader
|
183
188
|
[pug-npm]: https://img.shields.io/npm/v/pug-loader.svg
|
184
189
|
[pug-size]: https://packagephobia.com/badge?p=pug-loader
|
190
|
+
[pug3-npm]: https://img.shields.io/npm/v/@webdiscus/pug-loader.svg
|
191
|
+
[pug3-size]: https://packagephobia.com/badge?p=@webdiscus/pug-loader
|
185
192
|
[jade-npm]: https://img.shields.io/npm/v/jade-loader.svg
|
186
193
|
[jade-size]: https://packagephobia.com/badge?p=jade-loader
|
187
194
|
[md-npm]: https://img.shields.io/npm/v/markdown-loader.svg
|
package/lib/Compilation.js
CHANGED
@@ -4241,7 +4241,11 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4241
4241
|
if (!isSourceEqual(this.assets[file], source)) {
|
4242
4242
|
this.errors.push(
|
4243
4243
|
new WebpackError(
|
4244
|
-
`Conflict: Multiple assets emit different content to the same filename ${file}
|
4244
|
+
`Conflict: Multiple assets emit different content to the same filename ${file}${
|
4245
|
+
assetInfo.sourceFilename
|
4246
|
+
? `. Original source ${assetInfo.sourceFilename}`
|
4247
|
+
: ""
|
4248
|
+
}`
|
4245
4249
|
)
|
4246
4250
|
);
|
4247
4251
|
this.assets[file] = source;
|
package/lib/Compiler.js
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
-
const parseJson = require("json-parse-better-errors");
|
8
|
+
const parseJson = require("json-parse-even-better-errors");
|
9
9
|
const DelegatedModuleFactoryPlugin = require("./DelegatedModuleFactoryPlugin");
|
10
10
|
const ExternalModuleFactoryPlugin = require("./ExternalModuleFactoryPlugin");
|
11
11
|
const WebpackError = require("./WebpackError");
|
package/lib/FileSystemInfo.js
CHANGED
@@ -8,6 +8,7 @@
|
|
8
8
|
const { create: createResolver } = require("enhanced-resolve");
|
9
9
|
const nodeModule = require("module");
|
10
10
|
const asyncLib = require("neo-async");
|
11
|
+
const { isAbsolute } = require("path");
|
11
12
|
const AsyncQueue = require("./util/AsyncQueue");
|
12
13
|
const StackedCacheMap = require("./util/StackedCacheMap");
|
13
14
|
const createHash = require("./util/createHash");
|
@@ -207,6 +208,12 @@ class SnapshotIterable {
|
|
207
208
|
class Snapshot {
|
208
209
|
constructor() {
|
209
210
|
this._flags = 0;
|
211
|
+
/** @type {Iterable<string> | undefined} */
|
212
|
+
this._cachedFileIterable = undefined;
|
213
|
+
/** @type {Iterable<string> | undefined} */
|
214
|
+
this._cachedContextIterable = undefined;
|
215
|
+
/** @type {Iterable<string> | undefined} */
|
216
|
+
this._cachedMissingIterable = undefined;
|
210
217
|
/** @type {number | undefined} */
|
211
218
|
this.startTime = undefined;
|
212
219
|
/** @type {Map<string, FileSystemInfoEntry | null> | undefined} */
|
@@ -417,31 +424,43 @@ class Snapshot {
|
|
417
424
|
* @returns {Iterable<string>} iterable
|
418
425
|
*/
|
419
426
|
getFileIterable() {
|
420
|
-
|
421
|
-
s
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
427
|
+
if (this._cachedFileIterable === undefined) {
|
428
|
+
this._cachedFileIterable = this._createIterable(s => [
|
429
|
+
s.fileTimestamps,
|
430
|
+
s.fileHashes,
|
431
|
+
s.fileTshs,
|
432
|
+
s.managedFiles
|
433
|
+
]);
|
434
|
+
}
|
435
|
+
return this._cachedFileIterable;
|
426
436
|
}
|
427
437
|
|
428
438
|
/**
|
429
439
|
* @returns {Iterable<string>} iterable
|
430
440
|
*/
|
431
441
|
getContextIterable() {
|
432
|
-
|
433
|
-
s
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
442
|
+
if (this._cachedContextIterable === undefined) {
|
443
|
+
this._cachedContextIterable = this._createIterable(s => [
|
444
|
+
s.contextTimestamps,
|
445
|
+
s.contextHashes,
|
446
|
+
s.contextTshs,
|
447
|
+
s.managedContexts
|
448
|
+
]);
|
449
|
+
}
|
450
|
+
return this._cachedContextIterable;
|
438
451
|
}
|
439
452
|
|
440
453
|
/**
|
441
454
|
* @returns {Iterable<string>} iterable
|
442
455
|
*/
|
443
456
|
getMissingIterable() {
|
444
|
-
|
457
|
+
if (this._cachedMissingIterable === undefined) {
|
458
|
+
this._cachedMissingIterable = this._createIterable(s => [
|
459
|
+
s.missingExistence,
|
460
|
+
s.managedMissing
|
461
|
+
]);
|
462
|
+
}
|
463
|
+
return this._cachedMissingIterable;
|
445
464
|
}
|
446
465
|
}
|
447
466
|
|
@@ -1633,7 +1652,9 @@ class FileSystemInfo {
|
|
1633
1652
|
let request = relative(this.fs, context, childPath);
|
1634
1653
|
if (request.endsWith(".js")) request = request.slice(0, -3);
|
1635
1654
|
request = request.replace(/\\/g, "/");
|
1636
|
-
if (!request.startsWith("../")
|
1655
|
+
if (!request.startsWith("../") && !isAbsolute(request)) {
|
1656
|
+
request = `./${request}`;
|
1657
|
+
}
|
1637
1658
|
push({
|
1638
1659
|
type: RBDT_RESOLVE_CJS_FILE,
|
1639
1660
|
context,
|
package/lib/NodeStuffPlugin.js
CHANGED
@@ -64,7 +64,7 @@ class NodeStuffPlugin {
|
|
64
64
|
new NodeStuffInWebError(
|
65
65
|
dep.loc,
|
66
66
|
"global",
|
67
|
-
"The global namespace object is Node.js feature and
|
67
|
+
"The global namespace object is a Node.js feature and isn't available in browsers."
|
68
68
|
)
|
69
69
|
);
|
70
70
|
}
|
@@ -117,7 +117,7 @@ class NodeStuffPlugin {
|
|
117
117
|
setConstant(
|
118
118
|
"__filename",
|
119
119
|
"/index.js",
|
120
|
-
"
|
120
|
+
"__filename is a Node.js feature and isn't available in browsers."
|
121
121
|
);
|
122
122
|
break;
|
123
123
|
case true:
|
@@ -144,7 +144,7 @@ class NodeStuffPlugin {
|
|
144
144
|
setConstant(
|
145
145
|
"__dirname",
|
146
146
|
"/",
|
147
|
-
"
|
147
|
+
"__dirname is a Node.js feature and isn't available in browsers."
|
148
148
|
);
|
149
149
|
break;
|
150
150
|
case true:
|
package/lib/NormalModule.js
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
-
const parseJson = require("json-parse-better-errors");
|
8
|
+
const parseJson = require("json-parse-even-better-errors");
|
9
9
|
const { getContext, runLoaders } = require("loader-runner");
|
10
10
|
const querystring = require("querystring");
|
11
11
|
const { HookMap, SyncHook, AsyncSeriesBailHook } = require("tapable");
|
package/lib/RuntimePlugin.js
CHANGED
@@ -26,6 +26,7 @@ const GlobalRuntimeModule = require("./runtime/GlobalRuntimeModule");
|
|
26
26
|
const HasOwnPropertyRuntimeModule = require("./runtime/HasOwnPropertyRuntimeModule");
|
27
27
|
const LoadScriptRuntimeModule = require("./runtime/LoadScriptRuntimeModule");
|
28
28
|
const MakeNamespaceObjectRuntimeModule = require("./runtime/MakeNamespaceObjectRuntimeModule");
|
29
|
+
const NonceRuntimeModule = require("./runtime/NonceRuntimeModule");
|
29
30
|
const OnChunksLoadedRuntimeModule = require("./runtime/OnChunksLoadedRuntimeModule");
|
30
31
|
const PublicPathRuntimeModule = require("./runtime/PublicPathRuntimeModule");
|
31
32
|
const RelativeUrlRuntimeModule = require("./runtime/RelativeUrlRuntimeModule");
|
@@ -431,6 +432,12 @@ class RuntimePlugin {
|
|
431
432
|
return true;
|
432
433
|
}
|
433
434
|
});
|
435
|
+
compilation.hooks.runtimeRequirementInTree
|
436
|
+
.for(RuntimeGlobals.scriptNonce)
|
437
|
+
.tap("RuntimePlugin", chunk => {
|
438
|
+
compilation.addRuntimeModule(chunk, new NonceRuntimeModule());
|
439
|
+
return true;
|
440
|
+
});
|
434
441
|
// TODO webpack 6: remove CompatRuntimeModule
|
435
442
|
compilation.hooks.additionalTreeRuntimeRequirements.tap(
|
436
443
|
"RuntimePlugin",
|
package/lib/config/defaults.js
CHANGED
@@ -190,7 +190,8 @@ const applyWebpackOptionsDefaults = options => {
|
|
190
190
|
syncWebAssembly: options.experiments.syncWebAssembly,
|
191
191
|
asyncWebAssembly: options.experiments.asyncWebAssembly,
|
192
192
|
css: options.experiments.css,
|
193
|
-
futureDefaults
|
193
|
+
futureDefaults,
|
194
|
+
isNode: targetProperties && targetProperties.node === true
|
194
195
|
});
|
195
196
|
|
196
197
|
applyOutputDefaults(options.output, {
|
@@ -451,11 +452,12 @@ const applySnapshotDefaults = (snapshot, { production, futureDefaults }) => {
|
|
451
452
|
* @param {JavascriptParserOptions} parserOptions parser options
|
452
453
|
* @param {Object} options options
|
453
454
|
* @param {boolean} options.futureDefaults is future defaults enabled
|
455
|
+
* @param {boolean} options.isNode is node target platform
|
454
456
|
* @returns {void}
|
455
457
|
*/
|
456
458
|
const applyJavascriptParserOptionsDefaults = (
|
457
459
|
parserOptions,
|
458
|
-
{ futureDefaults }
|
460
|
+
{ futureDefaults, isNode }
|
459
461
|
) => {
|
460
462
|
D(parserOptions, "unknownContextRequest", ".");
|
461
463
|
D(parserOptions, "unknownContextRegExp", false);
|
@@ -470,6 +472,10 @@ const applyJavascriptParserOptionsDefaults = (
|
|
470
472
|
D(parserOptions, "wrappedContextCritical", false);
|
471
473
|
D(parserOptions, "strictThisContextOnImports", false);
|
472
474
|
D(parserOptions, "importMeta", true);
|
475
|
+
D(parserOptions, "dynamicImportMode", "lazy");
|
476
|
+
D(parserOptions, "dynamicImportPrefetch", false);
|
477
|
+
D(parserOptions, "dynamicImportPreload", false);
|
478
|
+
D(parserOptions, "createRequire", isNode);
|
473
479
|
if (futureDefaults) D(parserOptions, "exportsPresence", "error");
|
474
480
|
};
|
475
481
|
|
@@ -481,11 +487,12 @@ const applyJavascriptParserOptionsDefaults = (
|
|
481
487
|
* @param {boolean} options.asyncWebAssembly is asyncWebAssembly enabled
|
482
488
|
* @param {CssExperimentOptions} options.css is css enabled
|
483
489
|
* @param {boolean} options.futureDefaults is future defaults enabled
|
490
|
+
* @param {boolean} options.isNode is node target platform
|
484
491
|
* @returns {void}
|
485
492
|
*/
|
486
493
|
const applyModuleDefaults = (
|
487
494
|
module,
|
488
|
-
{ cache, syncWebAssembly, asyncWebAssembly, css, futureDefaults }
|
495
|
+
{ cache, syncWebAssembly, asyncWebAssembly, css, futureDefaults, isNode }
|
489
496
|
) => {
|
490
497
|
if (cache) {
|
491
498
|
D(module, "unsafeCache", module => {
|
@@ -504,7 +511,8 @@ const applyModuleDefaults = (
|
|
504
511
|
|
505
512
|
F(module.parser, "javascript", () => ({}));
|
506
513
|
applyJavascriptParserOptionsDefaults(module.parser.javascript, {
|
507
|
-
futureDefaults
|
514
|
+
futureDefaults,
|
515
|
+
isNode
|
508
516
|
});
|
509
517
|
|
510
518
|
A(module, "defaultRules", () => {
|
@@ -65,6 +65,7 @@ class ModuleFederationPlugin {
|
|
65
65
|
library,
|
66
66
|
filename: options.filename,
|
67
67
|
runtime: options.runtime,
|
68
|
+
shareScope: options.shareScope,
|
68
69
|
exposes: options.exposes
|
69
70
|
}).apply(compiler);
|
70
71
|
}
|
@@ -76,6 +77,7 @@ class ModuleFederationPlugin {
|
|
76
77
|
) {
|
77
78
|
new ContainerReferencePlugin({
|
78
79
|
remoteType,
|
80
|
+
shareScope: options.shareScope,
|
79
81
|
remotes: options.remotes
|
80
82
|
}).apply(compiler);
|
81
83
|
}
|
@@ -108,13 +108,15 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
|
108
108
|
'link.rel = "stylesheet";',
|
109
109
|
"link.href = url;",
|
110
110
|
crossOriginLoading
|
111
|
-
?
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
111
|
+
? crossOriginLoading === "use-credentials"
|
112
|
+
? 'link.crossOrigin = "use-credentials";'
|
113
|
+
: Template.asString([
|
114
|
+
"if (link.src.indexOf(window.location.origin + '/') !== 0) {",
|
115
|
+
Template.indent(
|
116
|
+
`link.crossOrigin = ${JSON.stringify(crossOriginLoading)};`
|
117
|
+
),
|
118
|
+
"}"
|
119
|
+
])
|
118
120
|
: ""
|
119
121
|
]);
|
120
122
|
|