webpack 4.41.1 → 4.41.5

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.
@@ -50,7 +50,8 @@ export type Externals =
50
50
  request: string,
51
51
  callback: (err?: Error, result?: string) => void
52
52
  ) => void)
53
- | ExternalItem)[];
53
+ | ExternalItem
54
+ )[];
54
55
  /**
55
56
  * This interface was referenced by `WebpackOptions`'s JSON-Schema
56
57
  * via the `definition` "ExternalItem".
@@ -391,7 +392,8 @@ export interface WebpackOptions {
391
392
  | "normal"
392
393
  | "detailed"
393
394
  | "verbose"
394
- | "errors-warnings");
395
+ | "errors-warnings"
396
+ );
395
397
  /**
396
398
  * Environment to build for
397
399
  */
@@ -404,7 +406,8 @@ export interface WebpackOptions {
404
406
  | "node-webkit"
405
407
  | "electron-main"
406
408
  | "electron-renderer"
407
- | "electron-preload")
409
+ | "electron-preload"
410
+ )
408
411
  | ((compiler: import("../lib/Compiler")) => void);
409
412
  /**
410
413
  * Enter watch mode, which rebuilds on file change.
@@ -45,18 +45,20 @@ class CommonJsStuffPlugin {
45
45
  .tap("CommonJsStuffPlugin", expr => {
46
46
  parser.state.module.buildMeta.moduleConcatenationBailout =
47
47
  "module.loaded";
48
- return ParserHelpers.toConstantDependency(parser, "module.l")(
49
- expr
50
- );
48
+ return ParserHelpers.toConstantDependency(
49
+ parser,
50
+ "module.l"
51
+ )(expr);
51
52
  });
52
53
  parser.hooks.expression
53
54
  .for("module.id")
54
55
  .tap("CommonJsStuffPlugin", expr => {
55
56
  parser.state.module.buildMeta.moduleConcatenationBailout =
56
57
  "module.id";
57
- return ParserHelpers.toConstantDependency(parser, "module.i")(
58
- expr
59
- );
58
+ return ParserHelpers.toConstantDependency(
59
+ parser,
60
+ "module.i"
61
+ )(expr);
60
62
  });
61
63
  parser.hooks.expression
62
64
  .for("module.exports")
@@ -190,9 +190,10 @@ class DefinePlugin {
190
190
  strCode
191
191
  )(expr);
192
192
  } else {
193
- return ParserHelpers.toConstantDependency(parser, strCode)(
194
- expr
195
- );
193
+ return ParserHelpers.toConstantDependency(
194
+ parser,
195
+ strCode
196
+ )(expr);
196
197
  }
197
198
  });
198
199
  }
@@ -255,9 +256,10 @@ class DefinePlugin {
255
256
  strCode
256
257
  )(expr);
257
258
  } else {
258
- return ParserHelpers.toConstantDependency(parser, strCode)(
259
- expr
260
- );
259
+ return ParserHelpers.toConstantDependency(
260
+ parser,
261
+ strCode
262
+ )(expr);
261
263
  }
262
264
  });
263
265
  parser.hooks.typeof.for(key).tap("DefinePlugin", expr => {
@@ -6,6 +6,7 @@
6
6
 
7
7
  const { RawSource } = require("webpack-sources");
8
8
  const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
9
+ const { absolutify } = require("./util/identifier");
9
10
 
10
11
  const cache = new WeakMap();
11
12
 
@@ -60,7 +61,11 @@ class EvalSourceMapDevToolModuleTemplatePlugin {
60
61
  obj[key] = sourceMap[key];
61
62
  return obj;
62
63
  }, {});
64
+ const context = this.compilation.compiler.options.context;
63
65
  const modules = sourceMap.sources.map(source => {
66
+ if (source.startsWith("webpack://")) {
67
+ source = absolutify(context, source.slice(10));
68
+ }
64
69
  const module = self.compilation.findModule(source);
65
70
  return module || source;
66
71
  });
@@ -7,14 +7,11 @@
7
7
  const Queue = require("./util/Queue");
8
8
 
9
9
  const addToSet = (a, b) => {
10
- let changed = false;
10
+ const size = a.size;
11
11
  for (const item of b) {
12
- if (!a.has(item)) {
13
- a.add(item);
14
- changed = true;
15
- }
12
+ a.add(item);
16
13
  }
17
- return changed;
14
+ return a.size !== size;
18
15
  };
19
16
 
20
17
  class FlagDependencyExportsPlugin {
@@ -114,11 +111,7 @@ class FlagDependencyExportsPlugin {
114
111
  if (module.buildMeta.providedExports !== true) {
115
112
  moduleWithExports =
116
113
  module.buildMeta && module.buildMeta.exportsType;
117
- moduleProvidedExports = Array.isArray(
118
- module.buildMeta.providedExports
119
- )
120
- ? new Set(module.buildMeta.providedExports)
121
- : new Set();
114
+ moduleProvidedExports = new Set();
122
115
  providedExportsAreTemporary = false;
123
116
  processDependenciesBlock(module);
124
117
  module.buildInfo.temporaryProvidedExports = providedExportsAreTemporary;
@@ -62,9 +62,10 @@ class ProvidePlugin {
62
62
  return false;
63
63
  }
64
64
  if (scopedName) {
65
- ParserHelpers.toConstantDependency(parser, nameIdentifier)(
66
- expr
67
- );
65
+ ParserHelpers.toConstantDependency(
66
+ parser,
67
+ nameIdentifier
68
+ )(expr);
68
69
  }
69
70
  return true;
70
71
  });
@@ -9,6 +9,7 @@ const { ConcatSource, RawSource } = require("webpack-sources");
9
9
  const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
10
10
  const SourceMapDevToolModuleOptionsPlugin = require("./SourceMapDevToolModuleOptionsPlugin");
11
11
  const createHash = require("./util/createHash");
12
+ const { absolutify } = require("./util/identifier");
12
13
 
13
14
  const validateOptions = require("schema-utils");
14
15
  const schema = require("../schemas/plugins/SourceMapDevToolPlugin.json");
@@ -68,16 +69,24 @@ const getTaskForFile = (file, asset, chunk, options, compilation) => {
68
69
  sourceMap = asset.map(options);
69
70
  source = asset.source();
70
71
  }
71
- if (sourceMap) {
72
- return {
73
- chunk,
74
- file,
75
- asset,
76
- source,
77
- sourceMap,
78
- modules: undefined
79
- };
80
- }
72
+ if (!sourceMap || typeof source !== "string") return;
73
+ const context = compilation.options.context;
74
+ const modules = sourceMap.sources.map(source => {
75
+ if (source.startsWith("webpack://")) {
76
+ source = absolutify(context, source.slice(10));
77
+ }
78
+ const module = compilation.findModule(source);
79
+ return module || source;
80
+ });
81
+
82
+ return {
83
+ chunk,
84
+ file,
85
+ asset,
86
+ source,
87
+ sourceMap,
88
+ modules
89
+ };
81
90
  };
82
91
 
83
92
  class SourceMapDevToolPlugin {
@@ -212,10 +221,7 @@ class SourceMapDevToolPlugin {
212
221
  );
213
222
 
214
223
  if (task) {
215
- const modules = task.sourceMap.sources.map(source => {
216
- const module = compilation.findModule(source);
217
- return module || source;
218
- });
224
+ const modules = task.modules;
219
225
 
220
226
  for (let idx = 0; idx < modules.length; idx++) {
221
227
  const module = modules[idx];
@@ -234,8 +240,6 @@ class SourceMapDevToolPlugin {
234
240
  }
235
241
  }
236
242
 
237
- task.modules = modules;
238
-
239
243
  tasks.push(task);
240
244
  }
241
245
  });
package/lib/Stats.js CHANGED
@@ -974,18 +974,15 @@ class Stats {
974
974
  }
975
975
  if (typeof obj.builtAt === "number") {
976
976
  const builtAtDate = new Date(obj.builtAt);
977
- let timeZone = null;
977
+ let timeZone = undefined;
978
978
 
979
979
  try {
980
- timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
980
+ builtAtDate.toLocaleTimeString();
981
981
  } catch (err) {
982
- // disregard the RangeError
983
- }
984
-
985
- // Force UTC if runtime timezone could not be detected.
986
- if (!timeZone || timeZone.toLowerCase() === "etc/unknown") {
982
+ // Force UTC if runtime timezone is unsupported
987
983
  timeZone = "UTC";
988
984
  }
985
+
989
986
  colors.normal("Built at: ");
990
987
  colors.normal(
991
988
  builtAtDate.toLocaleDateString(undefined, {
@@ -5,34 +5,31 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- /**
9
- * @enum {string}
10
- */
11
8
  const LogType = Object.freeze({
12
- error: "error", // message, c style arguments
13
- warn: "warn", // message, c style arguments
14
- info: "info", // message, c style arguments
15
- log: "log", // message, c style arguments
16
- debug: "debug", // message, c style arguments
9
+ error: /** @type {"error"} */ ("error"), // message, c style arguments
10
+ warn: /** @type {"warn"} */ ("warn"), // message, c style arguments
11
+ info: /** @type {"info"} */ ("info"), // message, c style arguments
12
+ log: /** @type {"log"} */ ("log"), // message, c style arguments
13
+ debug: /** @type {"debug"} */ ("debug"), // message, c style arguments
17
14
 
18
- trace: "trace", // no arguments
15
+ trace: /** @type {"trace"} */ ("trace"), // no arguments
19
16
 
20
- group: "group", // [label]
21
- groupCollapsed: "groupCollapsed", // [label]
22
- groupEnd: "groupEnd", // [label]
17
+ group: /** @type {"group"} */ ("group"), // [label]
18
+ groupCollapsed: /** @type {"groupCollapsed"} */ ("groupCollapsed"), // [label]
19
+ groupEnd: /** @type {"groupEnd"} */ ("groupEnd"), // [label]
23
20
 
24
- profile: "profile", // [profileName]
25
- profileEnd: "profileEnd", // [profileName]
21
+ profile: /** @type {"profile"} */ ("profile"), // [profileName]
22
+ profileEnd: /** @type {"profileEnd"} */ ("profileEnd"), // [profileName]
26
23
 
27
- time: "time", // name, time as [seconds, nanoseconds]
24
+ time: /** @type {"time"} */ ("time"), // name, time as [seconds, nanoseconds]
28
25
 
29
- clear: "clear", // no arguments
30
- status: "status" // message, arguments
26
+ clear: /** @type {"clear"} */ ("clear"), // no arguments
27
+ status: /** @type {"status"} */ ("status") // message, arguments
31
28
  });
