webpack 5.48.0 → 5.51.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.

Files changed (50) hide show
  1. package/README.md +4 -16
  2. package/hot/only-dev-server.js +1 -1
  3. package/hot/poll.js +1 -1
  4. package/hot/signal.js +1 -1
  5. package/lib/CompatibilityPlugin.js +21 -4
  6. package/lib/Compilation.js +8 -3
  7. package/lib/EvalSourceMapDevToolPlugin.js +2 -2
  8. package/lib/ExternalModuleFactoryPlugin.js +1 -1
  9. package/lib/FileSystemInfo.js +665 -193
  10. package/lib/HotModuleReplacementPlugin.js +4 -4
  11. package/lib/Module.js +1 -0
  12. package/lib/MultiCompiler.js +0 -2
  13. package/lib/NormalModule.js +51 -20
  14. package/lib/NormalModuleFactory.js +137 -74
  15. package/lib/Parser.js +1 -0
  16. package/lib/RuntimeGlobals.js +5 -0
  17. package/lib/SourceMapDevToolPlugin.js +2 -2
  18. package/lib/WebpackOptionsApply.js +8 -0
  19. package/lib/asset/AssetModulesPlugin.js +0 -1
  20. package/lib/config/defaults.js +27 -6
  21. package/lib/config/normalization.js +6 -1
  22. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +10 -1
  23. package/lib/hmr/HotModuleReplacement.runtime.js +5 -1
  24. package/lib/index.js +0 -3
  25. package/lib/javascript/JavascriptParser.js +2 -0
  26. package/lib/library/ModuleLibraryPlugin.js +4 -0
  27. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +7 -1
  28. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +2 -2
  29. package/lib/node/ReadFileCompileWasmPlugin.js +2 -1
  30. package/lib/node/RequireChunkLoadingRuntimeModule.js +7 -1
  31. package/lib/optimize/ConcatenatedModule.js +3 -3
  32. package/lib/optimize/SplitChunksPlugin.js +4 -4
  33. package/lib/schemes/HttpUriPlugin.js +942 -25
  34. package/lib/serialization/BinaryMiddleware.js +293 -267
  35. package/lib/util/fs.js +40 -0
  36. package/lib/util/identifier.js +26 -8
  37. package/lib/wasm-async/{AsyncWasmChunkLoadingRuntimeModule.js → AsyncWasmLoadingRuntimeModule.js} +3 -3
  38. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +18 -2
  39. package/lib/web/FetchCompileAsyncWasmPlugin.js +2 -2
  40. package/lib/web/FetchCompileWasmPlugin.js +2 -1
  41. package/lib/web/JsonpChunkLoadingRuntimeModule.js +21 -8
  42. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +7 -1
  43. package/package.json +1 -1
  44. package/schemas/WebpackOptions.check.js +1 -1
  45. package/schemas/WebpackOptions.json +43 -0
  46. package/schemas/plugins/schemes/HttpUriPlugin.check.d.ts +7 -0
  47. package/schemas/plugins/schemes/HttpUriPlugin.check.js +6 -0
  48. package/schemas/plugins/schemes/HttpUriPlugin.json +42 -0
  49. package/types.d.ts +110 -14
  50. package/lib/schemes/HttpsUriPlugin.js +0 -63
package/README.md CHANGED
@@ -138,25 +138,13 @@ or are automatically applied via regex from your webpack configuration.
138
138
 
139
139
  #### Files
140
140
 
141
- | Name | Status | Install Size | Description |
142
- | :-----------------: | :---------: | :----------: | :---------------------------------------------------------------------------------------- |
143
- | [raw-loader][raw] | ![raw-npm] | ![raw-size] | Loads raw content of a file (utf-8) |
144
- | [val-loader][val] | ![val-npm] | ![val-size] | Executes code as module and considers exports as JS code |
145
- | [url-loader][url] | ![url-npm] | ![url-size] | Works like the file loader, but can return a Data Url if the file is smaller than a limit |
146
- | [file-loader][file] | ![file-npm] | ![file-size] | Emits the file into the output folder and returns the (relative) url |
147
-
148
- [raw]: https://github.com/webpack-contrib/raw-loader
149
- [raw-npm]: https://img.shields.io/npm/v/raw-loader.svg
150
- [raw-size]: https://packagephobia.com/badge?p=raw-loader
141
+ | Name | Status | Install Size | Description |
142
+ | :---------------: | :--------: | :----------: | :------------------------------------------------------- |
143
+ | [val-loader][val] | ![val-npm] | ![val-size] | Executes code as module and considers exports as JS code |
144
+
151
145
  [val]: https://github.com/webpack-contrib/val-loader
