webpack 5.10.3 → 5.11.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.

@@ -167,7 +167,7 @@ const { isSourceEqual } = require("./util/source");
167
167
  */
168
168
 
169
169
  /**
170
- * @typedef {Object} AssetInfo
170
+ * @typedef {Object} KnownAssetInfo
171
171
  * @property {boolean=} immutable true, if the asset can be long term cached forever (contains a hash)
172
172
  * @property {boolean=} minimized whether the asset is minimized
173
173
  * @property {string | string[]=} fullhash the value(s) of the full hash used for this asset
@@ -182,6 +182,8 @@ const { isSourceEqual } = require("./util/source");
182
182
  * @property {Record<string, string | string[]>=} related object of pointers to other assets, keyed by type of relation (only points from parent to child)
183
183
  */
184
184
 
185
+ /** @typedef {KnownAssetInfo & Record<string, any>} AssetInfo */
186
+
185
187
  /**
186
188
  * @typedef {Object} Asset
187
189
  * @property {string} name the filename of the asset
package/lib/Module.js CHANGED
@@ -153,7 +153,7 @@ class Module extends DependenciesBlock {
153
153
  this._errors = undefined;
154
154
  /** @type {BuildMeta} */
155
155
  this.buildMeta = undefined;
156
- /** @type {object} */
156
+ /** @type {Record<string, any>} */
157
157
  this.buildInfo = undefined;
158
158
  /** @type {Dependency[] | undefined} */
159
159
  this.presentationalDependencies = undefined;
package/lib/index.js CHANGED
@@ -22,6 +22,8 @@ const memorize = require("./util/memorize");
22
22
  /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptionsNormalized */
23
23
  /** @typedef {import("../declarations/WebpackOptions").WebpackPluginFunction} WebpackPluginFunction */
24
24
  /** @typedef {import("../declarations/WebpackOptions").WebpackPluginInstance} WebpackPluginInstance */
25
+ /** @typedef {import("./Compilation").Asset} Asset */
26
+ /** @typedef {import("./Compilation").AssetInfo} AssetInfo */
25
27
  /** @typedef {import("./Parser").ParserState} ParserState */
26
28
 
27
29
  /**
@@ -260,6 +262,9 @@ module.exports = mergeExports(fn, {
260
262
  get WatchIgnorePlugin() {
261
263
  return require("./WatchIgnorePlugin");
262
264
  },
265
+ get WebpackError() {
266
+ return require("./WebpackError");
267
+ },
263
268
  get WebpackOptionsApply() {
264
269
  return require("./WebpackOptionsApply");
265
270
  },
@@ -96,8 +96,10 @@ class RuleSetCompiler {
96
96
  }
97
97
  } else if (p in data) {
98
98
  const value = data[p];
99
- if (!condition.fn(value)) return false;
100
- continue;
99
+ if (value !== undefined) {
100
+ if (!condition.fn(value)) return false;
101
+ continue;
102
+ }
101
103
  }
102
104
  if (!condition.matchWhenEmpty) {
103
105
  return false;
@@ -69,94 +69,105 @@ const REMOVED = {
69
69
  };
70
70
  /* cSpell:enable */
71
71
 
