webpack 4.36.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.
- package/declarations/WebpackOptions.d.ts +35 -10
- package/lib/Chunk.js +5 -1
- package/lib/ChunkGroup.js +1 -1
- package/lib/Compilation.js +83 -477
- package/lib/Compiler.js +42 -2
- package/lib/MultiCompiler.js +8 -1
- package/lib/NormalModule.js +15 -4
- package/lib/ProgressPlugin.js +21 -63
- package/lib/ResolverFactory.js +9 -13
- package/lib/SourceMapDevToolPlugin.js +25 -17
- package/lib/Stats.js +227 -3
- package/lib/SystemMainTemplatePlugin.js +5 -1
- package/lib/TemplatedPathPlugin.js +8 -1
- package/lib/WebpackOptionsDefaulter.js +12 -1
- package/lib/buildChunkGraph.js +689 -0
- package/lib/logging/Logger.js +131 -0
- package/lib/logging/createConsoleLogger.js +209 -0
- package/lib/logging/runtime.js +36 -0
- package/lib/logging/truncateArgs.js +74 -0
- package/lib/node/NodeEnvironmentPlugin.js +16 -0
- package/lib/node/nodeConsole.js +133 -0
- package/lib/web/JsonpMainTemplatePlugin.js +1 -1
- package/lib/webpack.js +3 -1
- package/package.json +18 -20
- package/schemas/WebpackOptions.json +53 -1
@@ -0,0 +1,131 @@
|
|
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
|
+
* @enum {string}
|
10
|
+
*/
|
11
|
+
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
|
17
|
+
|
18
|
+
trace: "trace", // no arguments
|
19
|
+
|
20
|
+
group: "group", // [label]
|
21
|
+
groupCollapsed: "groupCollapsed", // [label]
|
22
|
+
groupEnd: "groupEnd", // [label]
|
23
|
+
|
24
|
+
profile: "profile", // [profileName]
|
25
|
+
profileEnd: "profileEnd", // [profileName]
|
26
|
+
|
27
|
+
time: "time", // name, time as [seconds, nanoseconds]
|
28
|
+
|
29
|
+
clear: "clear", // no arguments
|
30
|
+
status: "status" // message, arguments
|
31
|
+
});
|
32
|
+
|
33
|
+
exports.LogType = LogType;
|
34
|
+
|
35
|
+
/** @typedef {LogType} LogTypeEnum */
|
36
|
+
|
37
|
+
const LOG_SYMBOL = Symbol("webpack logger raw log method");
|
38
|
+
const TIMERS_SYMBOL = Symbol("webpack logger times");
|
39
|
+
|
40
|
+
class WebpackLogger {
|
41
|
+
/**
|
42
|
+
* @param {function(LogType, any[]=): void} log log function
|
43
|
+
*/
|
44
|
+
constructor(log) {
|
45
|
+
this[LOG_SYMBOL] = log;
|
46
|
+
}
|
47
|
+
|
48
|
+
error(...args) {
|
49
|
+
this[LOG_SYMBOL](LogType.error, args);
|
50
|
+
}
|
51
|
+
|
52
|
+
warn(...args) {
|
53
|
+
this[LOG_SYMBOL](LogType.warn, args);
|
54
|
+
}
|
55
|
+
|
56
|
+
info(...args) {
|
57
|
+
this[LOG_SYMBOL](LogType.info, args);
|
58
|
+
}
|
59
|
+
|
60
|
+
log(...args) {
|
61
|
+
this[LOG_SYMBOL](LogType.log, args);
|
62
|
+
}
|
63
|
+
|
64
|
+
debug(...args) {
|
65
|
+
this[LOG_SYMBOL](LogType.debug, args);
|
66
|
+
}
|
67
|
+
|
68
|
+
assert(assertion, ...args) {
|
69
|
+
if (!assertion) {
|
70
|
+
this[LOG_SYMBOL](LogType.error, args);
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
trace() {
|
75
|
+
this[LOG_SYMBOL](LogType.trace, ["Trace"]);
|
76
|
+
}
|
77
|
+
|
78
|
+
clear() {
|
79
|
+
this[LOG_SYMBOL](LogType.clear);
|
80
|
+
}
|
81
|
+
|
82
|
+
status(...args) {
|
83
|
+
this[LOG_SYMBOL](LogType.status, args);
|
84
|
+
}
|
85
|
+
|
86
|
+
group(...args) {
|
87
|
+
this[LOG_SYMBOL](LogType.group, args);
|
88
|
+
}
|
89
|
+
|
90
|
+
groupCollapsed(...args) {
|
91
|
+
this[LOG_SYMBOL](LogType.groupCollapsed, args);
|
92
|
+
}
|
93
|
+
|
94
|
+
groupEnd(...args) {
|
95
|
+
this[LOG_SYMBOL](LogType.groupEnd, args);
|
96
|
+
}
|
97
|
+
|
98
|
+
profile(label) {
|
99
|
+
this[LOG_SYMBOL](LogType.profile, [label]);
|
100
|
+
}
|
101
|
+
|
102
|
+
profileEnd(label) {
|
103
|
+
this[LOG_SYMBOL](LogType.profileEnd, [label]);
|
104
|
+
}
|
105
|
+
|
106
|
+
time(label) {
|
107
|
+
this[TIMERS_SYMBOL] = this[TIMERS_SYMBOL] || new Map();
|
108
|
+
this[TIMERS_SYMBOL].set(label, process.hrtime());
|
109
|
+
}
|
110
|
+
|
111
|
+
timeLog(label) {
|
112
|
+
const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label);
|
113
|
+
if (!prev) {
|
114
|
+
throw new Error(`No such label '${label}' for WebpackLogger.timeLog()`);
|
115
|
+
}
|
116
|
+
const time = process.hrtime(prev);
|
117
|
+
this[LOG_SYMBOL](LogType.time, [label, ...time]);
|
118
|
+
}
|
119
|
+
|
120
|
+
timeEnd(label) {
|
121
|
+
const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label);
|
122
|
+
if (!prev) {
|
123
|
+
throw new Error(`No such label '${label}' for WebpackLogger.timeEnd()`);
|
124
|
+
}
|
125
|
+
const time = process.hrtime(prev);
|
126
|
+
this[TIMERS_SYMBOL].delete(label);
|
127
|
+
this[LOG_SYMBOL](LogType.time, [label, ...time]);
|
128
|
+
}
|
129
|
+
}
|
130
|
+
|
131
|
+
exports.Logger = WebpackLogger;
|
@@ -0,0 +1,209 @@
|
|
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 { LogType } = require("./Logger");
|
9
|
+
|
10
|
+
/** @typedef {import("./Logger").LogTypeEnum} LogTypeEnum */
|
11
|
+
/** @typedef {import("../../declarations/WebpackOptions").FilterTypes} FilterTypes */
|
12
|
+
/** @typedef {import("../../declarations/WebpackOptions").FilterItemTypes} FilterItemTypes */
|
13
|
+
|
14
|
+
/** @typedef {function(string): boolean} FilterFunction */
|
15
|
+
|
16
|
+
/**
|
17
|
+
* @typedef {Object} LoggerOptions
|
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
|
21
|
+
*/
|
22
|
+
|
23
|
+
/**
|
24
|
+
* @param {FilterItemTypes} item an input item
|
25
|
+
* @returns {FilterFunction} filter funtion
|
26
|
+
*/
|
27
|
+
const filterToFunction = item => {
|
28
|
+
if (typeof item === "string") {
|
29
|
+
const regExp = new RegExp(
|
30
|
+
`[\\\\/]${item.replace(
|
31
|
+
// eslint-disable-next-line no-useless-escape
|
32
|
+
/[-[\]{}()*+?.\\^$|]/g,
|
33
|
+
"\\$&"
|
34
|
+
)}([\\\\/]|$|!|\\?)`
|
35
|
+
);
|
36
|
+
return ident => regExp.test(ident);
|
37
|
+
}
|
38
|
+
if (item && typeof item === "object" && typeof item.test === "function") {
|
39
|
+
return ident => item.test(ident);
|
40
|
+
}
|
41
|
+
if (typeof item === "function") {
|
42
|
+
return item;
|
43
|
+
}
|
44
|
+
if (typeof item === "boolean") {
|
45
|
+
return () => item;
|
46
|
+
}
|
47
|
+
};
|
48
|
+
|
49
|
+
/**
|
50
|
+
* @enum {number} */
|
51
|
+
const LogLevel = {
|
52
|
+
none: 6,
|
53
|
+
false: 6,
|
54
|
+
error: 5,
|
55
|
+
warn: 4,
|
56
|
+
info: 3,
|
57
|
+
log: 2,
|
58
|
+
true: 2,
|
59
|
+
verbose: 1
|
60
|
+
};
|
61
|
+
|
62
|
+
/**
|
63
|
+
* @param {LoggerOptions} options options object
|
64
|
+
* @returns {function(string, LogTypeEnum, any[]): void} logging function
|
65
|
+
*/
|
66
|
+
module.exports = ({ level = "info", debug = false, console }) => {
|
67
|
+
const debugFilters =
|
68
|
+
typeof debug === "boolean"
|
69
|
+
? [() => debug]
|
70
|
+
: /** @type {FilterItemTypes[]} */ ([])
|
71
|
+
.concat(debug)
|
72
|
+
.map(filterToFunction);
|
73
|
+
/** @type {number} */
|
74
|
+
const loglevel = LogLevel[`${level}`] || 0;
|
75
|
+
|
76
|
+
/**
|
77
|
+
* @param {string} name name of the logger
|
78
|
+
* @param {LogTypeEnum} type type of the log entry
|
79
|
+
* @param {any[]} args arguments of the log entry
|
80
|
+
* @returns {void}
|
81
|
+
*/
|
82
|
+
const logger = (name, type, args) => {
|
83
|
+
const labeledArgs = () => {
|
84
|
+
if (Array.isArray(args)) {
|
85
|
+
if (args.length > 0 && typeof args[0] === "string") {
|
86
|
+
return [`[${name}] ${args[0]}`, ...args.slice(1)];
|
87
|
+
} else {
|
88
|
+
return [`[${name}]`, ...args];
|
89
|
+
}
|
90
|
+
} else {
|
91
|
+
return [];
|
92
|
+
}
|
93
|
+
};
|
94
|
+
const debug = debugFilters.some(f => f(name));
|
95
|
+
switch (type) {
|
96
|
+
case LogType.debug:
|
97
|
+
if (!debug) return;
|
98
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
99
|
+
if (typeof console.debug === "function") {
|
100
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
101
|
+
console.debug(...labeledArgs());
|
102
|
+
} else {
|
103
|
+
console.log(...labeledArgs());
|
104
|
+
}
|
105
|
+
break;
|
106
|
+
case LogType.log:
|
107
|
+
if (!debug && loglevel > LogLevel.log) return;
|
108
|
+
console.log(...labeledArgs());
|
109
|
+
break;
|
110
|
+
case LogType.info:
|
111
|
+
if (!debug && loglevel > LogLevel.info) return;
|
112
|
+
console.info(...labeledArgs());
|
113
|
+
break;
|
114
|
+
case LogType.warn:
|
115
|
+
if (!debug && loglevel > LogLevel.warn) return;
|
116
|
+
console.warn(...labeledArgs());
|
117
|
+
break;
|
118
|
+
case LogType.error:
|
119
|
+
if (!debug && loglevel > LogLevel.error) return;
|
120
|
+
console.error(...labeledArgs());
|
121
|
+
break;
|
122
|
+
case LogType.trace:
|
123
|
+
if (!debug) return;
|
124
|
+
console.trace();
|
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
|
139
|
+
case LogType.group:
|
140
|
+
if (!debug && loglevel > LogLevel.log) return;
|
141
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
142
|
+
if (typeof console.group === "function") {
|
143
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
144
|
+
console.group(...labeledArgs());
|
145
|
+
} else {
|
146
|
+
console.log(...labeledArgs());
|
147
|
+
}
|
148
|
+
break;
|
149
|
+
case LogType.groupEnd:
|
150
|
+
if (!debug && loglevel > LogLevel.log) return;
|
151
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
152
|
+
if (typeof console.groupEnd === "function") {
|
153
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
154
|
+
console.groupEnd();
|
155
|
+
}
|
156
|
+
break;
|
157
|
+
case LogType.time: {
|
158
|
+
if (!debug && loglevel > LogLevel.log) return;
|
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
|
+
}
|
166
|
+
break;
|
167
|
+
}
|
168
|
+
case LogType.profile:
|
169
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
170
|
+
if (typeof console.profile === "function") {
|
171
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
172
|
+
console.profile(...labeledArgs());
|
173
|
+
}
|
174
|
+
break;
|
175
|
+
case LogType.profileEnd:
|
176
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
177
|
+
if (typeof console.profileEnd === "function") {
|
178
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
179
|
+
console.profileEnd(...labeledArgs());
|
180
|
+
}
|
181
|
+
break;
|
182
|
+
case LogType.clear:
|
183
|
+
if (!debug && loglevel > LogLevel.log) return;
|
184
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
185
|
+
if (typeof console.clear === "function") {
|
186
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
187
|
+
console.clear();
|
188
|
+
}
|
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;
|
204
|
+
default:
|
205
|
+
throw new Error(`Unexpected LogType ${type}`);
|
206
|
+
}
|
207
|
+
};
|
208
|
+
return logger;
|
209
|
+
};
|
@@ -0,0 +1,36 @@
|
|
1
|
+
const SyncBailHook = require("tapable/lib/SyncBailHook");
|
2
|
+
const { Logger } = require("./Logger");
|
3
|
+
const createConsoleLogger = require("./createConsoleLogger");
|
4
|
+
|
5
|
+
/** @type {createConsoleLogger.LoggerOptions} */
|
6
|
+
let currentDefaultLoggerOptions = {
|
7
|
+
level: "info",
|
8
|
+
debug: false,
|
9
|
+
console
|
10
|
+
};
|
11
|
+
let currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions);
|
12
|
+
|
13
|
+
/**
|
14
|
+
* @param {string} name name of the logger
|
15
|
+
* @returns {Logger} a logger
|
16
|
+
*/
|
17
|
+
exports.getLogger = name => {
|
18
|
+
return new Logger((type, args) => {
|
19
|
+
if (exports.hooks.log.call(name, type, args) === undefined) {
|
20
|
+
currentDefaultLogger(name, type, args);
|
21
|
+
}
|
22
|
+
});
|
23
|
+
};
|
24
|
+
|
25
|
+
/**
|
26
|
+
* @param {createConsoleLogger.LoggerOptions} options new options, merge with old options
|
27
|
+
* @returns {void}
|
28
|
+
*/
|
29
|
+
exports.configureDefaultLogger = options => {
|
30
|
+
Object.assign(currentDefaultLoggerOptions, options);
|
31
|
+
currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions);
|
32
|
+
};
|
33
|
+
|
34
|
+
exports.hooks = {
|
35
|
+
log: new SyncBailHook(["origin", "type", "args"])
|
36
|
+
};
|
@@ -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;
|
@@ -8,9 +8,25 @@ const NodeWatchFileSystem = require("./NodeWatchFileSystem");
|
|
8
8
|
const NodeOutputFileSystem = require("./NodeOutputFileSystem");
|
9
9
|
const NodeJsInputFileSystem = require("enhanced-resolve/lib/NodeJsInputFileSystem");
|
10
10
|
const CachedInputFileSystem = require("enhanced-resolve/lib/CachedInputFileSystem");
|
11
|
+
const createConsoleLogger = require("../logging/createConsoleLogger");
|
12
|
+
const nodeConsole = require("./nodeConsole");
|
11
13
|
|
12
14
|
class NodeEnvironmentPlugin {
|
15
|
+
constructor(options) {
|
16
|
+
this.options = options || {};
|
17
|
+
}
|
18
|
+
|
13
19
|
apply(compiler) {
|
20
|
+
compiler.infrastructureLogger = createConsoleLogger(
|
21
|
+
Object.assign(
|
22
|
+
{
|
23
|
+
level: "info",
|
24
|
+
debug: false,
|
25
|
+
console: nodeConsole
|
26
|
+
},
|
27
|
+
this.options.infrastructureLogging
|
28
|
+
)
|
29
|
+
);
|
14
30
|
compiler.inputFileSystem = new CachedInputFileSystem(
|
15
31
|
new NodeJsInputFileSystem(),
|
16
32
|
60000
|
@@ -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/lib/webpack.js
CHANGED
@@ -40,7 +40,9 @@ const webpack = (options, callback) => {
|
|
40
40
|
|
41
41
|
compiler = new Compiler(options.context);
|
42
42
|
compiler.options = options;
|
43
|
-
new NodeEnvironmentPlugin(
|
43
|
+
new NodeEnvironmentPlugin({
|
44
|
+
infrastructureLogging: options.infrastructureLogging
|
45
|
+
}).apply(compiler);
|
44
46
|
if (options.plugins && Array.isArray(options.plugins)) {
|
45
47
|
for (const plugin of options.plugins) {
|
46
48
|
if (typeof plugin === "function") {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "4.
|
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.
|
13
|
-
"ajv": "^6.
|
14
|
-
"ajv-keywords": "^3.1
|
15
|
-
"chrome-trace-event": "^1.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.
|
17
|
+
"eslint-scope": "^4.0.3",
|
18
18
|
"json-parse-better-errors": "^1.0.2",
|
19
|
-
"loader-runner": "^2.
|
20
|
-
"loader-utils": "^1.
|
21
|
-
"memory-fs": "
|
22
|
-
"micromatch": "^3.1.
|
23
|
-
"mkdirp": "
|
24
|
-
"neo-async": "^2.
|
25
|
-
"node-libs-browser": "^2.
|
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.
|
28
|
-
"terser-webpack-plugin": "^1.1
|
29
|
-
"watchpack": "^1.
|
30
|
-
"webpack-sources": "^1.
|
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.
|
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",
|