webpack 4.35.3 → 4.38.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 +36 -11
- package/lib/AbstractMethodError.js +43 -0
- package/lib/Chunk.js +5 -1
- package/lib/ChunkGroup.js +1 -1
- package/lib/Compilation.js +87 -471
- package/lib/Compiler.js +33 -0
- package/lib/HashedModuleIdsPlugin.js +3 -1
- package/lib/JavascriptModulesPlugin.js +2 -3
- package/lib/ModuleFilenameHelpers.js +2 -1
- package/lib/NamedModulesPlugin.js +2 -1
- package/lib/NormalModule.js +16 -5
- package/lib/NormalModuleFactory.js +2 -2
- package/lib/OptionsDefaulter.js +9 -9
- package/lib/ProgressPlugin.js +0 -1
- package/lib/ResolverFactory.js +11 -14
- package/lib/SourceMapDevToolPlugin.js +110 -22
- package/lib/Stats.js +221 -3
- package/lib/Template.js +1 -1
- package/lib/TemplatedPathPlugin.js +4 -1
- package/lib/WebpackOptionsApply.js +5 -6
- package/lib/WebpackOptionsDefaulter.js +12 -1
- package/lib/buildChunkGraph.js +689 -0
- package/lib/debug/ProfilingPlugin.js +1 -1
- package/lib/logging/Logger.js +126 -0
- package/lib/logging/createConsoleLogger.js +188 -0
- package/lib/logging/runtime.js +35 -0
- package/lib/node/NodeEnvironmentPlugin.js +14 -0
- package/lib/util/cleverMerge.js +77 -0
- package/lib/util/createHash.js +57 -12
- package/lib/util/objectToMap.js +1 -1
- package/lib/wasm/WebAssemblyGenerator.js +7 -7
- package/lib/webpack.js +3 -1
- package/package.json +2 -1
- package/schemas/WebpackOptions.json +54 -2
@@ -0,0 +1,126 @@
|
|
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
|
+
});
|
31
|
+
|
32
|
+
exports.LogType = LogType;
|
33
|
+
|
34
|
+
/** @typedef {LogType} LogTypeEnum */
|
35
|
+
|
36
|
+
const LOG_SYMBOL = Symbol("webpack logger raw log method");
|
37
|
+
const TIMERS_SYMBOL = Symbol("webpack logger times");
|
38
|
+
|
39
|
+
class WebpackLogger {
|
40
|
+
/**
|
41
|
+
* @param {function(LogType, any[]=): void} log log function
|
42
|
+
*/
|
43
|
+
constructor(log) {
|
44
|
+
this[LOG_SYMBOL] = log;
|
45
|
+
}
|
46
|
+
|
47
|
+
error(...args) {
|
48
|
+
this[LOG_SYMBOL](LogType.error, args);
|
49
|
+
}
|
50
|
+
|
51
|
+
warn(...args) {
|
52
|
+
this[LOG_SYMBOL](LogType.warn, args);
|
53
|
+
}
|
54
|
+
|
55
|
+
info(...args) {
|
56
|
+
this[LOG_SYMBOL](LogType.info, args);
|
57
|
+
}
|
58
|
+
|
59
|
+
log(...args) {
|
60
|
+
this[LOG_SYMBOL](LogType.log, args);
|
61
|
+
}
|
62
|
+
|
63
|
+
debug(...args) {
|
64
|
+
this[LOG_SYMBOL](LogType.debug, args);
|
65
|
+
}
|
66
|
+
|
67
|
+
assert(assertion, ...args) {
|
68
|
+
if (!assertion) {
|
69
|
+
this[LOG_SYMBOL](LogType.error, args);
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
trace() {
|
74
|
+
this[LOG_SYMBOL](LogType.trace, ["Trace"]);
|
75
|
+
}
|
76
|
+
|
77
|
+
clear() {
|
78
|
+
this[LOG_SYMBOL](LogType.clear);
|
79
|
+
}
|
80
|
+
|
81
|
+
group(...args) {
|
82
|
+
this[LOG_SYMBOL](LogType.group, args);
|
83
|
+
}
|
84
|
+
|
85
|
+
groupCollapsed(...args) {
|
86
|
+
this[LOG_SYMBOL](LogType.groupCollapsed, args);
|
87
|
+
}
|
88
|
+
|
89
|
+
groupEnd(...args) {
|
90
|
+
this[LOG_SYMBOL](LogType.groupEnd, args);
|
91
|
+
}
|
92
|
+
|
93
|
+
profile(label) {
|
94
|
+
this[LOG_SYMBOL](LogType.profile, [label]);
|
95
|
+
}
|
96
|
+
|
97
|
+
profileEnd(label) {
|
98
|
+
this[LOG_SYMBOL](LogType.profileEnd, [label]);
|
99
|
+
}
|
100
|
+
|
101
|
+
time(label) {
|
102
|
+
this[TIMERS_SYMBOL] = this[TIMERS_SYMBOL] || new Map();
|
103
|
+
this[TIMERS_SYMBOL].set(label, process.hrtime());
|
104
|
+
}
|
105
|
+
|
106
|
+
timeLog(label) {
|
107
|
+
const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label);
|
108
|
+
if (!prev) {
|
109
|
+
throw new Error(`No such label '${label}' for WebpackLogger.timeLog()`);
|
110
|
+
}
|
111
|
+
const time = process.hrtime(prev);
|
112
|
+
this[LOG_SYMBOL](LogType.time, [label, ...time]);
|
113
|
+
}
|
114
|
+
|
115
|
+
timeEnd(label) {
|
116
|
+
const prev = this[TIMERS_SYMBOL] && this[TIMERS_SYMBOL].get(label);
|
117
|
+
if (!prev) {
|
118
|
+
throw new Error(`No such label '${label}' for WebpackLogger.timeEnd()`);
|
119
|
+
}
|
120
|
+
const time = process.hrtime(prev);
|
121
|
+
this[TIMERS_SYMBOL].delete(label);
|
122
|
+
this[LOG_SYMBOL](LogType.time, [label, ...time]);
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
exports.Logger = WebpackLogger;
|
@@ -0,0 +1,188 @@
|
|
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"} options.level loglevel
|
19
|
+
* @property {FilterTypes|boolean} options.debug filter for debug logging
|
20
|
+
*/
|
21
|
+
|
22
|
+
/**
|
23
|
+
* @param {FilterItemTypes} item an input item
|
24
|
+
* @returns {FilterFunction} filter funtion
|
25
|
+
*/
|
26
|
+
const filterToFunction = item => {
|
27
|
+
if (typeof item === "string") {
|
28
|
+
const regExp = new RegExp(
|
29
|
+
`[\\\\/]${item.replace(
|
30
|
+
// eslint-disable-next-line no-useless-escape
|
31
|
+
/[-[\]{}()*+?.\\^$|]/g,
|
32
|
+
"\\$&"
|
33
|
+
)}([\\\\/]|$|!|\\?)`
|
34
|
+
);
|
35
|
+
return ident => regExp.test(ident);
|
36
|
+
}
|
37
|
+
if (item && typeof item === "object" && typeof item.test === "function") {
|
38
|
+
return ident => item.test(ident);
|
39
|
+
}
|
40
|
+
if (typeof item === "function") {
|
41
|
+
return item;
|
42
|
+
}
|
43
|
+
if (typeof item === "boolean") {
|
44
|
+
return () => item;
|
45
|
+
}
|
46
|
+
};
|
47
|
+
|
48
|
+
/**
|
49
|
+
* @enum {number} */
|
50
|
+
const LogLevel = {
|
51
|
+
none: 6,
|
52
|
+
false: 6,
|
53
|
+
error: 5,
|
54
|
+
warn: 4,
|
55
|
+
info: 3,
|
56
|
+
log: 2,
|
57
|
+
true: 2,
|
58
|
+
verbose: 1
|
59
|
+
};
|
60
|
+
|
61
|
+
/**
|
62
|
+
* @param {LoggerOptions} options options object
|
63
|
+
* @returns {function(string, LogTypeEnum, any[]): void} logging function
|
64
|
+
*/
|
65
|
+
module.exports = ({ level = "info", debug = false }) => {
|
66
|
+
const debugFilters =
|
67
|
+
typeof debug === "boolean"
|
68
|
+
? [() => debug]
|
69
|
+
: /** @type {FilterItemTypes[]} */ ([])
|
70
|
+
.concat(debug)
|
71
|
+
.map(filterToFunction);
|
72
|
+
/** @type {number} */
|
73
|
+
const loglevel = LogLevel[`${level}`] || 0;
|
74
|
+
|
75
|
+
/**
|
76
|
+
* @param {string} name name of the logger
|
77
|
+
* @param {LogTypeEnum} type type of the log entry
|
78
|
+
* @param {any[]} args arguments of the log entry
|
79
|
+
* @returns {void}
|
80
|
+
*/
|
81
|
+
const logger = (name, type, args) => {
|
82
|
+
const labeledArgs = (prefix = "") => {
|
83
|
+
if (Array.isArray(args)) {
|
84
|
+
if (args.length > 0 && typeof args[0] === "string") {
|
85
|
+
return [`${prefix}[${name}] ${args[0]}`, ...args.slice(1)];
|
86
|
+
} else {
|
87
|
+
return [`${prefix}[${name}]`, ...args];
|
88
|
+
}
|
89
|
+
} else {
|
90
|
+
return [];
|
91
|
+
}
|
92
|
+
};
|
93
|
+
const debug = debugFilters.some(f => f(name));
|
94
|
+
switch (type) {
|
95
|
+
case LogType.debug:
|
96
|
+
if (!debug) return;
|
97
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
98
|
+
if (typeof console.debug === "function") {
|
99
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
100
|
+
console.debug(...labeledArgs());
|
101
|
+
} else {
|
102
|
+
console.log(...labeledArgs());
|
103
|
+
}
|
104
|
+
break;
|
105
|
+
case LogType.log:
|
106
|
+
if (!debug && loglevel > LogLevel.log) return;
|
107
|
+
console.log(...labeledArgs());
|
108
|
+
break;
|
109
|
+
case LogType.info:
|
110
|
+
if (!debug && loglevel > LogLevel.info) return;
|
111
|
+
console.info(...labeledArgs("<i> "));
|
112
|
+
break;
|
113
|
+
case LogType.warn:
|
114
|
+
if (!debug && loglevel > LogLevel.warn) return;
|
115
|
+
console.warn(...labeledArgs("<w> "));
|
116
|
+
break;
|
117
|
+
case LogType.error:
|
118
|
+
if (!debug && loglevel > LogLevel.error) return;
|
119
|
+
console.error(...labeledArgs("<e> "));
|
120
|
+
break;
|
121
|
+
case LogType.trace:
|
122
|
+
if (!debug) return;
|
123
|
+
console.trace();
|
124
|
+
break;
|
125
|
+
case LogType.group:
|
126
|
+
if (!debug && loglevel > LogLevel.log) return;
|
127
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
128
|
+
if (typeof console.group === "function") {
|
129
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
130
|
+
console.group(...labeledArgs());
|
131
|
+
} else {
|
132
|
+
console.log(...labeledArgs());
|
133
|
+
}
|
134
|
+
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
|
+
case LogType.groupEnd:
|
146
|
+
if (!debug && loglevel > LogLevel.log) return;
|
147
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
148
|
+
if (typeof console.groupEnd === "function") {
|
149
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
150
|
+
console.groupEnd();
|
151
|
+
} else {
|
152
|
+
console.log(...labeledArgs("</g> "));
|
153
|
+
}
|
154
|
+
break;
|
155
|
+
case LogType.time:
|
156
|
+
if (!debug && loglevel > LogLevel.log) return;
|
157
|
+
console.log(
|
158
|
+
`[${name}] ${args[0]}: ${args[1] * 1000 + args[2] / 1000000}ms`
|
159
|
+
);
|
160
|
+
break;
|
161
|
+
case LogType.profile:
|
162
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
163
|
+
if (typeof console.profile === "function") {
|
164
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
165
|
+
console.profile(...labeledArgs());
|
166
|
+
}
|
167
|
+
break;
|
168
|
+
case LogType.profileEnd:
|
169
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
170
|
+
if (typeof console.profileEnd === "function") {
|
171
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
172
|
+
console.profileEnd(...labeledArgs());
|
173
|
+
}
|
174
|
+
break;
|
175
|
+
case LogType.clear:
|
176
|
+
if (!debug && loglevel > LogLevel.log) return;
|
177
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
178
|
+
if (typeof console.clear === "function") {
|
179
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
180
|
+
console.clear();
|
181
|
+
}
|
182
|
+
break;
|
183
|
+
default:
|
184
|
+
throw new Error(`Unexpected LogType ${type}`);
|
185
|
+
}
|
186
|
+
};
|
187
|
+
return logger;
|
188
|
+
};
|
@@ -0,0 +1,35 @@
|
|
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
|
+
};
|
10
|
+
let currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions);
|
11
|
+
|
12
|
+
/**
|
13
|
+
* @param {string} name name of the logger
|
14
|
+
* @returns {Logger} a logger
|
15
|
+
*/
|
16
|
+
exports.getLogger = name => {
|
17
|
+
return new Logger((type, args) => {
|
18
|
+
if (exports.hooks.log.call(name, type, args) === undefined) {
|
19
|
+
currentDefaultLogger(name, type, args);
|
20
|
+
}
|
21
|
+
});
|
22
|
+
};
|
23
|
+
|
24
|
+
/**
|
25
|
+
* @param {createConsoleLogger.LoggerOptions} options new options, merge with old options
|
26
|
+
* @returns {void}
|
27
|
+
*/
|
28
|
+
exports.configureDefaultLogger = options => {
|
29
|
+
Object.assign(currentDefaultLoggerOptions, options);
|
30
|
+
currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions);
|
31
|
+
};
|
32
|
+
|
33
|
+
exports.hooks = {
|
34
|
+
log: new SyncBailHook(["origin", "type", "args"])
|
35
|
+
};
|
@@ -8,9 +8,23 @@ 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");
|
11
12
|
|
12
13
|
class NodeEnvironmentPlugin {
|
14
|
+
constructor(options) {
|
15
|
+
this.options = options || {};
|
16
|
+
}
|
17
|
+
|
13
18
|
apply(compiler) {
|
19
|
+
compiler.infrastructureLogger = createConsoleLogger(
|
20
|
+
Object.assign(
|
21
|
+
{
|
22
|
+
level: "info",
|
23
|
+
debug: false
|
24
|
+
},
|
25
|
+
this.options.infrastructureLogging
|
26
|
+
)
|
27
|
+
);
|
14
28
|
compiler.inputFileSystem = new CachedInputFileSystem(
|
15
29
|
new NodeJsInputFileSystem(),
|
16
30
|
60000
|
@@ -0,0 +1,77 @@
|
|
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 mergeCache = new WeakMap();
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Merges two given objects and caches the result to avoid computation if same objects passed as arguments again.
|
12
|
+
* @example
|
13
|
+
* // performs cleverMerge(first, second), stores the result in WeakMap and returns result
|
14
|
+
* cachedCleverMerge({a: 1}, {a: 2})
|
15
|
+
* {a: 2}
|
16
|
+
* // when same arguments passed, gets the result from WeakMap and returns it.
|
17
|
+
* cachedCleverMerge({a: 1}, {a: 2})
|
18
|
+
* {a: 2}
|
19
|
+
* @param {object} first first object
|
20
|
+
* @param {object} second second object
|
21
|
+
* @returns {object} merged object of first and second object
|
22
|
+
*/
|
23
|
+
const cachedCleverMerge = (first, second) => {
|
24
|
+
let innerCache = mergeCache.get(first);
|
25
|
+
if (innerCache === undefined) {
|
26
|
+
innerCache = new WeakMap();
|
27
|
+
mergeCache.set(first, innerCache);
|
28
|
+
}
|
29
|
+
const prevMerge = innerCache.get(second);
|
30
|
+
if (prevMerge !== undefined) return prevMerge;
|
31
|
+
const newMerge = cleverMerge(first, second);
|
32
|
+
innerCache.set(second, newMerge);
|
33
|
+
return newMerge;
|
34
|
+
};
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Merges two objects. Objects are not deeply merged.
|
38
|
+
* TODO webpack 5: merge objects deeply clever.
|
39
|
+
* Arrays might reference the old value with "..."
|
40
|
+
* @param {object} first first object
|
41
|
+
* @param {object} second second object
|
42
|
+
* @returns {object} merged object of first and second object
|
43
|
+
*/
|
44
|
+
const cleverMerge = (first, second) => {
|
45
|
+
const newObject = Object.assign({}, first);
|
46
|
+
for (const key of Object.keys(second)) {
|
47
|
+
if (!(key in newObject)) {
|
48
|
+
newObject[key] = second[key];
|
49
|
+
continue;
|
50
|
+
}
|
51
|
+
const secondValue = second[key];
|
52
|
+
if (!Array.isArray(secondValue)) {
|
53
|
+
newObject[key] = secondValue;
|
54
|
+
continue;
|
55
|
+
}
|
56
|
+
const firstValue = newObject[key];
|
57
|
+
if (Array.isArray(firstValue)) {
|
58
|
+
const newArray = [];
|
59
|
+
for (const item of secondValue) {
|
60
|
+
if (item === "...") {
|
61
|
+
for (const item of firstValue) {
|
62
|
+
newArray.push(item);
|
63
|
+
}
|
64
|
+
} else {
|
65
|
+
newArray.push(item);
|
66
|
+
}
|
67
|
+
}
|
68
|
+
newObject[key] = newArray;
|
69
|
+
} else {
|
70
|
+
newObject[key] = secondValue;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
return newObject;
|
74
|
+
};
|
75
|
+
|
76
|
+
exports.cachedCleverMerge = cachedCleverMerge;
|
77
|
+
exports.cleverMerge = cleverMerge;
|
package/lib/util/createHash.js
CHANGED
@@ -4,24 +4,50 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
-
|
8
|
-
/**
|
9
|
-
* @typedef {Object} Hash
|
10
|
-
* @property {function(string|Buffer, string=): Hash} update
|
11
|
-
* @property {function(string): string} digest
|
12
|
-
*/
|
7
|
+
const AbstractMethodError = require("../AbstractMethodError");
|
13
8
|
|
14
9
|
const BULK_SIZE = 1000;
|
15
10
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
11
|
+
class Hash {
|
12
|
+
/**
|
13
|
+
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
14
|
+
* @param {string|Buffer} data data
|
15
|
+
* @param {string=} inputEncoding data encoding
|
16
|
+
* @returns {this} updated hash
|
17
|
+
*/
|
18
|
+
update(data, inputEncoding) {
|
19
|
+
throw new AbstractMethodError();
|
20
|
+
}
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
24
|
+
* @param {string=} encoding encoding of the return value
|
25
|
+
* @returns {string|Buffer} digest
|
26
|
+
*/
|
27
|
+
digest(encoding) {
|
28
|
+
throw new AbstractMethodError();
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
exports.Hash = Hash;
|
33
|
+
/** @typedef {typeof Hash} HashConstructor */
|
34
|
+
|
35
|
+
class BulkUpdateDecorator extends Hash {
|
36
|
+
/**
|
37
|
+
* @param {Hash} hash hash
|
38
|
+
*/
|
20
39
|
constructor(hash) {
|
40
|
+
super();
|
21
41
|
this.hash = hash;
|
22
42
|
this.buffer = "";
|
23
43
|
}
|
24
44
|
|
45
|
+
/**
|
46
|
+
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
47
|
+
* @param {string|Buffer} data data
|
48
|
+
* @param {string=} inputEncoding data encoding
|
49
|
+
* @returns {this} updated hash
|
50
|
+
*/
|
25
51
|
update(data, inputEncoding) {
|
26
52
|
if (
|
27
53
|
inputEncoding !== undefined ||
|
@@ -43,6 +69,11 @@ class BulkUpdateDecorator {
|
|
43
69
|
return this;
|
44
70
|
}
|
45
71
|
|
72
|
+
/**
|
73
|
+
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
74
|
+
* @param {string=} encoding encoding of the return value
|
75
|
+
* @returns {string|Buffer} digest
|
76
|
+
*/
|
46
77
|
digest(encoding) {
|
47
78
|
if (this.buffer.length > 0) {
|
48
79
|
this.hash.update(this.buffer);
|
@@ -54,18 +85,32 @@ class BulkUpdateDecorator {
|
|
54
85
|
}
|
55
86
|
}
|
56
87
|
|
57
|
-
|
58
|
-
|
88
|
+
/**
|
89
|
+
* istanbul ignore next
|
90
|
+
*/
|
91
|
+
class DebugHash extends Hash {
|
59
92
|
constructor() {
|
93
|
+
super();
|
60
94
|
this.string = "";
|
61
95
|
}
|
62
96
|
|
97
|
+
/**
|
98
|
+
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
99
|
+
* @param {string|Buffer} data data
|
100
|
+
* @param {string=} inputEncoding data encoding
|
101
|
+
* @returns {this} updated hash
|
102
|
+
*/
|
63
103
|
update(data, inputEncoding) {
|
64
104
|
if (typeof data !== "string") data = data.toString("utf-8");
|
65
105
|
this.string += data;
|
66
106
|
return this;
|
67
107
|
}
|
68
108
|
|
109
|
+
/**
|
110
|
+
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
111
|
+
* @param {string=} encoding encoding of the return value
|
112
|
+
* @returns {string|Buffer} digest
|
113
|
+
*/
|
69
114
|
digest(encoding) {
|
70
115
|
return this.string.replace(/[^a-z0-9]+/gi, m =>
|
71
116
|
Buffer.from(m).toString("hex")
|
package/lib/util/objectToMap.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* convert an object into its 2D array equivalent to be turned
|
3
3
|
* into an ES6 map
|
4
4
|
*
|
5
|
-
* @param {object} obj
|
5
|
+
* @param {object} obj any object type that works with Object.keys()
|
6
6
|
* @returns {Map<TODO, TODO>} an ES6 Map of KV pairs
|
7
7
|
*/
|
8
8
|
module.exports = function objectToMap(obj) {
|
@@ -48,7 +48,7 @@ const compose = (...fns) => {
|
|
48
48
|
/**
|
49
49
|
* Removes the start instruction
|
50
50
|
*
|
51
|
-
* @param {Object} state
|
51
|
+
* @param {Object} state unused state
|
52
52
|
* @returns {ArrayBufferTransform} transform
|
53
53
|
*/
|
54
54
|
const removeStartFunc = state => bin => {
|
@@ -62,7 +62,7 @@ const removeStartFunc = state => bin => {
|
|
62
62
|
/**
|
63
63
|
* Get imported globals
|
64
64
|
*
|
65
|
-
* @param {Object} ast
|
65
|
+
* @param {Object} ast Module's AST
|
66
66
|
* @returns {Array<t.ModuleImport>} - nodes
|
67
67
|
*/
|
68
68
|
const getImportedGlobals = ast => {
|
@@ -96,7 +96,7 @@ const getCountImportedFunc = ast => {
|
|
96
96
|
/**
|
97
97
|
* Get next type index
|
98
98
|
*
|
99
|
-
* @param {Object} ast
|
99
|
+
* @param {Object} ast Module's AST
|
100
100
|
* @returns {t.Index} - index
|
101
101
|
*/
|
102
102
|
const getNextTypeIndex = ast => {
|
@@ -116,8 +116,8 @@ const getNextTypeIndex = ast => {
|
|
116
116
|
* in order to have the correct index we shift the index by number of external
|
117
117
|
* functions.
|
118
118
|
*
|
119
|
-
* @param {Object} ast
|
120
|
-
* @param {Number} countImportedFunc
|
119
|
+
* @param {Object} ast Module's AST
|
120
|
+
* @param {Number} countImportedFunc number of imported funcs
|
121
121
|
* @returns {t.Index} - index
|
122
122
|
*/
|
123
123
|
const getNextFuncIndex = (ast, countImportedFunc) => {
|
@@ -163,7 +163,7 @@ const createDefaultInitForGlobal = globalType => {
|
|
163
163
|
*
|
164
164
|
* Note that globals will become mutable.
|
165
165
|
*
|
166
|
-
* @param {Object} state
|
166
|
+
* @param {Object} state unused state
|
167
167
|
* @returns {ArrayBufferTransform} transform
|
168
168
|
*/
|
169
169
|
const rewriteImportedGlobals = state => bin => {
|
@@ -279,7 +279,7 @@ const rewriteImports = ({ ast, usedDependencyMap }) => bin => {
|
|
279
279
|
* The init function fills the globals given input arguments.
|
280
280
|
*
|
281
281
|
* @param {Object} state transformation state
|
282
|
-
* @param {Object} state.ast
|
282
|
+
* @param {Object} state.ast Module's ast
|
283
283
|
* @param {t.Identifier} state.initFuncId identifier of the init function
|
284
284
|
* @param {t.Index} state.startAtFuncOffset index of the start function
|
285
285
|
* @param {t.ModuleImport[]} state.importedGlobals list of imported globals
|
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.38.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",
|
@@ -44,6 +44,7 @@
|
|
44
44
|
"eslint": "^5.8.0",
|
45
45
|
"eslint-config-prettier": "^4.0.0",
|
46
46
|
"eslint-plugin-jest": "^22.2.2",
|
47
|
+
"eslint-plugin-jsdoc": "^15.3.2",
|
47
48
|
"eslint-plugin-node": "^8.0.0",
|
48
49
|
"eslint-plugin-prettier": "^3.0.0",
|
49
50
|
"express": "~4.16.4",
|