webpack 4.38.0 → 4.39.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.
@@ -913,11 +913,6 @@ class Compilation extends Tapable {
913
913
  iterationDependencies(dependencies);
914
914
 
915
915
  const afterBuild = () => {
916
- if (currentProfile) {
917
- const afterBuilding = Date.now();
918
- currentProfile.building = afterBuilding - afterFactory;
919
- }
920
-
921
916
  if (recursive && addModuleResult.dependencies) {
922
917
  this.processModuleDependencies(dependentModule, callback);
923
918
  } else {
@@ -1059,11 +1054,6 @@ class Compilation extends Tapable {
1059
1054
  module.addReason(null, dependency);
1060
1055
 
1061
1056
  const afterBuild = () => {
1062
- if (currentProfile) {
1063
- const afterBuilding = Date.now();
1064
- currentProfile.building = afterBuilding - afterFactory;
1065
- }
1066
-
1067
1057
  if (addModuleResult.dependencies) {
1068
1058
  this.processModuleDependencies(module, err => {
1069
1059
  if (err) return callback(err);
package/lib/Compiler.js CHANGED
@@ -55,6 +55,8 @@ class Compiler extends Tapable {
55
55
  run: new AsyncSeriesHook(["compiler"]),
56
56
  /** @type {AsyncSeriesHook<Compilation>} */
57
57
  emit: new AsyncSeriesHook(["compilation"]),
58
+ /** @type {AsyncSeriesHook<string, Buffer>} */
59
+ assetEmitted: new AsyncSeriesHook(["file", "content"]),
58
60
  /** @type {AsyncSeriesHook<Compilation>} */
59
61
  afterEmit: new AsyncSeriesHook(["compilation"]),
60
62
 
@@ -86,7 +88,7 @@ class Compiler extends Tapable {
86
88
  watchClose: new SyncHook([]),
87
89
 
88
90
  /** @type {SyncBailHook<string, string, any[]>} */
89
- infrastructurelog: new SyncBailHook(["origin", "type", "args"]),
91
+ infrastructureLog: new SyncBailHook(["origin", "type", "args"]),
90
92
 
91
93
  // TODO the following hooks are weirdly located here
92
94
  // TODO move them for webpack 5
@@ -101,6 +103,8 @@ class Compiler extends Tapable {
101
103
  /** @type {SyncBailHook<string, Entry>} */
102
104
  entryOption: new SyncBailHook(["context", "entry"])
103
105
  };
106
+ // TODO webpack 5 remove this
107
+ this.hooks.infrastructurelog = this.hooks.infrastructureLog;
104
108
 
105
109
  this._pluginCompat.tap("Compiler", options => {
106
110
  switch (options.name) {
@@ -221,7 +225,7 @@ class Compiler extends Tapable {
221
225
  );
222
226
  }
223
227
  }
224
- if (this.hooks.infrastructurelog.call(name, type, args) === undefined) {
228
+ if (this.hooks.infrastructureLog.call(name, type, args) === undefined) {
225
229
  if (this.infrastructureLogger !== undefined) {
226
230
  this.infrastructureLogger(name, type, args);
227
231
  }
@@ -430,7 +434,7 @@ class Compiler extends Tapable {
430
434
  : targetFileGeneration + 1;
431
435
  cacheEntry.writtenTo.set(targetPath, newGeneration);
432
436
  this._assetEmittingWrittenFiles.set(targetPath, newGeneration);
433
- callback();
437
+ this.hooks.assetEmitted.callAsync(file, content, callback);
434
438
  });
435
439
  } else {
436
440
  if (source.existsAt === targetPath) {
@@ -445,7 +449,10 @@ class Compiler extends Tapable {
445
449
 
446
450
  source.existsAt = targetPath;
447
451
  source.emitted = true;
448
- this.outputFileSystem.writeFile(targetPath, content, callback);
452
+ this.outputFileSystem.writeFile(targetPath, content, err => {
453
+ if (err) return callback(err);
454
+ this.hooks.assetEmitted.callAsync(file, content, callback);
455
+ });
449
456
  }
450
457
  };
451
458
 
@@ -18,7 +18,10 @@ module.exports = class MultiCompiler extends Tapable {
18
18
  invalid: new MultiHook(compilers.map(c => c.hooks.invalid)),
19
19
  run: new MultiHook(compilers.map(c => c.hooks.run)),
20
20
  watchClose: new SyncHook([]),
21
- watchRun: new MultiHook(compilers.map(c => c.hooks.watchRun))
21
+ watchRun: new MultiHook(compilers.map(c => c.hooks.watchRun)),
22
+ infrastructureLog: new MultiHook(
23
+ compilers.map(c => c.hooks.infrastructureLog)
24
+ )
22
25
  };
23
26
  if (!Array.isArray(compilers)) {
24
27
  compilers = Object.keys(compilers).map(name => {
@@ -90,6 +93,10 @@ module.exports = class MultiCompiler extends Tapable {
90
93
  }
91
94
  }
92
95
 
96
+ getInfrastructureLogger(name) {
97
+ return this.compilers[0].getInfrastructureLogger(name);
98
+ }
99
+
93
100
  validateDependencies(callback) {
94
101
  const edges = new Set();
95
102
  const missing = [];
@@ -10,50 +10,14 @@ const schema = require("../schemas/plugins/ProgressPlugin.json");
10
10
  /** @typedef {import("../declarations/plugins/ProgressPlugin").ProgressPluginArgument} ProgressPluginArgument */
11
11
  /** @typedef {import("../declarations/plugins/ProgressPlugin").ProgressPluginOptions} ProgressPluginOptions */
12
12
 
13
- const createDefaultHandler = profile => {
14
- let lineCaretPosition = 0;
15
- let lastMessage = "";
13
+ const createDefaultHandler = (profile, logger) => {
16
14
  let lastState;
17
15
  let lastStateTime;
18
16
 
19
17
  const defaultHandler = (percentage, msg, ...args) => {
20
- let state = msg;
21
- const details = args.filter(v => v.length);
22
- const maxLineLength = process.stderr.columns || Infinity;
23
- if (percentage < 1) {
24
- percentage = Math.floor(percentage * 100);
25
- msg = `${percentage}% ${msg}`;
26
- if (percentage < 100) {
27
- msg = ` ${msg}`;
28
- }
29
- if (percentage < 10) {
30
- msg = ` ${msg}`;
31
- }
32
-
33
- if (details.length) {
34
- const maxTotalDetailsLength = maxLineLength - msg.length;
35
- const totalDetailsLength = details.reduce(
36
- (a, b) => a + b.length,
37
- details.length // account for added space before each detail text
38
- );
39
- const maxDetailLength =
40
- totalDetailsLength < maxTotalDetailsLength
41
- ? Infinity
42
- : Math.floor(maxTotalDetailsLength / details.length);
43
-
44
- for (let detail of details) {
45
- if (!detail) continue;
46
- if (detail.length + 1 > maxDetailLength) {
47
- const truncatePrefix = "...";
48
- detail = `${truncatePrefix}${detail.substr(
49
- -(maxDetailLength - truncatePrefix.length - 1)
50
- )}`;
51
- }
52
- msg += ` ${detail}`;
53
- }
54
- }
55
- }
18
+ logger.status(`${Math.floor(percentage * 100)}%`, msg, ...args);
56
19
  if (profile) {
20
+ let state = msg;
57
21
  state = state.replace(/^\d+\/\d+\s+/, "");
58
22
  if (percentage === 0) {
59
23
  lastState = null;
@@ -61,33 +25,23 @@ const createDefaultHandler = profile => {
61
25
  } else if (state !== lastState || percentage === 1) {
62
26
  const now = Date.now();
63
27
  if (lastState) {
64
- const stateMsg = `${now - lastStateTime}ms ${lastState}`;
65
- goToLineStart(stateMsg);
66
- process.stderr.write(stateMsg + "\n");
67
- lineCaretPosition = 0;
28
+ const diff = now - lastStateTime;
29
+ const stateMsg = `${diff}ms ${lastState}`;
30
+ if (diff > 1000) {
31
+ logger.warn(stateMsg);
32
+ } else if (diff > 10) {
33
+ logger.info(stateMsg);
34
+ } else if (diff > 0) {
35
+ logger.log(stateMsg);
36
+ } else {
37
+ logger.debug(stateMsg);
38
+ }
68
39
  }
69
40
  lastState = state;
70
41
  lastStateTime = now;
71
42
  }
72
43
  }
73
- if (lastMessage !== msg) {
74
- goToLineStart(msg);
75
- msg = msg.substring(0, maxLineLength);
76
- process.stderr.write(msg);
77
- lastMessage = msg;
78
- }
79
- };
80
-
81
- const goToLineStart = nextMessage => {
82
- let str = "";
83
- for (; lineCaretPosition > nextMessage.length; lineCaretPosition--) {
84
- str += "\b \b";
85
- }
86
- for (var i = 0; i < lineCaretPosition; i++) {
87
- str += "\b";
88
- }
89
- lineCaretPosition = nextMessage.length;
90
- if (str) process.stderr.write(str);
44
+ if (percentage === 1) logger.status();
91
45
  };
92
46
 
93
47
  return defaultHandler;
@@ -118,7 +72,12 @@ class ProgressPlugin {
118
72
 
119
73
  apply(compiler) {
120
74
  const { modulesCount } = this;
121
- const handler = this.handler || createDefaultHandler(this.profile);
75
+ const handler =
76
+ this.handler ||
77
+ createDefaultHandler(
78
+ this.profile,
79
+ compiler.getInfrastructureLogger("webpack.Progress")
80
+ );
122
81
  const showEntries = this.showEntries;
123
82
  const showModules = this.showModules;
124
83
  const showActiveModules = this.showActiveModules;
package/lib/Stats.js CHANGED
@@ -755,6 +755,7 @@ class Stats {
755
755
  LogType.profile,
756
756
  LogType.profileEnd,
757
757
  LogType.time,
758
+ LogType.status,
758
759
  LogType.clear
759
760
  ]);
760
761
  collapsedGroups = true;
@@ -1442,7 +1443,7 @@ class Stats {
1442
1443
  let indent = "";
1443
1444
  for (const entry of logData.entries) {
1444
1445
  let color = colors.normal;
1445
- let prefix = "";
1446
+ let prefix = " ";
1446
1447
  switch (entry.type) {
1447
1448
  case LogType.clear:
1448
1449
  colors.normal(`${indent}-------`);
@@ -1467,6 +1468,10 @@ class Stats {
1467
1468
  case LogType.debug:
1468
1469
  color = colors.normal;
1469
1470
  break;
1471
+ case LogType.status:
1472
+ color = colors.magenta;
1473
+ prefix = "<s> ";
1474
+ break;
1470
1475
  case LogType.profile:
1471
1476
  color = colors.magenta;
1472
1477
  prefix = "<p> ";
@@ -1481,13 +1486,14 @@ class Stats {
1481
1486
  break;
1482
1487
  case LogType.group:
1483
1488
  color = colors.cyan;
1489
+ prefix = "<-> ";
1484
1490
  break;
1485
1491
  case LogType.groupCollapsed:
1486
1492
  color = colors.cyan;
1487
1493
  prefix = "<+> ";
1488
1494
  break;
1489
1495
  case LogType.groupEnd:
1490
- if (indent.length > 2)
1496
+ if (indent.length >= 2)
1491
1497
  indent = indent.slice(0, indent.length - 2);
1492
1498
  continue;
1493
1499
  }
@@ -34,7 +34,11 @@ class SystemMainTemplatePlugin {
34
34
  const externals = chunk.getModules().filter(m => m.external);
35
35
 
36
36
  // The name this bundle should be registered as with System
37
- const name = this.name ? `${JSON.stringify(this.name)}, ` : "";
37
+ const name = this.name
38
+ ? `${JSON.stringify(
39
+ mainTemplate.getAssetPath(this.name, { hash, chunk })
40
+ )}, `
41
+ : "";
38
42
 
39
43
  // The array of dependencies that are external to webpack and will be provided by System
40
44
  const systemDependencies = JSON.stringify(
@@ -47,12 +47,18 @@ const getReplacer = (value, allowEmpty) => {
47
47
  }
48
48
  return "";
49
49
  } else {
50
- return `${value}`;
50
+ return `${escapePathVariables(value)}`;
51
51
  }
52
52
  };
53
53
  return fn;
54
54
  };
55
55
 
56
+ const escapePathVariables = value => {
57
+ return typeof value === "string"
58
+ ? value.replace(/\[(\\*[\w:]+\\*)\]/gi, "[\\$1\\]")
59
+ : value;
60
+ };
61
+
56
62
  const replacePathVariables = (path, data) => {
57
63
  const chunk = data.chunk;
58
64
  const chunkId = chunk && chunk.id;
@@ -114,6 +120,7 @@ const replacePathVariables = (path, data) => {
114
120
  .replace(REGEXP_QUERY, getReplacer(data.query, true))
115
121
  // only available in sourceMappingURLComment
116
122
  .replace(REGEXP_URL, getReplacer(data.url))
123
+ .replace(/\[\\(\\*[\w:]+\\*)\\\]/gi, "[$1]")
117
124
  );
118
125
  };
119
126
 
@@ -26,7 +26,8 @@ const LogType = Object.freeze({
26
26
 
27
27
  time: "time", // name, time as [seconds, nanoseconds]
28
28
 
29
- clear: "clear" // no arguments
29
+ clear: "clear", // no arguments
30
+ status: "status" // message, arguments
30
31
  });
31
32
 
32
33
  exports.LogType = LogType;
@@ -78,6 +79,10 @@ class WebpackLogger {
78
79
  this[LOG_SYMBOL](LogType.clear);
79
80
  }
80
81
 
82
+ status(...args) {
83
+ this[LOG_SYMBOL](LogType.status, args);
84
+ }
85
+
81
86
  group(...args) {
82
87
  this[LOG_SYMBOL](LogType.group, args);
83
88
  }
@@ -15,8 +15,9 @@ const { LogType } = require("./Logger");
15
15
 
16
16
  /**
17
17
  * @typedef {Object} LoggerOptions
18
- * @property {false|true|"none"|"error"|"warn"|"info"|"log"|"verbose"} options.level loglevel
19
- * @property {FilterTypes|boolean} options.debug filter for debug logging
18
+ * @property {false|true|"none"|"error"|"warn"|"info"|"log"|"verbose"} level loglevel
19
+ * @property {FilterTypes|boolean} debug filter for debug logging
20
+ * @property {Console & { status?: Function, logTime?: Function }} console the console to log to
20
21
  */
21
22
 
22
23
  /**
@@ -62,7 +63,7 @@ const LogLevel = {
62
63
  * @param {LoggerOptions} options options object
63
64
  * @returns {function(string, LogTypeEnum, any[]): void} logging function
64
65
  */
65
- module.exports = ({ level = "info", debug = false }) => {
66
+ module.exports = ({ level = "info", debug = false, console }) => {
66
67
  const debugFilters =
67
68
  typeof debug === "boolean"
68
69
  ? [() => debug]
@@ -79,12 +80,12 @@ module.exports = ({ level = "info", debug = false }) => {
79
80
  * @returns {void}
80
81
  */
81
82
  const logger = (name, type, args) => {
82
- const labeledArgs = (prefix = "") => {
83
+ const labeledArgs = () => {
83
84
  if (Array.isArray(args)) {
84
85
  if (args.length > 0 && typeof args[0] === "string") {
85
- return [`${prefix}[${name}] ${args[0]}`, ...args.slice(1)];
86
+ return [`[${name}] ${args[0]}`, ...args.slice(1)];
86
87
  } else {
87
- return [`${prefix}[${name}]`, ...args];
88
+ return [`[${name}]`, ...args];
88
89
  }
89
90
  } else {
90
91
  return [];
@@ -108,20 +109,33 @@ module.exports = ({ level = "info", debug = false }) => {
108
109
  break;
109
110
  case LogType.info:
110
111
  if (!debug && loglevel > LogLevel.info) return;
111
- console.info(...labeledArgs("<i> "));
112
+ console.info(...labeledArgs());
112
113
  break;
113
114
  case LogType.warn:
114
115
  if (!debug && loglevel > LogLevel.warn) return;
115
- console.warn(...labeledArgs("<w> "));
116
+ console.warn(...labeledArgs());
116
117
  break;
117
118
  case LogType.error:
118
119
  if (!debug && loglevel > LogLevel.error) return;
119
- console.error(...labeledArgs("<e> "));
120
+ console.error(...labeledArgs());
120
121
  break;
121
122
  case LogType.trace:
122
123
  if (!debug) return;
123
124
  console.trace();
124
125
  break;
126
+ case LogType.groupCollapsed:
127
+ if (!debug && loglevel > LogLevel.log) return;
128
+ if (!debug && loglevel > LogLevel.verbose) {
129
+ // eslint-disable-next-line node/no-unsupported-features/node-builtins
130
+ if (typeof console.groupCollapsed === "function") {
131
+ // eslint-disable-next-line node/no-unsupported-features/node-builtins
132
+ console.groupCollapsed(...labeledArgs());
133
+ } else {
134
+ console.log(...labeledArgs());
135
+ }
136
+ break;
137
+ }
138
+ // falls through
125
139
  case LogType.group:
126
140
  if (!debug && loglevel > LogLevel.log) return;
127
141
  // eslint-disable-next-line node/no-unsupported-features/node-builtins
@@ -132,32 +146,25 @@ module.exports = ({ level = "info", debug = false }) => {
132
146
  console.log(...labeledArgs());
133
147
  }
134
148
  break;
135
- case LogType.groupCollapsed:
136
- if (!debug && loglevel > LogLevel.log) return;
137
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
138
- if (typeof console.groupCollapsed === "function") {
139
- // eslint-disable-next-line node/no-unsupported-features/node-builtins
140
- console.groupCollapsed(...labeledArgs());
141
- } else {
142
- console.log(...labeledArgs("<g> "));
143
- }
144
- break;
145
149
  case LogType.groupEnd:
146
150
  if (!debug && loglevel > LogLevel.log) return;
147
151
  // eslint-disable-next-line node/no-unsupported-features/node-builtins
148
152
  if (typeof console.groupEnd === "function") {
149
153
  // eslint-disable-next-line node/no-unsupported-features/node-builtins
150
154
  console.groupEnd();
151
- } else {
152
- console.log(...labeledArgs("</g> "));
153
155
  }
154
156
  break;
155
- case LogType.time:
157
+ case LogType.time: {
156
158
  if (!debug && loglevel > LogLevel.log) return;
157
- console.log(
158
- `[${name}] ${args[0]}: ${args[1] * 1000 + args[2] / 1000000}ms`
159
- );
159
+ const ms = args[1] * 1000 + args[2] / 1000000;
160
+ const msg = `[${name}] ${args[0]}: ${ms}ms`;
161
+ if (typeof console.logTime === "function") {
162
+ console.logTime(msg);
163
+ } else {
164
+ console.log(msg);
165
+ }
160
166
  break;
167
+ }
161
168
  case LogType.profile:
162
169
  // eslint-disable-next-line node/no-unsupported-features/node-builtins
163
170
  if (typeof console.profile === "function") {
@@ -180,6 +187,20 @@ module.exports = ({ level = "info", debug = false }) => {
180
187
  console.clear();
181
188
  }
182
189
  break;
190
+ case LogType.status:
191
+ if (!debug && loglevel > LogLevel.info) return;
192
+ if (typeof console.status === "function") {
193
+ if (args.length === 0) {
194
+ console.status();
195
+ } else {
196
+ console.status(...labeledArgs());
197
+ }
198
+ } else {
199
+ if (args.length !== 0) {
200
+ console.info(...labeledArgs());
201
+ }
202
+ }
203
+ break;
183
204
  default:
184
205
  throw new Error(`Unexpected LogType ${type}`);
185
206
  }
@@ -5,7 +5,8 @@ const createConsoleLogger = require("./createConsoleLogger");
5
5
  /** @type {createConsoleLogger.LoggerOptions} */
6
6
  let currentDefaultLoggerOptions = {
7
7
  level: "info",
8
- debug: false
8
+ debug: false,
9
+ console
9
10
  };
10
11
  let currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions);
11
12
 
@@ -0,0 +1,74 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+
6
+ "use strict";
7
+
8
+ /**
9
+ * @param {any[]} args items to be truncated
10
+ * @param {number} maxLength maximum length of args including spaces between
11
+ * @returns {string[]} truncated args
12
+ */
13
+ const truncateArgs = (args, maxLength) => {
14
+ const lengths = args.map(a => `${a}`.length);
15
+ const availableLength = maxLength - lengths.length + 1;
16
+
17
+ if (availableLength > 0 && args.length === 1) {
18
+ if (availableLength > 3) {
19
+ return ["..." + args[0].slice(-availableLength + 3)];
20
+ } else {
21
+ return [args[0].slice(-availableLength)];
22
+ }
23
+ }
24
+
25
+ // Check if there is space for at least 4 chars per arg
26
+ if (availableLength < lengths.reduce((s, i) => s + Math.min(i, 6), 0)) {
27
+ // remove args
28
+ if (args.length > 1)
29
+ return truncateArgs(args.slice(0, args.length - 1), maxLength);
30
+ return [];
31
+ }
32
+
33
+ let currentLength = lengths.reduce((a, b) => a + b, 0);
34
+
35
+ // Check if all fits into maxLength
36
+ if (currentLength <= availableLength) return args;
37
+
38
+ // Try to remove chars from the longest items until it fits
39
+ while (currentLength > availableLength) {
40
+ const maxLength = Math.max(...lengths);
41
+ const shorterItems = lengths.filter(l => l !== maxLength);
42
+ const nextToMaxLength =
43
+ shorterItems.length > 0 ? Math.max(...shorterItems) : 0;
44
+ const maxReduce = maxLength - nextToMaxLength;
45
+ let maxItems = lengths.length - shorterItems.length;
46
+ let overrun = currentLength - availableLength;
47
+ for (let i = 0; i < lengths.length; i++) {
48
+ if (lengths[i] === maxLength) {
49
+ const reduce = Math.min(Math.floor(overrun / maxItems), maxReduce);
50
+ lengths[i] -= reduce;
51
+ currentLength -= reduce;
52
+ overrun -= reduce;
53
+ maxItems--;
54
+ }
55
+ }
56
+ }
57
+
58
+ // Return args reduced to length in lengths
59
+ return args.map((a, i) => {
60
+ const str = `${a}`;
61
+ const length = lengths[i];
62
+ if (str.length === length) {
63
+ return str;
64
+ } else if (length > 5) {
65
+ return "..." + str.slice(-length + 3);
66
+ } else if (length > 0) {
67
+ return str.slice(-length);
68
+ } else {
69
+ return "";
70
+ }
71
+ });
72
+ };
73
+
74
+ module.exports = truncateArgs;
@@ -9,6 +9,7 @@ const NodeOutputFileSystem = require("./NodeOutputFileSystem");
9
9
  const NodeJsInputFileSystem = require("enhanced-resolve/lib/NodeJsInputFileSystem");
10
10
  const CachedInputFileSystem = require("enhanced-resolve/lib/CachedInputFileSystem");
11
11
  const createConsoleLogger = require("../logging/createConsoleLogger");
12
+ const nodeConsole = require("./nodeConsole");
12
13
 
13
14
  class NodeEnvironmentPlugin {
14
15
  constructor(options) {
@@ -20,7 +21,8 @@ class NodeEnvironmentPlugin {
20
21
  Object.assign(
21
22
  {
22
23
  level: "info",
23
- debug: false
24
+ debug: false,
25
+ console: nodeConsole
24
26
  },
25
27
  this.options.infrastructureLogging
26
28
  )
@@ -0,0 +1,133 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+
6
+ "use strict";
7
+
8
+ const truncateArgs = require("../logging/truncateArgs");
9
+ const util = require("util");
10
+
11
+ const tty = process.stderr.isTTY && process.env.TERM !== "dumb";
12
+
13
+ let currentStatusMessage = undefined;
14
+ let hasStatusMessage = false;
15
+ let currentIndent = "";
16
+ let currentCollapsed = 0;
17
+
18
+ const indent = (str, prefix, colorPrefix, colorSuffix) => {
19
+ if (str === "") return str;
20
+ prefix = currentIndent + prefix;
21
+ if (tty) {
22
+ return (
23
+ prefix +
24
+ colorPrefix +
25
+ str.replace(/\n/g, colorSuffix + "\n" + prefix + colorPrefix) +
26
+ colorSuffix
27
+ );
28
+ } else {
29
+ return prefix + str.replace(/\n/g, "\n" + prefix);
30
+ }
31
+ };
32
+
33
+ const clearStatusMessage = () => {
34
+ if (hasStatusMessage) {
35
+ process.stderr.write("\x1b[2K\r");
36
+ hasStatusMessage = false;
37
+ }
38
+ };
39
+
40
+ const writeStatusMessage = () => {
41
+ if (!currentStatusMessage) return;
42
+ const l = process.stderr.columns;
43
+ const args = l ? truncateArgs(currentStatusMessage, l) : currentStatusMessage;
44
+ const str = args.join(" ");
45
+ const coloredStr = `\u001b[1m${str}\u001b[39m\u001b[22m`;
46
+ process.stderr.write(`\x1b[2K\r${coloredStr}`);
47
+ hasStatusMessage = true;
48
+ };
49
+
50
+ const writeColored = (prefix, colorPrefix, colorSuffix) => {
51
+ return (...args) => {
52
+ if (currentCollapsed > 0) return;
53
+ clearStatusMessage();
54
+ // @ts-ignore
55
+ const str = indent(util.format(...args), prefix, colorPrefix, colorSuffix);
56
+ process.stderr.write(str + "\n");
57
+ writeStatusMessage();
58
+ };
59
+ };
60
+
61
+ const writeGroupMessage = writeColored(
62
+ "<-> ",
63
+ "\u001b[1m\u001b[36m",
64
+ "\u001b[39m\u001b[22m"
65
+ );
66
+
67
+ const writeGroupCollapsedMessage = writeColored(
68
+ "<+> ",
69
+ "\u001b[1m\u001b[36m",
70
+ "\u001b[39m\u001b[22m"
71
+ );
72
+
73
+ module.exports = {
74
+ log: writeColored(" ", "\u001b[1m", "\u001b[22m"),
75
+ debug: writeColored(" ", "", ""),
76
+ trace: writeColored(" ", "", ""),
77
+ info: writeColored("<i> ", "\u001b[1m\u001b[32m", "\u001b[39m\u001b[22m"),
78
+ warn: writeColored("<w> ", "\u001b[1m\u001b[33m", "\u001b[39m\u001b[22m"),
79
+ error: writeColored("<e> ", "\u001b[1m\u001b[31m", "\u001b[39m\u001b[22m"),
80
+ logTime: writeColored("<t> ", "\u001b[1m\u001b[35m", "\u001b[39m\u001b[22m"),
81
+ group: (...args) => {
82
+ writeGroupMessage(...args);
83
+ if (currentCollapsed > 0) {
84
+ currentCollapsed++;
85
+ } else {
86
+ currentIndent += " ";
87
+ }
88
+ },
89
+ groupCollapsed: (...args) => {
90
+ writeGroupCollapsedMessage(...args);
91
+ currentCollapsed++;
92
+ },
93
+ groupEnd: () => {
94
+ if (currentCollapsed > 0) currentCollapsed--;
95
+ else if (currentIndent.length >= 2)
96
+ currentIndent = currentIndent.slice(0, currentIndent.length - 2);
97
+ },
98
+ // eslint-disable-next-line node/no-unsupported-features/node-builtins
99
+ profile: console.profile && (name => console.profile(name)),
100
+ // eslint-disable-next-line node/no-unsupported-features/node-builtins
101
+ profileEnd: console.profileEnd && (name => console.profileEnd(name)),
102
+ clear:
103
+ tty &&
104
+ // eslint-disable-next-line node/no-unsupported-features/node-builtins
105
+ console.clear &&
106
+ (() => {
107
+ clearStatusMessage();
108
+ // eslint-disable-next-line node/no-unsupported-features/node-builtins
109
+ console.clear();
110
+ writeStatusMessage();
111
+ }),
112
+ status: tty
113
+ ? (name, ...args) => {
114
+ args = args.filter(Boolean);
115
+ if (name === undefined && args.length === 0) {
116
+ clearStatusMessage();
117
+ currentStatusMessage = undefined;
118
+ } else if (
119
+ typeof name === "string" &&
120
+ name.startsWith("[webpack.Progress] ")
121
+ ) {
122
+ currentStatusMessage = [name.slice(19), ...args];
123
+ writeStatusMessage();
124
+ } else if (name === "[webpack.Progress]") {
125
+ currentStatusMessage = [...args];
126
+ writeStatusMessage();
127
+ } else {
128
+ currentStatusMessage = [name, ...args];
129
+ writeStatusMessage();
130
+ }
131
+ }
132
+ : writeColored("<s> ", "", "")
133
+ };
@@ -367,7 +367,7 @@ class JsonpMainTemplatePlugin {
367
367
  "for(;i < chunkIds.length; i++) {",
368
368
  Template.indent([
369
369
  "chunkId = chunkIds[i];",
370
- "if(installedChunks[chunkId]) {",
370
+ "if(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) {",
371
371
  Template.indent("resolves.push(installedChunks[chunkId][0]);"),
372
372
  "}",
373
373
  "installedChunks[chunkId] = 0;"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "4.38.0",
3
+ "version": "4.39.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",
@@ -9,25 +9,25 @@
9
9
  "@webassemblyjs/helper-module-context": "1.8.5",
10
10
  "@webassemblyjs/wasm-edit": "1.8.5",
11
11
  "@webassemblyjs/wasm-parser": "1.8.5",
12
- "acorn": "^6.2.0",
13
- "ajv": "^6.1.0",
14
- "ajv-keywords": "^3.1.0",
15
- "chrome-trace-event": "^1.0.0",
12
+ "acorn": "^6.2.1",
13
+ "ajv": "^6.10.2",
14
+ "ajv-keywords": "^3.4.1",
15
+ "chrome-trace-event": "^1.0.2",
16
16
  "enhanced-resolve": "^4.1.0",
17
- "eslint-scope": "^4.0.0",
17
+ "eslint-scope": "^4.0.3",
18
18
  "json-parse-better-errors": "^1.0.2",
19
- "loader-runner": "^2.3.0",
20
- "loader-utils": "^1.1.0",
21
- "memory-fs": "~0.4.1",
22
- "micromatch": "^3.1.8",
23
- "mkdirp": "~0.5.0",
24
- "neo-async": "^2.5.0",
25
- "node-libs-browser": "^2.0.0",
19
+ "loader-runner": "^2.4.0",
20
+ "loader-utils": "^1.2.3",
21
+ "memory-fs": "^0.4.1",
22
+ "micromatch": "^3.1.10",
23
+ "mkdirp": "^0.5.1",
24
+ "neo-async": "^2.6.1",
25
+ "node-libs-browser": "^2.2.1",
26
26
  "schema-utils": "^1.0.0",
27
- "tapable": "^1.1.0",
28
- "terser-webpack-plugin": "^1.1.0",
29
- "watchpack": "^1.5.0",
30
- "webpack-sources": "^1.3.0"
27
+ "tapable": "^1.1.3",
28
+ "terser-webpack-plugin": "^1.4.1",
29
+ "watchpack": "^1.6.0",
30
+ "webpack-sources": "^1.4.1"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^10.12.21",
@@ -53,8 +53,6 @@
53
53
  "husky": "^1.1.3",
54
54
  "i18n-webpack-plugin": "^1.0.0",
55
55
  "istanbul": "^0.4.5",
56
- "jade": "^1.11.0",
57
- "jade-loader": "~0.8.0",
58
56
  "jest": "24.1.0",
59
57
  "jest-junit": "^6.2.1",
60
58
  "json-loader": "^0.5.7",
@@ -64,7 +62,7 @@
64
62
  "lint-staged": "^8.0.4",
65
63
  "lodash": "^4.17.4",
66
64
  "prettier": "^1.14.3",
67
- "pug": "^2.0.3",
65
+ "pug": "^2.0.4",
68
66
  "pug-loader": "^2.4.0",
69
67
  "raw-loader": "^1.0.0",
70
68
  "react": "^16.8.0",