webpack 4.37.0 → 4.39.2

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.
@@ -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,76 @@
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 >= args[0].length) {
19
+ return args;
20
+ } else if (availableLength > 3) {
21
+ return ["..." + args[0].slice(-availableLength + 3)];
22
+ } else {
23
+ return [args[0].slice(-availableLength)];
24
+ }
25
+ }
26
+
27
+ // Check if there is space for at least 4 chars per arg
28
+ if (availableLength < lengths.reduce((s, i) => s + Math.min(i, 6), 0)) {
29
+ // remove args
30
+ if (args.length > 1)
31
+ return truncateArgs(args.slice(0, args.length - 1), maxLength);
32
+ return [];
33
+ }
34
+
35
+ let currentLength = lengths.reduce((a, b) => a + b, 0);
36
+
37
+ // Check if all fits into maxLength
38
+ if (currentLength <= availableLength) return args;
39
+
40
+ // Try to remove chars from the longest items until it fits
41
+ while (currentLength > availableLength) {
42
+ const maxLength = Math.max(...lengths);
43
+ const shorterItems = lengths.filter(l => l !== maxLength);
44
+ const nextToMaxLength =
45
+ shorterItems.length > 0 ? Math.max(...shorterItems) : 0;
46
+ const maxReduce = maxLength - nextToMaxLength;
47
+ let maxItems = lengths.length - shorterItems.length;
48
+ let overrun = currentLength - availableLength;
49
+ for (let i = 0; i < lengths.length; i++) {
50
+ if (lengths[i] === maxLength) {
51
+ const reduce = Math.min(Math.floor(overrun / maxItems), maxReduce);
52
+ lengths[i] -= reduce;
53
+ currentLength -= reduce;
54
+ overrun -= reduce;
55
+ maxItems--;
56
+ }
57
+ }
58
+ }
59
+
60
+ // Return args reduced to length in lengths
61
+ return args.map((a, i) => {
62
+ const str = `${a}`;
63
+ const length = lengths[i];
64
+ if (str.length === length) {
65
+ return str;
66
+ } else if (length > 5) {
67
+ return "..." + str.slice(-length + 3);
68
+ } else if (length > 0) {
69
+ return str.slice(-length);
70
+ } else {
71
+ return "";
72
+ }
73
+ });
74
+ };
75
+
76
+ 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,135 @@
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
44
+ ? truncateArgs(currentStatusMessage, l - 1)
45
+ : currentStatusMessage;
46
+ const str = args.join(" ");
47
+ const coloredStr = `\u001b[1m${str}\u001b[39m\u001b[22m`;
48
+ process.stderr.write(`\x1b[2K\r${coloredStr}`);
49
+ hasStatusMessage = true;
50
+ };
51
+
52
+ const writeColored = (prefix, colorPrefix, colorSuffix) => {
53
+ return (...args) => {
54
+ if (currentCollapsed > 0) return;
55
+ clearStatusMessage();
56
+ // @ts-ignore
57
+ const str = indent(util.format(...args), prefix, colorPrefix, colorSuffix);
58
+ process.stderr.write(str + "\n");
59
+ writeStatusMessage();
60
+ };
61
+ };
62
+
63
+ const writeGroupMessage = writeColored(
64
+ "<-> ",
65
+ "\u001b[1m\u001b[36m",
66
+ "\u001b[39m\u001b[22m"
67
+ );
68
+
69
+ const writeGroupCollapsedMessage = writeColored(
70
+ "<+> ",
71
+ "\u001b[1m\u001b[36m",
72
+ "\u001b[39m\u001b[22m"
73
+ );
74
+
75
+ module.exports = {
76
+ log: writeColored(" ", "\u001b[1m", "\u001b[22m"),
77
+ debug: writeColored(" ", "", ""),
78
+ trace: writeColored(" ", "", ""),
79
+ info: writeColored("<i> ", "\u001b[1m\u001b[32m", "\u001b[39m\u001b[22m"),
80
+ warn: writeColored("<w> ", "\u001b[1m\u001b[33m", "\u001b[39m\u001b[22m"),
81
+ error: writeColored("<e> ", "\u001b[1m\u001b[31m", "\u001b[39m\u001b[22m"),
82
+ logTime: writeColored("<t> ", "\u001b[1m\u001b[35m", "\u001b[39m\u001b[22m"),
83
+ group: (...args) => {
84
+ writeGroupMessage(...args);
85
+ if (currentCollapsed > 0) {
86
+ currentCollapsed++;
87
+ } else {
88
+ currentIndent += " ";
89
+ }
90
+ },
91
+ groupCollapsed: (...args) => {
92
+ writeGroupCollapsedMessage(...args);
93
+ currentCollapsed++;
94
+ },
95
+ groupEnd: () => {
96
+ if (currentCollapsed > 0) currentCollapsed--;
97
+ else if (currentIndent.length >= 2)
98
+ currentIndent = currentIndent.slice(0, currentIndent.length - 2);
99
+ },
100
+ // eslint-disable-next-line node/no-unsupported-features/node-builtins
101
+ profile: console.profile && (name => console.profile(name)),
102
+ // eslint-disable-next-line node/no-unsupported-features/node-builtins
103
+ profileEnd: console.profileEnd && (name => console.profileEnd(name)),
104
+ clear:
105
+ tty &&
106
+ // eslint-disable-next-line node/no-unsupported-features/node-builtins
107
+ console.clear &&
108
+ (() => {
109
+ clearStatusMessage();
110
+ // eslint-disable-next-line node/no-unsupported-features/node-builtins
111
+ console.clear();
112
+ writeStatusMessage();
113
+ }),
114
+ status: tty
115
+ ? (name, ...args) => {
116
+ args = args.filter(Boolean);
117
+ if (name === undefined && args.length === 0) {
118
+ clearStatusMessage();
119
+ currentStatusMessage = undefined;
120
+ } else if (
121
+ typeof name === "string" &&
122
+ name.startsWith("[webpack.Progress] ")
123
+ ) {
124
+ currentStatusMessage = [name.slice(19), ...args];
125
+ writeStatusMessage();
126
+ } else if (name === "[webpack.Progress]") {
127
+ currentStatusMessage = [...args];
128
+ writeStatusMessage();
129
+ } else {
130
+ currentStatusMessage = [name, ...args];
131
+ writeStatusMessage();
132
+ }
133
+ }
134
+ : writeColored("<s> ", "", "")
135
+ };
@@ -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.37.0",
3
+ "version": "4.39.2",
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",