@rspack/core 1.0.0-beta.1 → 1.0.0-beta.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.
- package/dist/ChunkGroup.d.ts +1 -0
- package/dist/ChunkGroup.js +3 -0
- package/dist/Compilation.d.ts +18 -0
- package/dist/Compiler.js +2 -2
- 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 +1 -1
- package/dist/Resolver.d.ts +1 -2
- package/dist/RspackError.js +1 -1
- package/dist/Stats.js +22 -2
- package/dist/Template.js +2 -2
- package/dist/builtin-loader/lightningcss/index.js +1 -1
- package/dist/builtin-plugin/DefinePlugin.js +1 -1
- 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/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/SwcJsMinimizerPlugin.d.ts +1 -2
- package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +3 -5
- package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +7 -5
- package/dist/builtin-plugin/css-extract/loader.js +4 -10
- package/dist/builtin-plugin/lazy-compilation/backend.js +4 -4
- 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 +440 -68
- package/dist/config/zod.js +21 -1
- package/dist/container/default.runtime.js +1 -1
- package/dist/lib/AbstractMethodError.js +2 -3
- package/dist/lib/Cache.d.ts +1 -1
- 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/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/formatLocation.d.ts +1 -1
- package/dist/loader-runner/index.js +6 -7
- 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 +29 -36
- 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 +1 -2
- package/dist/stats/DefaultStatsPrinterPlugin.js +18 -19
- package/dist/stats/StatsFactory.d.ts +2 -1
- package/dist/stats/StatsFactory.js +2 -6
- package/dist/stats/statsFactoryUtils.d.ts +63 -23
- package/dist/util/SizeFormatHelpers.js +1 -1
- package/dist/util/bindingVersionCheck.js +3 -3
- package/dist/util/cleverMerge.js +3 -2
- package/dist/util/comparators.d.ts +1 -1
- package/dist/util/comparators.js +5 -4
- package/dist/util/createHash.js +1 -1
- package/dist/util/fs.js +2 -2
- package/dist/util/identifier.js +2 -2
- package/dist/util/index.js +1 -1
- package/dist/util/memoize.js +1 -4
- 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/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,15 +31,14 @@ 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;
|
|
@@ -47,10 +46,10 @@ module.exports = ({ colors, appendOnly, stream }) => {
|
|
|
47
46
|
if (colors) {
|
|
48
47
|
return (prefix +
|
|
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 prefix + str.replace(/\n/g,
|
|
52
|
+
return prefix + 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, ...args) => {
|
|
124
|
+
args = args.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);
|
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
import { type BuiltinPlugin, BuiltinPluginName } from "@rspack/binding";
|
|
1
|
+
import { type BuiltinPlugin, BuiltinPluginName, type RawProvideOptions } from "@rspack/binding";
|
|
2
2
|
import type { Compiler } from "../Compiler";
|
|
3
3
|
import { RspackBuiltinPlugin } from "../builtin-plugin/base";
|
|
4
|
-
export type ProvideSharedPluginOptions = {
|
|
5
|
-
provides: Provides
|
|
4
|
+
export type ProvideSharedPluginOptions<Enhanced extends boolean = false> = {
|
|
5
|
+
provides: Provides<Enhanced>;
|
|
6
6
|
shareScope?: string;
|
|
7
|
-
enhanced?:
|
|
7
|
+
enhanced?: Enhanced;
|
|
8
8
|
};
|
|
9
|
-
export type Provides = (ProvidesItem | ProvidesObject)[] | ProvidesObject
|
|
9
|
+
export type Provides<Enhanced extends boolean> = (ProvidesItem | ProvidesObject<Enhanced>)[] | ProvidesObject<Enhanced>;
|
|
10
10
|
export type ProvidesItem = string;
|
|
11
|
-
export type ProvidesObject = {
|
|
12
|
-
[k: string]: ProvidesConfig | ProvidesItem;
|
|
11
|
+
export type ProvidesObject<Enhanced extends boolean> = {
|
|
12
|
+
[k: string]: ProvidesConfig<Enhanced> | ProvidesItem;
|
|
13
13
|
};
|
|
14
|
-
export type ProvidesConfig =
|
|
14
|
+
export type ProvidesConfig<Enhanced extends boolean> = Enhanced extends true ? ProvidesEnhancedConfig : ProvidesV1Config;
|
|
15
|
+
type ProvidesV1Config = {
|
|
15
16
|
eager?: boolean;
|
|
16
17
|
shareKey: string;
|
|
17
18
|
shareScope?: string;
|
|
18
19
|
version?: false | string;
|
|
19
20
|
};
|
|
20
|
-
|
|
21
|
+
type ProvidesEnhancedConfig = ProvidesV1Config & ProvidesEnhancedExtraConfig;
|
|
22
|
+
type ProvidesEnhancedExtraConfig = {
|
|
23
|
+
singleton?: boolean;
|
|
24
|
+
strictVersion?: boolean;
|
|
25
|
+
requiredVersion?: false | string;
|
|
26
|
+
};
|
|
27
|
+
export declare class ProvideSharedPlugin<Enhanced extends boolean = false> extends RspackBuiltinPlugin {
|
|
21
28
|
name: BuiltinPluginName;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
version: string | false | undefined;
|
|
26
|
-
shareScope: string;
|
|
27
|
-
eager: boolean;
|
|
28
|
-
}][];
|
|
29
|
-
enhanced: boolean;
|
|
30
|
-
};
|
|
31
|
-
constructor(options: ProvideSharedPluginOptions);
|
|
29
|
+
_provides: [string, Omit<RawProvideOptions, "key">][];
|
|
30
|
+
_enhanced?: Enhanced;
|
|
31
|
+
constructor(options: ProvideSharedPluginOptions<Enhanced>);
|
|
32
32
|
raw(compiler: Compiler): BuiltinPlugin;
|
|
33
33
|
}
|
|
34
|
+
export {};
|
|
@@ -9,29 +9,38 @@ class ProvideSharedPlugin extends base_1.RspackBuiltinPlugin {
|
|
|
9
9
|
constructor(options) {
|
|
10
10
|
super();
|
|
11
11
|
this.name = binding_1.BuiltinPluginName.ProvideSharedPlugin;
|
|
12
|
-
this.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}, item => ({
|
|
12
|
+
this._provides = (0, options_1.parseOptions)(options.provides, item => {
|
|
13
|
+
if (Array.isArray(item))
|
|
14
|
+
throw new Error("Unexpected array of provides");
|
|
15
|
+
return {
|
|
16
|
+
shareKey: item,
|
|
17
|
+
version: undefined,
|
|
18
|
+
shareScope: options.shareScope || "default",
|
|
19
|
+
eager: false
|
|
20
|
+
};
|
|
21
|
+
}, item => {
|
|
22
|
+
const raw = {
|
|
24
23
|
shareKey: item.shareKey,
|
|
25
24
|
version: item.version,
|
|
26
25
|
shareScope: item.shareScope || options.shareScope || "default",
|
|
27
26
|
eager: !!item.eager
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
};
|
|
28
|
+
if (options.enhanced) {
|
|
29
|
+
const enhancedItem = item;
|
|
30
|
+
return {
|
|
31
|
+
...raw,
|
|
32
|
+
singleton: enhancedItem.singleton,
|
|
33
|
+
requiredVersion: enhancedItem.requiredVersion,
|
|
34
|
+
strictVersion: enhancedItem.strictVersion
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return raw;
|
|
38
|
+
});
|
|
39
|
+
this._enhanced = options.enhanced;
|
|
31
40
|
}
|
|
32
41
|
raw(compiler) {
|
|
33
|
-
new ShareRuntimePlugin_1.ShareRuntimePlugin(this.
|
|
34
|
-
const rawOptions = this.
|
|
42
|
+
new ShareRuntimePlugin_1.ShareRuntimePlugin(this._enhanced ?? false).apply(compiler);
|
|
43
|
+
const rawOptions = this._provides.map(([key, v]) => ({
|
|
35
44
|
key,
|
|
36
45
|
...v
|
|
37
46
|
}));
|
|
@@ -40,6 +40,9 @@ export declare class SharePlugin {
|
|
|
40
40
|
shareScope: string | undefined;
|
|
41
41
|
version: string | false | undefined;
|
|
42
42
|
eager: boolean | undefined;
|
|
43
|
+
singleton: boolean | undefined;
|
|
44
|
+
requiredVersion: string | false | undefined;
|
|
45
|
+
strictVersion: boolean | undefined;
|
|
43
46
|
};
|
|
44
47
|
}[];
|
|
45
48
|
_enhanced: boolean;
|
|
@@ -39,7 +39,10 @@ class SharePlugin {
|
|
|
39
39
|
shareKey: options.shareKey || key,
|
|
40
40
|
shareScope: options.shareScope,
|
|
41
41
|
version: options.version,
|
|
42
|
-
eager: options.eager
|
|
42
|
+
eager: options.eager,
|
|
43
|
+
singleton: options.singleton,
|
|
44
|
+
requiredVersion: options.requiredVersion,
|
|
45
|
+
strictVersion: options.strictVersion
|
|
43
46
|
}
|
|
44
47
|
}));
|
|
45
48
|
this._shareScope = options.shareScope;
|