@rsbuild/webpack 0.7.3 → 0.7.4
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/index.cjs +79 -83
- package/dist/index.d.ts +0 -1
- package/dist/index.js +35 -44
- package/package.json +5 -6
package/dist/index.cjs
CHANGED
|
@@ -38,6 +38,26 @@ var __publicField = (obj, key, value) => {
|
|
|
38
38
|
return value;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
+
// src/shared.ts
|
|
42
|
+
var import_core, getChainUtils, initRsbuildConfig, createDevServer, startProdServer, formatStats, getDevMiddleware, getStatsOptions, stringifyConfig, outputInspectConfigFiles;
|
|
43
|
+
var init_shared = __esm({
|
|
44
|
+
"src/shared.ts"() {
|
|
45
|
+
"use strict";
|
|
46
|
+
import_core = require("@rsbuild/core");
|
|
47
|
+
({
|
|
48
|
+
getChainUtils,
|
|
49
|
+
initRsbuildConfig,
|
|
50
|
+
createDevServer,
|
|
51
|
+
startProdServer,
|
|
52
|
+
formatStats,
|
|
53
|
+
getDevMiddleware,
|
|
54
|
+
getStatsOptions,
|
|
55
|
+
stringifyConfig,
|
|
56
|
+
outputInspectConfigFiles
|
|
57
|
+
} = import_core.__internalHelper);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
41
61
|
// src/inspectConfig.ts
|
|
42
62
|
var inspectConfig_exports = {};
|
|
43
63
|
__export(inspectConfig_exports, {
|
|
@@ -64,13 +84,13 @@ async function inspectConfig({
|
|
|
64
84
|
...context.normalizedConfig,
|
|
65
85
|
pluginNames: pluginManager.getPlugins().map((p) => p.name)
|
|
66
86
|
};
|
|
67
|
-
const rawRsbuildConfig = await
|
|
87
|
+
const rawRsbuildConfig = await stringifyConfig(
|
|
68
88
|
rsbuildDebugConfig,
|
|
69
89
|
inspectOptions.verbose
|
|
70
90
|
);
|
|
71
91
|
const rawBundlerConfigs = await Promise.all(
|
|
72
92
|
webpackConfigs.map(
|
|
73
|
-
(config) =>
|
|
93
|
+
(config) => stringifyConfig(config, inspectOptions.verbose)
|
|
74
94
|
)
|
|
75
95
|
);
|
|
76
96
|
let outputPath = inspectOptions.outputPath || context.distPath;
|
|
@@ -78,7 +98,7 @@ async function inspectConfig({
|
|
|
78
98
|
outputPath = (0, import_node_path.join)(context.rootPath, outputPath);
|
|
79
99
|
}
|
|
80
100
|
if (inspectOptions.writeToDisk) {
|
|
81
|
-
await
|
|
101
|
+
await outputInspectConfigFiles({
|
|
82
102
|
rsbuildConfig: context.normalizedConfig,
|
|
83
103
|
rawRsbuildConfig,
|
|
84
104
|
bundlerConfigs: rawBundlerConfigs,
|
|
@@ -105,57 +125,40 @@ var init_inspectConfig = __esm({
|
|
|
105
125
|
import_node_path = require("path");
|
|
106
126
|
import_shared = require("@rsbuild/shared");
|
|
107
127
|
init_initConfigs();
|
|
108
|
-
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
// src/shared.ts
|
|
112
|
-
var import_core, getChainUtils, initRsbuildConfig, createDevServer, startProdServer, formatStats, getDevMiddleware, getStatsOptions;
|
|
113
|
-
var init_shared = __esm({
|
|
114
|
-
"src/shared.ts"() {
|
|
115
|
-
"use strict";
|
|
116
|
-
import_core = require("@rsbuild/core");
|
|
117
|
-
({
|
|
118
|
-
getChainUtils,
|
|
119
|
-
initRsbuildConfig,
|
|
120
|
-
createDevServer,
|
|
121
|
-
startProdServer,
|
|
122
|
-
formatStats,
|
|
123
|
-
getDevMiddleware,
|
|
124
|
-
getStatsOptions
|
|
125
|
-
} = import_core.__internalHelper);
|
|
128
|
+
init_shared();
|
|
126
129
|
}
|
|
127
130
|
});
|
|
128
131
|
|
|
129
132
|
// src/webpackConfig.ts
|
|
130
133
|
async function modifyWebpackChain(context, utils, chain) {
|
|
131
|
-
(0,
|
|
134
|
+
(0, import_shared3.debug)("modify webpack chain");
|
|
132
135
|
const [modifiedChain] = await context.hooks.modifyWebpackChain.call(
|
|
133
136
|
chain,
|
|
134
137
|
utils
|
|
135
138
|
);
|
|
136
139
|
if (context.config.tools?.webpackChain) {
|
|
137
|
-
for (const item of (0,
|
|
140
|
+
for (const item of (0, import_shared3.castArray)(context.config.tools.webpackChain)) {
|
|
138
141
|
item(modifiedChain, utils);
|
|
139
142
|
}
|
|
140
143
|
}
|
|
141
|
-
(0,
|
|
144
|
+
(0, import_shared3.debug)("modify webpack chain done");
|
|
142
145
|
return modifiedChain;
|
|
143
146
|
}
|
|
144
147
|
async function modifyWebpackConfig(context, webpackConfig, utils) {
|
|
145
|
-
(0,
|
|
148
|
+
(0, import_shared3.debug)("modify webpack config");
|
|
146
149
|
let [modifiedConfig] = await context.hooks.modifyWebpackConfig.call(
|
|
147
150
|
webpackConfig,
|
|
148
151
|
utils
|
|
149
152
|
);
|
|
150
153
|
if (context.config.tools?.webpack) {
|
|
151
|
-
modifiedConfig = (0,
|
|
154
|
+
modifiedConfig = (0, import_shared3.reduceConfigsWithContext)({
|
|
152
155
|
initial: modifiedConfig,
|
|
153
156
|
config: context.config.tools.webpack,
|
|
154
157
|
ctx: utils,
|
|
155
158
|
mergeFn: utils.mergeConfig
|
|
156
159
|
});
|
|
157
160
|
}
|
|
158
|
-
(0,
|
|
161
|
+
(0, import_shared3.debug)("modify webpack config done");
|
|
159
162
|
return modifiedConfig;
|
|
160
163
|
}
|
|
161
164
|
async function getChainUtils2(target) {
|
|
@@ -179,7 +182,7 @@ async function getConfigUtils(config, chainUtils) {
|
|
|
179
182
|
...chainUtils,
|
|
180
183
|
mergeConfig: merge,
|
|
181
184
|
addRules(rules) {
|
|
182
|
-
const ruleArr = (0,
|
|
185
|
+
const ruleArr = (0, import_shared3.castArray)(rules);
|
|
183
186
|
if (!config.module) {
|
|
184
187
|
config.module = {};
|
|
185
188
|
}
|
|
@@ -189,14 +192,14 @@ async function getConfigUtils(config, chainUtils) {
|
|
|
189
192
|
config.module.rules.unshift(...ruleArr);
|
|
190
193
|
},
|
|
191
194
|
prependPlugins(plugins) {
|
|
192
|
-
const pluginArr = (0,
|
|
195
|
+
const pluginArr = (0, import_shared3.castArray)(plugins);
|
|
193
196
|
if (!config.plugins) {
|
|
194
197
|
config.plugins = [];
|
|
195
198
|
}
|
|
196
199
|
config.plugins.unshift(...pluginArr);
|
|
197
200
|
},
|
|
198
201
|
appendPlugins(plugins) {
|
|
199
|
-
const pluginArr = (0,
|
|
202
|
+
const pluginArr = (0, import_shared3.castArray)(plugins);
|
|
200
203
|
if (!config.plugins) {
|
|
201
204
|
config.plugins = [];
|
|
202
205
|
}
|
|
@@ -224,7 +227,7 @@ async function generateWebpackConfig({
|
|
|
224
227
|
ProvidePlugin,
|
|
225
228
|
HotModuleReplacementPlugin
|
|
226
229
|
} = webpack2;
|
|
227
|
-
const bundlerChain = await (0,
|
|
230
|
+
const bundlerChain = await (0, import_shared3.modifyBundlerChain)(context, {
|
|
228
231
|
...chainUtils,
|
|
229
232
|
bundler: {
|
|
230
233
|
BannerPlugin,
|
|
@@ -234,16 +237,8 @@ async function generateWebpackConfig({
|
|
|
234
237
|
HotModuleReplacementPlugin
|
|
235
238
|
}
|
|
236
239
|
});
|
|
237
|
-
const chain = await modifyWebpackChain(
|
|
238
|
-
|
|
239
|
-
chainUtils,
|
|
240
|
-
// module rules not support merge
|
|
241
|
-
// need a special rule merge or use bundlerChain as WebpackChain
|
|
242
|
-
bundlerChain
|
|
243
|
-
);
|
|
244
|
-
let webpackConfig = (0, import_shared2.chainToConfig)(
|
|
245
|
-
chain
|
|
246
|
-
);
|
|
240
|
+
const chain = await modifyWebpackChain(context, chainUtils, bundlerChain);
|
|
241
|
+
let webpackConfig = (0, import_shared3.chainToConfig)(chain);
|
|
247
242
|
webpackConfig = await modifyWebpackConfig(
|
|
248
243
|
context,
|
|
249
244
|
webpackConfig,
|
|
@@ -251,12 +246,12 @@ async function generateWebpackConfig({
|
|
|
251
246
|
);
|
|
252
247
|
return webpackConfig;
|
|
253
248
|
}
|
|
254
|
-
var import_core2,
|
|
249
|
+
var import_core2, import_shared3;
|
|
255
250
|
var init_webpackConfig = __esm({
|
|
256
251
|
"src/webpackConfig.ts"() {
|
|
257
252
|
"use strict";
|
|
258
253
|
import_core2 = require("@rsbuild/core");
|
|
259
|
-
|
|
254
|
+
import_shared3 = require("@rsbuild/shared");
|
|
260
255
|
init_shared();
|
|
261
256
|
}
|
|
262
257
|
});
|
|
@@ -275,7 +270,7 @@ async function initConfigs({
|
|
|
275
270
|
const webpackConfigs = await Promise.all(
|
|
276
271
|
targets.map((target) => generateWebpackConfig({ target, context }))
|
|
277
272
|
);
|
|
278
|
-
if ((0,
|
|
273
|
+
if ((0, import_shared5.isDebug)()) {
|
|
279
274
|
const inspect = () => {
|
|
280
275
|
const inspectOptions = {
|
|
281
276
|
verbose: true,
|
|
@@ -296,11 +291,11 @@ async function initConfigs({
|
|
|
296
291
|
webpackConfigs
|
|
297
292
|
};
|
|
298
293
|
}
|
|
299
|
-
var
|
|
294
|
+
var import_shared5;
|
|
300
295
|
var init_initConfigs = __esm({
|
|
301
296
|
"src/initConfigs.ts"() {
|
|
302
297
|
"use strict";
|
|
303
|
-
|
|
298
|
+
import_shared5 = require("@rsbuild/shared");
|
|
304
299
|
init_inspectConfig();
|
|
305
300
|
init_shared();
|
|
306
301
|
init_webpackConfig();
|
|
@@ -317,7 +312,7 @@ async function createCompiler({
|
|
|
317
312
|
context,
|
|
318
313
|
webpackConfigs
|
|
319
314
|
}) {
|
|
320
|
-
(0,
|
|
315
|
+
(0, import_shared7.debug)("create compiler");
|
|
321
316
|
await context.hooks.onBeforeCreateCompiler.call({
|
|
322
317
|
bundlerConfigs: webpackConfigs
|
|
323
318
|
});
|
|
@@ -334,7 +329,7 @@ async function createCompiler({
|
|
|
334
329
|
if (level === "warning") {
|
|
335
330
|
import_core3.logger.warn(message);
|
|
336
331
|
}
|
|
337
|
-
if ((0,
|
|
332
|
+
if ((0, import_shared7.isDev)()) {
|
|
338
333
|
await context.hooks.onDevCompileDone.call({
|
|
339
334
|
isFirstCompile,
|
|
340
335
|
stats
|
|
@@ -343,11 +338,11 @@ async function createCompiler({
|
|
|
343
338
|
isFirstCompile = false;
|
|
344
339
|
};
|
|
345
340
|
let isFirstCompile = true;
|
|
346
|
-
(0,
|
|
341
|
+
(0, import_shared7.onCompileDone)(compiler, done, import_MultiStats.default);
|
|
347
342
|
await context.hooks.onAfterCreateCompiler.call({
|
|
348
343
|
compiler
|
|
349
344
|
});
|
|
350
|
-
(0,
|
|
345
|
+
(0, import_shared7.debug)("create compiler done");
|
|
351
346
|
return compiler;
|
|
352
347
|
}
|
|
353
348
|
async function createDevMiddleware(options, customCompiler) {
|
|
@@ -366,12 +361,12 @@ async function createDevMiddleware(options, customCompiler) {
|
|
|
366
361
|
compiler
|
|
367
362
|
};
|
|
368
363
|
}
|
|
369
|
-
var import_core3,
|
|
364
|
+
var import_core3, import_shared7, import_MultiStats;
|
|
370
365
|
var init_createCompiler = __esm({
|
|
371
366
|
"src/createCompiler.ts"() {
|
|
372
367
|
"use strict";
|
|
373
368
|
import_core3 = require("@rsbuild/core");
|
|
374
|
-
|
|
369
|
+
import_shared7 = require("@rsbuild/shared");
|
|
375
370
|
import_MultiStats = __toESM(require("webpack/lib/MultiStats.js"));
|
|
376
371
|
init_initConfigs();
|
|
377
372
|
init_shared();
|
|
@@ -1827,11 +1822,11 @@ var init_utils = __esm({
|
|
|
1827
1822
|
});
|
|
1828
1823
|
|
|
1829
1824
|
// src/progress/helpers/bar.ts
|
|
1830
|
-
var
|
|
1825
|
+
var import_shared9, import_cli_truncate, defaultOption, padding, FULL_WIDTH, MIDDLE_WIDTH, renderBar;
|
|
1831
1826
|
var init_bar = __esm({
|
|
1832
1827
|
"src/progress/helpers/bar.ts"() {
|
|
1833
1828
|
"use strict";
|
|
1834
|
-
|
|
1829
|
+
import_shared9 = require("@rsbuild/shared");
|
|
1835
1830
|
import_cli_truncate = __toESM(require_cli_truncate());
|
|
1836
1831
|
init_utils();
|
|
1837
1832
|
defaultOption = {
|
|
@@ -1885,15 +1880,15 @@ var init_bar = __esm({
|
|
|
1885
1880
|
} = mergedOptions;
|
|
1886
1881
|
const space = " ".repeat(spaceWidth);
|
|
1887
1882
|
const percent = clamp(Math.floor(current / total * 100), 0, 100);
|
|
1888
|
-
const barColor =
|
|
1889
|
-
const backgroundColor =
|
|
1890
|
-
const doneColor = hasErrors ?
|
|
1883
|
+
const barColor = import_shared9.color[color];
|
|
1884
|
+
const backgroundColor = import_shared9.color[bgColor];
|
|
1885
|
+
const doneColor = hasErrors ? import_shared9.color.red : barColor;
|
|
1891
1886
|
const idColor = done ? doneColor : barColor;
|
|
1892
1887
|
const id = mergedOptions.id ? idColor(padding(mergedOptions.id, maxIdLen)) : "";
|
|
1893
1888
|
const { columns: terminalWidth = FULL_WIDTH } = process.stdout;
|
|
1894
1889
|
if (done) {
|
|
1895
1890
|
if (hasErrors) {
|
|
1896
|
-
const message2 =
|
|
1891
|
+
const message2 = import_shared9.color.bold(doneColor(errorInfo));
|
|
1897
1892
|
if (terminalWidth >= MIDDLE_WIDTH) {
|
|
1898
1893
|
return [idColor(errorIcon), id, doneColor(`${space}${message2}`)].join(
|
|
1899
1894
|
""
|
|
@@ -1903,7 +1898,7 @@ var init_bar = __esm({
|
|
|
1903
1898
|
}
|
|
1904
1899
|
return "";
|
|
1905
1900
|
}
|
|
1906
|
-
const msgStr =
|
|
1901
|
+
const msgStr = import_shared9.color[messageColor](
|
|
1907
1902
|
(0, import_cli_truncate.default)(message, messageWidth, { position: "start" })
|
|
1908
1903
|
);
|
|
1909
1904
|
const left = clamp(Math.floor(percent * width / 100), 0, width);
|
|
@@ -2093,16 +2088,17 @@ var init_log = __esm({
|
|
|
2093
2088
|
});
|
|
2094
2089
|
|
|
2095
2090
|
// src/progress/helpers/bus.ts
|
|
2096
|
-
var import_node_console,
|
|
2091
|
+
var import_node_console, import_cli_truncate2, import_patch_console, colorList, getProgressColor, Bus, bus;
|
|
2097
2092
|
var init_bus = __esm({
|
|
2098
2093
|
"src/progress/helpers/bus.ts"() {
|
|
2099
2094
|
"use strict";
|
|
2100
2095
|
import_node_console = require("console");
|
|
2101
|
-
import_shared9 = require("@rsbuild/shared");
|
|
2102
2096
|
import_cli_truncate2 = __toESM(require_cli_truncate());
|
|
2103
2097
|
import_patch_console = __toESM(require_build());
|
|
2104
2098
|
init_bar();
|
|
2105
2099
|
init_log();
|
|
2100
|
+
colorList = ["green", "cyan", "yellow", "blue", "magenta"];
|
|
2101
|
+
getProgressColor = (index) => colorList[index % colorList.length];
|
|
2106
2102
|
Bus = class {
|
|
2107
2103
|
constructor() {
|
|
2108
2104
|
__publicField(this, "states", []);
|
|
@@ -2142,7 +2138,7 @@ var init_bus = __esm({
|
|
|
2142
2138
|
this.prevOutput = this.states.map((i, k) => {
|
|
2143
2139
|
const bar = renderBar({
|
|
2144
2140
|
maxIdLen,
|
|
2145
|
-
color: i.color ??
|
|
2141
|
+
color: i.color ?? getProgressColor(k),
|
|
2146
2142
|
...i
|
|
2147
2143
|
});
|
|
2148
2144
|
if (bar) {
|
|
@@ -2234,24 +2230,24 @@ function createNonTTYLogger() {
|
|
|
2234
2230
|
}
|
|
2235
2231
|
prevPercentage = 100;
|
|
2236
2232
|
if (hasErrors) {
|
|
2237
|
-
|
|
2233
|
+
import_core4.logger.error(`${id} compile failed in ${compileTime}`);
|
|
2238
2234
|
} else {
|
|
2239
|
-
|
|
2235
|
+
import_core4.logger.ready(`${id} compiled in ${compileTime}`);
|
|
2240
2236
|
}
|
|
2241
2237
|
} else if (current - prevPercentage > 10) {
|
|
2242
2238
|
prevPercentage = current;
|
|
2243
|
-
|
|
2239
|
+
import_core4.logger.info(`${id} compile progress: ${current.toFixed(0)}%`);
|
|
2244
2240
|
}
|
|
2245
2241
|
};
|
|
2246
2242
|
return {
|
|
2247
2243
|
log
|
|
2248
2244
|
};
|
|
2249
2245
|
}
|
|
2250
|
-
var
|
|
2246
|
+
var import_core4;
|
|
2251
2247
|
var init_nonTty = __esm({
|
|
2252
2248
|
"src/progress/helpers/nonTty.ts"() {
|
|
2253
2249
|
"use strict";
|
|
2254
|
-
|
|
2250
|
+
import_core4 = require("@rsbuild/core");
|
|
2255
2251
|
}
|
|
2256
2252
|
});
|
|
2257
2253
|
|
|
@@ -2260,11 +2256,11 @@ var ProgressPlugin_exports = {};
|
|
|
2260
2256
|
__export(ProgressPlugin_exports, {
|
|
2261
2257
|
ProgressPlugin: () => ProgressPlugin
|
|
2262
2258
|
});
|
|
2263
|
-
var
|
|
2259
|
+
var import_shared10, import_webpack, ProgressPlugin;
|
|
2264
2260
|
var init_ProgressPlugin = __esm({
|
|
2265
2261
|
"src/progress/ProgressPlugin.ts"() {
|
|
2266
2262
|
"use strict";
|
|
2267
|
-
|
|
2263
|
+
import_shared10 = require("@rsbuild/shared");
|
|
2268
2264
|
import_webpack = __toESM(require("webpack"));
|
|
2269
2265
|
init_helpers();
|
|
2270
2266
|
init_nonTty();
|
|
@@ -2323,10 +2319,10 @@ var init_ProgressPlugin = __esm({
|
|
|
2323
2319
|
this.hasCompileErrors = stat.hasErrors();
|
|
2324
2320
|
const hrtime = process.hrtime(startTime);
|
|
2325
2321
|
const seconds = hrtime[0] + hrtime[1] / 1e9;
|
|
2326
|
-
this.compileTime = (0,
|
|
2322
|
+
this.compileTime = (0, import_shared10.prettyTime)(seconds);
|
|
2327
2323
|
startTime = null;
|
|
2328
2324
|
if (!this.hasCompileErrors) {
|
|
2329
|
-
|
|
2325
|
+
import_shared10.logger.ready(`${this.id} compiled in ${this.compileTime}`);
|
|
2330
2326
|
}
|
|
2331
2327
|
}
|
|
2332
2328
|
});
|
|
@@ -2357,18 +2353,18 @@ async function applyTsConfigPathsPlugin({
|
|
|
2357
2353
|
}
|
|
2358
2354
|
]);
|
|
2359
2355
|
}
|
|
2360
|
-
var import_node_fs,
|
|
2356
|
+
var import_node_fs, import_shared11, getMainFields, pluginAdaptor;
|
|
2361
2357
|
var init_plugin = __esm({
|
|
2362
2358
|
"src/plugin.ts"() {
|
|
2363
2359
|
"use strict";
|
|
2364
2360
|
import_node_fs = __toESM(require("fs"));
|
|
2365
|
-
|
|
2361
|
+
import_shared11 = require("@rsbuild/shared");
|
|
2366
2362
|
getMainFields = (chain, target) => {
|
|
2367
2363
|
const mainFields = chain.resolve.mainFields.values();
|
|
2368
2364
|
if (mainFields.length) {
|
|
2369
2365
|
return mainFields;
|
|
2370
2366
|
}
|
|
2371
|
-
if ((0,
|
|
2367
|
+
if ((0, import_shared11.isWebTarget)(target)) {
|
|
2372
2368
|
return ["browser", "module", "main"];
|
|
2373
2369
|
}
|
|
2374
2370
|
return ["module", "main"];
|
|
@@ -2392,7 +2388,7 @@ var init_plugin = __esm({
|
|
|
2392
2388
|
const { ProgressPlugin: ProgressPlugin2 } = await Promise.resolve().then(() => (init_ProgressPlugin(), ProgressPlugin_exports));
|
|
2393
2389
|
chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(ProgressPlugin2, [
|
|
2394
2390
|
{
|
|
2395
|
-
id:
|
|
2391
|
+
id: import_shared11.TARGET_ID_MAP[target],
|
|
2396
2392
|
...progress === true ? {} : progress
|
|
2397
2393
|
}
|
|
2398
2394
|
]);
|
|
@@ -2432,18 +2428,18 @@ var build_exports = {};
|
|
|
2432
2428
|
__export(build_exports, {
|
|
2433
2429
|
build: () => build
|
|
2434
2430
|
});
|
|
2435
|
-
var
|
|
2431
|
+
var import_core5, import_shared12, import_MultiStats2, build;
|
|
2436
2432
|
var init_build = __esm({
|
|
2437
2433
|
"src/build.ts"() {
|
|
2438
2434
|
"use strict";
|
|
2439
|
-
|
|
2440
|
-
|
|
2435
|
+
import_core5 = require("@rsbuild/core");
|
|
2436
|
+
import_shared12 = require("@rsbuild/shared");
|
|
2441
2437
|
import_MultiStats2 = __toESM(require("webpack/lib/MultiStats.js"));
|
|
2442
2438
|
init_createCompiler();
|
|
2443
2439
|
init_initConfigs();
|
|
2444
2440
|
build = async (initOptions, { mode = "production", watch, compiler: customCompiler } = {}) => {
|
|
2445
|
-
if (!(0,
|
|
2446
|
-
(0,
|
|
2441
|
+
if (!(0, import_shared12.getNodeEnv)()) {
|
|
2442
|
+
(0, import_shared12.setNodeEnv)(mode);
|
|
2447
2443
|
}
|
|
2448
2444
|
const { context } = initOptions;
|
|
2449
2445
|
let compiler;
|
|
@@ -2467,11 +2463,11 @@ var init_build = __esm({
|
|
|
2467
2463
|
isFirstCompile = false;
|
|
2468
2464
|
await p;
|
|
2469
2465
|
};
|
|
2470
|
-
(0,
|
|
2466
|
+
(0, import_shared12.onCompileDone)(compiler, onDone, import_MultiStats2.default);
|
|
2471
2467
|
if (watch) {
|
|
2472
2468
|
compiler.watch({}, (err) => {
|
|
2473
2469
|
if (err) {
|
|
2474
|
-
|
|
2470
|
+
import_core5.logger.error(err);
|
|
2475
2471
|
}
|
|
2476
2472
|
});
|
|
2477
2473
|
return;
|
|
@@ -2483,7 +2479,7 @@ var init_build = __esm({
|
|
|
2483
2479
|
reject(buildError);
|
|
2484
2480
|
} else {
|
|
2485
2481
|
compiler.close((closeErr) => {
|
|
2486
|
-
closeErr &&
|
|
2482
|
+
closeErr && import_core5.logger.error(closeErr);
|
|
2487
2483
|
resolve({ stats });
|
|
2488
2484
|
});
|
|
2489
2485
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -46,27 +46,43 @@ var __publicField = (obj, key, value) => {
|
|
|
46
46
|
return value;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
// ../../../node_modules/.pnpm/@modern-js+module-tools@2.
|
|
49
|
+
// ../../../node_modules/.pnpm/@modern-js+module-tools@2.52.0_eslint@9.4.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
|
|
50
50
|
import { fileURLToPath } from "url";
|
|
51
51
|
import path from "path";
|
|
52
52
|
var init_esm = __esm({
|
|
53
|
-
"../../../node_modules/.pnpm/@modern-js+module-tools@2.
|
|
53
|
+
"../../../node_modules/.pnpm/@modern-js+module-tools@2.52.0_eslint@9.4.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js"() {
|
|
54
54
|
"use strict";
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
+
// src/shared.ts
|
|
59
|
+
import { __internalHelper } from "@rsbuild/core";
|
|
60
|
+
var getChainUtils, initRsbuildConfig, createDevServer, startProdServer, formatStats, getDevMiddleware, getStatsOptions, stringifyConfig, outputInspectConfigFiles;
|
|
61
|
+
var init_shared = __esm({
|
|
62
|
+
"src/shared.ts"() {
|
|
63
|
+
"use strict";
|
|
64
|
+
init_esm();
|
|
65
|
+
({
|
|
66
|
+
getChainUtils,
|
|
67
|
+
initRsbuildConfig,
|
|
68
|
+
createDevServer,
|
|
69
|
+
startProdServer,
|
|
70
|
+
formatStats,
|
|
71
|
+
getDevMiddleware,
|
|
72
|
+
getStatsOptions,
|
|
73
|
+
stringifyConfig,
|
|
74
|
+
outputInspectConfigFiles
|
|
75
|
+
} = __internalHelper);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
58
79
|
// src/inspectConfig.ts
|
|
59
80
|
var inspectConfig_exports = {};
|
|
60
81
|
__export(inspectConfig_exports, {
|
|
61
82
|
inspectConfig: () => inspectConfig
|
|
62
83
|
});
|
|
63
84
|
import { isAbsolute, join } from "path";
|
|
64
|
-
import {
|
|
65
|
-
getNodeEnv,
|
|
66
|
-
outputInspectConfigFiles,
|
|
67
|
-
setNodeEnv,
|
|
68
|
-
stringifyConfig
|
|
69
|
-
} from "@rsbuild/shared";
|
|
85
|
+
import { getNodeEnv, setNodeEnv } from "@rsbuild/shared";
|
|
70
86
|
async function inspectConfig({
|
|
71
87
|
context,
|
|
72
88
|
pluginManager,
|
|
@@ -127,30 +143,14 @@ var init_inspectConfig = __esm({
|
|
|
127
143
|
"use strict";
|
|
128
144
|
init_esm();
|
|
129
145
|
init_initConfigs();
|
|
130
|
-
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
// src/shared.ts
|
|
134
|
-
import { __internalHelper } from "@rsbuild/core";
|
|
135
|
-
var getChainUtils, initRsbuildConfig, createDevServer, startProdServer, formatStats, getDevMiddleware, getStatsOptions;
|
|
136
|
-
var init_shared = __esm({
|
|
137
|
-
"src/shared.ts"() {
|
|
138
|
-
"use strict";
|
|
139
|
-
init_esm();
|
|
140
|
-
({
|
|
141
|
-
getChainUtils,
|
|
142
|
-
initRsbuildConfig,
|
|
143
|
-
createDevServer,
|
|
144
|
-
startProdServer,
|
|
145
|
-
formatStats,
|
|
146
|
-
getDevMiddleware,
|
|
147
|
-
getStatsOptions
|
|
148
|
-
} = __internalHelper);
|
|
146
|
+
init_shared();
|
|
149
147
|
}
|
|
150
148
|
});
|
|
151
149
|
|
|
152
150
|
// src/webpackConfig.ts
|
|
153
|
-
import {
|
|
151
|
+
import {
|
|
152
|
+
__internalHelper as __internalHelper2
|
|
153
|
+
} from "@rsbuild/core";
|
|
154
154
|
import {
|
|
155
155
|
castArray,
|
|
156
156
|
chainToConfig,
|
|
@@ -265,16 +265,8 @@ async function generateWebpackConfig({
|
|
|
265
265
|
HotModuleReplacementPlugin
|
|
266
266
|
}
|
|
267
267
|
});
|
|
268
|
-
const chain = await modifyWebpackChain(
|
|
269
|
-
|
|
270
|
-
chainUtils,
|
|
271
|
-
// module rules not support merge
|
|
272
|
-
// need a special rule merge or use bundlerChain as WebpackChain
|
|
273
|
-
bundlerChain
|
|
274
|
-
);
|
|
275
|
-
let webpackConfig = chainToConfig(
|
|
276
|
-
chain
|
|
277
|
-
);
|
|
268
|
+
const chain = await modifyWebpackChain(context, chainUtils, bundlerChain);
|
|
269
|
+
let webpackConfig = chainToConfig(chain);
|
|
278
270
|
webpackConfig = await modifyWebpackConfig(
|
|
279
271
|
context,
|
|
280
272
|
webpackConfig,
|
|
@@ -291,9 +283,7 @@ var init_webpackConfig = __esm({
|
|
|
291
283
|
});
|
|
292
284
|
|
|
293
285
|
// src/initConfigs.ts
|
|
294
|
-
import {
|
|
295
|
-
isDebug
|
|
296
|
-
} from "@rsbuild/shared";
|
|
286
|
+
import { isDebug } from "@rsbuild/shared";
|
|
297
287
|
async function initConfigs({
|
|
298
288
|
context,
|
|
299
289
|
pluginManager,
|
|
@@ -2147,8 +2137,7 @@ var init_log = __esm({
|
|
|
2147
2137
|
|
|
2148
2138
|
// src/progress/helpers/bus.ts
|
|
2149
2139
|
import { Console } from "console";
|
|
2150
|
-
|
|
2151
|
-
var import_cli_truncate2, import_patch_console, Bus, bus;
|
|
2140
|
+
var import_cli_truncate2, import_patch_console, colorList, getProgressColor, Bus, bus;
|
|
2152
2141
|
var init_bus = __esm({
|
|
2153
2142
|
"src/progress/helpers/bus.ts"() {
|
|
2154
2143
|
"use strict";
|
|
@@ -2157,6 +2146,8 @@ var init_bus = __esm({
|
|
|
2157
2146
|
import_patch_console = __toESM(require_build());
|
|
2158
2147
|
init_bar();
|
|
2159
2148
|
init_log();
|
|
2149
|
+
colorList = ["green", "cyan", "yellow", "blue", "magenta"];
|
|
2150
|
+
getProgressColor = (index) => colorList[index % colorList.length];
|
|
2160
2151
|
Bus = class {
|
|
2161
2152
|
constructor() {
|
|
2162
2153
|
__publicField(this, "states", []);
|
|
@@ -2276,7 +2267,7 @@ var init_helpers = __esm({
|
|
|
2276
2267
|
});
|
|
2277
2268
|
|
|
2278
2269
|
// src/progress/helpers/nonTty.ts
|
|
2279
|
-
import { logger as logger2 } from "@rsbuild/
|
|
2270
|
+
import { logger as logger2 } from "@rsbuild/core";
|
|
2280
2271
|
function createNonTTYLogger() {
|
|
2281
2272
|
let prevPercentage = 0;
|
|
2282
2273
|
const log = ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/webpack",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"homepage": "https://rsbuild.dev",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,12 +24,11 @@
|
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"copy-webpack-plugin": "9.1.0",
|
|
27
|
-
"mini-css-extract-plugin": "2.
|
|
28
|
-
"postcss": "^8.4.38",
|
|
27
|
+
"mini-css-extract-plugin": "2.9.0",
|
|
29
28
|
"tsconfig-paths-webpack-plugin": "4.1.0",
|
|
30
29
|
"webpack": "^5.91.0",
|
|
31
|
-
"@rsbuild/core": "0.7.
|
|
32
|
-
"@rsbuild/shared": "0.7.
|
|
30
|
+
"@rsbuild/core": "0.7.4",
|
|
31
|
+
"@rsbuild/shared": "0.7.4"
|
|
33
32
|
},
|
|
34
33
|
"devDependencies": {
|
|
35
34
|
"@types/node": "18.x",
|
|
@@ -37,7 +36,7 @@
|
|
|
37
36
|
"cli-truncate": "2.1.0",
|
|
38
37
|
"patch-console": "1.0.0",
|
|
39
38
|
"typescript": "^5.4.2",
|
|
40
|
-
"@scripts/test-helper": "0.7.
|
|
39
|
+
"@scripts/test-helper": "0.7.4"
|
|
41
40
|
},
|
|
42
41
|
"publishConfig": {
|
|
43
42
|
"access": "public",
|