@rsbuild/webpack 1.3.4 → 1.4.1
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/{997.js → 0~0.js} +14 -19
- package/dist/{812.js → 0~502.js} +70 -75
- package/dist/{997.cjs → 1~0.cjs} +13 -19
- package/dist/{818.cjs → 1~363.cjs} +58 -70
- package/dist/index.cjs +37 -36
- package/dist/index.js +25 -36
- package/package.json +9 -9
package/dist/{997.js → 0~0.js}
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
export const __webpack_id__ = "0";
|
|
1
2
|
export const __webpack_ids__ = [
|
|
2
|
-
"
|
|
3
|
+
"0"
|
|
3
4
|
];
|
|
4
5
|
export const __webpack_modules__ = {
|
|
5
6
|
"../../../node_modules/.pnpm/ansi-escapes@4.3.2/node_modules/ansi-escapes/index.js": function(module) {
|
|
@@ -821,24 +822,18 @@ export const __webpack_modules__ = {
|
|
|
821
822
|
});
|
|
822
823
|
let routes = route(fromModel);
|
|
823
824
|
Object.keys(routes).forEach((toModel)=>{
|
|
824
|
-
let fn = routes[toModel];
|
|
825
|
-
convert[fromModel][toModel] = function(
|
|
826
|
-
let
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
return
|
|
835
|
-
}
|
|
836
|
-
let wrappedFn = function(...args) {
|
|
837
|
-
let arg0 = args[0];
|
|
838
|
-
return null == arg0 ? arg0 : (arg0.length > 1 && (args = arg0), fn(args));
|
|
839
|
-
};
|
|
840
|
-
return 'conversion' in fn && (wrappedFn.conversion = fn.conversion), wrappedFn;
|
|
841
|
-
}(fn);
|
|
825
|
+
let wrappedFn, wrappedFn1, fn = routes[toModel];
|
|
826
|
+
convert[fromModel][toModel] = (wrappedFn = function(...args) {
|
|
827
|
+
let arg0 = args[0];
|
|
828
|
+
if (null == arg0) return arg0;
|
|
829
|
+
arg0.length > 1 && (args = arg0);
|
|
830
|
+
let result = fn(args);
|
|
831
|
+
if ('object' == typeof result) for(let len = result.length, i = 0; i < len; i++)result[i] = Math.round(result[i]);
|
|
832
|
+
return result;
|
|
833
|
+
}, 'conversion' in fn && (wrappedFn.conversion = fn.conversion), wrappedFn), convert[fromModel][toModel].raw = (wrappedFn1 = function(...args) {
|
|
834
|
+
let arg0 = args[0];
|
|
835
|
+
return null == arg0 ? arg0 : (arg0.length > 1 && (args = arg0), fn(args));
|
|
836
|
+
}, 'conversion' in fn && (wrappedFn1.conversion = fn.conversion), wrappedFn1);
|
|
842
837
|
});
|
|
843
838
|
}), module.exports = convert;
|
|
844
839
|
},
|
package/dist/{812.js → 0~502.js}
RENAMED
|
@@ -1,21 +1,26 @@
|
|
|
1
|
+
import picocolors from "picocolors";
|
|
2
|
+
import webpack from "webpack";
|
|
3
|
+
import { Console } from "node:console";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_stream__ from "stream";
|
|
5
|
+
export const __webpack_id__ = "502";
|
|
1
6
|
export const __webpack_ids__ = [
|
|
2
|
-
"
|
|
7
|
+
"502"
|
|
3
8
|
];
|
|
4
9
|
export const __webpack_modules__ = {
|
|
5
10
|
"./src/progress/ProgressPlugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
6
11
|
__webpack_require__.d(__webpack_exports__, {
|
|
7
12
|
ProgressPlugin: ()=>ProgressPlugin
|
|
8
13
|
});
|
|
9
|
-
var core_ = __webpack_require__("@rsbuild/core"),
|
|
14
|
+
var core_ = __webpack_require__("@rsbuild/core"), cli_truncate = __webpack_require__("../../../node_modules/.pnpm/cli-truncate@2.1.0/node_modules/cli-truncate/index.js"), cli_truncate_default = __webpack_require__.n(cli_truncate);
|
|
10
15
|
let clamp = (x, min, max)=>Math.min(max, Math.max(min, x)), defaultOption = {
|
|
11
16
|
total: 100,
|
|
12
17
|
current: 0,
|
|
13
18
|
color: 'green',
|
|
14
19
|
bgColor: 'gray',
|
|
15
|
-
char:
|
|
20
|
+
char: '━',
|
|
16
21
|
width: 25,
|
|
17
|
-
buildIcon:
|
|
18
|
-
errorIcon:
|
|
22
|
+
buildIcon: '◯',
|
|
23
|
+
errorIcon: '✖',
|
|
19
24
|
errorInfo: 'compile failed',
|
|
20
25
|
message: '',
|
|
21
26
|
done: !1,
|
|
@@ -26,15 +31,7 @@ export const __webpack_modules__ = {
|
|
|
26
31
|
maxIdLen: 16,
|
|
27
32
|
hasErrors: !1
|
|
28
33
|
};
|
|
29
|
-
var
|
|
30
|
-
function _define_property(obj, key, value) {
|
|
31
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
32
|
-
value: value,
|
|
33
|
-
enumerable: !0,
|
|
34
|
-
configurable: !0,
|
|
35
|
-
writable: !0
|
|
36
|
-
}) : obj[key] = value, obj;
|
|
37
|
-
}
|
|
34
|
+
var build = __webpack_require__("../../../node_modules/.pnpm/patch-console@1.0.0/node_modules/patch-console/build/index.js"), build_default = __webpack_require__.n(build), ansi_escapes = __webpack_require__("../../../node_modules/.pnpm/ansi-escapes@4.3.2/node_modules/ansi-escapes/index.js"), ansi_escapes_default = __webpack_require__.n(ansi_escapes);
|
|
38
35
|
let colorList = [
|
|
39
36
|
'green',
|
|
40
37
|
'cyan',
|
|
@@ -42,48 +39,61 @@ export const __webpack_modules__ = {
|
|
|
42
39
|
'blue',
|
|
43
40
|
'magenta'
|
|
44
41
|
], bus = new class {
|
|
42
|
+
states = [];
|
|
43
|
+
log;
|
|
44
|
+
restore;
|
|
45
|
+
prevOutput;
|
|
46
|
+
destroyed = !1;
|
|
47
|
+
constructor(){
|
|
48
|
+
var stream;
|
|
49
|
+
let previousLineCount, previousOutput, render;
|
|
50
|
+
this.prevOutput = '', this.log = (stream = process.stdout, previousLineCount = 0, previousOutput = '', (render = (str)=>{
|
|
51
|
+
let output = `${str}\n`;
|
|
52
|
+
output !== previousOutput && (previousOutput = output, stream.write(ansi_escapes_default().eraseLines(previousLineCount) + output), previousLineCount = output.split('\n').length);
|
|
53
|
+
}).clear = ()=>{
|
|
54
|
+
stream.write(ansi_escapes_default().eraseLines(previousLineCount)), previousOutput = '', previousLineCount = 0;
|
|
55
|
+
}, render.done = ()=>{
|
|
56
|
+
previousOutput = '', previousLineCount = 0;
|
|
57
|
+
}, render), console.Console = Console, this.restore = build_default()((type, data)=>{
|
|
58
|
+
this.writeToStd(type, data);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
45
61
|
update(state) {
|
|
46
62
|
let index = this.states.findIndex((i)=>i.id === state.id);
|
|
47
|
-
|
|
48
|
-
this.states[index] = state;
|
|
63
|
+
-1 === index ? this.states.push(state) : this.states[index] = state;
|
|
49
64
|
}
|
|
50
65
|
writeToStd(type = 'stdout', data) {
|
|
51
66
|
this.log.clear(), data && ('stdout' === type ? process.stdout.write(data) : 'stderr' === type && process.stderr.write(data)), this.log(this.prevOutput);
|
|
52
67
|
}
|
|
53
68
|
render() {
|
|
54
|
-
let maxIdLen = Math.max(...this.states.map((i)=>{
|
|
55
|
-
var _i_id;
|
|
56
|
-
return (null == (_i_id = i.id) ? void 0 : _i_id.length) ?? 0;
|
|
57
|
-
})) + 2, { columns = 70 } = process.stdout;
|
|
69
|
+
let maxIdLen = Math.max(...this.states.map((i)=>i.id?.length ?? 0)) + 2, { columns = 70 } = process.stdout;
|
|
58
70
|
this.prevOutput = this.states.map((i, k)=>{
|
|
59
71
|
let bar = ((option)=>{
|
|
60
|
-
|
|
72
|
+
var id;
|
|
73
|
+
let left, right, mergedOptions = {
|
|
61
74
|
...defaultOption,
|
|
62
75
|
...option
|
|
63
|
-
}, { total, done, buildIcon, errorIcon, errorInfo, width, current, color, bgColor, char, message, messageWidth, spaceWidth, messageColor, maxIdLen, hasErrors } = mergedOptions, space = ' '.repeat(spaceWidth), percent = clamp(Math.floor(current / total * 100), 0, 100), barColor =
|
|
64
|
-
let left = Math.floor((maxLen - id.length) / 2), right = maxLen - left - id.length;
|
|
65
|
-
return ' '.repeat(left) + id + ' '.repeat(right);
|
|
66
|
-
})(mergedOptions.id, maxIdLen)) : '', { columns: terminalWidth = 70 } = process.stdout;
|
|
76
|
+
}, { total, done, buildIcon, errorIcon, errorInfo, width, current, color, bgColor, char, message, messageWidth, spaceWidth, messageColor, maxIdLen, hasErrors } = mergedOptions, space = ' '.repeat(spaceWidth), percent = clamp(Math.floor(current / total * 100), 0, 100), barColor = picocolors[color], backgroundColor = picocolors[bgColor], doneColor = hasErrors ? picocolors.red : barColor, idColor = done ? doneColor : barColor, id1 = mergedOptions.id ? idColor((left = Math.floor((maxIdLen - (id = mergedOptions.id).length) / 2), right = maxIdLen - left - id.length, ' '.repeat(left) + id + ' '.repeat(right))) : '', { columns: terminalWidth = 70 } = process.stdout;
|
|
67
77
|
if (done) {
|
|
68
78
|
if (hasErrors) {
|
|
69
|
-
let message =
|
|
79
|
+
let message = picocolors.bold(doneColor(errorInfo));
|
|
70
80
|
return terminalWidth >= 40 ? [
|
|
71
81
|
idColor(errorIcon),
|
|
72
|
-
|
|
82
|
+
id1,
|
|
73
83
|
doneColor(`${space}${message}`)
|
|
74
84
|
].join('') : [
|
|
75
|
-
|
|
85
|
+
id1,
|
|
76
86
|
doneColor(`${message}`)
|
|
77
87
|
].join('');
|
|
78
88
|
}
|
|
79
89
|
return '';
|
|
80
90
|
}
|
|
81
|
-
let msgStr =
|
|
91
|
+
let msgStr = picocolors[messageColor](cli_truncate_default()(message, messageWidth, {
|
|
82
92
|
position: 'start'
|
|
83
|
-
})),
|
|
93
|
+
})), left1 = clamp(Math.floor(percent * width / 100), 0, width), right1 = clamp(width - left1, 0, width), barStr = `${barColor(char.repeat(left1))}${backgroundColor(char.repeat(right1))}`, percentStr = `${percent.toString().padStart(3)}%`;
|
|
84
94
|
return terminalWidth >= 70 ? [
|
|
85
95
|
idColor(buildIcon),
|
|
86
|
-
|
|
96
|
+
id1,
|
|
87
97
|
space,
|
|
88
98
|
barStr,
|
|
89
99
|
space,
|
|
@@ -92,14 +102,14 @@ export const __webpack_modules__ = {
|
|
|
92
102
|
msgStr
|
|
93
103
|
].join('') : terminalWidth >= 40 ? [
|
|
94
104
|
idColor(buildIcon),
|
|
95
|
-
|
|
105
|
+
id1,
|
|
96
106
|
space,
|
|
97
107
|
barStr,
|
|
98
108
|
space,
|
|
99
109
|
percentStr
|
|
100
110
|
].join('') : [
|
|
101
111
|
idColor(buildIcon),
|
|
102
|
-
|
|
112
|
+
id1,
|
|
103
113
|
space,
|
|
104
114
|
percentStr
|
|
105
115
|
].join('');
|
|
@@ -119,51 +129,17 @@ export const __webpack_modules__ = {
|
|
|
119
129
|
clear() {
|
|
120
130
|
this.log.clear(), this.log.done();
|
|
121
131
|
}
|
|
122
|
-
constructor(){
|
|
123
|
-
_define_property(this, "states", []), _define_property(this, "log", void 0), _define_property(this, "restore", void 0), _define_property(this, "prevOutput", void 0), _define_property(this, "destroyed", !1), this.prevOutput = '', this.log = ((stream)=>{
|
|
124
|
-
let previousLineCount = 0, previousOutput = '', render = (str)=>{
|
|
125
|
-
let output = `${str}\n`;
|
|
126
|
-
output !== previousOutput && (previousOutput = output, stream.write(ansi_escapes_default().eraseLines(previousLineCount) + output), previousLineCount = output.split('\n').length);
|
|
127
|
-
};
|
|
128
|
-
return render.clear = ()=>{
|
|
129
|
-
stream.write(ansi_escapes_default().eraseLines(previousLineCount)), previousOutput = '', previousLineCount = 0;
|
|
130
|
-
}, render.done = ()=>{
|
|
131
|
-
previousOutput = '', previousLineCount = 0;
|
|
132
|
-
}, render;
|
|
133
|
-
})(process.stdout), console.Console = external_node_console_.Console, this.restore = build_default()((type, data)=>{
|
|
134
|
-
this.writeToStd(type, data);
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
132
|
}();
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}) : obj[key] = value, obj;
|
|
145
|
-
}
|
|
146
|
-
class ProgressPlugin extends external_webpack_.default.ProgressPlugin {
|
|
147
|
-
apply(compiler) {
|
|
148
|
-
super.apply(compiler);
|
|
149
|
-
let startTime = null;
|
|
150
|
-
compiler.hooks.compile.tap(this.name, ()=>{
|
|
151
|
-
this.compileTime = null, startTime = process.hrtime();
|
|
152
|
-
}), compiler.hooks.done.tap(this.name, (stat)=>{
|
|
153
|
-
if (startTime) {
|
|
154
|
-
this.hasCompileErrors = stat.hasErrors();
|
|
155
|
-
let hrtime = process.hrtime(startTime), seconds = hrtime[0] + hrtime[1] / 1e9;
|
|
156
|
-
if (this.compileTime = this.prettyTime(seconds), startTime = null, !this.hasCompileErrors) {
|
|
157
|
-
let suffix = this.id ? external_picocolors_.default.gray(` (${this.id})`) : '';
|
|
158
|
-
core_.logger.ready(`built in ${this.compileTime} ${suffix}`);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
}
|
|
133
|
+
class ProgressPlugin extends webpack.ProgressPlugin {
|
|
134
|
+
name = 'ProgressPlugin';
|
|
135
|
+
id;
|
|
136
|
+
hasCompileErrors = !1;
|
|
137
|
+
compileTime = null;
|
|
138
|
+
prettyTime;
|
|
163
139
|
constructor(options){
|
|
164
140
|
let prevPercentage, prevPercentage1, { id = 'Rsbuild' } = options, nonTTYLogger = (prevPercentage = 0, {
|
|
165
141
|
log: ({ id, done, current, hasErrors, compileTime })=>{
|
|
166
|
-
let suffix =
|
|
142
|
+
let suffix = picocolors.gray(`(${id})`);
|
|
167
143
|
if (done) {
|
|
168
144
|
if (100 === prevPercentage) return;
|
|
169
145
|
prevPercentage = 100, hasErrors ? core_.logger.error(`built failed in ${compileTime} ${suffix}`) : core_.logger.ready(`built in ${compileTime} ${suffix}`);
|
|
@@ -202,8 +178,27 @@ export const __webpack_modules__ = {
|
|
|
202
178
|
compileTime: this.compileTime
|
|
203
179
|
});
|
|
204
180
|
}
|
|
205
|
-
}),
|
|
181
|
+
}), this.id = id, this.prettyTime = options.prettyTime;
|
|
182
|
+
}
|
|
183
|
+
apply(compiler) {
|
|
184
|
+
super.apply(compiler);
|
|
185
|
+
let startTime = null;
|
|
186
|
+
compiler.hooks.compile.tap(this.name, ()=>{
|
|
187
|
+
this.compileTime = null, startTime = process.hrtime();
|
|
188
|
+
}), compiler.hooks.done.tap(this.name, (stat)=>{
|
|
189
|
+
if (startTime) {
|
|
190
|
+
this.hasCompileErrors = stat.hasErrors();
|
|
191
|
+
let hrtime = process.hrtime(startTime), seconds = hrtime[0] + hrtime[1] / 1e9;
|
|
192
|
+
if (this.compileTime = this.prettyTime(seconds), startTime = null, !this.hasCompileErrors) {
|
|
193
|
+
let suffix = this.id ? picocolors.gray(` (${this.id})`) : '';
|
|
194
|
+
core_.logger.ready(`built in ${this.compileTime} ${suffix}`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
});
|
|
206
198
|
}
|
|
207
199
|
}
|
|
200
|
+
},
|
|
201
|
+
stream: function(module) {
|
|
202
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_stream__;
|
|
208
203
|
}
|
|
209
204
|
};
|
package/dist/{997.cjs → 1~0.cjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
exports.ids = [
|
|
2
|
-
"
|
|
2
|
+
"0"
|
|
3
3
|
], exports.modules = {
|
|
4
4
|
"../../../node_modules/.pnpm/ansi-escapes@4.3.2/node_modules/ansi-escapes/index.js": function(module) {
|
|
5
5
|
"use strict";
|
|
@@ -825,24 +825,18 @@ exports.ids = [
|
|
|
825
825
|
});
|
|
826
826
|
let routes = route(fromModel);
|
|
827
827
|
Object.keys(routes).forEach((toModel)=>{
|
|
828
|
-
let fn = routes[toModel];
|
|
829
|
-
convert[fromModel][toModel] = function(
|
|
830
|
-
let
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
return
|
|
839
|
-
}
|
|
840
|
-
let wrappedFn = function(...args) {
|
|
841
|
-
let arg0 = args[0];
|
|
842
|
-
return null == arg0 ? arg0 : (arg0.length > 1 && (args = arg0), fn(args));
|
|
843
|
-
};
|
|
844
|
-
return 'conversion' in fn && (wrappedFn.conversion = fn.conversion), wrappedFn;
|
|
845
|
-
}(fn);
|
|
828
|
+
let wrappedFn, wrappedFn1, fn = routes[toModel];
|
|
829
|
+
convert[fromModel][toModel] = (wrappedFn = function(...args) {
|
|
830
|
+
let arg0 = args[0];
|
|
831
|
+
if (null == arg0) return arg0;
|
|
832
|
+
arg0.length > 1 && (args = arg0);
|
|
833
|
+
let result = fn(args);
|
|
834
|
+
if ('object' == typeof result) for(let len = result.length, i = 0; i < len; i++)result[i] = Math.round(result[i]);
|
|
835
|
+
return result;
|
|
836
|
+
}, 'conversion' in fn && (wrappedFn.conversion = fn.conversion), wrappedFn), convert[fromModel][toModel].raw = (wrappedFn1 = function(...args) {
|
|
837
|
+
let arg0 = args[0];
|
|
838
|
+
return null == arg0 ? arg0 : (arg0.length > 1 && (args = arg0), fn(args));
|
|
839
|
+
}, 'conversion' in fn && (wrappedFn1.conversion = fn.conversion), wrappedFn1);
|
|
846
840
|
});
|
|
847
841
|
}), module.exports = convert;
|
|
848
842
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.ids = [
|
|
3
|
-
"
|
|
3
|
+
"363"
|
|
4
4
|
], exports.modules = {
|
|
5
5
|
"./src/progress/ProgressPlugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
6
6
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -12,10 +12,10 @@ exports.ids = [
|
|
|
12
12
|
current: 0,
|
|
13
13
|
color: 'green',
|
|
14
14
|
bgColor: 'gray',
|
|
15
|
-
char:
|
|
15
|
+
char: '━',
|
|
16
16
|
width: 25,
|
|
17
|
-
buildIcon:
|
|
18
|
-
errorIcon:
|
|
17
|
+
buildIcon: '◯',
|
|
18
|
+
errorIcon: '✖',
|
|
19
19
|
errorInfo: 'compile failed',
|
|
20
20
|
message: '',
|
|
21
21
|
done: !1,
|
|
@@ -27,14 +27,6 @@ exports.ids = [
|
|
|
27
27
|
hasErrors: !1
|
|
28
28
|
};
|
|
29
29
|
var external_node_console_ = __webpack_require__("node:console"), build = __webpack_require__("../../../node_modules/.pnpm/patch-console@1.0.0/node_modules/patch-console/build/index.js"), build_default = __webpack_require__.n(build), ansi_escapes = __webpack_require__("../../../node_modules/.pnpm/ansi-escapes@4.3.2/node_modules/ansi-escapes/index.js"), ansi_escapes_default = __webpack_require__.n(ansi_escapes);
|
|
30
|
-
function _define_property(obj, key, value) {
|
|
31
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
32
|
-
value: value,
|
|
33
|
-
enumerable: !0,
|
|
34
|
-
configurable: !0,
|
|
35
|
-
writable: !0
|
|
36
|
-
}) : obj[key] = value, obj;
|
|
37
|
-
}
|
|
38
30
|
let colorList = [
|
|
39
31
|
'green',
|
|
40
32
|
'cyan',
|
|
@@ -42,37 +34,51 @@ exports.ids = [
|
|
|
42
34
|
'blue',
|
|
43
35
|
'magenta'
|
|
44
36
|
], bus = new class {
|
|
37
|
+
states = [];
|
|
38
|
+
log;
|
|
39
|
+
restore;
|
|
40
|
+
prevOutput;
|
|
41
|
+
destroyed = !1;
|
|
42
|
+
constructor(){
|
|
43
|
+
this.prevOutput = '', this.log = ((stream)=>{
|
|
44
|
+
let previousLineCount = 0, previousOutput = '', render = (str)=>{
|
|
45
|
+
let output = `${str}\n`;
|
|
46
|
+
output !== previousOutput && (previousOutput = output, stream.write(ansi_escapes_default().eraseLines(previousLineCount) + output), previousLineCount = output.split('\n').length);
|
|
47
|
+
};
|
|
48
|
+
return render.clear = ()=>{
|
|
49
|
+
stream.write(ansi_escapes_default().eraseLines(previousLineCount)), previousOutput = '', previousLineCount = 0;
|
|
50
|
+
}, render.done = ()=>{
|
|
51
|
+
previousOutput = '', previousLineCount = 0;
|
|
52
|
+
}, render;
|
|
53
|
+
})(process.stdout), console.Console = external_node_console_.Console, this.restore = build_default()((type, data)=>{
|
|
54
|
+
this.writeToStd(type, data);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
45
57
|
update(state) {
|
|
46
58
|
let index = this.states.findIndex((i)=>i.id === state.id);
|
|
47
|
-
|
|
48
|
-
this.states[index] = state;
|
|
59
|
+
-1 === index ? this.states.push(state) : this.states[index] = state;
|
|
49
60
|
}
|
|
50
61
|
writeToStd(type = 'stdout', data) {
|
|
51
62
|
this.log.clear(), data && ('stdout' === type ? process.stdout.write(data) : 'stderr' === type && process.stderr.write(data)), this.log(this.prevOutput);
|
|
52
63
|
}
|
|
53
64
|
render() {
|
|
54
|
-
let maxIdLen = Math.max(...this.states.map((i)=>{
|
|
55
|
-
var _i_id;
|
|
56
|
-
return (null == (_i_id = i.id) ? void 0 : _i_id.length) ?? 0;
|
|
57
|
-
})) + 2, { columns = 70 } = process.stdout;
|
|
65
|
+
let maxIdLen = Math.max(...this.states.map((i)=>i.id?.length ?? 0)) + 2, { columns = 70 } = process.stdout;
|
|
58
66
|
this.prevOutput = this.states.map((i, k)=>{
|
|
59
67
|
let bar = ((option)=>{
|
|
60
|
-
|
|
68
|
+
var id;
|
|
69
|
+
let left, right, mergedOptions = {
|
|
61
70
|
...defaultOption,
|
|
62
71
|
...option
|
|
63
|
-
}, { total, done, buildIcon, errorIcon, errorInfo, width, current, color, bgColor, char, message, messageWidth, spaceWidth, messageColor, maxIdLen, hasErrors } = mergedOptions, space = ' '.repeat(spaceWidth), percent = clamp(Math.floor(current / total * 100), 0, 100), barColor = external_picocolors_default()[color], backgroundColor = external_picocolors_default()[bgColor], doneColor = hasErrors ? external_picocolors_default().red : barColor, idColor = done ? doneColor : barColor,
|
|
64
|
-
let left = Math.floor((maxLen - id.length) / 2), right = maxLen - left - id.length;
|
|
65
|
-
return ' '.repeat(left) + id + ' '.repeat(right);
|
|
66
|
-
})(mergedOptions.id, maxIdLen)) : '', { columns: terminalWidth = 70 } = process.stdout;
|
|
72
|
+
}, { total, done, buildIcon, errorIcon, errorInfo, width, current, color, bgColor, char, message, messageWidth, spaceWidth, messageColor, maxIdLen, hasErrors } = mergedOptions, space = ' '.repeat(spaceWidth), percent = clamp(Math.floor(current / total * 100), 0, 100), barColor = external_picocolors_default()[color], backgroundColor = external_picocolors_default()[bgColor], doneColor = hasErrors ? external_picocolors_default().red : barColor, idColor = done ? doneColor : barColor, id1 = mergedOptions.id ? idColor((left = Math.floor((maxIdLen - (id = mergedOptions.id).length) / 2), right = maxIdLen - left - id.length, ' '.repeat(left) + id + ' '.repeat(right))) : '', { columns: terminalWidth = 70 } = process.stdout;
|
|
67
73
|
if (done) {
|
|
68
74
|
if (hasErrors) {
|
|
69
75
|
let message = external_picocolors_default().bold(doneColor(errorInfo));
|
|
70
76
|
return terminalWidth >= 40 ? [
|
|
71
77
|
idColor(errorIcon),
|
|
72
|
-
|
|
78
|
+
id1,
|
|
73
79
|
doneColor(`${space}${message}`)
|
|
74
80
|
].join('') : [
|
|
75
|
-
|
|
81
|
+
id1,
|
|
76
82
|
doneColor(`${message}`)
|
|
77
83
|
].join('');
|
|
78
84
|
}
|
|
@@ -80,10 +86,10 @@ exports.ids = [
|
|
|
80
86
|
}
|
|
81
87
|
let msgStr = external_picocolors_default()[messageColor](cli_truncate_default()(message, messageWidth, {
|
|
82
88
|
position: 'start'
|
|
83
|
-
})),
|
|
89
|
+
})), left1 = clamp(Math.floor(percent * width / 100), 0, width), right1 = clamp(width - left1, 0, width), barStr = `${barColor(char.repeat(left1))}${backgroundColor(char.repeat(right1))}`, percentStr = `${percent.toString().padStart(3)}%`;
|
|
84
90
|
return terminalWidth >= 70 ? [
|
|
85
91
|
idColor(buildIcon),
|
|
86
|
-
|
|
92
|
+
id1,
|
|
87
93
|
space,
|
|
88
94
|
barStr,
|
|
89
95
|
space,
|
|
@@ -92,14 +98,14 @@ exports.ids = [
|
|
|
92
98
|
msgStr
|
|
93
99
|
].join('') : terminalWidth >= 40 ? [
|
|
94
100
|
idColor(buildIcon),
|
|
95
|
-
|
|
101
|
+
id1,
|
|
96
102
|
space,
|
|
97
103
|
barStr,
|
|
98
104
|
space,
|
|
99
105
|
percentStr
|
|
100
106
|
].join('') : [
|
|
101
107
|
idColor(buildIcon),
|
|
102
|
-
|
|
108
|
+
id1,
|
|
103
109
|
space,
|
|
104
110
|
percentStr
|
|
105
111
|
].join('');
|
|
@@ -119,49 +125,15 @@ exports.ids = [
|
|
|
119
125
|
clear() {
|
|
120
126
|
this.log.clear(), this.log.done();
|
|
121
127
|
}
|
|
122
|
-
constructor(){
|
|
123
|
-
_define_property(this, "states", []), _define_property(this, "log", void 0), _define_property(this, "restore", void 0), _define_property(this, "prevOutput", void 0), _define_property(this, "destroyed", !1), this.prevOutput = '', this.log = ((stream)=>{
|
|
124
|
-
let previousLineCount = 0, previousOutput = '', render = (str)=>{
|
|
125
|
-
let output = `${str}\n`;
|
|
126
|
-
output !== previousOutput && (previousOutput = output, stream.write(ansi_escapes_default().eraseLines(previousLineCount) + output), previousLineCount = output.split('\n').length);
|
|
127
|
-
};
|
|
128
|
-
return render.clear = ()=>{
|
|
129
|
-
stream.write(ansi_escapes_default().eraseLines(previousLineCount)), previousOutput = '', previousLineCount = 0;
|
|
130
|
-
}, render.done = ()=>{
|
|
131
|
-
previousOutput = '', previousLineCount = 0;
|
|
132
|
-
}, render;
|
|
133
|
-
})(process.stdout), console.Console = external_node_console_.Console, this.restore = build_default()((type, data)=>{
|
|
134
|
-
this.writeToStd(type, data);
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
128
|
}();
|
|
138
|
-
function ProgressPlugin_define_property(obj, key, value) {
|
|
139
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
140
|
-
value: value,
|
|
141
|
-
enumerable: !0,
|
|
142
|
-
configurable: !0,
|
|
143
|
-
writable: !0
|
|
144
|
-
}) : obj[key] = value, obj;
|
|
145
|
-
}
|
|
146
129
|
class ProgressPlugin extends external_webpack_default().ProgressPlugin {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}), compiler.hooks.done.tap(this.name, (stat)=>{
|
|
153
|
-
if (startTime) {
|
|
154
|
-
this.hasCompileErrors = stat.hasErrors();
|
|
155
|
-
let hrtime = process.hrtime(startTime), seconds = hrtime[0] + hrtime[1] / 1e9;
|
|
156
|
-
if (this.compileTime = this.prettyTime(seconds), startTime = null, !this.hasCompileErrors) {
|
|
157
|
-
let suffix = this.id ? external_picocolors_default().gray(` (${this.id})`) : '';
|
|
158
|
-
core_.logger.ready(`built in ${this.compileTime} ${suffix}`);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
}
|
|
130
|
+
name = 'ProgressPlugin';
|
|
131
|
+
id;
|
|
132
|
+
hasCompileErrors = !1;
|
|
133
|
+
compileTime = null;
|
|
134
|
+
prettyTime;
|
|
163
135
|
constructor(options){
|
|
164
|
-
|
|
136
|
+
const { id = 'Rsbuild' } = options, nonTTYLogger = function() {
|
|
165
137
|
let prevPercentage = 0;
|
|
166
138
|
return {
|
|
167
139
|
log: ({ id, done, current, hasErrors, compileTime })=>{
|
|
@@ -208,7 +180,23 @@ exports.ids = [
|
|
|
208
180
|
compileTime: this.compileTime
|
|
209
181
|
});
|
|
210
182
|
}
|
|
211
|
-
}),
|
|
183
|
+
}), this.id = id, this.prettyTime = options.prettyTime;
|
|
184
|
+
}
|
|
185
|
+
apply(compiler) {
|
|
186
|
+
super.apply(compiler);
|
|
187
|
+
let startTime = null;
|
|
188
|
+
compiler.hooks.compile.tap(this.name, ()=>{
|
|
189
|
+
this.compileTime = null, startTime = process.hrtime();
|
|
190
|
+
}), compiler.hooks.done.tap(this.name, (stat)=>{
|
|
191
|
+
if (startTime) {
|
|
192
|
+
this.hasCompileErrors = stat.hasErrors();
|
|
193
|
+
let hrtime = process.hrtime(startTime), seconds = hrtime[0] + hrtime[1] / 1e9;
|
|
194
|
+
if (this.compileTime = this.prettyTime(seconds), startTime = null, !this.hasCompileErrors) {
|
|
195
|
+
let suffix = this.id ? external_picocolors_default().gray(` (${this.id})`) : '';
|
|
196
|
+
core_.logger.ready(`built in ${this.compileTime} ${suffix}`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
});
|
|
212
200
|
}
|
|
213
201
|
}
|
|
214
202
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
const __rslib_import_meta_url__ = 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
3
3
|
var __webpack_modules__ = {
|
|
4
4
|
"@rsbuild/core": function(module) {
|
|
5
5
|
module.exports = require("@rsbuild/core");
|
|
@@ -62,7 +62,7 @@ __webpack_require__.m = __webpack_modules__, __webpack_require__.n = (module)=>{
|
|
|
62
62
|
enumerable: !0,
|
|
63
63
|
get: definition[key]
|
|
64
64
|
});
|
|
65
|
-
}, __webpack_require__.f = {}, __webpack_require__.e = (chunkId)=>Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key)=>(__webpack_require__.f[key](chunkId, promises), promises), [])), __webpack_require__.u = (chunkId)=>"" + chunkId + ".cjs", __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports1)=>{
|
|
65
|
+
}, __webpack_require__.f = {}, __webpack_require__.e = (chunkId)=>Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key)=>(__webpack_require__.f[key](chunkId, promises), promises), [])), __webpack_require__.u = (chunkId)=>"1~" + chunkId + ".cjs", __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports1)=>{
|
|
66
66
|
'undefined' != typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
67
67
|
value: 'Module'
|
|
68
68
|
}), Object.defineProperty(exports1, '__esModule', {
|
|
@@ -70,7 +70,7 @@ __webpack_require__.m = __webpack_modules__, __webpack_require__.n = (module)=>{
|
|
|
70
70
|
});
|
|
71
71
|
}, __webpack_require__.nmd = (module)=>(module.paths = [], module.children || (module.children = []), module), (()=>{
|
|
72
72
|
var installedChunks = {
|
|
73
|
-
|
|
73
|
+
410: 1
|
|
74
74
|
};
|
|
75
75
|
__webpack_require__.f.require = (chunkId, promises)=>{
|
|
76
76
|
installedChunks[chunkId] || ((chunk)=>{
|
|
@@ -93,7 +93,6 @@ for(var __webpack_i__ in (()=>{
|
|
|
93
93
|
arr
|
|
94
94
|
];
|
|
95
95
|
async function modifyWebpackChain(context, utils, chain) {
|
|
96
|
-
var _utils_environment_config_tools;
|
|
97
96
|
core_.logger.debug('modify webpack chain');
|
|
98
97
|
let [modifiedChain] = await context.hooks.modifyWebpackChain.callChain({
|
|
99
98
|
environment: utils.environment.name,
|
|
@@ -102,11 +101,10 @@ for(var __webpack_i__ in (()=>{
|
|
|
102
101
|
utils
|
|
103
102
|
]
|
|
104
103
|
});
|
|
105
|
-
if (
|
|
104
|
+
if (utils.environment.config.tools?.webpackChain) for (let item of castArray(utils.environment.config.tools.webpackChain))item(modifiedChain, utils);
|
|
106
105
|
return core_.logger.debug('modify webpack chain done'), modifiedChain;
|
|
107
106
|
}
|
|
108
107
|
async function modifyWebpackConfig(context, webpackConfig, utils) {
|
|
109
|
-
var _utils_environment_config_tools;
|
|
110
108
|
core_.logger.debug('modify webpack config');
|
|
111
109
|
let [modifiedConfig] = await context.hooks.modifyWebpackConfig.callChain({
|
|
112
110
|
environment: utils.environment.name,
|
|
@@ -115,7 +113,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
115
113
|
utils
|
|
116
114
|
]
|
|
117
115
|
});
|
|
118
|
-
return
|
|
116
|
+
return utils.environment.config.tools?.webpack && (modifiedConfig = (0, external_reduce_configs_namespaceObject.reduceConfigsWithContext)({
|
|
119
117
|
initial: modifiedConfig,
|
|
120
118
|
config: utils.environment.config.tools.webpack,
|
|
121
119
|
ctx: utils,
|
|
@@ -182,21 +180,28 @@ for(var __webpack_i__ in (()=>{
|
|
|
182
180
|
};
|
|
183
181
|
}
|
|
184
182
|
async function createCompiler_createCompiler(options) {
|
|
185
|
-
core_.logger.debug('
|
|
186
|
-
let { helpers, context } = options, { webpackConfigs } = await initConfigs(options);
|
|
183
|
+
core_.logger.debug('creating compiler');
|
|
184
|
+
let HOOK_NAME = 'rsbuild:compiler', { helpers, context } = options, { webpackConfigs } = await initConfigs(options);
|
|
187
185
|
await context.hooks.onBeforeCreateCompiler.callBatch({
|
|
188
186
|
bundlerConfigs: webpackConfigs,
|
|
189
187
|
environments: context.environments
|
|
190
188
|
});
|
|
191
189
|
let { default: webpack } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "webpack?5a4d")), compiler = webpack(1 === webpackConfigs.length ? webpackConfigs[0] : webpackConfigs);
|
|
192
|
-
return compiler.hooks.
|
|
193
|
-
|
|
194
|
-
|
|
190
|
+
return compiler.hooks.run.tap(HOOK_NAME, ()=>{
|
|
191
|
+
context.buildState.status = 'building';
|
|
192
|
+
}), compiler.hooks.watchRun.tap(HOOK_NAME, ()=>{
|
|
193
|
+
context.buildState.status = 'building';
|
|
194
|
+
}), compiler.hooks.invalid.tap(HOOK_NAME, ()=>{
|
|
195
|
+
context.buildState.status = 'idle', context.buildState.hasErrors = !1;
|
|
196
|
+
}), compiler.hooks.done.tap(HOOK_NAME, (stats)=>{
|
|
197
|
+
let hasErrors = stats.hasErrors();
|
|
198
|
+
context.buildState.hasErrors = hasErrors, context.buildState.status = 'done';
|
|
199
|
+
let statsOptions = helpers.getStatsOptions(compiler), statsJson = stats.toJson({
|
|
195
200
|
moduleTrace: !0,
|
|
196
201
|
children: !0,
|
|
197
202
|
preset: 'errors-warnings',
|
|
198
203
|
...statsOptions
|
|
199
|
-
}), { message, level } = helpers.formatStats(statsJson,
|
|
204
|
+
}), { message, level } = helpers.formatStats(statsJson, hasErrors);
|
|
200
205
|
'error' === level ? core_.logger.error(message) : 'warning' === level && core_.logger.warn(message);
|
|
201
206
|
}), 'dev' === context.action && helpers.registerDevHook({
|
|
202
207
|
compiler,
|
|
@@ -206,7 +211,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
206
211
|
}), await context.hooks.onAfterCreateCompiler.callBatch({
|
|
207
212
|
compiler,
|
|
208
213
|
environments: context.environments
|
|
209
|
-
}), core_.logger.debug('
|
|
214
|
+
}), core_.logger.debug('compiler created'), {
|
|
210
215
|
compiler,
|
|
211
216
|
webpackConfigs
|
|
212
217
|
};
|
|
@@ -235,7 +240,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
235
240
|
};
|
|
236
241
|
let { stats } = await new Promise((resolve, reject)=>{
|
|
237
242
|
compiler.run((err, stats)=>{
|
|
238
|
-
err ? reject(err) :
|
|
243
|
+
err ? reject(err) : stats?.hasErrors() ? reject(Error('webpack build failed.')) : compiler.close((closeErr)=>{
|
|
239
244
|
closeErr && core_.logger.error(closeErr), resolve({
|
|
240
245
|
stats
|
|
241
246
|
});
|
|
@@ -275,36 +280,33 @@ for(var __webpack_i__ in (()=>{
|
|
|
275
280
|
name: 'rsbuild-webpack:adaptor',
|
|
276
281
|
setup (api) {
|
|
277
282
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, target })=>{
|
|
278
|
-
|
|
283
|
+
var chain1, target1, target2;
|
|
284
|
+
let mainFields, { config, tsconfigPath } = environment, aliasStrategy = config.source.aliasStrategy ?? config.resolve.aliasStrategy;
|
|
279
285
|
tsconfigPath && 'prefer-tsconfig' === aliasStrategy && await applyTsConfigPathsPlugin({
|
|
280
286
|
chain,
|
|
281
287
|
CHAIN_ID,
|
|
282
288
|
configFile: tsconfigPath,
|
|
283
|
-
mainFields: (
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
'module',
|
|
292
|
-
'main'
|
|
293
|
-
];
|
|
294
|
-
})(chain, target),
|
|
289
|
+
mainFields: (chain1 = chain, target1 = target, (mainFields = chain1.resolve.mainFields.values()).length ? mainFields : castArray(target2 = target1).includes('web') || target2.includes('web-worker') ? [
|
|
290
|
+
'browser',
|
|
291
|
+
'module',
|
|
292
|
+
'main'
|
|
293
|
+
] : [
|
|
294
|
+
'module',
|
|
295
|
+
'main'
|
|
296
|
+
]),
|
|
295
297
|
extensions: chain.resolve.extensions.values()
|
|
296
298
|
});
|
|
297
|
-
let
|
|
298
|
-
if (
|
|
299
|
+
let { progressBar } = config.dev;
|
|
300
|
+
if (progressBar) {
|
|
299
301
|
let { ProgressPlugin } = await Promise.all([
|
|
300
|
-
__webpack_require__.e("
|
|
301
|
-
__webpack_require__.e("
|
|
302
|
+
__webpack_require__.e("0"),
|
|
303
|
+
__webpack_require__.e("363")
|
|
302
304
|
]).then(__webpack_require__.bind(__webpack_require__, "./src/progress/ProgressPlugin.ts"));
|
|
303
305
|
chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(ProgressPlugin, [
|
|
304
306
|
{
|
|
305
307
|
id: environment.name,
|
|
306
308
|
prettyTime: helpers1.prettyTime,
|
|
307
|
-
...!0 ===
|
|
309
|
+
...!0 === progressBar ? {} : progressBar
|
|
308
310
|
}
|
|
309
311
|
]);
|
|
310
312
|
}
|
|
@@ -318,9 +320,8 @@ for(var __webpack_i__ in (()=>{
|
|
|
318
320
|
]);
|
|
319
321
|
}
|
|
320
322
|
}), api.modifyWebpackConfig(async (config)=>{
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
copyPlugin && copyPlugin.patterns.every((pattern)=>'string' != typeof pattern && pattern.context && !external_node_fs_default().existsSync(pattern.context)) && (config.plugins = null == (_config_plugins1 = config.plugins) ? void 0 : _config_plugins1.filter((item)=>(null == item ? void 0 : item.constructor.name) !== 'CopyPlugin'));
|
|
323
|
+
let copyPlugin = config.plugins?.find((item)=>item?.constructor.name === 'CopyPlugin');
|
|
324
|
+
copyPlugin && copyPlugin.patterns.every((pattern)=>'string' != typeof pattern && pattern.context && !external_node_fs_default().existsSync(pattern.context)) && (config.plugins = config.plugins?.filter((item)=>item?.constructor.name !== 'CopyPlugin'));
|
|
324
325
|
});
|
|
325
326
|
}
|
|
326
327
|
})
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,10 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ from "@rsbuild/core";
|
|
2
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_console_8631dfae__ from "node:console";
|
|
3
|
-
import * as __WEBPACK_EXTERNAL_MODULE_picocolors__ from "picocolors";
|
|
4
|
-
import * as __WEBPACK_EXTERNAL_MODULE_stream__ from "stream";
|
|
5
|
-
import * as __WEBPACK_EXTERNAL_MODULE_webpack__ from "webpack";
|
|
6
2
|
import MultiStats from "webpack/lib/MultiStats.js";
|
|
7
3
|
import { reduceConfigsWithContext } from "reduce-configs";
|
|
8
4
|
import node_fs from "node:fs";
|
|
9
5
|
var installedChunks, installChunk, __webpack_modules__ = {
|
|
10
6
|
"@rsbuild/core": function(module) {
|
|
11
7
|
module.exports = __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__;
|
|
12
|
-
},
|
|
13
|
-
"node:console": function(module) {
|
|
14
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_node_console_8631dfae__;
|
|
15
|
-
},
|
|
16
|
-
picocolors: function(module) {
|
|
17
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_picocolors__;
|
|
18
|
-
},
|
|
19
|
-
stream: function(module) {
|
|
20
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_stream__;
|
|
21
|
-
},
|
|
22
|
-
webpack: function(module) {
|
|
23
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_webpack__;
|
|
24
8
|
}
|
|
25
9
|
}, __webpack_module_cache__ = {};
|
|
26
10
|
function __webpack_require__(moduleId) {
|
|
@@ -43,8 +27,8 @@ __webpack_require__.m = __webpack_modules__, __webpack_require__.n = (module)=>{
|
|
|
43
27
|
enumerable: !0,
|
|
44
28
|
get: definition[key]
|
|
45
29
|
});
|
|
46
|
-
}, __webpack_require__.f = {}, __webpack_require__.e = (chunkId)=>Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key)=>(__webpack_require__.f[key](chunkId, promises), promises), [])), __webpack_require__.u = (chunkId)=>"" + chunkId + ".js", __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.nmd = (module)=>(module.paths = [], module.children || (module.children = []), module), installedChunks = {
|
|
47
|
-
|
|
30
|
+
}, __webpack_require__.f = {}, __webpack_require__.e = (chunkId)=>Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key)=>(__webpack_require__.f[key](chunkId, promises), promises), [])), __webpack_require__.u = (chunkId)=>"0~" + chunkId + ".js", __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.nmd = (module)=>(module.paths = [], module.children || (module.children = []), module), installedChunks = {
|
|
31
|
+
410: 0
|
|
48
32
|
}, installChunk = (data)=>{
|
|
49
33
|
var moduleId, chunkId, __webpack_ids__ = data.__webpack_ids__, __webpack_modules__ = data.__webpack_modules__, __webpack_runtime__ = data.__webpack_runtime__, i = 0;
|
|
50
34
|
for(moduleId in __webpack_modules__)__webpack_require__.o(__webpack_modules__, moduleId) && (__webpack_require__.m[moduleId] = __webpack_modules__[moduleId]);
|
|
@@ -71,7 +55,6 @@ let castArray = (arr)=>void 0 === arr ? [] : Array.isArray(arr) ? arr : [
|
|
|
71
55
|
arr
|
|
72
56
|
];
|
|
73
57
|
async function modifyWebpackChain(context, utils, chain) {
|
|
74
|
-
var _utils_environment_config_tools;
|
|
75
58
|
core_.logger.debug('modify webpack chain');
|
|
76
59
|
let [modifiedChain] = await context.hooks.modifyWebpackChain.callChain({
|
|
77
60
|
environment: utils.environment.name,
|
|
@@ -80,11 +63,10 @@ async function modifyWebpackChain(context, utils, chain) {
|
|
|
80
63
|
utils
|
|
81
64
|
]
|
|
82
65
|
});
|
|
83
|
-
if (
|
|
66
|
+
if (utils.environment.config.tools?.webpackChain) for (let item of castArray(utils.environment.config.tools.webpackChain))item(modifiedChain, utils);
|
|
84
67
|
return core_.logger.debug('modify webpack chain done'), modifiedChain;
|
|
85
68
|
}
|
|
86
69
|
async function modifyWebpackConfig(context, webpackConfig, utils) {
|
|
87
|
-
var _utils_environment_config_tools;
|
|
88
70
|
core_.logger.debug('modify webpack config');
|
|
89
71
|
let [modifiedConfig] = await context.hooks.modifyWebpackConfig.callChain({
|
|
90
72
|
environment: utils.environment.name,
|
|
@@ -93,7 +75,7 @@ async function modifyWebpackConfig(context, webpackConfig, utils) {
|
|
|
93
75
|
utils
|
|
94
76
|
]
|
|
95
77
|
});
|
|
96
|
-
return
|
|
78
|
+
return utils.environment.config.tools?.webpack && (modifiedConfig = reduceConfigsWithContext({
|
|
97
79
|
initial: modifiedConfig,
|
|
98
80
|
config: utils.environment.config.tools.webpack,
|
|
99
81
|
ctx: utils,
|
|
@@ -160,20 +142,28 @@ async function initConfigs({ context, pluginManager, rsbuildOptions, helpers })
|
|
|
160
142
|
};
|
|
161
143
|
}
|
|
162
144
|
async function createCompiler_createCompiler(options) {
|
|
163
|
-
core_.logger.debug('
|
|
164
|
-
let { helpers, context } = options, { webpackConfigs } = await initConfigs(options);
|
|
145
|
+
core_.logger.debug('creating compiler');
|
|
146
|
+
let HOOK_NAME = 'rsbuild:compiler', { helpers, context } = options, { webpackConfigs } = await initConfigs(options);
|
|
165
147
|
await context.hooks.onBeforeCreateCompiler.callBatch({
|
|
166
148
|
bundlerConfigs: webpackConfigs,
|
|
167
149
|
environments: context.environments
|
|
168
150
|
});
|
|
169
151
|
let { default: webpack } = await import("webpack"), compiler = webpack(1 === webpackConfigs.length ? webpackConfigs[0] : webpackConfigs);
|
|
170
|
-
return compiler.hooks.
|
|
152
|
+
return compiler.hooks.run.tap(HOOK_NAME, ()=>{
|
|
153
|
+
context.buildState.status = 'building';
|
|
154
|
+
}), compiler.hooks.watchRun.tap(HOOK_NAME, ()=>{
|
|
155
|
+
context.buildState.status = 'building';
|
|
156
|
+
}), compiler.hooks.invalid.tap(HOOK_NAME, ()=>{
|
|
157
|
+
context.buildState.status = 'idle', context.buildState.hasErrors = !1;
|
|
158
|
+
}), compiler.hooks.done.tap(HOOK_NAME, (stats)=>{
|
|
159
|
+
let hasErrors = stats.hasErrors();
|
|
160
|
+
context.buildState.hasErrors = hasErrors, context.buildState.status = 'done';
|
|
171
161
|
let statsOptions = helpers.getStatsOptions(compiler), statsJson = stats.toJson({
|
|
172
162
|
moduleTrace: !0,
|
|
173
163
|
children: !0,
|
|
174
164
|
preset: 'errors-warnings',
|
|
175
165
|
...statsOptions
|
|
176
|
-
}), { message, level } = helpers.formatStats(statsJson,
|
|
166
|
+
}), { message, level } = helpers.formatStats(statsJson, hasErrors);
|
|
177
167
|
'error' === level ? core_.logger.error(message) : 'warning' === level && core_.logger.warn(message);
|
|
178
168
|
}), 'dev' === context.action && helpers.registerDevHook({
|
|
179
169
|
compiler,
|
|
@@ -183,7 +173,7 @@ async function createCompiler_createCompiler(options) {
|
|
|
183
173
|
}), await context.hooks.onAfterCreateCompiler.callBatch({
|
|
184
174
|
compiler,
|
|
185
175
|
environments: context.environments
|
|
186
|
-
}), core_.logger.debug('
|
|
176
|
+
}), core_.logger.debug('compiler created'), {
|
|
187
177
|
compiler,
|
|
188
178
|
webpackConfigs
|
|
189
179
|
};
|
|
@@ -212,7 +202,7 @@ let build = async (initOptions, { watch, compiler: customCompiler } = {})=>{
|
|
|
212
202
|
};
|
|
213
203
|
let { stats } = await new Promise((resolve, reject)=>{
|
|
214
204
|
compiler.run((err, stats)=>{
|
|
215
|
-
err ? reject(err) :
|
|
205
|
+
err ? reject(err) : stats?.hasErrors() ? reject(Error('webpack build failed.')) : compiler.close((closeErr)=>{
|
|
216
206
|
closeErr && core_.logger.error(closeErr), resolve({
|
|
217
207
|
stats
|
|
218
208
|
});
|
|
@@ -269,17 +259,17 @@ let webpackProvider = async ({ context, pluginManager, rsbuildOptions, helpers }
|
|
|
269
259
|
})(chain, target),
|
|
270
260
|
extensions: chain.resolve.extensions.values()
|
|
271
261
|
});
|
|
272
|
-
let
|
|
273
|
-
if (
|
|
262
|
+
let { progressBar } = config.dev;
|
|
263
|
+
if (progressBar) {
|
|
274
264
|
let { ProgressPlugin } = await Promise.all([
|
|
275
|
-
__webpack_require__.e("
|
|
276
|
-
__webpack_require__.e("
|
|
265
|
+
__webpack_require__.e("0"),
|
|
266
|
+
__webpack_require__.e("502")
|
|
277
267
|
]).then(__webpack_require__.bind(__webpack_require__, "./src/progress/ProgressPlugin.ts"));
|
|
278
268
|
chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(ProgressPlugin, [
|
|
279
269
|
{
|
|
280
270
|
id: environment.name,
|
|
281
271
|
prettyTime: helpers.prettyTime,
|
|
282
|
-
...!0 ===
|
|
272
|
+
...!0 === progressBar ? {} : progressBar
|
|
283
273
|
}
|
|
284
274
|
]);
|
|
285
275
|
}
|
|
@@ -293,9 +283,8 @@ let webpackProvider = async ({ context, pluginManager, rsbuildOptions, helpers }
|
|
|
293
283
|
]);
|
|
294
284
|
}
|
|
295
285
|
}), api.modifyWebpackConfig(async (config)=>{
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
copyPlugin && copyPlugin.patterns.every((pattern)=>'string' != typeof pattern && pattern.context && !node_fs.existsSync(pattern.context)) && (config.plugins = null == (_config_plugins1 = config.plugins) ? void 0 : _config_plugins1.filter((item)=>(null == item ? void 0 : item.constructor.name) !== 'CopyPlugin'));
|
|
286
|
+
let copyPlugin = config.plugins?.find((item)=>item?.constructor.name === 'CopyPlugin');
|
|
287
|
+
copyPlugin && copyPlugin.patterns.every((pattern)=>'string' != typeof pattern && pattern.context && !node_fs.existsSync(pattern.context)) && (config.plugins = config.plugins?.filter((item)=>item?.constructor.name !== 'CopyPlugin'));
|
|
299
288
|
});
|
|
300
289
|
}
|
|
301
290
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/webpack",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"homepage": "https://rsbuild.rs",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,21 +24,21 @@
|
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"copy-webpack-plugin": "11.0.0",
|
|
27
|
-
"html-webpack-plugin": "^5.6.
|
|
28
|
-
"mini-css-extract-plugin": "2.9.
|
|
27
|
+
"html-webpack-plugin": "^5.6.4",
|
|
28
|
+
"mini-css-extract-plugin": "2.9.4",
|
|
29
29
|
"picocolors": "^1.1.1",
|
|
30
30
|
"reduce-configs": "^1.1.1",
|
|
31
31
|
"tsconfig-paths-webpack-plugin": "4.2.0",
|
|
32
|
-
"webpack": "^5.101.
|
|
32
|
+
"webpack": "^5.101.3"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@rslib/core": "0.
|
|
36
|
-
"@types/node": "^22.
|
|
35
|
+
"@rslib/core": "0.14.0",
|
|
36
|
+
"@types/node": "^22.18.6",
|
|
37
37
|
"ansi-escapes": "4.3.2",
|
|
38
38
|
"cli-truncate": "2.1.0",
|
|
39
39
|
"patch-console": "1.0.0",
|
|
40
40
|
"typescript": "^5.9.2",
|
|
41
|
-
"@rsbuild/core": "1.
|
|
41
|
+
"@rsbuild/core": "1.5.13",
|
|
42
42
|
"@scripts/test-helper": "1.0.1"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "rslib build",
|
|
53
|
-
"dev": "rslib build
|
|
54
|
-
"bump": "
|
|
53
|
+
"dev": "rslib build -w",
|
|
54
|
+
"bump": "pnpx bumpp --no-tag"
|
|
55
55
|
}
|
|
56
56
|
}
|