72
- const validateSchema = (schema, options) => {
73
- validate(schema, options, {
74
- name: "Webpack",
75
- postFormatter: (formattedError, error) => {
76
- const children = error.children;
77
- if (
78
- children &&
79
- children.some(
80
- child =>
81
- child.keyword === "absolutePath" &&
82
- child.dataPath === ".output.filename"
83
- )
84
- ) {
85
- return `${formattedError}\nPlease use output.path to specify absolute path and output.filename for the file name.`;
86
- }
87
-
88
- if (
89
- children &&
90
- children.some(
91
- child => child.keyword === "pattern" && child.dataPath === ".devtool"
92
- )
93
- ) {
94
- return (
95
- `${formattedError}\n` +
96
- "BREAKING CHANGE since webpack 5: The devtool option is more strict.\n" +
97
- "Please strictly follow the order of the keywords in the pattern."
98
- );
99
- }
100
-
101
- if (error.keyword === "additionalProperties") {
102
- const params = /** @type {import("ajv").AdditionalPropertiesParams} */ (error.params);
72
+ /**
73
+ * @param {Parameters<typeof validate>[0]} schema a json schema
74
+ * @param {Parameters<typeof validate>[1]} options the options that should be validated
75
+ * @param {Parameters<typeof validate>[2]=} validationConfiguration configuration for generating errors
76
+ * @returns {void}
77
+ */
78
+ const validateSchema = (schema, options, validationConfiguration) => {
79
+ validate(
80
+ schema,
81
+ options,
82
+ validationConfiguration || {
83
+ name: "Webpack",
84
+ postFormatter: (formattedError, error) => {
85
+ const children = error.children;
103
86
  if (
104
- Object.prototype.hasOwnProperty.call(
105
- DID_YOU_MEAN,
106
- params.additionalProperty
87
+ children &&
88
+ children.some(
89
+ child =>
90
+ child.keyword === "absolutePath" &&
91
+ child.dataPath === ".output.filename"
107
92
  )
108
93
  ) {
109
- return `${formattedError}\nDid you mean ${
110
- DID_YOU_MEAN[params.additionalProperty]
111
- }?`;
94
+ return `${formattedError}\nPlease use output.path to specify absolute path and output.filename for the file name.`;
112
95
  }
113
96
 
114
97
  if (
115
- Object.prototype.hasOwnProperty.call(
116
- REMOVED,
117
- params.additionalProperty
98
+ children &&
99
+ children.some(
100
+ child =>
101
+ child.keyword === "pattern" && child.dataPath === ".devtool"
118
102
  )
119
103
  ) {
120
- return `${formattedError}\n${REMOVED[params.additionalProperty]}?`;
104
+ return (
105
+ `${formattedError}\n` +
106
+ "BREAKING CHANGE since webpack 5: The devtool option is more strict.\n" +
107
+ "Please strictly follow the order of the keywords in the pattern."
108
+ );
121
109
  }
122
110
 
123
- if (!error.dataPath) {
124
- if (params.additionalProperty === "debug") {
125
- return (
126
- `${formattedError}\n` +
127
- "The 'debug' property was removed in webpack 2.0.0.\n" +
128
- "Loaders should be updated to allow passing this option via loader options in module.rules.\n" +
129
- "Until loaders are updated one can use the LoaderOptionsPlugin to switch loaders into debug mode:\n" +
130
- "plugins: [\n" +
131
- " new webpack.LoaderOptionsPlugin({\n" +
132
- " debug: true\n" +
133
- " })\n" +
134
- "]"
135
- );
111
+ if (error.keyword === "additionalProperties") {
112
+ const params = /** @type {import("ajv").AdditionalPropertiesParams} */ (error.params);
113
+ if (
114
+ Object.prototype.hasOwnProperty.call(
115
+ DID_YOU_MEAN,
116
+ params.additionalProperty
117
+ )
118
+ ) {
119
+ return `${formattedError}\nDid you mean ${
120
+ DID_YOU_MEAN[params.additionalProperty]
121
+ }?`;
136
122
  }
137
123
 
138
- if (params.additionalProperty) {
139
- return (
140
- `${formattedError}\n` +
141
- "For typos: please correct them.\n" +
142
- "For loader options: webpack >= v2.0.0 no longer allows custom properties in configuration.\n" +
143
- " Loaders should be updated to allow passing options via loader options in module.rules.\n" +
144
- " Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:\n" +
145
- " plugins: [\n" +
146
- " new webpack.LoaderOptionsPlugin({\n" +
147
- " // test: /\\.xxx$/, // may apply this only for some modules\n" +
148
- " options: {\n" +
149
- ` ${params.additionalProperty}: …\n` +
150
- " }\n" +
151
- " })\n" +
152
- " ]"
153
- );
124
+ if (
125
+ Object.prototype.hasOwnProperty.call(
126
+ REMOVED,
127
+ params.additionalProperty
128
+ )
129
+ ) {
130
+ return `${formattedError}\n${REMOVED[params.additionalProperty]}?`;
131
+ }
132
+
133
+ if (!error.dataPath) {
134
+ if (params.additionalProperty === "debug") {
135
+ return (
136
+ `${formattedError}\n` +
137
+ "The 'debug' property was removed in webpack 2.0.0.\n" +
138
+ "Loaders should be updated to allow passing this option via loader options in module.rules.\n" +
139
+ "Until loaders are updated one can use the LoaderOptionsPlugin to switch loaders into debug mode:\n" +
140
+ "plugins: [\n" +
141
+ " new webpack.LoaderOptionsPlugin({\n" +
142
+ " debug: true\n" +
143
+ " })\n" +
144
+ "]"
145
+ );
146
+ }
147
+
148
+ if (params.additionalProperty) {
149
+ return (
150
+ `${formattedError}\n` +
151
+ "For typos: please correct them.\n" +
152
+ "For loader options: webpack >= v2.0.0 no longer allows custom properties in configuration.\n" +
153
+ " Loaders should be updated to allow passing options via loader options in module.rules.\n" +
154
+ " Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:\n" +
155
+ " plugins: [\n" +
156
+ " new webpack.LoaderOptionsPlugin({\n" +
157
+ " // test: /\\.xxx$/, // may apply this only for some modules\n" +
158
+ " options: {\n" +
159
+ ` ${params.additionalProperty}: …\n` +
160
+ " }\n" +
161
+ " })\n" +
162
+ " ]"
163
+ );
164
+ }
154
165
  }
155
166
  }
156
- }
157
167
 
158
- return formattedError;
168
+ return formattedError;
169
+ }
159
170
  }
160
- });
171
+ );
161
172
  };
162
173
  module.exports = validateSchema;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.10.3",
3
+ "version": "5.11.0",
4
4
  "author": "Tobias Koppers @sokra",
5
5
  "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
6
6
  "license": "MIT",
@@ -92,7 +92,7 @@
92
92
  "style-loader": "^2.0.0",
93
93
  "terser": "^5.5.0",
94
94
  "toml": "^3.0.0",
95
- "tooling": "webpack/tooling#v1.10.0",
95
+ "tooling": "webpack/tooling#v1.10.2",
96
96
  "ts-loader": "^8.0.2",
97
97
  "typescript": "^4.2.0-dev.20201130",
98
98
  "url-loader": "^4.1.0",