@rsbuild/webpack 0.7.0-beta.2 → 0.7.0-beta.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 +160 -205
- package/dist/index.js +113 -181
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -109,58 +109,62 @@ var init_inspectConfig = __esm({
|
|
|
109
109
|
});
|
|
110
110
|
|
|
111
111
|
// src/shared.ts
|
|
112
|
-
var
|
|
112
|
+
var import_core, plugins, createContext, createPublicContext, getPluginAPI, getChainUtils, initRsbuildConfig, setCssExtractPlugin, createDevServer, startProdServer, formatStats, getDevMiddleware, getStatsOptions;
|
|
113
113
|
var init_shared = __esm({
|
|
114
114
|
"src/shared.ts"() {
|
|
115
115
|
"use strict";
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
116
|
+
import_core = require("@rsbuild/core");
|
|
117
|
+
({
|
|
118
|
+
plugins,
|
|
119
|
+
createContext,
|
|
120
|
+
createPublicContext,
|
|
121
|
+
getPluginAPI,
|
|
122
|
+
getChainUtils,
|
|
123
|
+
initRsbuildConfig,
|
|
124
|
+
setCssExtractPlugin,
|
|
125
|
+
createDevServer,
|
|
126
|
+
startProdServer,
|
|
127
|
+
formatStats,
|
|
128
|
+
getDevMiddleware,
|
|
129
|
+
getStatsOptions
|
|
130
|
+
} = import_core.__internalHelper);
|
|
126
131
|
}
|
|
127
132
|
});
|
|
128
133
|
|
|
129
134
|
// src/webpackConfig.ts
|
|
130
135
|
async function modifyWebpackChain(context, utils, chain) {
|
|
131
|
-
(0,
|
|
136
|
+
(0, import_shared2.debug)("modify webpack chain");
|
|
132
137
|
const [modifiedChain] = await context.hooks.modifyWebpackChain.call(
|
|
133
138
|
chain,
|
|
134
139
|
utils
|
|
135
140
|
);
|
|
136
141
|
if (context.config.tools?.webpackChain) {
|
|
137
|
-
for (const item of (0,
|
|
142
|
+
for (const item of (0, import_shared2.castArray)(context.config.tools.webpackChain)) {
|
|
138
143
|
item(modifiedChain, utils);
|
|
139
144
|
}
|
|
140
145
|
}
|
|
141
|
-
(0,
|
|
146
|
+
(0, import_shared2.debug)("modify webpack chain done");
|
|
142
147
|
return modifiedChain;
|
|
143
148
|
}
|
|
144
149
|
async function modifyWebpackConfig(context, webpackConfig, utils) {
|
|
145
|
-
(0,
|
|
150
|
+
(0, import_shared2.debug)("modify webpack config");
|
|
146
151
|
let [modifiedConfig] = await context.hooks.modifyWebpackConfig.call(
|
|
147
152
|
webpackConfig,
|
|
148
153
|
utils
|
|
149
154
|
);
|
|
150
155
|
if (context.config.tools?.webpack) {
|
|
151
|
-
modifiedConfig = (0,
|
|
156
|
+
modifiedConfig = (0, import_shared2.mergeChainedOptions)({
|
|
152
157
|
defaults: modifiedConfig,
|
|
153
158
|
options: context.config.tools.webpack,
|
|
154
159
|
utils,
|
|
155
160
|
mergeFn: utils.mergeConfig
|
|
156
161
|
});
|
|
157
162
|
}
|
|
158
|
-
(0,
|
|
163
|
+
(0, import_shared2.debug)("modify webpack config done");
|
|
159
164
|
return modifiedConfig;
|
|
160
165
|
}
|
|
161
|
-
async function
|
|
166
|
+
async function getChainUtils2(target) {
|
|
162
167
|
const { default: webpack2 } = await import("webpack");
|
|
163
|
-
const { getHTMLPlugin } = await import("@rsbuild/core/internal");
|
|
164
168
|
const nameMap = {
|
|
165
169
|
web: "client",
|
|
166
170
|
node: "server",
|
|
@@ -168,11 +172,10 @@ async function getChainUtils(target) {
|
|
|
168
172
|
"service-worker": "service-worker"
|
|
169
173
|
};
|
|
170
174
|
return {
|
|
171
|
-
...
|
|
175
|
+
...getChainUtils(target),
|
|
172
176
|
name: nameMap[target] || "",
|
|
173
177
|
webpack: webpack2,
|
|
174
|
-
|
|
175
|
-
HtmlWebpackPlugin: getHTMLPlugin()
|
|
178
|
+
HtmlWebpackPlugin: import_core2.__internalHelper.getHTMLPlugin()
|
|
176
179
|
};
|
|
177
180
|
}
|
|
178
181
|
async function getConfigUtils(config, chainUtils) {
|
|
@@ -181,7 +184,7 @@ async function getConfigUtils(config, chainUtils) {
|
|
|
181
184
|
...chainUtils,
|
|
182
185
|
mergeConfig: merge,
|
|
183
186
|
addRules(rules) {
|
|
184
|
-
const ruleArr = (0,
|
|
187
|
+
const ruleArr = (0, import_shared2.castArray)(rules);
|
|
185
188
|
if (!config.module) {
|
|
186
189
|
config.module = {};
|
|
187
190
|
}
|
|
@@ -191,14 +194,14 @@ async function getConfigUtils(config, chainUtils) {
|
|
|
191
194
|
config.module.rules.unshift(...ruleArr);
|
|
192
195
|
},
|
|
193
196
|
prependPlugins(plugins2) {
|
|
194
|
-
const pluginArr = (0,
|
|
197
|
+
const pluginArr = (0, import_shared2.castArray)(plugins2);
|
|
195
198
|
if (!config.plugins) {
|
|
196
199
|
config.plugins = [];
|
|
197
200
|
}
|
|
198
201
|
config.plugins.unshift(...pluginArr);
|
|
199
202
|
},
|
|
200
203
|
appendPlugins(plugins2) {
|
|
201
|
-
const pluginArr = (0,
|
|
204
|
+
const pluginArr = (0, import_shared2.castArray)(plugins2);
|
|
202
205
|
if (!config.plugins) {
|
|
203
206
|
config.plugins = [];
|
|
204
207
|
}
|
|
@@ -217,7 +220,7 @@ async function generateWebpackConfig({
|
|
|
217
220
|
target,
|
|
218
221
|
context
|
|
219
222
|
}) {
|
|
220
|
-
const chainUtils = await
|
|
223
|
+
const chainUtils = await getChainUtils2(target);
|
|
221
224
|
const { default: webpack2 } = await import("webpack");
|
|
222
225
|
const {
|
|
223
226
|
BannerPlugin,
|
|
@@ -226,7 +229,7 @@ async function generateWebpackConfig({
|
|
|
226
229
|
ProvidePlugin,
|
|
227
230
|
HotModuleReplacementPlugin
|
|
228
231
|
} = webpack2;
|
|
229
|
-
const bundlerChain = await (0,
|
|
232
|
+
const bundlerChain = await (0, import_shared2.modifyBundlerChain)(context, {
|
|
230
233
|
...chainUtils,
|
|
231
234
|
bundler: {
|
|
232
235
|
BannerPlugin,
|
|
@@ -243,7 +246,7 @@ async function generateWebpackConfig({
|
|
|
243
246
|
// need a special rule merge or use bundlerChain as WebpackChain
|
|
244
247
|
bundlerChain
|
|
245
248
|
);
|
|
246
|
-
let webpackConfig = (0,
|
|
249
|
+
let webpackConfig = (0, import_shared2.chainToConfig)(
|
|
247
250
|
chain
|
|
248
251
|
);
|
|
249
252
|
webpackConfig = await modifyWebpackConfig(
|
|
@@ -253,12 +256,12 @@ async function generateWebpackConfig({
|
|
|
253
256
|
);
|
|
254
257
|
return webpackConfig;
|
|
255
258
|
}
|
|
256
|
-
var
|
|
259
|
+
var import_core2, import_shared2;
|
|
257
260
|
var init_webpackConfig = __esm({
|
|
258
261
|
"src/webpackConfig.ts"() {
|
|
259
262
|
"use strict";
|
|
260
|
-
|
|
261
|
-
|
|
263
|
+
import_core2 = require("@rsbuild/core");
|
|
264
|
+
import_shared2 = require("@rsbuild/shared");
|
|
262
265
|
init_shared();
|
|
263
266
|
}
|
|
264
267
|
});
|
|
@@ -269,7 +272,7 @@ async function initConfigs({
|
|
|
269
272
|
pluginManager,
|
|
270
273
|
rsbuildOptions
|
|
271
274
|
}) {
|
|
272
|
-
const normalizedConfig = await
|
|
275
|
+
const normalizedConfig = await initRsbuildConfig({
|
|
273
276
|
context,
|
|
274
277
|
pluginManager
|
|
275
278
|
});
|
|
@@ -277,7 +280,7 @@ async function initConfigs({
|
|
|
277
280
|
const webpackConfigs = await Promise.all(
|
|
278
281
|
targets.map((target) => generateWebpackConfig({ target, context }))
|
|
279
282
|
);
|
|
280
|
-
if ((0,
|
|
283
|
+
if ((0, import_shared4.isDebug)()) {
|
|
281
284
|
const inspect = () => {
|
|
282
285
|
const inspectOptions = {
|
|
283
286
|
verbose: true,
|
|
@@ -298,13 +301,13 @@ async function initConfigs({
|
|
|
298
301
|
webpackConfigs
|
|
299
302
|
};
|
|
300
303
|
}
|
|
301
|
-
var
|
|
304
|
+
var import_shared4;
|
|
302
305
|
var init_initConfigs = __esm({
|
|
303
306
|
"src/initConfigs.ts"() {
|
|
304
307
|
"use strict";
|
|
305
|
-
|
|
306
|
-
import_shared5 = require("@rsbuild/shared");
|
|
308
|
+
import_shared4 = require("@rsbuild/shared");
|
|
307
309
|
init_inspectConfig();
|
|
310
|
+
init_shared();
|
|
308
311
|
init_webpackConfig();
|
|
309
312
|
}
|
|
310
313
|
});
|
|
@@ -326,9 +329,9 @@ async function createCompiler({
|
|
|
326
329
|
const { default: webpack2 } = await import("webpack");
|
|
327
330
|
const compiler = webpackConfigs.length === 1 ? webpack2(webpackConfigs[0]) : webpack2(webpackConfigs);
|
|
328
331
|
const done = async (stats) => {
|
|
329
|
-
const { message, level } =
|
|
332
|
+
const { message, level } = formatStats(
|
|
330
333
|
stats,
|
|
331
|
-
|
|
334
|
+
getStatsOptions(compiler)
|
|
332
335
|
);
|
|
333
336
|
if (level === "error") {
|
|
334
337
|
import_shared6.logger.error(message);
|
|
@@ -364,122 +367,18 @@ async function createDevMiddleware(options, customCompiler) {
|
|
|
364
367
|
});
|
|
365
368
|
}
|
|
366
369
|
return {
|
|
367
|
-
devMiddleware:
|
|
370
|
+
devMiddleware: getDevMiddleware(compiler),
|
|
368
371
|
compiler
|
|
369
372
|
};
|
|
370
373
|
}
|
|
371
|
-
var
|
|
374
|
+
var import_shared6, import_MultiStats;
|
|
372
375
|
var init_createCompiler = __esm({
|
|
373
376
|
"src/createCompiler.ts"() {
|
|
374
377
|
"use strict";
|
|
375
|
-
import_internal3 = require("@rsbuild/core/internal");
|
|
376
378
|
import_shared6 = require("@rsbuild/shared");
|
|
377
379
|
import_MultiStats = __toESM(require("webpack/lib/MultiStats.js"));
|
|
378
380
|
init_initConfigs();
|
|
379
|
-
|
|
380
|
-
});
|
|
381
|
-
|
|
382
|
-
// src/plugins/resolve.ts
|
|
383
|
-
var resolve_exports = {};
|
|
384
|
-
__export(resolve_exports, {
|
|
385
|
-
pluginResolve: () => pluginResolve
|
|
386
|
-
});
|
|
387
|
-
async function applyTsConfigPathsPlugin({
|
|
388
|
-
chain,
|
|
389
|
-
CHAIN_ID,
|
|
390
|
-
mainFields,
|
|
391
|
-
extensions,
|
|
392
|
-
configFile
|
|
393
|
-
}) {
|
|
394
|
-
const { TsconfigPathsPlugin } = await import("tsconfig-paths-webpack-plugin");
|
|
395
|
-
chain.resolve.plugin(CHAIN_ID.RESOLVE_PLUGIN.TS_CONFIG_PATHS).use(TsconfigPathsPlugin, [
|
|
396
|
-
{
|
|
397
|
-
configFile,
|
|
398
|
-
extensions,
|
|
399
|
-
// https://github.com/dividab/tsconfig-paths-webpack-plugin/pull/106
|
|
400
|
-
mainFields
|
|
401
|
-
}
|
|
402
|
-
]);
|
|
403
|
-
}
|
|
404
|
-
var import_shared7, getMainFields, pluginResolve;
|
|
405
|
-
var init_resolve = __esm({
|
|
406
|
-
"src/plugins/resolve.ts"() {
|
|
407
|
-
"use strict";
|
|
408
|
-
import_shared7 = require("@rsbuild/shared");
|
|
409
|
-
getMainFields = (chain, target) => {
|
|
410
|
-
const mainFields = chain.resolve.mainFields.values();
|
|
411
|
-
if (mainFields.length) {
|
|
412
|
-
return mainFields;
|
|
413
|
-
}
|
|
414
|
-
if ((0, import_shared7.isWebTarget)(target)) {
|
|
415
|
-
return ["browser", "module", "main"];
|
|
416
|
-
}
|
|
417
|
-
return ["module", "main"];
|
|
418
|
-
};
|
|
419
|
-
pluginResolve = () => ({
|
|
420
|
-
name: "rsbuild-webpack:resolve",
|
|
421
|
-
setup(api) {
|
|
422
|
-
(0, import_shared7.applyResolvePlugin)(api);
|
|
423
|
-
api.modifyBundlerChain(async (chain, { CHAIN_ID, target }) => {
|
|
424
|
-
const config = api.getNormalizedConfig();
|
|
425
|
-
if (api.context.tsconfigPath && config.source.aliasStrategy === "prefer-tsconfig") {
|
|
426
|
-
await applyTsConfigPathsPlugin({
|
|
427
|
-
chain,
|
|
428
|
-
CHAIN_ID,
|
|
429
|
-
configFile: api.context.tsconfigPath,
|
|
430
|
-
mainFields: getMainFields(chain, target),
|
|
431
|
-
extensions: chain.resolve.extensions.values()
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
});
|
|
439
|
-
|
|
440
|
-
// src/plugins/copy.ts
|
|
441
|
-
var copy_exports = {};
|
|
442
|
-
__export(copy_exports, {
|
|
443
|
-
pluginCopy: () => pluginCopy
|
|
444
|
-
});
|
|
445
|
-
var import_node_fs2, pluginCopy;
|
|
446
|
-
var init_copy = __esm({
|
|
447
|
-
"src/plugins/copy.ts"() {
|
|
448
|
-
"use strict";
|
|
449
|
-
import_node_fs2 = __toESM(require("fs"));
|
|
450
|
-
pluginCopy = () => ({
|
|
451
|
-
name: "rsbuild-webpack:copy",
|
|
452
|
-
setup(api) {
|
|
453
|
-
api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
|
|
454
|
-
const config = api.getNormalizedConfig();
|
|
455
|
-
const { copy } = config.output;
|
|
456
|
-
if (!copy) {
|
|
457
|
-
return;
|
|
458
|
-
}
|
|
459
|
-
const { default: CopyPlugin } = await import(
|
|
460
|
-
// @ts-expect-error copy-webpack-plugin does not provide types
|
|
461
|
-
"copy-webpack-plugin"
|
|
462
|
-
);
|
|
463
|
-
const options = Array.isArray(copy) ? { patterns: copy } : copy;
|
|
464
|
-
chain.plugin(CHAIN_ID.PLUGIN.COPY).use(CopyPlugin, [options]);
|
|
465
|
-
});
|
|
466
|
-
api.modifyWebpackConfig(async (config) => {
|
|
467
|
-
const copyPlugin = config.plugins?.find(
|
|
468
|
-
(item) => item?.constructor.name === "CopyPlugin"
|
|
469
|
-
);
|
|
470
|
-
if (copyPlugin) {
|
|
471
|
-
const isContextNotExists = copyPlugin.patterns.every(
|
|
472
|
-
(pattern) => typeof pattern !== "string" && pattern.context && !import_node_fs2.default.existsSync(pattern.context)
|
|
473
|
-
);
|
|
474
|
-
if (isContextNotExists) {
|
|
475
|
-
config.plugins = config.plugins?.filter(
|
|
476
|
-
(item) => item?.constructor.name !== "CopyPlugin"
|
|
477
|
-
);
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
});
|
|
481
|
-
}
|
|
482
|
-
});
|
|
381
|
+
init_shared();
|
|
483
382
|
}
|
|
484
383
|
});
|
|
485
384
|
|
|
@@ -2440,32 +2339,92 @@ var init_ProgressPlugin = __esm({
|
|
|
2440
2339
|
}
|
|
2441
2340
|
});
|
|
2442
2341
|
|
|
2443
|
-
// src/
|
|
2444
|
-
var
|
|
2445
|
-
__export(
|
|
2446
|
-
|
|
2342
|
+
// src/plugin.ts
|
|
2343
|
+
var plugin_exports = {};
|
|
2344
|
+
__export(plugin_exports, {
|
|
2345
|
+
pluginAdaptor: () => pluginAdaptor
|
|
2447
2346
|
});
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2347
|
+
async function applyTsConfigPathsPlugin({
|
|
2348
|
+
chain,
|
|
2349
|
+
CHAIN_ID,
|
|
2350
|
+
mainFields,
|
|
2351
|
+
extensions,
|
|
2352
|
+
configFile
|
|
2353
|
+
}) {
|
|
2354
|
+
const { TsconfigPathsPlugin } = await import("tsconfig-paths-webpack-plugin");
|
|
2355
|
+
chain.resolve.plugin(CHAIN_ID.RESOLVE_PLUGIN.TS_CONFIG_PATHS).use(TsconfigPathsPlugin, [
|
|
2356
|
+
{
|
|
2357
|
+
configFile,
|
|
2358
|
+
extensions,
|
|
2359
|
+
// https://github.com/dividab/tsconfig-paths-webpack-plugin/pull/106
|
|
2360
|
+
mainFields
|
|
2361
|
+
}
|
|
2362
|
+
]);
|
|
2363
|
+
}
|
|
2364
|
+
var import_node_fs, import_shared12, getMainFields, pluginAdaptor;
|
|
2365
|
+
var init_plugin = __esm({
|
|
2366
|
+
"src/plugin.ts"() {
|
|
2451
2367
|
"use strict";
|
|
2368
|
+
import_node_fs = __toESM(require("fs"));
|
|
2452
2369
|
import_shared12 = require("@rsbuild/shared");
|
|
2453
|
-
|
|
2454
|
-
|
|
2370
|
+
getMainFields = (chain, target) => {
|
|
2371
|
+
const mainFields = chain.resolve.mainFields.values();
|
|
2372
|
+
if (mainFields.length) {
|
|
2373
|
+
return mainFields;
|
|
2374
|
+
}
|
|
2375
|
+
if ((0, import_shared12.isWebTarget)(target)) {
|
|
2376
|
+
return ["browser", "module", "main"];
|
|
2377
|
+
}
|
|
2378
|
+
return ["module", "main"];
|
|
2379
|
+
};
|
|
2380
|
+
pluginAdaptor = () => ({
|
|
2381
|
+
name: "rsbuild-webpack:adaptor",
|
|
2455
2382
|
setup(api) {
|
|
2456
|
-
api.modifyBundlerChain(async (chain, {
|
|
2383
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID, target }) => {
|
|
2457
2384
|
const config = api.getNormalizedConfig();
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2385
|
+
if (api.context.tsconfigPath && config.source.aliasStrategy === "prefer-tsconfig") {
|
|
2386
|
+
await applyTsConfigPathsPlugin({
|
|
2387
|
+
chain,
|
|
2388
|
+
CHAIN_ID,
|
|
2389
|
+
configFile: api.context.tsconfigPath,
|
|
2390
|
+
mainFields: getMainFields(chain, target),
|
|
2391
|
+
extensions: chain.resolve.extensions.values()
|
|
2392
|
+
});
|
|
2393
|
+
}
|
|
2394
|
+
const progress = config.dev.progressBar ?? true;
|
|
2395
|
+
if (progress) {
|
|
2396
|
+
const { ProgressPlugin: ProgressPlugin2 } = await Promise.resolve().then(() => (init_ProgressPlugin(), ProgressPlugin_exports));
|
|
2397
|
+
chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(ProgressPlugin2, [
|
|
2398
|
+
{
|
|
2399
|
+
id: import_shared12.TARGET_ID_MAP[target],
|
|
2400
|
+
...progress === true ? {} : progress
|
|
2401
|
+
}
|
|
2402
|
+
]);
|
|
2461
2403
|
}
|
|
2462
|
-
const {
|
|
2463
|
-
|
|
2464
|
-
{
|
|
2465
|
-
|
|
2466
|
-
|
|
2404
|
+
const { copy } = config.output;
|
|
2405
|
+
if (copy) {
|
|
2406
|
+
const { default: CopyPlugin } = await import(
|
|
2407
|
+
// @ts-expect-error copy-webpack-plugin does not provide types
|
|
2408
|
+
"copy-webpack-plugin"
|
|
2409
|
+
);
|
|
2410
|
+
const options = Array.isArray(copy) ? { patterns: copy } : copy;
|
|
2411
|
+
chain.plugin(CHAIN_ID.PLUGIN.COPY).use(CopyPlugin, [options]);
|
|
2412
|
+
}
|
|
2413
|
+
});
|
|
2414
|
+
api.modifyWebpackConfig(async (config) => {
|
|
2415
|
+
const copyPlugin = config.plugins?.find(
|
|
2416
|
+
(item) => item?.constructor.name === "CopyPlugin"
|
|
2417
|
+
);
|
|
2418
|
+
if (copyPlugin) {
|
|
2419
|
+
const isContextNotExists = copyPlugin.patterns.every(
|
|
2420
|
+
(pattern) => typeof pattern !== "string" && pattern.context && !import_node_fs.default.existsSync(pattern.context)
|
|
2421
|
+
);
|
|
2422
|
+
if (isContextNotExists) {
|
|
2423
|
+
config.plugins = config.plugins?.filter(
|
|
2424
|
+
(item) => item?.constructor.name !== "CopyPlugin"
|
|
2425
|
+
);
|
|
2467
2426
|
}
|
|
2468
|
-
|
|
2427
|
+
}
|
|
2469
2428
|
});
|
|
2470
2429
|
}
|
|
2471
2430
|
});
|
|
@@ -2545,19 +2504,19 @@ __export(src_exports, {
|
|
|
2545
2504
|
module.exports = __toCommonJS(src_exports);
|
|
2546
2505
|
|
|
2547
2506
|
// src/provider.ts
|
|
2548
|
-
var import_internal4 = require("@rsbuild/core/internal");
|
|
2549
2507
|
var import_shared14 = require("@rsbuild/shared");
|
|
2550
2508
|
init_initConfigs();
|
|
2509
|
+
init_shared();
|
|
2551
2510
|
var webpackProvider = async ({
|
|
2552
2511
|
pluginManager,
|
|
2553
2512
|
rsbuildOptions
|
|
2554
2513
|
}) => {
|
|
2555
2514
|
const rsbuildConfig = (0, import_shared14.pickRsbuildConfig)(rsbuildOptions.rsbuildConfig);
|
|
2556
|
-
const context = await
|
|
2557
|
-
const pluginAPI =
|
|
2515
|
+
const context = await createContext(rsbuildOptions, rsbuildConfig, "webpack");
|
|
2516
|
+
const pluginAPI = getPluginAPI({ context, pluginManager });
|
|
2558
2517
|
context.pluginAPI = pluginAPI;
|
|
2559
2518
|
const { default: cssExtractPlugin } = await import("mini-css-extract-plugin");
|
|
2560
|
-
|
|
2519
|
+
setCssExtractPlugin(cssExtractPlugin);
|
|
2561
2520
|
const createCompiler2 = async () => {
|
|
2562
2521
|
const { createCompiler: createCompiler3 } = await Promise.resolve().then(() => (init_createCompiler(), createCompiler_exports));
|
|
2563
2522
|
const { webpackConfigs } = await initConfigs({
|
|
@@ -2571,42 +2530,41 @@ var webpackProvider = async ({
|
|
|
2571
2530
|
bundler: "webpack",
|
|
2572
2531
|
pluginAPI,
|
|
2573
2532
|
createCompiler: createCompiler2,
|
|
2574
|
-
publicContext:
|
|
2533
|
+
publicContext: createPublicContext(context),
|
|
2575
2534
|
async applyDefaultPlugins() {
|
|
2576
2535
|
const allPlugins = await Promise.all([
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
import_internal4.plugins.html(async (tags) => {
|
|
2536
|
+
plugins.basic(),
|
|
2537
|
+
plugins.entry(),
|
|
2538
|
+
plugins.cache(),
|
|
2539
|
+
plugins.target(),
|
|
2540
|
+
plugins.output(),
|
|
2541
|
+
plugins.resolve(),
|
|
2542
|
+
plugins.fileSize(),
|
|
2543
|
+
plugins.cleanOutput(),
|
|
2544
|
+
plugins.asset(),
|
|
2545
|
+
plugins.html(async (tags) => {
|
|
2588
2546
|
const result = await context.hooks.modifyHTMLTags.call(tags);
|
|
2589
2547
|
return result[0];
|
|
2590
2548
|
}),
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2549
|
+
plugins.wasm(),
|
|
2550
|
+
plugins.moment(),
|
|
2551
|
+
plugins.nodeAddons(),
|
|
2552
|
+
plugins.define(),
|
|
2553
|
+
plugins.css(),
|
|
2554
|
+
plugins.less(),
|
|
2555
|
+
plugins.sass(),
|
|
2556
|
+
plugins.bundleAnalyzer(),
|
|
2557
|
+
plugins.rsdoctor(),
|
|
2558
|
+
plugins.splitChunks(),
|
|
2559
|
+
plugins.startUrl(),
|
|
2560
|
+
plugins.inlineChunk(),
|
|
2561
|
+
plugins.externals(),
|
|
2562
|
+
plugins.performance(),
|
|
2563
|
+
plugins.resourceHints(),
|
|
2564
|
+
plugins.server(),
|
|
2565
|
+
plugins.moduleFederation(),
|
|
2566
|
+
plugins.manifest(),
|
|
2567
|
+
Promise.resolve().then(() => (init_plugin(), plugin_exports)).then((m) => m.pluginAdaptor())
|
|
2610
2568
|
]);
|
|
2611
2569
|
pluginManager.addPlugins(allPlugins);
|
|
2612
2570
|
},
|
|
@@ -2619,9 +2577,8 @@ var webpackProvider = async ({
|
|
|
2619
2577
|
return webpackConfigs;
|
|
2620
2578
|
},
|
|
2621
2579
|
async createDevServer(options) {
|
|
2622
|
-
const { createDevServer } = await import("@rsbuild/core/internal");
|
|
2623
2580
|
const { createDevMiddleware: createDevMiddleware2 } = await Promise.resolve().then(() => (init_createCompiler(), createCompiler_exports));
|
|
2624
|
-
await
|
|
2581
|
+
await initRsbuildConfig({ context, pluginManager });
|
|
2625
2582
|
return createDevServer(
|
|
2626
2583
|
{ context, pluginManager, rsbuildOptions },
|
|
2627
2584
|
createDevMiddleware2,
|
|
@@ -2629,9 +2586,8 @@ var webpackProvider = async ({
|
|
|
2629
2586
|
);
|
|
2630
2587
|
},
|
|
2631
2588
|
async startDevServer(options) {
|
|
2632
|
-
const { createDevServer } = await import("@rsbuild/core/internal");
|
|
2633
2589
|
const { createDevMiddleware: createDevMiddleware2 } = await Promise.resolve().then(() => (init_createCompiler(), createCompiler_exports));
|
|
2634
|
-
await
|
|
2590
|
+
await initRsbuildConfig({
|
|
2635
2591
|
context,
|
|
2636
2592
|
pluginManager
|
|
2637
2593
|
});
|
|
@@ -2647,8 +2603,7 @@ var webpackProvider = async ({
|
|
|
2647
2603
|
return server.listen();
|
|
2648
2604
|
},
|
|
2649
2605
|
async preview(options) {
|
|
2650
|
-
|
|
2651
|
-
await (0, import_internal4.initRsbuildConfig)({
|
|
2606
|
+
await initRsbuildConfig({
|
|
2652
2607
|
context,
|
|
2653
2608
|
pluginManager
|
|
2654
2609
|
});
|
package/dist/index.js
CHANGED
|
@@ -49,13 +49,9 @@ var __publicField = (obj, key, value) => {
|
|
|
49
49
|
// ../../../node_modules/.pnpm/@modern-js+module-tools@2.49.3_eslint@8.57.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
|
-
var getFilename, getDirname, __dirname;
|
|
53
52
|
var init_esm = __esm({
|
|
54
53
|
"../../../node_modules/.pnpm/@modern-js+module-tools@2.49.3_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js"() {
|
|
55
54
|
"use strict";
|
|
56
|
-
getFilename = () => fileURLToPath(import.meta.url);
|
|
57
|
-
getDirname = () => path.dirname(getFilename());
|
|
58
|
-
__dirname = /* @__PURE__ */ getDirname();
|
|
59
55
|
}
|
|
60
56
|
});
|
|
61
57
|
|
|
@@ -135,30 +131,31 @@ var init_inspectConfig = __esm({
|
|
|
135
131
|
});
|
|
136
132
|
|
|
137
133
|
// src/shared.ts
|
|
138
|
-
import
|
|
139
|
-
|
|
140
|
-
import {
|
|
141
|
-
getSharedPkgCompiledPath
|
|
142
|
-
} from "@rsbuild/shared";
|
|
143
|
-
var getCompiledPath;
|
|
134
|
+
import { __internalHelper } from "@rsbuild/core";
|
|
135
|
+
var plugins, createContext, createPublicContext, getPluginAPI, getChainUtils, initRsbuildConfig, setCssExtractPlugin, createDevServer, startProdServer, formatStats, getDevMiddleware, getStatsOptions;
|
|
144
136
|
var init_shared = __esm({
|
|
145
137
|
"src/shared.ts"() {
|
|
146
138
|
"use strict";
|
|
147
139
|
init_esm();
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
140
|
+
({
|
|
141
|
+
plugins,
|
|
142
|
+
createContext,
|
|
143
|
+
createPublicContext,
|
|
144
|
+
getPluginAPI,
|
|
145
|
+
getChainUtils,
|
|
146
|
+
initRsbuildConfig,
|
|
147
|
+
setCssExtractPlugin,
|
|
148
|
+
createDevServer,
|
|
149
|
+
startProdServer,
|
|
150
|
+
formatStats,
|
|
151
|
+
getDevMiddleware,
|
|
152
|
+
getStatsOptions
|
|
153
|
+
} = __internalHelper);
|
|
155
154
|
}
|
|
156
155
|
});
|
|
157
156
|
|
|
158
157
|
// src/webpackConfig.ts
|
|
159
|
-
import {
|
|
160
|
-
getChainUtils as getBaseChainUtils
|
|
161
|
-
} from "@rsbuild/core/internal";
|
|
158
|
+
import { __internalHelper as __internalHelper2 } from "@rsbuild/core";
|
|
162
159
|
import {
|
|
163
160
|
castArray,
|
|
164
161
|
chainToConfig,
|
|
@@ -197,9 +194,8 @@ async function modifyWebpackConfig(context, webpackConfig, utils) {
|
|
|
197
194
|
debug("modify webpack config done");
|
|
198
195
|
return modifiedConfig;
|
|
199
196
|
}
|
|
200
|
-
async function
|
|
197
|
+
async function getChainUtils2(target) {
|
|
201
198
|
const { default: webpack2 } = await import("webpack");
|
|
202
|
-
const { getHTMLPlugin } = await import("@rsbuild/core/internal");
|
|
203
199
|
const nameMap = {
|
|
204
200
|
web: "client",
|
|
205
201
|
node: "server",
|
|
@@ -207,11 +203,10 @@ async function getChainUtils(target) {
|
|
|
207
203
|
"service-worker": "service-worker"
|
|
208
204
|
};
|
|
209
205
|
return {
|
|
210
|
-
...
|
|
206
|
+
...getChainUtils(target),
|
|
211
207
|
name: nameMap[target] || "",
|
|
212
208
|
webpack: webpack2,
|
|
213
|
-
|
|
214
|
-
HtmlWebpackPlugin: getHTMLPlugin()
|
|
209
|
+
HtmlWebpackPlugin: __internalHelper2.getHTMLPlugin()
|
|
215
210
|
};
|
|
216
211
|
}
|
|
217
212
|
async function getConfigUtils(config, chainUtils) {
|
|
@@ -256,7 +251,7 @@ async function generateWebpackConfig({
|
|
|
256
251
|
target,
|
|
257
252
|
context
|
|
258
253
|
}) {
|
|
259
|
-
const chainUtils = await
|
|
254
|
+
const chainUtils = await getChainUtils2(target);
|
|
260
255
|
const { default: webpack2 } = await import("webpack");
|
|
261
256
|
const {
|
|
262
257
|
BannerPlugin,
|
|
@@ -301,9 +296,6 @@ var init_webpackConfig = __esm({
|
|
|
301
296
|
});
|
|
302
297
|
|
|
303
298
|
// src/initConfigs.ts
|
|
304
|
-
import {
|
|
305
|
-
initRsbuildConfig
|
|
306
|
-
} from "@rsbuild/core/internal";
|
|
307
299
|
import {
|
|
308
300
|
isDebug
|
|
309
301
|
} from "@rsbuild/shared";
|
|
@@ -346,6 +338,7 @@ var init_initConfigs = __esm({
|
|
|
346
338
|
"use strict";
|
|
347
339
|
init_esm();
|
|
348
340
|
init_inspectConfig();
|
|
341
|
+
init_shared();
|
|
349
342
|
init_webpackConfig();
|
|
350
343
|
}
|
|
351
344
|
});
|
|
@@ -356,11 +349,6 @@ __export(createCompiler_exports, {
|
|
|
356
349
|
createCompiler: () => createCompiler,
|
|
357
350
|
createDevMiddleware: () => createDevMiddleware
|
|
358
351
|
});
|
|
359
|
-
import {
|
|
360
|
-
formatStats,
|
|
361
|
-
getDevMiddleware,
|
|
362
|
-
getStatsOptions
|
|
363
|
-
} from "@rsbuild/core/internal";
|
|
364
352
|
import {
|
|
365
353
|
debug as debug2,
|
|
366
354
|
isDev,
|
|
@@ -426,115 +414,7 @@ var init_createCompiler = __esm({
|
|
|
426
414
|
"use strict";
|
|
427
415
|
init_esm();
|
|
428
416
|
init_initConfigs();
|
|
429
|
-
|
|
430
|
-
});
|
|
431
|
-
|
|
432
|
-
// src/plugins/resolve.ts
|
|
433
|
-
var resolve_exports = {};
|
|
434
|
-
__export(resolve_exports, {
|
|
435
|
-
pluginResolve: () => pluginResolve
|
|
436
|
-
});
|
|
437
|
-
import {
|
|
438
|
-
applyResolvePlugin,
|
|
439
|
-
isWebTarget
|
|
440
|
-
} from "@rsbuild/shared";
|
|
441
|
-
async function applyTsConfigPathsPlugin({
|
|
442
|
-
chain,
|
|
443
|
-
CHAIN_ID,
|
|
444
|
-
mainFields,
|
|
445
|
-
extensions,
|
|
446
|
-
configFile
|
|
447
|
-
}) {
|
|
448
|
-
const { TsconfigPathsPlugin } = await import("tsconfig-paths-webpack-plugin");
|
|
449
|
-
chain.resolve.plugin(CHAIN_ID.RESOLVE_PLUGIN.TS_CONFIG_PATHS).use(TsconfigPathsPlugin, [
|
|
450
|
-
{
|
|
451
|
-
configFile,
|
|
452
|
-
extensions,
|
|
453
|
-
// https://github.com/dividab/tsconfig-paths-webpack-plugin/pull/106
|
|
454
|
-
mainFields
|
|
455
|
-
}
|
|
456
|
-
]);
|
|
457
|
-
}
|
|
458
|
-
var getMainFields, pluginResolve;
|
|
459
|
-
var init_resolve = __esm({
|
|
460
|
-
"src/plugins/resolve.ts"() {
|
|
461
|
-
"use strict";
|
|
462
|
-
init_esm();
|
|
463
|
-
getMainFields = (chain, target) => {
|
|
464
|
-
const mainFields = chain.resolve.mainFields.values();
|
|
465
|
-
if (mainFields.length) {
|
|
466
|
-
return mainFields;
|
|
467
|
-
}
|
|
468
|
-
if (isWebTarget(target)) {
|
|
469
|
-
return ["browser", "module", "main"];
|
|
470
|
-
}
|
|
471
|
-
return ["module", "main"];
|
|
472
|
-
};
|
|
473
|
-
pluginResolve = () => ({
|
|
474
|
-
name: "rsbuild-webpack:resolve",
|
|
475
|
-
setup(api) {
|
|
476
|
-
applyResolvePlugin(api);
|
|
477
|
-
api.modifyBundlerChain(async (chain, { CHAIN_ID, target }) => {
|
|
478
|
-
const config = api.getNormalizedConfig();
|
|
479
|
-
if (api.context.tsconfigPath && config.source.aliasStrategy === "prefer-tsconfig") {
|
|
480
|
-
await applyTsConfigPathsPlugin({
|
|
481
|
-
chain,
|
|
482
|
-
CHAIN_ID,
|
|
483
|
-
configFile: api.context.tsconfigPath,
|
|
484
|
-
mainFields: getMainFields(chain, target),
|
|
485
|
-
extensions: chain.resolve.extensions.values()
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
// src/plugins/copy.ts
|
|
495
|
-
var copy_exports = {};
|
|
496
|
-
__export(copy_exports, {
|
|
497
|
-
pluginCopy: () => pluginCopy
|
|
498
|
-
});
|
|
499
|
-
import fs2 from "fs";
|
|
500
|
-
var pluginCopy;
|
|
501
|
-
var init_copy = __esm({
|
|
502
|
-
"src/plugins/copy.ts"() {
|
|
503
|
-
"use strict";
|
|
504
|
-
init_esm();
|
|
505
|
-
pluginCopy = () => ({
|
|
506
|
-
name: "rsbuild-webpack:copy",
|
|
507
|
-
setup(api) {
|
|
508
|
-
api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
|
|
509
|
-
const config = api.getNormalizedConfig();
|
|
510
|
-
const { copy } = config.output;
|
|
511
|
-
if (!copy) {
|
|
512
|
-
return;
|
|
513
|
-
}
|
|
514
|
-
const { default: CopyPlugin } = await import(
|
|
515
|
-
// @ts-expect-error copy-webpack-plugin does not provide types
|
|
516
|
-
"copy-webpack-plugin"
|
|
517
|
-
);
|
|
518
|
-
const options = Array.isArray(copy) ? { patterns: copy } : copy;
|
|
519
|
-
chain.plugin(CHAIN_ID.PLUGIN.COPY).use(CopyPlugin, [options]);
|
|
520
|
-
});
|
|
521
|
-
api.modifyWebpackConfig(async (config) => {
|
|
522
|
-
const copyPlugin = config.plugins?.find(
|
|
523
|
-
(item) => item?.constructor.name === "CopyPlugin"
|
|
524
|
-
);
|
|
525
|
-
if (copyPlugin) {
|
|
526
|
-
const isContextNotExists = copyPlugin.patterns.every(
|
|
527
|
-
(pattern) => typeof pattern !== "string" && pattern.context && !fs2.existsSync(pattern.context)
|
|
528
|
-
);
|
|
529
|
-
if (isContextNotExists) {
|
|
530
|
-
config.plugins = config.plugins?.filter(
|
|
531
|
-
(item) => item?.constructor.name !== "CopyPlugin"
|
|
532
|
-
);
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
});
|
|
417
|
+
init_shared();
|
|
538
418
|
}
|
|
539
419
|
});
|
|
540
420
|
|
|
@@ -2518,33 +2398,96 @@ var init_ProgressPlugin = __esm({
|
|
|
2518
2398
|
}
|
|
2519
2399
|
});
|
|
2520
2400
|
|
|
2521
|
-
// src/
|
|
2522
|
-
var
|
|
2523
|
-
__export(
|
|
2524
|
-
|
|
2401
|
+
// src/plugin.ts
|
|
2402
|
+
var plugin_exports = {};
|
|
2403
|
+
__export(plugin_exports, {
|
|
2404
|
+
pluginAdaptor: () => pluginAdaptor
|
|
2525
2405
|
});
|
|
2526
|
-
import
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2406
|
+
import fs from "fs";
|
|
2407
|
+
import {
|
|
2408
|
+
TARGET_ID_MAP,
|
|
2409
|
+
isWebTarget
|
|
2410
|
+
} from "@rsbuild/shared";
|
|
2411
|
+
async function applyTsConfigPathsPlugin({
|
|
2412
|
+
chain,
|
|
2413
|
+
CHAIN_ID,
|
|
2414
|
+
mainFields,
|
|
2415
|
+
extensions,
|
|
2416
|
+
configFile
|
|
2417
|
+
}) {
|
|
2418
|
+
const { TsconfigPathsPlugin } = await import("tsconfig-paths-webpack-plugin");
|
|
2419
|
+
chain.resolve.plugin(CHAIN_ID.RESOLVE_PLUGIN.TS_CONFIG_PATHS).use(TsconfigPathsPlugin, [
|
|
2420
|
+
{
|
|
2421
|
+
configFile,
|
|
2422
|
+
extensions,
|
|
2423
|
+
// https://github.com/dividab/tsconfig-paths-webpack-plugin/pull/106
|
|
2424
|
+
mainFields
|
|
2425
|
+
}
|
|
2426
|
+
]);
|
|
2427
|
+
}
|
|
2428
|
+
var getMainFields, pluginAdaptor;
|
|
2429
|
+
var init_plugin = __esm({
|
|
2430
|
+
"src/plugin.ts"() {
|
|
2530
2431
|
"use strict";
|
|
2531
2432
|
init_esm();
|
|
2532
|
-
|
|
2533
|
-
|
|
2433
|
+
getMainFields = (chain, target) => {
|
|
2434
|
+
const mainFields = chain.resolve.mainFields.values();
|
|
2435
|
+
if (mainFields.length) {
|
|
2436
|
+
return mainFields;
|
|
2437
|
+
}
|
|
2438
|
+
if (isWebTarget(target)) {
|
|
2439
|
+
return ["browser", "module", "main"];
|
|
2440
|
+
}
|
|
2441
|
+
return ["module", "main"];
|
|
2442
|
+
};
|
|
2443
|
+
pluginAdaptor = () => ({
|
|
2444
|
+
name: "rsbuild-webpack:adaptor",
|
|
2534
2445
|
setup(api) {
|
|
2535
|
-
api.modifyBundlerChain(async (chain, {
|
|
2446
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID, target }) => {
|
|
2536
2447
|
const config = api.getNormalizedConfig();
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2448
|
+
if (api.context.tsconfigPath && config.source.aliasStrategy === "prefer-tsconfig") {
|
|
2449
|
+
await applyTsConfigPathsPlugin({
|
|
2450
|
+
chain,
|
|
2451
|
+
CHAIN_ID,
|
|
2452
|
+
configFile: api.context.tsconfigPath,
|
|
2453
|
+
mainFields: getMainFields(chain, target),
|
|
2454
|
+
extensions: chain.resolve.extensions.values()
|
|
2455
|
+
});
|
|
2540
2456
|
}
|
|
2541
|
-
const
|
|
2542
|
-
|
|
2543
|
-
{
|
|
2544
|
-
|
|
2545
|
-
|
|
2457
|
+
const progress = config.dev.progressBar ?? true;
|
|
2458
|
+
if (progress) {
|
|
2459
|
+
const { ProgressPlugin: ProgressPlugin2 } = await Promise.resolve().then(() => (init_ProgressPlugin(), ProgressPlugin_exports));
|
|
2460
|
+
chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(ProgressPlugin2, [
|
|
2461
|
+
{
|
|
2462
|
+
id: TARGET_ID_MAP[target],
|
|
2463
|
+
...progress === true ? {} : progress
|
|
2464
|
+
}
|
|
2465
|
+
]);
|
|
2466
|
+
}
|
|
2467
|
+
const { copy } = config.output;
|
|
2468
|
+
if (copy) {
|
|
2469
|
+
const { default: CopyPlugin } = await import(
|
|
2470
|
+
// @ts-expect-error copy-webpack-plugin does not provide types
|
|
2471
|
+
"copy-webpack-plugin"
|
|
2472
|
+
);
|
|
2473
|
+
const options = Array.isArray(copy) ? { patterns: copy } : copy;
|
|
2474
|
+
chain.plugin(CHAIN_ID.PLUGIN.COPY).use(CopyPlugin, [options]);
|
|
2475
|
+
}
|
|
2476
|
+
});
|
|
2477
|
+
api.modifyWebpackConfig(async (config) => {
|
|
2478
|
+
const copyPlugin = config.plugins?.find(
|
|
2479
|
+
(item) => item?.constructor.name === "CopyPlugin"
|
|
2480
|
+
);
|
|
2481
|
+
if (copyPlugin) {
|
|
2482
|
+
const isContextNotExists = copyPlugin.patterns.every(
|
|
2483
|
+
(pattern) => typeof pattern !== "string" && pattern.context && !fs.existsSync(pattern.context)
|
|
2484
|
+
);
|
|
2485
|
+
if (isContextNotExists) {
|
|
2486
|
+
config.plugins = config.plugins?.filter(
|
|
2487
|
+
(item) => item?.constructor.name !== "CopyPlugin"
|
|
2488
|
+
);
|
|
2546
2489
|
}
|
|
2547
|
-
|
|
2490
|
+
}
|
|
2548
2491
|
});
|
|
2549
2492
|
}
|
|
2550
2493
|
});
|
|
@@ -2628,14 +2571,7 @@ init_esm();
|
|
|
2628
2571
|
// src/provider.ts
|
|
2629
2572
|
init_esm();
|
|
2630
2573
|
init_initConfigs();
|
|
2631
|
-
|
|
2632
|
-
createContext,
|
|
2633
|
-
createPublicContext,
|
|
2634
|
-
getPluginAPI,
|
|
2635
|
-
initRsbuildConfig as initRsbuildConfig2,
|
|
2636
|
-
plugins,
|
|
2637
|
-
setCssExtractPlugin
|
|
2638
|
-
} from "@rsbuild/core/internal";
|
|
2574
|
+
init_shared();
|
|
2639
2575
|
import {
|
|
2640
2576
|
pickRsbuildConfig
|
|
2641
2577
|
} from "@rsbuild/shared";
|
|
@@ -2670,11 +2606,10 @@ var webpackProvider = async ({
|
|
|
2670
2606
|
plugins.cache(),
|
|
2671
2607
|
plugins.target(),
|
|
2672
2608
|
plugins.output(),
|
|
2673
|
-
|
|
2609
|
+
plugins.resolve(),
|
|
2674
2610
|
plugins.fileSize(),
|
|
2675
2611
|
plugins.cleanOutput(),
|
|
2676
2612
|
plugins.asset(),
|
|
2677
|
-
Promise.resolve().then(() => (init_copy(), copy_exports)).then((m) => m.pluginCopy()),
|
|
2678
2613
|
plugins.html(async (tags) => {
|
|
2679
2614
|
const result = await context.hooks.modifyHTMLTags.call(tags);
|
|
2680
2615
|
return result[0];
|
|
@@ -2683,7 +2618,6 @@ var webpackProvider = async ({
|
|
|
2683
2618
|
plugins.moment(),
|
|
2684
2619
|
plugins.nodeAddons(),
|
|
2685
2620
|
plugins.define(),
|
|
2686
|
-
Promise.resolve().then(() => (init_progress(), progress_exports)).then((m) => m.pluginProgress()),
|
|
2687
2621
|
plugins.css(),
|
|
2688
2622
|
plugins.less(),
|
|
2689
2623
|
plugins.sass(),
|
|
@@ -2697,7 +2631,8 @@ var webpackProvider = async ({
|
|
|
2697
2631
|
plugins.resourceHints(),
|
|
2698
2632
|
plugins.server(),
|
|
2699
2633
|
plugins.moduleFederation(),
|
|
2700
|
-
plugins.manifest()
|
|
2634
|
+
plugins.manifest(),
|
|
2635
|
+
Promise.resolve().then(() => (init_plugin(), plugin_exports)).then((m) => m.pluginAdaptor())
|
|
2701
2636
|
]);
|
|
2702
2637
|
pluginManager.addPlugins(allPlugins);
|
|
2703
2638
|
},
|
|
@@ -2710,9 +2645,8 @@ var webpackProvider = async ({
|
|
|
2710
2645
|
return webpackConfigs;
|
|
2711
2646
|
},
|
|
2712
2647
|
async createDevServer(options) {
|
|
2713
|
-
const { createDevServer } = await import("@rsbuild/core/internal");
|
|
2714
2648
|
const { createDevMiddleware: createDevMiddleware2 } = await Promise.resolve().then(() => (init_createCompiler(), createCompiler_exports));
|
|
2715
|
-
await
|
|
2649
|
+
await initRsbuildConfig({ context, pluginManager });
|
|
2716
2650
|
return createDevServer(
|
|
2717
2651
|
{ context, pluginManager, rsbuildOptions },
|
|
2718
2652
|
createDevMiddleware2,
|
|
@@ -2720,9 +2654,8 @@ var webpackProvider = async ({
|
|
|
2720
2654
|
);
|
|
2721
2655
|
},
|
|
2722
2656
|
async startDevServer(options) {
|
|
2723
|
-
const { createDevServer } = await import("@rsbuild/core/internal");
|
|
2724
2657
|
const { createDevMiddleware: createDevMiddleware2 } = await Promise.resolve().then(() => (init_createCompiler(), createCompiler_exports));
|
|
2725
|
-
await
|
|
2658
|
+
await initRsbuildConfig({
|
|
2726
2659
|
context,
|
|
2727
2660
|
pluginManager
|
|
2728
2661
|
});
|
|
@@ -2738,8 +2671,7 @@ var webpackProvider = async ({
|
|
|
2738
2671
|
return server.listen();
|
|
2739
2672
|
},
|
|
2740
2673
|
async preview(options) {
|
|
2741
|
-
|
|
2742
|
-
await initRsbuildConfig2({
|
|
2674
|
+
await initRsbuildConfig({
|
|
2743
2675
|
context,
|
|
2744
2676
|
pluginManager
|
|
2745
2677
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/webpack",
|
|
3
|
-
"version": "0.7.0-beta.
|
|
3
|
+
"version": "0.7.0-beta.4",
|
|
4
4
|
"homepage": "https://rsbuild.dev",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"postcss": "^8.4.38",
|
|
29
29
|
"tsconfig-paths-webpack-plugin": "4.1.0",
|
|
30
30
|
"webpack": "^5.91.0",
|
|
31
|
-
"@rsbuild/core": "0.7.0-beta.
|
|
32
|
-
"@rsbuild/shared": "0.7.0-beta.
|
|
31
|
+
"@rsbuild/core": "0.7.0-beta.4",
|
|
32
|
+
"@rsbuild/shared": "0.7.0-beta.4"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "18.x",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"cli-truncate": "2.1.0",
|
|
38
38
|
"patch-console": "1.0.0",
|
|
39
39
|
"typescript": "^5.4.2",
|
|
40
|
-
"@scripts/test-helper": "0.7.0-beta.
|
|
40
|
+
"@scripts/test-helper": "0.7.0-beta.4"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public",
|