webpack 4.41.4 → 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
  });
@@ -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");
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "4.41.4",
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",
@@ -30,10 +30,12 @@
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",