@rspack/core 1.0.0-beta.1 → 1.0.0-beta.3
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/dist/ChunkGroup.d.ts +1 -0
- package/dist/ChunkGroup.js +3 -0
- package/dist/Compilation.d.ts +38 -1
- package/dist/Compilation.js +109 -44
- package/dist/Compiler.d.ts +1 -0
- package/dist/Compiler.js +31 -26
- package/dist/ExecuteModulePlugin.d.ts +0 -1
- package/dist/ExecuteModulePlugin.js +0 -1
- package/dist/Module.d.ts +1 -2
- package/dist/Module.js +0 -1
- package/dist/MultiCompiler.js +11 -7
- package/dist/MultiStats.d.ts +1 -1
- package/dist/MultiStats.js +19 -16
- package/dist/NormalModule.js +3 -4
- package/dist/Resolver.d.ts +1 -2
- package/dist/RspackError.js +1 -1
- package/dist/Stats.d.ts +1 -1
- package/dist/Stats.js +22 -2
- package/dist/Template.d.ts +4 -4
- package/dist/Template.js +8 -6
- package/dist/Watching.js +3 -5
- package/dist/builtin-loader/lightningcss/index.js +1 -1
- package/dist/builtin-plugin/DefinePlugin.js +1 -1
- package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +11 -10
- package/dist/builtin-plugin/DynamicEntryPlugin.js +26 -15
- package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +2 -2
- package/dist/builtin-plugin/EnableChunkLoadingPlugin.js +1 -1
- package/dist/builtin-plugin/EnableLibraryPlugin.js +1 -6
- package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +2 -2
- package/dist/builtin-plugin/EnableWasmLoadingPlugin.js +1 -1
- package/dist/builtin-plugin/EntryPlugin.d.ts +2 -2
- package/dist/builtin-plugin/ExternalsPlugin.js +1 -1
- package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +0 -1
- package/dist/builtin-plugin/JavascriptModulesPlugin.js +1 -1
- package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +21 -4
- package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +29 -5
- package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +4 -6
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +17 -12
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +11 -9
- package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +13 -11
- package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +1 -1
- package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +9 -7
- package/dist/builtin-plugin/css-extract/loader.js +5 -12
- package/dist/builtin-plugin/lazy-compilation/backend.js +4 -4
- package/dist/config/adapter.d.ts +2 -2
- package/dist/config/adapter.js +1 -0
- package/dist/config/adapterRuleUse.d.ts +2 -6
- package/dist/config/adapterRuleUse.js +7 -6
- package/dist/config/defaults.js +21 -32
- package/dist/config/normalization.d.ts +1 -0
- package/dist/config/normalization.js +5 -2
- package/dist/config/zod.d.ts +762 -114
- package/dist/config/zod.js +29 -6
- package/dist/container/default.runtime.js +1 -1
- package/dist/exports.d.ts +4 -3
- package/dist/exports.js +5 -2
- package/dist/lib/AbstractMethodError.js +2 -3
- package/dist/lib/Cache.d.ts +1 -1
- package/dist/lib/Cache.js +6 -4
- package/dist/lib/CacheFacade.js +8 -9
- package/dist/lib/Dependency.d.ts +23 -0
- package/dist/lib/Dependency.js +11 -0
- package/dist/lib/EnvironmentPlugin.js +1 -3
- package/dist/lib/LoaderOptionsPlugin.d.ts +4 -2
- package/dist/lib/LoaderOptionsPlugin.js +0 -2
- package/dist/lib/ModuleFilenameHelpers.js +1 -1
- package/dist/lib/WebpackError.d.ts +0 -6
- package/dist/lib/WebpackError.js +0 -8
- package/dist/lib/cache/MemoryCachePlugin.d.ts +5 -0
- package/dist/lib/cache/MemoryCachePlugin.js +40 -0
- package/dist/lib/cache/mergeEtags.d.ts +3 -3
- package/dist/lib/cache/mergeEtags.js +5 -3
- package/dist/lib/formatLocation.d.ts +1 -1
- package/dist/loader-runner/index.js +10 -9
- package/dist/loader-runner/loadLoader.js +8 -11
- package/dist/logging/Logger.js +3 -3
- package/dist/logging/createConsoleLogger.d.ts +26 -6
- package/dist/logging/createConsoleLogger.js +21 -58
- package/dist/logging/runtime.d.ts +4 -10
- package/dist/logging/runtime.js +8 -23
- package/dist/logging/truncateArgs.d.ts +4 -4
- package/dist/logging/truncateArgs.js +5 -10
- package/dist/node/NodeEnvironmentPlugin.js +2 -2
- package/dist/node/NodeWatchFileSystem.js +6 -6
- package/dist/node/nodeConsole.d.ts +7 -21
- package/dist/node/nodeConsole.js +31 -38
- package/dist/rspackOptionsApply.d.ts +0 -1
- package/dist/rspackOptionsApply.js +8 -7
- package/dist/sharing/ProvideSharedPlugin.d.ts +20 -19
- package/dist/sharing/ProvideSharedPlugin.js +26 -17
- package/dist/sharing/SharePlugin.d.ts +3 -0
- package/dist/sharing/SharePlugin.js +4 -1
- package/dist/stats/DefaultStatsFactoryPlugin.js +187 -96
- package/dist/stats/DefaultStatsPresetPlugin.js +2 -5
- package/dist/stats/DefaultStatsPrinterPlugin.js +18 -19
- package/dist/stats/StatsFactory.d.ts +2 -1
- package/dist/stats/StatsFactory.js +5 -10
- package/dist/stats/StatsPrinter.js +3 -4
- package/dist/stats/statsFactoryUtils.d.ts +155 -28
- package/dist/util/SizeFormatHelpers.js +1 -1
- package/dist/util/assertNotNil.d.ts +1 -1
- package/dist/util/assetCondition.d.ts +2 -0
- package/dist/util/assetCondition.js +2 -0
- package/dist/util/bindingVersionCheck.js +3 -3
- package/dist/util/cleverMerge.js +8 -6
- package/dist/util/comparators.d.ts +1 -1
- package/dist/util/comparators.js +5 -4
- package/dist/util/createHash.js +11 -6
- package/dist/util/fs.js +2 -2
- package/dist/util/hash/wasm-hash.js +5 -4
- package/dist/util/identifier.d.ts +4 -4
- package/dist/util/identifier.js +10 -10
- package/dist/util/index.js +1 -1
- package/dist/util/memoize.js +4 -6
- package/dist/util/smartGrouping.js +4 -6
- package/dist/util/webpack.d.ts +1 -1
- package/dist/util/webpack.js +2 -1
- package/module.d.ts +1 -1
- package/package.json +3 -3
- package/dist/builtin-plugin/css-extract/loader-options.json +0 -37
- package/dist/builtin-plugin/css-extract/plugin-options.json +0 -79
|
@@ -8,38 +8,10 @@
|
|
|
8
8
|
* Copyright (c) JS Foundation and other contributors
|
|
9
9
|
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @typedef {Object} LoggerConsole
|
|
17
|
-
* @property {function(): void} clear
|
|
18
|
-
* @property {function(): void} trace
|
|
19
|
-
* @property {(...args: any[]) => void} info
|
|
20
|
-
* @property {(...args: any[]) => void} log
|
|
21
|
-
* @property {(...args: any[]) => void} warn
|
|
22
|
-
* @property {(...args: any[]) => void} error
|
|
23
|
-
* @property {(...args: any[]) => void=} debug
|
|
24
|
-
* @property {(...args: any[]) => void=} group
|
|
25
|
-
* @property {(...args: any[]) => void=} groupCollapsed
|
|
26
|
-
* @property {(...args: any[]) => void=} groupEnd
|
|
27
|
-
* @property {(...args: any[]) => void=} status
|
|
28
|
-
* @property {(...args: any[]) => void=} profile
|
|
29
|
-
* @property {(...args: any[]) => void=} profileEnd
|
|
30
|
-
* @property {(...args: any[]) => void=} logTime
|
|
31
|
-
*/
|
|
32
|
-
/**
|
|
33
|
-
* @typedef {Object} LoggerOptions
|
|
34
|
-
* @property {false|true|"none"|"error"|"warn"|"info"|"log"|"verbose"} level loglevel
|
|
35
|
-
* @property {FilterTypes|boolean} debug filter for debug logging
|
|
36
|
-
* @property {LoggerConsole} console the console to log to
|
|
37
|
-
*/
|
|
38
|
-
/**
|
|
39
|
-
* @param {FilterItemTypes} item an input item
|
|
40
|
-
* @returns {FilterFunction} filter function
|
|
41
|
-
*/
|
|
42
|
-
const filterToFunction = item => {
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createConsoleLogger = void 0;
|
|
13
|
+
const Logger_1 = require("./Logger");
|
|
14
|
+
const filterToFunction = (item) => {
|
|
43
15
|
if (typeof item === "string") {
|
|
44
16
|
const regExp = new RegExp(`[\\\\/]${item.replace(
|
|
45
17
|
// eslint-disable-next-line no-useless-escape
|
|
@@ -56,9 +28,6 @@ const filterToFunction = item => {
|
|
|
56
28
|
return () => item;
|
|
57
29
|
}
|
|
58
30
|
};
|
|
59
|
-
/**
|
|
60
|
-
* @enum {number}
|
|
61
|
-
*/
|
|
62
31
|
const LogLevel = {
|
|
63
32
|
none: 6,
|
|
64
33
|
false: 6,
|
|
@@ -69,18 +38,11 @@ const LogLevel = {
|
|
|
69
38
|
true: 2,
|
|
70
39
|
verbose: 1
|
|
71
40
|
};
|
|
72
|
-
|
|
41
|
+
const createConsoleLogger = ({ level = "info", debug = false, console }) => {
|
|
73
42
|
const debugFilters = typeof debug === "boolean"
|
|
74
43
|
? [() => debug]
|
|
75
|
-
:
|
|
76
|
-
/** @type {number} */
|
|
44
|
+
: [].concat(debug).map(filterToFunction);
|
|
77
45
|
const loglevel = LogLevel[`${level}`] || 0;
|
|
78
|
-
/**
|
|
79
|
-
* @param {string} name name of the logger
|
|
80
|
-
* @param {LogTypeEnum} type type of the log entry
|
|
81
|
-
* @param {any[]} args arguments of the log entry
|
|
82
|
-
* @returns {void}
|
|
83
|
-
*/
|
|
84
46
|
const logger = (name, type, args) => {
|
|
85
47
|
const labeledArgs = () => {
|
|
86
48
|
if (Array.isArray(args)) {
|
|
@@ -93,7 +55,7 @@ module.exports = ({ level = "info", debug = false, console }) => {
|
|
|
93
55
|
};
|
|
94
56
|
const debug = debugFilters.some(f => f(name));
|
|
95
57
|
switch (type) {
|
|
96
|
-
case LogType.debug:
|
|
58
|
+
case Logger_1.LogType.debug:
|
|
97
59
|
if (!debug)
|
|
98
60
|
return;
|
|
99
61
|
if (typeof console.debug === "function") {
|
|
@@ -103,32 +65,32 @@ module.exports = ({ level = "info", debug = false, console }) => {
|
|
|
103
65
|
console.log(...labeledArgs());
|
|
104
66
|
}
|
|
105
67
|
break;
|
|
106
|
-
case LogType.log:
|
|
68
|
+
case Logger_1.LogType.log:
|
|
107
69
|
if (!debug && loglevel > LogLevel.log)
|
|
108
70
|
return;
|
|
109
71
|
console.log(...labeledArgs());
|
|
110
72
|
break;
|
|
111
|
-
case LogType.info:
|
|
73
|
+
case Logger_1.LogType.info:
|
|
112
74
|
if (!debug && loglevel > LogLevel.info)
|
|
113
75
|
return;
|
|
114
76
|
console.info(...labeledArgs());
|
|
115
77
|
break;
|
|
116
|
-
case LogType.warn:
|
|
78
|
+
case Logger_1.LogType.warn:
|
|
117
79
|
if (!debug && loglevel > LogLevel.warn)
|
|
118
80
|
return;
|
|
119
81
|
console.warn(...labeledArgs());
|
|
120
82
|
break;
|
|
121
|
-
case LogType.error:
|
|
83
|
+
case Logger_1.LogType.error:
|
|
122
84
|
if (!debug && loglevel > LogLevel.error)
|
|
123
85
|
return;
|
|
124
86
|
console.error(...labeledArgs());
|
|
125
87
|
break;
|
|
126
|
-
case LogType.trace:
|
|
88
|
+
case Logger_1.LogType.trace:
|
|
127
89
|
if (!debug)
|
|
128
90
|
return;
|
|
129
91
|
console.trace();
|
|
130
92
|
break;
|
|
131
|
-
case LogType.groupCollapsed:
|
|
93
|
+
case Logger_1.LogType.groupCollapsed:
|
|
132
94
|
if (!debug && loglevel > LogLevel.log)
|
|
133
95
|
return;
|
|
134
96
|
if (!debug && loglevel > LogLevel.verbose) {
|
|
@@ -141,7 +103,7 @@ module.exports = ({ level = "info", debug = false, console }) => {
|
|
|
141
103
|
break;
|
|
142
104
|
}
|
|
143
105
|
// falls through
|
|
144
|
-
case LogType.group:
|
|
106
|
+
case Logger_1.LogType.group:
|
|
145
107
|
if (!debug && loglevel > LogLevel.log)
|
|
146
108
|
return;
|
|
147
109
|
if (typeof console.group === "function") {
|
|
@@ -151,14 +113,14 @@ module.exports = ({ level = "info", debug = false, console }) => {
|
|
|
151
113
|
console.log(...labeledArgs());
|
|
152
114
|
}
|
|
153
115
|
break;
|
|
154
|
-
case LogType.groupEnd:
|
|
116
|
+
case Logger_1.LogType.groupEnd:
|
|
155
117
|
if (!debug && loglevel > LogLevel.log)
|
|
156
118
|
return;
|
|
157
119
|
if (typeof console.groupEnd === "function") {
|
|
158
120
|
console.groupEnd();
|
|
159
121
|
}
|
|
160
122
|
break;
|
|
161
|
-
case LogType.time: {
|
|
123
|
+
case Logger_1.LogType.time: {
|
|
162
124
|
if (!debug && loglevel > LogLevel.log)
|
|
163
125
|
return;
|
|
164
126
|
const ms = args[1] * 1000 + args[2] / 1000000;
|
|
@@ -171,24 +133,24 @@ module.exports = ({ level = "info", debug = false, console }) => {
|
|
|
171
133
|
}
|
|
172
134
|
break;
|
|
173
135
|
}
|
|
174
|
-
case LogType.profile:
|
|
136
|
+
case Logger_1.LogType.profile:
|
|
175
137
|
if (typeof console.profile === "function") {
|
|
176
138
|
console.profile(...labeledArgs());
|
|
177
139
|
}
|
|
178
140
|
break;
|
|
179
|
-
case LogType.profileEnd:
|
|
141
|
+
case Logger_1.LogType.profileEnd:
|
|
180
142
|
if (typeof console.profileEnd === "function") {
|
|
181
143
|
console.profileEnd(...labeledArgs());
|
|
182
144
|
}
|
|
183
145
|
break;
|
|
184
|
-
case LogType.clear:
|
|
146
|
+
case Logger_1.LogType.clear:
|
|
185
147
|
if (!debug && loglevel > LogLevel.log)
|
|
186
148
|
return;
|
|
187
149
|
if (typeof console.clear === "function") {
|
|
188
150
|
console.clear();
|
|
189
151
|
}
|
|
190
152
|
break;
|
|
191
|
-
case LogType.status:
|
|
153
|
+
case Logger_1.LogType.status:
|
|
192
154
|
if (!debug && loglevel > LogLevel.info)
|
|
193
155
|
return;
|
|
194
156
|
if (typeof console.status === "function") {
|
|
@@ -211,3 +173,4 @@ module.exports = ({ level = "info", debug = false, console }) => {
|
|
|
211
173
|
};
|
|
212
174
|
return logger;
|
|
213
175
|
};
|
|
176
|
+
exports.createConsoleLogger = createConsoleLogger;
|
|
@@ -7,16 +7,10 @@
|
|
|
7
7
|
* Copyright (c) JS Foundation and other contributors
|
|
8
8
|
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export declare const getLogger: (name: any) => any;
|
|
15
|
-
/**
|
|
16
|
-
* @param {createConsoleLogger.LoggerOptions} options new options, merge with old options
|
|
17
|
-
* @returns {void}
|
|
18
|
-
*/
|
|
19
|
-
export declare const configureDefaultLogger: (options: any) => void;
|
|
10
|
+
import { Logger } from "./Logger";
|
|
11
|
+
import { type LoggerOptions } from "./createConsoleLogger";
|
|
12
|
+
export declare const getLogger: (name: string) => Logger;
|
|
13
|
+
export declare const configureDefaultLogger: (options: LoggerOptions) => void;
|
|
20
14
|
export declare const hooks: {
|
|
21
15
|
log: any;
|
|
22
16
|
};
|
package/dist/logging/runtime.js
CHANGED
|
@@ -11,40 +11,25 @@
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.hooks = exports.configureDefaultLogger = exports.getLogger = void 0;
|
|
13
13
|
const SyncBailHook = require("tapable/lib/SyncBailHook");
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
/** @type {createConsoleLogger.LoggerOptions} */
|
|
14
|
+
const Logger_1 = require("./Logger");
|
|
15
|
+
const createConsoleLogger_1 = require("./createConsoleLogger");
|
|
17
16
|
const currentDefaultLoggerOptions = {
|
|
18
17
|
level: "info",
|
|
19
18
|
debug: false,
|
|
20
19
|
console
|
|
21
20
|
};
|
|
22
|
-
let currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* @returns {Logger} a logger
|
|
26
|
-
*/
|
|
27
|
-
// @ts-expect-error
|
|
28
|
-
const getLogger = name => {
|
|
29
|
-
return new Logger(
|
|
30
|
-
// @ts-expect-error
|
|
31
|
-
(type, args) => {
|
|
21
|
+
let currentDefaultLogger = (0, createConsoleLogger_1.createConsoleLogger)(currentDefaultLoggerOptions);
|
|
22
|
+
const getLogger = (name) => {
|
|
23
|
+
return new Logger_1.Logger((type, args) => {
|
|
32
24
|
if (exports.hooks.log.call(name, type, args) === undefined) {
|
|
33
25
|
currentDefaultLogger(name, type, args);
|
|
34
26
|
}
|
|
35
|
-
},
|
|
36
|
-
// @ts-expect-error
|
|
37
|
-
childName => exports.getLogger(`${name}/${childName}`));
|
|
27
|
+
}, childName => exports.getLogger(`${name}/${childName}`));
|
|
38
28
|
};
|
|
39
29
|
exports.getLogger = getLogger;
|
|
40
|
-
|
|
41
|
-
* @param {createConsoleLogger.LoggerOptions} options new options, merge with old options
|
|
42
|
-
* @returns {void}
|
|
43
|
-
*/
|
|
44
|
-
// @ts-expect-error
|
|
45
|
-
const configureDefaultLogger = options => {
|
|
30
|
+
const configureDefaultLogger = (options) => {
|
|
46
31
|
Object.assign(currentDefaultLoggerOptions, options);
|
|
47
|
-
currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions);
|
|
32
|
+
currentDefaultLogger = (0, createConsoleLogger_1.createConsoleLogger)(currentDefaultLoggerOptions);
|
|
48
33
|
};
|
|
49
34
|
exports.configureDefaultLogger = configureDefaultLogger;
|
|
50
35
|
exports.hooks = {
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
|
-
* @param
|
|
12
|
-
* @param
|
|
13
|
-
* @returns
|
|
11
|
+
* @param args items to be truncated
|
|
12
|
+
* @param maxLength maximum length of args including spaces between
|
|
13
|
+
* @returns truncated args
|
|
14
14
|
*/
|
|
15
|
-
declare const truncateArgs: (args: any, maxLength:
|
|
15
|
+
declare const truncateArgs: (args: any[], maxLength: number) => string[];
|
|
16
16
|
export { truncateArgs };
|
|
@@ -17,13 +17,11 @@ const arraySum = (array) => {
|
|
|
17
17
|
return sum;
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @returns
|
|
20
|
+
* @param args items to be truncated
|
|
21
|
+
* @param maxLength maximum length of args including spaces between
|
|
22
|
+
* @returns truncated args
|
|
23
23
|
*/
|
|
24
|
-
// @ts-expect-error
|
|
25
24
|
const truncateArgs = (args, maxLength) => {
|
|
26
|
-
// @ts-expect-error
|
|
27
25
|
const lengths = args.map(a => `${a}`.length);
|
|
28
26
|
const availableLength = maxLength - lengths.length + 1;
|
|
29
27
|
if (availableLength > 0 && args.length === 1) {
|
|
@@ -31,12 +29,11 @@ const truncateArgs = (args, maxLength) => {
|
|
|
31
29
|
return args;
|
|
32
30
|
}
|
|
33
31
|
if (availableLength > 3) {
|
|
34
|
-
return [
|
|
32
|
+
return [`...${args[0].slice(-availableLength + 3)}`];
|
|
35
33
|
}
|
|
36
34
|
return [args[0].slice(-availableLength)];
|
|
37
35
|
}
|
|
38
36
|
// Check if there is space for at least 4 chars per arg
|
|
39
|
-
// @ts-expect-error
|
|
40
37
|
if (availableLength < arraySum(lengths.map(i => Math.min(i, 6)))) {
|
|
41
38
|
// remove args
|
|
42
39
|
if (args.length > 1)
|
|
@@ -50,7 +47,6 @@ const truncateArgs = (args, maxLength) => {
|
|
|
50
47
|
// Try to remove chars from the longest items until it fits
|
|
51
48
|
while (currentLength > availableLength) {
|
|
52
49
|
const maxLength = Math.max(...lengths);
|
|
53
|
-
// @ts-expect-error
|
|
54
50
|
const shorterItems = lengths.filter(l => l !== maxLength);
|
|
55
51
|
const nextToMaxLength = shorterItems.length > 0 ? Math.max(...shorterItems) : 0;
|
|
56
52
|
const maxReduce = maxLength - nextToMaxLength;
|
|
@@ -67,7 +63,6 @@ const truncateArgs = (args, maxLength) => {
|
|
|
67
63
|
}
|
|
68
64
|
}
|
|
69
65
|
// Return args reduced to length in lengths
|
|
70
|
-
// @ts-expect-error
|
|
71
66
|
return args.map((a, i) => {
|
|
72
67
|
const str = `${a}`;
|
|
73
68
|
const length = lengths[i];
|
|
@@ -75,7 +70,7 @@ const truncateArgs = (args, maxLength) => {
|
|
|
75
70
|
return str;
|
|
76
71
|
}
|
|
77
72
|
if (length > 5) {
|
|
78
|
-
return
|
|
73
|
+
return `...${str.slice(-length + 3)}`;
|
|
79
74
|
}
|
|
80
75
|
if (length > 0) {
|
|
81
76
|
return str.slice(-length);
|
|
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
// @ts-expect-error
|
|
16
16
|
const CachedInputFileSystem_1 = __importDefault(require("../../compiled/enhanced-resolve/CachedInputFileSystem"));
|
|
17
17
|
const graceful_fs_1 = __importDefault(require("../../compiled/graceful-fs"));
|
|
18
|
-
const createConsoleLogger_1 =
|
|
18
|
+
const createConsoleLogger_1 = require("../logging/createConsoleLogger");
|
|
19
19
|
const NodeWatchFileSystem_1 = __importDefault(require("./NodeWatchFileSystem"));
|
|
20
20
|
const nodeConsole_1 = __importDefault(require("./nodeConsole"));
|
|
21
21
|
class NodeEnvironmentPlugin {
|
|
@@ -24,7 +24,7 @@ class NodeEnvironmentPlugin {
|
|
|
24
24
|
}
|
|
25
25
|
apply(compiler) {
|
|
26
26
|
const { infrastructureLogging } = this.options;
|
|
27
|
-
compiler.infrastructureLogger = (0, createConsoleLogger_1.
|
|
27
|
+
compiler.infrastructureLogger = (0, createConsoleLogger_1.createConsoleLogger)({
|
|
28
28
|
level: infrastructureLogging.level || "info",
|
|
29
29
|
debug: infrastructureLogging.debug || false,
|
|
30
30
|
console: infrastructureLogging.console ||
|
|
@@ -60,7 +60,7 @@ class NodeWatchFileSystem {
|
|
|
60
60
|
this.watcher.once("aggregated", (changes, removals) => {
|
|
61
61
|
// pause emitting events (avoids clearing aggregated changes and removals on timeout)
|
|
62
62
|
this.watcher.pause();
|
|
63
|
-
if (this.inputFileSystem
|
|
63
|
+
if (this.inputFileSystem?.purge) {
|
|
64
64
|
const fs = this.inputFileSystem;
|
|
65
65
|
for (const item of changes) {
|
|
66
66
|
fs.purge(item);
|
|
@@ -92,7 +92,7 @@ class NodeWatchFileSystem {
|
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
94
|
getAggregatedRemovals: node_util_1.default.deprecate(() => {
|
|
95
|
-
const items = this.watcher
|
|
95
|
+
const items = this.watcher?.aggregatedRemovals;
|
|
96
96
|
if (items && this.inputFileSystem && this.inputFileSystem.purge) {
|
|
97
97
|
const fs = this.inputFileSystem;
|
|
98
98
|
for (const item of items) {
|
|
@@ -102,7 +102,7 @@ class NodeWatchFileSystem {
|
|
|
102
102
|
return items;
|
|
103
103
|
}, "Watcher.getAggregatedRemovals is deprecated in favor of Watcher.getInfo since that's more performant.", "DEP_WEBPACK_WATCHER_GET_AGGREGATED_REMOVALS"),
|
|
104
104
|
getAggregatedChanges: node_util_1.default.deprecate(() => {
|
|
105
|
-
const items = this.watcher
|
|
105
|
+
const items = this.watcher?.aggregatedChanges;
|
|
106
106
|
if (items && this.inputFileSystem && this.inputFileSystem.purge) {
|
|
107
107
|
const fs = this.inputFileSystem;
|
|
108
108
|
for (const item of items) {
|
|
@@ -118,9 +118,9 @@ class NodeWatchFileSystem {
|
|
|
118
118
|
return fetchTimeInfo().contextTimeInfoEntries;
|
|
119
119
|
}, "Watcher.getContextTimeInfoEntries is deprecated in favor of Watcher.getInfo since that's more performant.", "DEP_WEBPACK_WATCHER_CONTEXT_TIME_INFO_ENTRIES"),
|
|
120
120
|
getInfo: () => {
|
|
121
|
-
const removals = this.watcher
|
|
122
|
-
const changes = this.watcher
|
|
123
|
-
if (this.inputFileSystem
|
|
121
|
+
const removals = this.watcher?.aggregatedRemovals;
|
|
122
|
+
const changes = this.watcher?.aggregatedChanges;
|
|
123
|
+
if (this.inputFileSystem?.purge) {
|
|
124
124
|
const fs = this.inputFileSystem;
|
|
125
125
|
if (removals) {
|
|
126
126
|
for (const item of removals) {
|
|
@@ -7,24 +7,10 @@
|
|
|
7
7
|
* Copyright (c) JS Foundation and other contributors
|
|
8
8
|
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
trace: (...args: any[]) => void;
|
|
18
|
-
info: (...args: any[]) => void;
|
|
19
|
-
warn: (...args: any[]) => void;
|
|
20
|
-
error: (...args: any[]) => void;
|
|
21
|
-
logTime: (...args: any[]) => void;
|
|
22
|
-
group: (...args: any[]) => void;
|
|
23
|
-
groupCollapsed: (...args: any[]) => void;
|
|
24
|
-
groupEnd: () => void;
|
|
25
|
-
profile: (name: any) => void;
|
|
26
|
-
profileEnd: (name: any) => void;
|
|
27
|
-
clear: false | (() => void);
|
|
28
|
-
status: (...args: any[]) => void;
|
|
29
|
-
};
|
|
30
|
-
export = _default;
|
|
10
|
+
/// <reference types="node" />
|
|
11
|
+
import type { LoggerConsole } from "../logging/createConsoleLogger";
|
|
12
|
+
export default function ({ colors, appendOnly, stream }: {
|
|
13
|
+
colors?: boolean;
|
|
14
|
+
appendOnly?: boolean;
|
|
15
|
+
stream: NodeJS.WritableStream;
|
|
16
|
+
}): LoggerConsole;
|
package/dist/node/nodeConsole.js
CHANGED
|
@@ -31,26 +31,25 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
31
31
|
__setModuleDefault(result, mod);
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
35
|
const util = __importStar(require("node:util"));
|
|
35
36
|
const truncateArgs_1 = require("../logging/truncateArgs");
|
|
36
|
-
|
|
37
|
-
// @ts-expect-error
|
|
37
|
+
function default_1({ colors, appendOnly, stream }) {
|
|
38
38
|
let currentStatusMessage = undefined;
|
|
39
39
|
let hasStatusMessage = false;
|
|
40
40
|
let currentIndent = "";
|
|
41
41
|
let currentCollapsed = 0;
|
|
42
|
-
// @ts-expect-error
|
|
43
42
|
const indent = (str, prefix, colorPrefix, colorSuffix) => {
|
|
44
43
|
if (str === "")
|
|
45
44
|
return str;
|
|
46
|
-
|
|
45
|
+
const prefixWithIndent = currentIndent + prefix;
|
|
47
46
|
if (colors) {
|
|
48
|
-
return (
|
|
47
|
+
return (prefixWithIndent +
|
|
49
48
|
colorPrefix +
|
|
50
|
-
str.replace(/\n/g, colorSuffix
|
|
49
|
+
str.replace(/\n/g, `${colorSuffix}\n${prefix}${colorPrefix}`) +
|
|
51
50
|
colorSuffix);
|
|
52
51
|
}
|
|
53
|
-
return
|
|
52
|
+
return prefixWithIndent + str.replace(/\n/g, `\n${prefix}`);
|
|
54
53
|
};
|
|
55
54
|
const clearStatusMessage = () => {
|
|
56
55
|
if (hasStatusMessage) {
|
|
@@ -59,9 +58,9 @@ module.exports = ({ colors, appendOnly, stream }) => {
|
|
|
59
58
|
}
|
|
60
59
|
};
|
|
61
60
|
const writeStatusMessage = () => {
|
|
62
|
-
// @ts-expect-error
|
|
63
61
|
if (!currentStatusMessage)
|
|
64
62
|
return;
|
|
63
|
+
//@ts-expect-error Property 'columns' does not exist on type 'WritableStream'.ts(2339)
|
|
65
64
|
const l = stream.columns;
|
|
66
65
|
const args = l
|
|
67
66
|
? (0, truncateArgs_1.truncateArgs)(currentStatusMessage, l - 1)
|
|
@@ -71,15 +70,13 @@ module.exports = ({ colors, appendOnly, stream }) => {
|
|
|
71
70
|
stream.write(`\x1b[2K\r${coloredStr}`);
|
|
72
71
|
hasStatusMessage = true;
|
|
73
72
|
};
|
|
74
|
-
// @ts-expect-error
|
|
75
73
|
const writeColored = (prefix, colorPrefix, colorSuffix) => {
|
|
76
|
-
// @ts-expect-error
|
|
77
74
|
return (...args) => {
|
|
78
75
|
if (currentCollapsed > 0)
|
|
79
76
|
return;
|
|
80
77
|
clearStatusMessage();
|
|
81
78
|
const str = indent(util.format(...args), prefix, colorPrefix, colorSuffix);
|
|
82
|
-
stream.write(str
|
|
79
|
+
stream.write(`${str}\n`);
|
|
83
80
|
writeStatusMessage();
|
|
84
81
|
};
|
|
85
82
|
};
|
|
@@ -93,7 +90,6 @@ module.exports = ({ colors, appendOnly, stream }) => {
|
|
|
93
90
|
warn: writeColored("<w> ", "\u001b[1m\u001b[33m", "\u001b[39m\u001b[22m"),
|
|
94
91
|
error: writeColored("<e> ", "\u001b[1m\u001b[31m", "\u001b[39m\u001b[22m"),
|
|
95
92
|
logTime: writeColored("<t> ", "\u001b[1m\u001b[35m", "\u001b[39m\u001b[22m"),
|
|
96
|
-
// @ts-expect-error
|
|
97
93
|
group: (...args) => {
|
|
98
94
|
writeGroupMessage(...args);
|
|
99
95
|
if (currentCollapsed > 0) {
|
|
@@ -103,7 +99,6 @@ module.exports = ({ colors, appendOnly, stream }) => {
|
|
|
103
99
|
currentIndent += " ";
|
|
104
100
|
}
|
|
105
101
|
},
|
|
106
|
-
// @ts-expect-error
|
|
107
102
|
groupCollapsed: (...args) => {
|
|
108
103
|
writeGroupCollapsedMessage(...args);
|
|
109
104
|
currentCollapsed++;
|
|
@@ -114,39 +109,37 @@ module.exports = ({ colors, appendOnly, stream }) => {
|
|
|
114
109
|
else if (currentIndent.length >= 2)
|
|
115
110
|
currentIndent = currentIndent.slice(0, currentIndent.length - 2);
|
|
116
111
|
},
|
|
117
|
-
// @ts-expect-error
|
|
118
112
|
profile: console.profile && (name => console.profile(name)),
|
|
119
|
-
// @ts-expect-error
|
|
120
113
|
profileEnd: console.profileEnd && (name => console.profileEnd(name)),
|
|
121
|
-
clear: !appendOnly &&
|
|
114
|
+
clear: (!appendOnly &&
|
|
122
115
|
console.clear &&
|
|
123
116
|
(() => {
|
|
124
117
|
clearStatusMessage();
|
|
125
118
|
console.clear();
|
|
126
119
|
writeStatusMessage();
|
|
127
|
-
}),
|
|
120
|
+
})),
|
|
128
121
|
status: appendOnly
|
|
129
122
|
? writeColored("<s> ", "", "")
|
|
130
|
-
:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
currentStatusMessage = undefined;
|
|
136
|
-
}
|
|
137
|
-
else if (typeof name === "string" &&
|
|
138
|
-
name.startsWith("[webpack.Progress] ")) {
|
|
139
|
-
currentStatusMessage = [name.slice(19), ...args];
|
|
140
|
-
writeStatusMessage();
|
|
141
|
-
}
|
|
142
|
-
else if (name === "[webpack.Progress]") {
|
|
143
|
-
currentStatusMessage = [...args];
|
|
144
|
-
writeStatusMessage();
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
currentStatusMessage = [name, ...args];
|
|
148
|
-
writeStatusMessage();
|
|
149
|
-
}
|
|
123
|
+
: (name, ...argsWithEmpty) => {
|
|
124
|
+
const args = argsWithEmpty.filter(Boolean);
|
|
125
|
+
if (name === undefined && args.length === 0) {
|
|
126
|
+
clearStatusMessage();
|
|
127
|
+
currentStatusMessage = undefined;
|
|
150
128
|
}
|
|
129
|
+
else if (typeof name === "string" &&
|
|
130
|
+
name.startsWith("[webpack.Progress] ")) {
|
|
131
|
+
currentStatusMessage = [name.slice(19), ...args];
|
|
132
|
+
writeStatusMessage();
|
|
133
|
+
}
|
|
134
|
+
else if (name === "[webpack.Progress]") {
|
|
135
|
+
currentStatusMessage = [...args];
|
|
136
|
+
writeStatusMessage();
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
currentStatusMessage = [name, ...args];
|
|
140
|
+
writeStatusMessage();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
151
143
|
};
|
|
152
|
-
}
|
|
144
|
+
}
|
|
145
|
+
exports.default = default_1;
|
|
@@ -19,12 +19,12 @@ const Module_1 = require("./Module");
|
|
|
19
19
|
const builtin_plugin_1 = require("./builtin-plugin");
|
|
20
20
|
const EntryOptionPlugin_1 = __importDefault(require("./lib/EntryOptionPlugin"));
|
|
21
21
|
const IgnoreWarningsPlugin_1 = __importDefault(require("./lib/IgnoreWarningsPlugin"));
|
|
22
|
+
const MemoryCachePlugin_1 = __importDefault(require("./lib/cache/MemoryCachePlugin"));
|
|
22
23
|
const DefaultStatsFactoryPlugin_1 = require("./stats/DefaultStatsFactoryPlugin");
|
|
23
24
|
const DefaultStatsPresetPlugin_1 = require("./stats/DefaultStatsPresetPlugin");
|
|
24
25
|
const DefaultStatsPrinterPlugin_1 = require("./stats/DefaultStatsPrinterPlugin");
|
|
25
26
|
const assertNotNil_1 = require("./util/assertNotNil");
|
|
26
27
|
class RspackOptionsApply {
|
|
27
|
-
constructor() { }
|
|
28
28
|
process(options, compiler) {
|
|
29
29
|
(0, node_assert_1.default)(options.output.path, "options.output.path should have value after `applyRspackOptionsDefaults`");
|
|
30
30
|
compiler.outputPath = options.output.path;
|
|
@@ -76,7 +76,7 @@ class RspackOptionsApply {
|
|
|
76
76
|
break;
|
|
77
77
|
}
|
|
78
78
|
default:
|
|
79
|
-
throw new Error(
|
|
79
|
+
throw new Error(`Unsupported chunk format '${options.output.chunkFormat}'.`);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
if (options.output.enabledChunkLoadingTypes &&
|
|
@@ -112,8 +112,8 @@ class RspackOptionsApply {
|
|
|
112
112
|
moduleFilenameTemplate: options.output.devtoolModuleFilenameTemplate,
|
|
113
113
|
fallbackModuleFilenameTemplate: options.output.devtoolFallbackModuleFilenameTemplate,
|
|
114
114
|
append: hidden ? false : undefined,
|
|
115
|
-
module: moduleMaps ? true : cheap
|
|
116
|
-
columns: cheap
|
|
115
|
+
module: moduleMaps ? true : !cheap,
|
|
116
|
+
columns: !cheap,
|
|
117
117
|
noSources: noSources,
|
|
118
118
|
namespace: options.output.devtoolNamespace
|
|
119
119
|
}).apply(compiler);
|
|
@@ -176,9 +176,7 @@ class RspackOptionsApply {
|
|
|
176
176
|
source: lazyOptions.test.source,
|
|
177
177
|
flags: lazyOptions.test.flags
|
|
178
178
|
}
|
|
179
|
-
: undefined,
|
|
180
|
-
// @ts-expect-error backend is hide
|
|
181
|
-
lazyOptions.backend).apply(compiler);
|
|
179
|
+
: undefined, lazyOptions.backend).apply(compiler);
|
|
182
180
|
}
|
|
183
181
|
if (options.output.enabledLibraryTypes &&
|
|
184
182
|
options.output.enabledLibraryTypes.length > 0) {
|
|
@@ -253,6 +251,9 @@ class RspackOptionsApply {
|
|
|
253
251
|
new builtin_plugin_1.SizeLimitsPlugin(options.performance).apply(compiler);
|
|
254
252
|
}
|
|
255
253
|
new builtin_plugin_1.WarnCaseSensitiveModulesPlugin().apply(compiler);
|
|
254
|
+
if (options.cache) {
|
|
255
|
+
new MemoryCachePlugin_1.default().apply(compiler);
|
|
256
|
+
}
|
|
256
257
|
new builtin_plugin_1.WorkerPlugin(options.output.workerChunkLoading, options.output.workerWasmLoading, options.output.module, options.output.workerPublicPath).apply(compiler);
|
|
257
258
|
new DefaultStatsFactoryPlugin_1.DefaultStatsFactoryPlugin().apply(compiler);
|
|
258
259
|
new DefaultStatsPresetPlugin_1.DefaultStatsPresetPlugin().apply(compiler);
|