152
146
  [val-npm]: https://img.shields.io/npm/v/val-loader.svg
153
147
  [val-size]: https://packagephobia.com/badge?p=val-loader
154
- [url]: https://github.com/webpack-contrib/url-loader
155
- [url-npm]: https://img.shields.io/npm/v/url-loader.svg
156
- [url-size]: https://packagephobia.com/badge?p=url-loader
157
- [file]: https://github.com/webpack-contrib/file-loader
158
- [file-npm]: https://img.shields.io/npm/v/file-loader.svg
159
- [file-size]: https://packagephobia.com/badge?p=file-loader
160
148
 
161
149
  #### JSON
162
150
 
@@ -13,7 +13,7 @@ if (module.hot) {
13
13
  module.hot
14
14
  .check()
15
15
  .then(function (updatedModules) {
16
- if (!updatedModules || updatedModules.length === 0) {
16
+ if (!updatedModules) {
17
17
  log("warning", "[HMR] Cannot find update. Need to do a full reload!");
18
18
  log(
19
19
  "warning",
package/hot/poll.js CHANGED
@@ -12,7 +12,7 @@ if (module.hot) {
12
12
  module.hot
13
13
  .check(true)
14
14
  .then(function (updatedModules) {
15
- if (!updatedModules || updatedModules.length === 0) {
15
+ if (!updatedModules) {
16
16
  if (fromUpdate) log("info", "[HMR] Update applied.");
17
17
  return;
18
18
  }
package/hot/signal.js CHANGED
@@ -9,7 +9,7 @@ if (module.hot) {
9
9
  module.hot
10
10
  .check()
11
11
  .then(function (updatedModules) {
12
- if (!updatedModules || updatedModules.length === 0) {
12
+ if (!updatedModules) {
13
13
  if (fromUpdate) log("info", "[HMR] Update applied.");
14
14
  else log("warning", "[HMR] Cannot find update.");
15
15
  return;
@@ -69,7 +69,8 @@ class CompatibilityPlugin {
69
69
  * @param {JavascriptParser} parser the parser
70
70
  * @returns {void}
71
71
  */
72
- const nestedWebpackRequireHandler = parser => {
72
+ const handler = parser => {
73
+ // Handle nested requires
73
74
  parser.hooks.preStatement.tap("CompatibilityPlugin", statement => {
74
75
  if (
75
76
  statement.type === "FunctionDeclaration" &&
@@ -117,17 +118,33 @@ class CompatibilityPlugin {
117
118
  parser.state.module.addPresentationalDependency(dep);
118
119
  return true;
119
120
  });
121
+
122
+ // Handle hashbang
123
+ parser.hooks.program.tap(
124
+ "CompatibilityPlugin",
125
+ (program, comments) => {
126
+ if (comments.length === 0) return;
127
+ const c = comments[0];
128
+ if (c.type === "Line" && c.range[0] === 0) {
129
+ if (parser.state.source.slice(0, 2).toString() !== "#!") return;
130
+ // this is a hashbang comment
131
+ const dep = new ConstDependency("//", 0);
132
+ dep.loc = c.loc;
133
+ parser.state.module.addPresentationalDependency(dep);
134
+ }
135
+ }
136
+ );
120
137
  };
121
138
 
122
139
  normalModuleFactory.hooks.parser
123
140
  .for("javascript/auto")
124
- .tap("CompatibilityPlugin", nestedWebpackRequireHandler);
141
+ .tap("CompatibilityPlugin", handler);
125
142
  normalModuleFactory.hooks.parser
126
143
  .for("javascript/dynamic")
127
- .tap("CompatibilityPlugin", nestedWebpackRequireHandler);
144
+ .tap("CompatibilityPlugin", handler);
128
145
  normalModuleFactory.hooks.parser
129
146
  .for("javascript/esm")
130
- .tap("CompatibilityPlugin", nestedWebpackRequireHandler);
147
+ .tap("CompatibilityPlugin", handler);
131
148
  }
132
149
  );
133
150
  }
@@ -1302,6 +1302,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1302
1302
 
1303
1303
  module.needBuild(
1304
1304
  {
1305
+ compilation: this,
1305
1306
  fileSystemInfo: this.fileSystemInfo,
1306
1307
  valueCacheVersions: this.valueCacheVersions
1307
1308
  },
@@ -1573,10 +1574,11 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1573
1574
  if (err) {
1574
1575
  if (dependencies.every(d => d.optional)) {
1575
1576
  this.warnings.push(err);
1577
+ return callback();
1576
1578
  } else {
1577
1579
  this.errors.push(err);
1580
+ return callback(err);
1578
1581
  }
1579
- return callback(err);
1580
1582
  }
1581
1583
 
1582
1584
  if (!newModule) {
@@ -1837,13 +1839,15 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1837
1839
  contextInfo,
1838
1840
  context
1839
1841
  },
1840
- err => {
1842
+ (err, result) => {
1841
1843
  if (err && this.bail) {
1842
1844
  callback(err);
1843
1845
  this.buildQueue.stop();
1844
1846
  this.rebuildQueue.stop();
1845
1847
  this.processDependenciesQueue.stop();
1846
1848
  this.factorizeQueue.stop();
1849
+ } else if (!err && result) {
1850
+ callback(null, result);
1847
1851
  } else {
1848
1852
  callback();
1849
1853
  }
@@ -3784,8 +3788,9 @@ This prevents using hashes of each other and should be avoided.`);
3784
3788
  /** @type {Map<string, {hash: string, source: Source, chunk: Chunk}>} */
3785
3789
  const alreadyWrittenFiles = new Map();
3786
3790
 
3787
- asyncLib.forEach(
3791
+ asyncLib.forEachLimit(
3788
3792
  this.chunks,
3793
+ 15,
3789
3794
  (chunk, callback) => {
3790
3795
  /** @type {RenderManifestEntry[]} */
3791
3796
  let manifest;
@@ -11,7 +11,7 @@ const NormalModule = require("./NormalModule");
11
11
  const SourceMapDevToolModuleOptionsPlugin = require("./SourceMapDevToolModuleOptionsPlugin");
12
12
  const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin");
13
13
  const ConcatenatedModule = require("./optimize/ConcatenatedModule");
14
- const { absolutify } = require("./util/identifier");
14
+ const { makePathsAbsolute } = require("./util/identifier");
15
15
 
16
16
  /** @typedef {import("webpack-sources").Source} Source */
17
17
  /** @typedef {import("../declarations/WebpackOptions").DevTool} DevToolOptions */
@@ -125,7 +125,7 @@ class EvalSourceMapDevToolPlugin {
125
125
  const root = compiler.root;
126
126
  const modules = sourceMap.sources.map(source => {
127
127
  if (!source.startsWith("webpack://")) return source;
128
- source = absolutify(context, source.slice(10), root);
128
+ source = makePathsAbsolute(context, source.slice(10), root);
129
129
  const module = compilation.findModule(source);
130
130
  return module || source;
131
131
  });
@@ -62,6 +62,7 @@ class ExternalModuleFactoryPlugin {
62
62
  const context = data.context;
63
63
  const contextInfo = data.contextInfo;
64
64
  const dependency = data.dependencies[0];
65
+ const dependencyType = data.dependencyType;
65
66
 
66
67
  /**
67
68
  * @param {string|string[]|boolean|Record<string, string|string[]>} value the external config
@@ -172,7 +173,6 @@ class ExternalModuleFactoryPlugin {
172
173
  cb
173
174
  );
174
175
  } else {
175
- const dependencyType = dependency.category || "";
176
176
  const promise = externals(
177
177
  {
178
178
  context,