32
29
 
33
30
  exports.LogType = LogType;
34
31
 
35
- /** @typedef {keyof typeof LogType} LogTypeEnum */
32
+ /** @typedef {typeof LogType[keyof typeof LogType]} LogTypeEnum */
36
33
 
37
34
  const LOG_SYMBOL = Symbol("webpack logger raw log method");
38
35
  const TIMERS_SYMBOL = Symbol("webpack logger times");
@@ -330,6 +330,7 @@ class ConcatenatedModule extends Module {
330
330
  );
331
331
 
332
332
  this.dependencies = [];
333
+ this.blocks = [];
333
334
 
334
335
  this.warnings = [];
335
336
  this.errors = [];
@@ -348,6 +349,10 @@ class ConcatenatedModule extends Module {
348
349
  )) {
349
350
  this.dependencies.push(d);
350
351
  }
352
+ // populate blocks
353
+ for (const d of m.blocks) {
354
+ this.blocks.push(d);
355
+ }
351
356
  // populate file dependencies
352
357
  if (m.buildInfo.fileDependencies) {
353
358
  for (const file of m.buildInfo.fileDependencies) {
@@ -115,7 +115,7 @@ class SideEffectsFlagPlugin {
115
115
  (dep instanceof HarmonyImportSpecifierDependency &&
116
116
  !dep.namespaceObjectAsContext)
117
117
  ) {
118
- const mapping = map.get(dep.id);
118
+ const mapping = map.get(dep._id);
119
119
  if (mapping) {
120
120
  dep.redirectedModule = mapping.module;
121
121
  dep.redirectedId = mapping.exportName;
@@ -1,6 +1,17 @@
1
1
  "use strict";
2
2
  const path = require("path");
3
3
 
4
+ /**
5
+ * @param {string} context context for relative path
6
+ * @param {string} relativePath path
7
+ * @returns {string} absolute path
8
+ */
9
+ const requestToAbsolute = (context, relativePath) => {
10
+ if (relativePath.startsWith("./") || relativePath.startsWith("../"))
11
+ return path.join(context, relativePath);
12
+ return relativePath;
13
+ };
14
+
4
15
  /**
5
16
  * @typedef {Object} MakeRelativePathsCache
6
17
  * @property {Map<string, Map<string, string>>=} relativePaths
@@ -100,3 +111,17 @@ exports.contextify = (context, request) => {
100
111
  })
101
112
  .join("!");
102
113
  };
114
+
115
+ /**
116
+ * @param {string} context absolute context path
117
+ * @param {string} request any request string
118
+ * @returns {string} a new request string using absolute paths when possible
119
+ */
120
+ const _absolutify = (context, request) => {
121
+ return request
122
+ .split("!")
123
+ .map(r => requestToAbsolute(context, r))
124
+ .join("!");
125
+ };
126
+
127
+ exports.absolutify = _absolutify;
@@ -5,15 +5,16 @@
5
5
  "use strict";
6
6
 
7
7
  const Generator = require("../Generator");
8
- const WebAssemblyParser = require("./WebAssemblyParser");
9
- const WebAssemblyGenerator = require("./WebAssemblyGenerator");
10
- const WebAssemblyJavascriptGenerator = require("./WebAssemblyJavascriptGenerator");
11
- const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
12
8
  const WebAssemblyExportImportedDependency = require("../dependencies/WebAssemblyExportImportedDependency");
9
+ const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
13
10
  const WebAssemblyInInitialChunkError = require("./WebAssemblyInInitialChunkError");
14
11
 
15
12
  /** @typedef {import("../Compiler")} Compiler */
16
13
 
14
+ let WebAssemblyGenerator;
15
+ let WebAssemblyJavascriptGenerator;
16
+ let WebAssemblyParser;
17
+
17
18
  class WebAssemblyModulesPlugin {
18
19
  constructor(options) {
19
20
  this.options = options;
@@ -40,12 +41,21 @@ class WebAssemblyModulesPlugin {
40
41
  normalModuleFactory.hooks.createParser
41
42
  .for("webassembly/experimental")
42
43
  .tap("WebAssemblyModulesPlugin", () => {
44
+ if (WebAssemblyParser === undefined) {
45
+ WebAssemblyParser = require("./WebAssemblyParser");
46
+ }
43
47
  return new WebAssemblyParser();
44
48
  });
45
49
 
46
50
  normalModuleFactory.hooks.createGenerator
47
51
  .for("webassembly/experimental")
48
52
  .tap("WebAssemblyModulesPlugin", () => {
53
+ if (WebAssemblyGenerator === undefined) {
54
+ WebAssemblyGenerator = require("./WebAssemblyGenerator");
55
+ }
56
+ if (WebAssemblyJavascriptGenerator === undefined) {
57
+ WebAssemblyJavascriptGenerator = require("./WebAssemblyJavascriptGenerator");
58
+ }
49
59
  return Generator.byType({
50
60
  javascript: new WebAssemblyJavascriptGenerator(),
51
61
  webassembly: new WebAssemblyGenerator(this.options)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "4.41.1",
3
+ "version": "4.41.5",
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",
@@ -25,15 +25,17 @@
25
25
  "node-libs-browser": "^2.2.1",
26
26
  "schema-utils": "^1.0.0",
27
27
  "tapable": "^1.1.3",
28
- "terser-webpack-plugin": "^1.4.1",
28
+ "terser-webpack-plugin": "^1.4.3",
29
29
  "watchpack": "^1.6.0",
30
30
  "webpack-sources": "^1.4.1"
31
31
  },
32
32
  "devDependencies": {
33
+ "@babel/core": "^7.7.2",
33
34
  "@types/node": "^10.12.21",
34
35
  "@types/tapable": "^1.0.1",
35
36
  "@types/webpack-sources": "^0.1.4",
36
37
  "@yarnpkg/lockfile": "^1.1.0",
38
+ "babel-loader": "^8.0.6",
37
39
  "benchmark": "^2.1.1",
38
40
  "bundle-loader": "~0.5.0",
39
41
  "coffee-loader": "^0.9.0",
@@ -88,6 +90,10 @@
88
90
  "type": "git",
89
91
  "url": "https://github.com/webpack/webpack.git"
90
92
  },
93
+ "funding": {
94
+ "type": "opencollective",
95
+ "url": "https://opencollective.com/webpack"
96
+ },
91
97
  "homepage": "https://github.com/webpack/webpack",
92
98
  "main": "lib/webpack.js",
93
99
  "web": "lib/webpack.web.js",