@rsbuild/core 2.1.13 → 2.2.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiled/connect-next/index.d.ts +11 -10
- package/compiled/connect-next/package.json +1 -1
- package/compiled/css-loader/index.js +2 -2
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/postcss-loader/index.js +6 -6
- package/dist/626.js +106 -65
- package/dist/client/hmr.js +2 -5
- package/dist/connect-next.js +1 -1
- package/dist/helpers/restartManager.d.ts +2 -0
- package/dist/manifest-plugin.js +1 -1
- package/dist/memfs.js +1 -1
- package/dist/open.js +2 -2
- package/dist/server/helper.d.ts +1 -1
- package/dist/server/runner/type.d.ts +1 -1
- package/dist/types/config.d.ts +1 -1
- package/package.json +5 -5
- package/types.d.ts +2 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
|
-
|
|
3
|
+
63: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
4
4
|
"use strict";
|
|
5
|
-
const { HtmlWebpackChildCompiler } = __nccwpck_require__(
|
|
5
|
+
const { HtmlWebpackChildCompiler } = __nccwpck_require__(292);
|
|
6
6
|
const compilerMap = new WeakMap();
|
|
7
7
|
class CachedChildCompilation {
|
|
8
8
|
constructor(compiler) {
|
|
@@ -311,7 +311,7 @@
|
|
|
311
311
|
}
|
|
312
312
|
module.exports = { CachedChildCompilation };
|
|
313
313
|
},
|
|
314
|
-
|
|
314
|
+
292: (module) => {
|
|
315
315
|
"use strict";
|
|
316
316
|
class HtmlWebpackChildCompiler {
|
|
317
317
|
constructor(templates) {
|
|
@@ -480,7 +480,7 @@
|
|
|
480
480
|
}
|
|
481
481
|
module.exports = { HtmlWebpackChildCompiler };
|
|
482
482
|
},
|
|
483
|
-
|
|
483
|
+
908: (module) => {
|
|
484
484
|
"use strict";
|
|
485
485
|
module.exports = {};
|
|
486
486
|
module.exports.none = (chunks) => chunks;
|
|
@@ -499,7 +499,7 @@
|
|
|
499
499
|
};
|
|
500
500
|
module.exports.auto = module.exports.none;
|
|
501
501
|
},
|
|
502
|
-
|
|
502
|
+
931: (module) => {
|
|
503
503
|
"use strict";
|
|
504
504
|
module.exports = function (err) {
|
|
505
505
|
return {
|
|
@@ -523,7 +523,7 @@
|
|
|
523
523
|
};
|
|
524
524
|
};
|
|
525
525
|
},
|
|
526
|
-
|
|
526
|
+
938: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
527
527
|
"use strict";
|
|
528
528
|
const { AsyncSeriesWaterfallHook } = __nccwpck_require__(517);
|
|
529
529
|
const htmlWebpackPluginHooksMap = new WeakMap();
|
|
@@ -549,7 +549,7 @@
|
|
|
549
549
|
}
|
|
550
550
|
module.exports = { getHtmlRspackPluginHooks };
|
|
551
551
|
},
|
|
552
|
-
|
|
552
|
+
439: (module) => {
|
|
553
553
|
const voidTags = [
|
|
554
554
|
"area",
|
|
555
555
|
"base",
|
|
@@ -617,19 +617,19 @@
|
|
|
617
617
|
htmlTagObjectToString,
|
|
618
618
|
};
|
|
619
619
|
},
|
|
620
|
-
|
|
620
|
+
630: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
621
621
|
"use strict";
|
|
622
622
|
const promisify = __nccwpck_require__(23).promisify;
|
|
623
623
|
const vm = __nccwpck_require__(154);
|
|
624
624
|
const fs = __nccwpck_require__(896);
|
|
625
625
|
const path = __nccwpck_require__(928);
|
|
626
|
-
const { CachedChildCompilation } = __nccwpck_require__(
|
|
626
|
+
const { CachedChildCompilation } = __nccwpck_require__(63);
|
|
627
627
|
const { createHtmlTagObject, htmlTagObjectToString, HtmlTagArray } =
|
|
628
|
-
__nccwpck_require__(
|
|
629
|
-
const prettyError = __nccwpck_require__(
|
|
630
|
-
const chunkSorter = __nccwpck_require__(
|
|
628
|
+
__nccwpck_require__(439);
|
|
629
|
+
const prettyError = __nccwpck_require__(931);
|
|
630
|
+
const chunkSorter = __nccwpck_require__(908);
|
|
631
631
|
const getHtmlRspackPluginHooks =
|
|
632
|
-
__nccwpck_require__(
|
|
632
|
+
__nccwpck_require__(938).getHtmlRspackPluginHooks;
|
|
633
633
|
const WITH_PLACEHOLDER = "function __with_placeholder__";
|
|
634
634
|
class HtmlRspackPlugin {
|
|
635
635
|
constructor(userOptions = {}) {
|
|
@@ -2403,6 +2403,6 @@
|
|
|
2403
2403
|
}
|
|
2404
2404
|
if (typeof __nccwpck_require__ !== "undefined")
|
|
2405
2405
|
__nccwpck_require__.ab = __dirname + "/";
|
|
2406
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
2406
|
+
var __webpack_exports__ = __nccwpck_require__(630);
|
|
2407
2407
|
module.exports = __webpack_exports__;
|
|
2408
2408
|
})();
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
"use strict";
|
|
3
3
|
var __webpack_modules__ = {
|
|
4
|
-
|
|
5
|
-
module.exports = __nccwpck_require__(
|
|
4
|
+
496: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
5
|
+
module.exports = __nccwpck_require__(606)["default"];
|
|
6
6
|
},
|
|
7
|
-
|
|
7
|
+
606: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
8
8
|
var __webpack_unused_export__;
|
|
9
9
|
__webpack_unused_export__ = { value: true };
|
|
10
10
|
exports["default"] = loader;
|
|
11
11
|
var _nodePath = _interopRequireDefault(__nccwpck_require__(760));
|
|
12
|
-
var _utils = __nccwpck_require__(
|
|
12
|
+
var _utils = __nccwpck_require__(255);
|
|
13
13
|
function _interopRequireDefault(e) {
|
|
14
14
|
return e && e.__esModule ? e : { default: e };
|
|
15
15
|
}
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
callback(null, result.css, map, { ast });
|
|
180
180
|
}
|
|
181
181
|
},
|
|
182
|
-
|
|
182
|
+
255: (module, exports, __nccwpck_require__) => {
|
|
183
183
|
module = __nccwpck_require__.nmd(module);
|
|
184
184
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
185
185
|
exports.exec = exec;
|
|
@@ -716,6 +716,6 @@
|
|
|
716
716
|
})();
|
|
717
717
|
if (typeof __nccwpck_require__ !== "undefined")
|
|
718
718
|
__nccwpck_require__.ab = __dirname + "/";
|
|
719
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
719
|
+
var __webpack_exports__ = __nccwpck_require__(496);
|
|
720
720
|
module.exports = __webpack_exports__;
|
|
721
721
|
})();
|
package/dist/626.js
CHANGED
|
@@ -11,6 +11,7 @@ import { URL as external_node_url_URL, pathToFileURL, fileURLToPath as __rspack_
|
|
|
11
11
|
import { isPromise, isRegExp } from "node:util/types";
|
|
12
12
|
import { readFile } from "node:fs/promises";
|
|
13
13
|
import node_zlib from "node:zlib";
|
|
14
|
+
import { once } from "node:events";
|
|
14
15
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
15
16
|
var superClass, superClass1, __rspack_import_meta_filename__ = __rspack_fileURLToPath(import.meta.url);
|
|
16
17
|
let __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
@@ -2995,7 +2996,7 @@ let withDefaultConfig = async (rootPath, userConfig)=>{
|
|
|
2995
2996
|
await isFileExists(tsconfigPath) && (config.source.tsconfigPath = tsconfigPath);
|
|
2996
2997
|
}
|
|
2997
2998
|
return config;
|
|
2998
|
-
}, exitHook_callbacks = new Set(), isCalled = !1, isRegistered = !1;
|
|
2999
|
+
}, restartPorts = new WeakMap(), exitHook_callbacks = new Set(), isCalled = !1, isRegistered = !1;
|
|
2999
3000
|
function exit(exitCode, type) {
|
|
3000
3001
|
if (!isCalled) {
|
|
3001
3002
|
for (let callback of (isCalled = !0, exitHook_callbacks))callback(exitCode);
|
|
@@ -3424,7 +3425,7 @@ function createPublicContext(context) {
|
|
|
3424
3425
|
async function createContext(options, userConfig, logger, loadConfigResult) {
|
|
3425
3426
|
let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = join(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, hooks = initHooks();
|
|
3426
3427
|
return {
|
|
3427
|
-
version: "2.
|
|
3428
|
+
version: "2.2.0-beta.2",
|
|
3428
3429
|
rootPath,
|
|
3429
3430
|
configFile: loadConfigResult?.filePath ?? userConfig._privateMeta?.configFilePath,
|
|
3430
3431
|
configFileDependencies: loadConfigResult?.dependencies ?? userConfig._privateMeta?.configFileDependencies ?? [],
|
|
@@ -3438,9 +3439,16 @@ async function createContext(options, userConfig, logger, loadConfigResult) {
|
|
|
3438
3439
|
publicPathnames: [],
|
|
3439
3440
|
hooks,
|
|
3440
3441
|
restartManager: (({ onRestart, restart })=>{
|
|
3441
|
-
let cleanups = new Set();
|
|
3442
|
+
let port, cleanups = new Set();
|
|
3442
3443
|
return {
|
|
3443
3444
|
canRestart: !!restart,
|
|
3445
|
+
setPort (nextPort) {
|
|
3446
|
+
port = nextPort;
|
|
3447
|
+
},
|
|
3448
|
+
inheritPort (options) {
|
|
3449
|
+
let inheritedPort = options ? restartPorts.get(options) : void 0;
|
|
3450
|
+
return options && restartPorts.delete(options), inheritedPort;
|
|
3451
|
+
},
|
|
3444
3452
|
registerCleanup: (cleanup)=>(cleanups.add(cleanup), ()=>{
|
|
3445
3453
|
cleanups.delete(cleanup);
|
|
3446
3454
|
}),
|
|
@@ -3461,7 +3469,13 @@ async function createContext(options, userConfig, logger, loadConfigResult) {
|
|
|
3461
3469
|
hasError || (hasError = !0, firstError = error);
|
|
3462
3470
|
}
|
|
3463
3471
|
if (hasError) throw firstError;
|
|
3464
|
-
return restart(context);
|
|
3472
|
+
if ('dev' !== context.action || void 0 === port) return restart(context);
|
|
3473
|
+
restartPorts.set(context.options, port);
|
|
3474
|
+
try {
|
|
3475
|
+
return await restart(context);
|
|
3476
|
+
} finally{
|
|
3477
|
+
restartPorts.delete(context.options);
|
|
3478
|
+
}
|
|
3465
3479
|
}
|
|
3466
3480
|
};
|
|
3467
3481
|
})({
|
|
@@ -5093,7 +5107,7 @@ let getPostcssLoaderOptions = async ({ config, root, postcssrcCache })=>{
|
|
|
5093
5107
|
}
|
|
5094
5108
|
});
|
|
5095
5109
|
finalOptions.postcssOptions ||= {};
|
|
5096
|
-
let updatePostcssOptions = (options)=>(options.plugins ||= [], extraPlugins.length && options.plugins.push(...extraPlugins), options.plugins = options.plugins.map((plugin)=>'function' == typeof plugin && plugin.postcss ? plugin() : plugin), options.config = !1, options), { postcssOptions } = finalOptions;
|
|
5110
|
+
let updatePostcssOptions = (options)=>(options.plugins ||= [], extraPlugins.length && options.plugins.push(...extraPlugins), options.plugins = options.plugins.map((plugin)=>'function' == typeof plugin && 'postcss' in plugin && plugin.postcss ? plugin() : plugin), options.config = !1, options), { postcssOptions } = finalOptions;
|
|
5097
5111
|
if ('function' == typeof postcssOptions) {
|
|
5098
5112
|
let postcssOptionsWrapper = (loaderContext)=>{
|
|
5099
5113
|
let options = postcssOptions(loaderContext);
|
|
@@ -5845,6 +5859,10 @@ let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
|
|
|
5845
5859
|
port,
|
|
5846
5860
|
host
|
|
5847
5861
|
}, ()=>{
|
|
5862
|
+
if (0 === port) {
|
|
5863
|
+
let address = server.address();
|
|
5864
|
+
address && 'string' != typeof address && (port = address.port);
|
|
5865
|
+
}
|
|
5848
5866
|
found = !0, server.close(resolve);
|
|
5849
5867
|
});
|
|
5850
5868
|
});
|
|
@@ -5853,14 +5871,14 @@ let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
|
|
|
5853
5871
|
port++, attempts++;
|
|
5854
5872
|
}
|
|
5855
5873
|
if (!found) throw Error(`${color.dim('[rsbuild:server]')} Failed to find an available port after ${tryLimits + 1} attempts, starting from ${color.yellow(original)}.`);
|
|
5856
|
-
if (port !== original && strictPort) throw Error(`${color.dim('[rsbuild:server]')} Port ${color.yellow(original)} is occupied, please choose another one.`);
|
|
5874
|
+
if (0 !== original && port !== original && strictPort) throw Error(`${color.dim('[rsbuild:server]')} Port ${color.yellow(original)} is occupied, please choose another one.`);
|
|
5857
5875
|
return port;
|
|
5858
|
-
}, resolvePort = async (config)=>{
|
|
5859
|
-
let { host, port: originalPort, strictPort } = config.server, port = await getPort({
|
|
5876
|
+
}, resolvePort = async (config, lastPort)=>{
|
|
5877
|
+
let { host, port: originalPort, strictPort } = config.server, preferredPort = 0 === originalPort ? lastPort : void 0, port = await getPort({
|
|
5860
5878
|
host,
|
|
5861
|
-
port: originalPort,
|
|
5862
|
-
strictPort
|
|
5863
|
-
}), portTip = port !== originalPort ? `port ${originalPort} is in use, ${color.yellow(`using port ${port}.`)}` : void 0;
|
|
5879
|
+
port: preferredPort ?? originalPort,
|
|
5880
|
+
strictPort: void 0 === preferredPort && strictPort
|
|
5881
|
+
}), portTip = 0 !== originalPort && port !== originalPort ? `port ${originalPort} is in use, ${color.yellow(`using port ${port}.`)}` : void 0;
|
|
5864
5882
|
return {
|
|
5865
5883
|
port,
|
|
5866
5884
|
portTip
|
|
@@ -6016,7 +6034,7 @@ async function open_open({ port, routes, config, protocol, clearCache, logger })
|
|
|
6016
6034
|
})(config);
|
|
6017
6035
|
clearCache && (openedURLs = []);
|
|
6018
6036
|
let urls = [], host = await getHostInUrl(config.server.host), baseUrl = `${protocol}://${host}:${port}`;
|
|
6019
|
-
for (let url of (targets.length ? urls.push(...targets.map((target)=>resolveUrl(replacePortPlaceholder(target, port), baseUrl))) : routes.length ? urls.push(`${baseUrl}${routes[0].pathname}`) : urls.push(baseUrl), before && await before(), urls))openedURLs.includes(url) || (openBrowser(url, logger), openedURLs.push(url));
|
|
6037
|
+
for (let url of (targets.length ? urls.push(...targets.map((target)=>resolveUrl(replacePortPlaceholder(target, port), baseUrl))) : routes.length ? urls.push(`${baseUrl}${routes[0].pathname}`) : urls.push(baseUrl), before && await before(), urls))openedURLs.includes(url) || (await openBrowser(url, logger), openedURLs.push(url));
|
|
6020
6038
|
}
|
|
6021
6039
|
let getServerUrlFromClientConfig = async (config, context)=>{
|
|
6022
6040
|
let { assetPrefix } = config.dev;
|
|
@@ -6071,7 +6089,7 @@ function pluginModuleFederation() {
|
|
|
6071
6089
|
let { moduleFederation } = config;
|
|
6072
6090
|
if (moduleFederation?.options && moduleFederation.options.exposes) {
|
|
6073
6091
|
let userConfig = api.getRsbuildConfig('original');
|
|
6074
|
-
config.dev ||= {}, config.server ||= {}, userConfig.server?.cors === void 0 && (config.server.cors = !0), config.server?.port
|
|
6092
|
+
config.dev ||= {}, config.server ||= {}, userConfig.server?.cors === void 0 && (config.server.cors = !0), config.server?.port === void 0 || config.dev.client?.port || (config.dev.client ||= {}, config.dev.client.port = 0 === config.server.port ? '<port>' : config.server.port), userConfig.dev?.assetPrefix === void 0 && config.dev.assetPrefix === config.server?.base && (config.dev.assetPrefix = !0);
|
|
6075
6093
|
}
|
|
6076
6094
|
}), api.modifyEnvironmentConfig((config)=>{
|
|
6077
6095
|
config.moduleFederation?.options && (config.source.include = [
|
|
@@ -6271,7 +6289,7 @@ function isTerminalTraceOutput(output) {
|
|
|
6271
6289
|
return 'stdout' === output || 'stderr' === output;
|
|
6272
6290
|
}
|
|
6273
6291
|
function resolveLayer(value) {
|
|
6274
|
-
return
|
|
6292
|
+
return 'OVERVIEW' === value ? 'info' : 'ALL' === value ? 'trace' : value;
|
|
6275
6293
|
}
|
|
6276
6294
|
async function ensureFileDir(outputFilePath) {
|
|
6277
6295
|
let dir = node_path.dirname(outputFilePath);
|
|
@@ -6828,7 +6846,7 @@ function createAssetsMiddleware(context, ready, outputFileSystem) {
|
|
|
6828
6846
|
}
|
|
6829
6847
|
async function setupOutputFileSystem(writeToDisk, compilers) {
|
|
6830
6848
|
if (!0 !== writeToDisk) {
|
|
6831
|
-
let { createFsFromVolume, Volume } = await import("./memfs.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/memfs@4.68.
|
|
6849
|
+
let { createFsFromVolume, Volume } = await import("./memfs.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/memfs@4.68.1/node_modules/memfs/lib/index.js", 23)), outputFileSystem = createFsFromVolume(new Volume());
|
|
6832
6850
|
for (let compiler of compilers)compiler.outputFileSystem = outputFileSystem;
|
|
6833
6851
|
}
|
|
6834
6852
|
let compiler = compilers.find((compiler)=>!!compiler.outputFileSystem);
|
|
@@ -7957,8 +7975,8 @@ class CommonJsRunner extends BasicRunner {
|
|
|
7957
7975
|
createGlobalContext() {
|
|
7958
7976
|
return {
|
|
7959
7977
|
console: console,
|
|
7960
|
-
setTimeout: (...args)=>{
|
|
7961
|
-
let timeout = setTimeout(...args);
|
|
7978
|
+
setTimeout: (callback, delay, ...args)=>{
|
|
7979
|
+
let timeout = setTimeout(callback, delay, ...args);
|
|
7962
7980
|
return timeout.unref(), timeout;
|
|
7963
7981
|
},
|
|
7964
7982
|
clearTimeout: clearTimeout,
|
|
@@ -8173,7 +8191,9 @@ async function devServer_createDevServer(options, createCompiler, config, devSer
|
|
|
8173
8191
|
])
|
|
8174
8192
|
}, { context } = options, { logger } = context;
|
|
8175
8193
|
logger.debug('create dev server');
|
|
8176
|
-
let
|
|
8194
|
+
let isDynamicPort = 0 === config.server.port, lastPort = isDynamicPort ? context.restartManager.inheritPort(devServerOptions) : void 0, { port, portTip } = await resolvePort(config, lastPort);
|
|
8195
|
+
isDynamicPort && context.restartManager.setPort(port);
|
|
8196
|
+
let { middlewareMode, host } = config.server, isHttps = !!config.server.https, routes = getRoutes(context), fallbackPathname = 0 === routes.length && context.environmentList.some((item)=>'web' === item.config.output.target) ? config.server.base : void 0;
|
|
8177
8197
|
context.devServer = {
|
|
8178
8198
|
hostname: host,
|
|
8179
8199
|
port,
|
|
@@ -8320,19 +8340,24 @@ async function devServer_createDevServer(options, createCompiler, config, devSer
|
|
|
8320
8340
|
listen: async ()=>{
|
|
8321
8341
|
if (!httpServer) throw Error(`${color.dim('[rsbuild:server]')} Can not listen dev server as ${color.yellow('server.middlewareMode')} is enabled.`);
|
|
8322
8342
|
let serverTerminator = getServerTerminator(httpServer);
|
|
8323
|
-
|
|
8324
|
-
|
|
8343
|
+
logger.debug('listen dev server'), context.hooks.onCloseDevServer.tap(serverTerminator);
|
|
8344
|
+
try {
|
|
8345
|
+
return httpServer.listen({
|
|
8325
8346
|
host,
|
|
8326
8347
|
port
|
|
8327
|
-
},
|
|
8328
|
-
|
|
8329
|
-
|
|
8330
|
-
|
|
8331
|
-
|
|
8332
|
-
|
|
8333
|
-
|
|
8334
|
-
|
|
8335
|
-
|
|
8348
|
+
}), await once(httpServer, 'listening'), middlewares.use(optionsFallbackMiddleware), middlewares.use(notFoundMiddleware), state.devMiddlewares && httpServer.on('upgrade', state.devMiddlewares.onUpgrade), logger.debug('listen dev server done'), await devServer.afterListen(), {
|
|
8349
|
+
port,
|
|
8350
|
+
urls: urls.map((item)=>item.url),
|
|
8351
|
+
server: devServer
|
|
8352
|
+
};
|
|
8353
|
+
} catch (error) {
|
|
8354
|
+
try {
|
|
8355
|
+
await closeServer();
|
|
8356
|
+
} catch (closeError) {
|
|
8357
|
+
logger.error('Failed to close dev server after startup error.'), logger.error(closeError);
|
|
8358
|
+
}
|
|
8359
|
+
throw error;
|
|
8360
|
+
}
|
|
8336
8361
|
},
|
|
8337
8362
|
afterListen: async ()=>{
|
|
8338
8363
|
await context.hooks.onAfterStartDevServer.callBatch({
|
|
@@ -8450,36 +8475,42 @@ async function startPreviewServer(context, config, { getPortSilently } = {}) {
|
|
|
8450
8475
|
for (let callback of (base && '/' !== base && middlewares.use(getBaseUrlMiddleware({
|
|
8451
8476
|
base
|
|
8452
8477
|
})), middlewares.use(assetsMiddleware), middlewares.use(getHtmlCompletionMiddleware(htmlMiddlewareOptions)), historyApiFallback && (middlewares.use(historyApiFallback_historyApiFallbackMiddleware(logger, !0 === historyApiFallback ? {} : historyApiFallback)), middlewares.use(assetsMiddleware)), postSetupCallbacks))await callback();
|
|
8453
|
-
|
|
8478
|
+
serverConfig.htmlFallback && middlewares.use(getHtmlFallbackMiddleware({
|
|
8454
8479
|
...htmlMiddlewareOptions,
|
|
8455
8480
|
logger
|
|
8456
|
-
})), middlewares.use(faviconFallbackMiddleware), middlewares.use(optionsFallbackMiddleware), middlewares.use(notFoundMiddleware)
|
|
8457
|
-
|
|
8481
|
+
})), middlewares.use(faviconFallbackMiddleware), middlewares.use(optionsFallbackMiddleware), middlewares.use(notFoundMiddleware);
|
|
8482
|
+
try {
|
|
8483
|
+
if (httpServer.listen({
|
|
8458
8484
|
host,
|
|
8459
8485
|
port
|
|
8460
|
-
},
|
|
8461
|
-
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
|
|
8466
|
-
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
8471
|
-
|
|
8472
|
-
|
|
8473
|
-
logger
|
|
8474
|
-
});
|
|
8475
|
-
}
|
|
8476
|
-
!getPortSilently && portTip && logger.info(portTip), resolve({
|
|
8477
|
-
port,
|
|
8478
|
-
urls: urls.map((item)=>item.url),
|
|
8479
|
-
server: previewServer
|
|
8486
|
+
}), await once(httpServer, 'listening'), await context.hooks.onAfterStartPreviewServer.callBatch({
|
|
8487
|
+
port,
|
|
8488
|
+
routes,
|
|
8489
|
+
environments: context.environments
|
|
8490
|
+
}), registerCleanup(closeServer), printUrls(), cliShortcutsEnabled) {
|
|
8491
|
+
let shortcutsOptions = 'boolean' == typeof config.dev.cliShortcuts ? {} : config.dev.cliShortcuts;
|
|
8492
|
+
await setupCliShortcuts({
|
|
8493
|
+
openPage,
|
|
8494
|
+
closeServer,
|
|
8495
|
+
printUrls,
|
|
8496
|
+
help: shortcutsOptions.help,
|
|
8497
|
+
customShortcuts: shortcutsOptions.custom,
|
|
8498
|
+
logger
|
|
8480
8499
|
});
|
|
8481
|
-
}
|
|
8482
|
-
|
|
8500
|
+
}
|
|
8501
|
+
return !getPortSilently && portTip && logger.info(portTip), {
|
|
8502
|
+
port,
|
|
8503
|
+
urls: urls.map((item)=>item.url),
|
|
8504
|
+
server: previewServer
|
|
8505
|
+
};
|
|
8506
|
+
} catch (error) {
|
|
8507
|
+
try {
|
|
8508
|
+
await closeServer();
|
|
8509
|
+
} catch (closeError) {
|
|
8510
|
+
logger.error('Failed to close preview server after startup error.'), logger.error(closeError);
|
|
8511
|
+
}
|
|
8512
|
+
throw error;
|
|
8513
|
+
}
|
|
8483
8514
|
}
|
|
8484
8515
|
function applyDefaultPlugins(pluginManager, context) {
|
|
8485
8516
|
pluginManager.addPlugins([
|
|
@@ -9343,7 +9374,19 @@ try {
|
|
|
9343
9374
|
javascript: {
|
|
9344
9375
|
dynamicImportMode: 'eager'
|
|
9345
9376
|
}
|
|
9346
|
-
}), isServer
|
|
9377
|
+
}), isServer) {
|
|
9378
|
+
if (!1 === splitChunks) chain.optimization.splitChunks(!1);
|
|
9379
|
+
else {
|
|
9380
|
+
let { preset = 'none', ...rest } = splitChunks;
|
|
9381
|
+
chain.optimization.splitChunks({
|
|
9382
|
+
chunks: 'all',
|
|
9383
|
+
...getSplitChunksByPreset(config, preset),
|
|
9384
|
+
...rest
|
|
9385
|
+
});
|
|
9386
|
+
}
|
|
9387
|
+
return;
|
|
9388
|
+
}
|
|
9389
|
+
if (isWebWorker) {
|
|
9347
9390
|
if (!1 === splitChunks || 0 === Object.keys(splitChunks).length) chain.optimization.splitChunks(!1);
|
|
9348
9391
|
else {
|
|
9349
9392
|
let { preset = 'none', ...rest } = splitChunks;
|
|
@@ -9541,11 +9584,11 @@ try {
|
|
|
9541
9584
|
{
|
|
9542
9585
|
name: 'rsbuild:server',
|
|
9543
9586
|
setup (api) {
|
|
9544
|
-
let onStartServer = ({ port, routes })=>{
|
|
9587
|
+
let onStartServer = async ({ port, routes })=>{
|
|
9545
9588
|
let config = api.getNormalizedConfig();
|
|
9546
9589
|
if (config.server.open) {
|
|
9547
9590
|
let protocol = config.server.https ? 'https' : 'http';
|
|
9548
|
-
open_open({
|
|
9591
|
+
await open_open({
|
|
9549
9592
|
port,
|
|
9550
9593
|
routes,
|
|
9551
9594
|
config,
|
|
@@ -9599,7 +9642,7 @@ try {
|
|
|
9599
9642
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev })=>{
|
|
9600
9643
|
let { output: { manifest }, dev: { writeToDisk } } = environment.config;
|
|
9601
9644
|
if (!1 === manifest) return;
|
|
9602
|
-
let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.2_@rspack+core@2.1
|
|
9645
|
+
let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.2_@rspack+core@2.2.0-beta.1/node_modules/rspack-manifest-plugin/dist/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
|
|
9603
9646
|
manifestFilenames.set(environment.name, manifestOptions.filename);
|
|
9604
9647
|
let pluginOptions = {
|
|
9605
9648
|
fileName: manifestOptions.filename,
|
|
@@ -9852,9 +9895,7 @@ async function createRsbuild(options = {}) {
|
|
|
9852
9895
|
context,
|
|
9853
9896
|
pluginManager,
|
|
9854
9897
|
rsbuildOptions: resolvedOptions
|
|
9855
|
-
}, createCompiler, config,
|
|
9856
|
-
...options
|
|
9857
|
-
})).listen();
|
|
9898
|
+
}, createCompiler, config, options)).listen();
|
|
9858
9899
|
}, createDevServer = async (options)=>{
|
|
9859
9900
|
context.action = 'dev', process.env.NODE_ENV || setNodeEnv('development');
|
|
9860
9901
|
let config = await initRsbuildConfig({
|
|
@@ -10095,7 +10136,7 @@ let cliState = {
|
|
|
10095
10136
|
loader: options.configLoader,
|
|
10096
10137
|
command
|
|
10097
10138
|
}), { content: config } = result;
|
|
10098
|
-
if (config.dev ||= {}, config.source ||= {}, config.server ||= {}, options.base && (config.server.base = options.base), options.root && (config.root = root), options.mode && (config.mode = options.mode), options.logLevel && (config.logLevel = options.logLevel), options.open && !config.server?.open && (config.server.open = options.open), void 0 !== options.host && (config.server.host = options.host), options.port && (config.server.port = options.port), void 0 !== options.strictPort && (config.server.strictPort = options.strictPort), void 0 !== options.distPath) {
|
|
10139
|
+
if (config.dev ||= {}, config.source ||= {}, config.server ||= {}, options.base && (config.server.base = options.base), options.root && (config.root = root), options.mode && (config.mode = options.mode), options.logLevel && (config.logLevel = options.logLevel), options.open && !config.server?.open && (config.server.open = options.open), void 0 !== options.host && (config.server.host = options.host), void 0 !== options.port && (config.server.port = options.port), void 0 !== options.strictPort && (config.server.strictPort = options.strictPort), void 0 !== options.distPath) {
|
|
10099
10140
|
config.output ||= {};
|
|
10100
10141
|
let { distPath } = config.output;
|
|
10101
10142
|
config.output.distPath = distPath && 'object' == typeof distPath ? {
|
|
@@ -10142,7 +10183,7 @@ let applyServerOptions = (command)=>{
|
|
|
10142
10183
|
};
|
|
10143
10184
|
function setupCommands(argv) {
|
|
10144
10185
|
let cli = ((name = "")=>new CAC(name))('rsbuild');
|
|
10145
|
-
cli.version("2.
|
|
10186
|
+
cli.version("2.2.0-beta.2"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
|
|
10146
10187
|
default: 'auto'
|
|
10147
10188
|
}).option('--dist-path <dir>', 'Set the root directory of output files').option('--source-map', 'Enable source map').option('--env-dir <dir>', 'Set the directory for loading `.env` files').option('--env-mode <mode>', 'Set the env mode to load the `.env.[mode]` file').option('--environment <name>', 'Set the environment name(s) to build', {
|
|
10148
10189
|
type: [
|
|
@@ -10207,7 +10248,7 @@ function setupCommands(argv) {
|
|
|
10207
10248
|
}
|
|
10208
10249
|
function showGreeting() {
|
|
10209
10250
|
let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
|
|
10210
|
-
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.
|
|
10251
|
+
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.2.0-beta.2\n`);
|
|
10211
10252
|
}
|
|
10212
10253
|
function setupLogLevel(argv) {
|
|
10213
10254
|
if (argv.length <= 3) return;
|
|
@@ -10229,5 +10270,5 @@ function runCLI({ argv = process.argv } = {}) {
|
|
|
10229
10270
|
src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
|
|
10230
10271
|
}
|
|
10231
10272
|
}
|
|
10232
|
-
let src_version = "2.
|
|
10273
|
+
let src_version = "2.2.0-beta.2";
|
|
10233
10274
|
export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, core_rspack as rspack, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger_createLogger as createLogger, mergeRsbuildConfig, mrmime_lookup, runCLI, src_logger as logger, src_version as version };
|
package/dist/client/hmr.js
CHANGED
|
@@ -2,10 +2,7 @@ import { logger } from "./307~0.js";
|
|
|
2
2
|
let createOverlay;
|
|
3
3
|
let clearOverlay;
|
|
4
4
|
const getErrorField = (error, field)=>{
|
|
5
|
-
if (error instanceof Error)
|
|
6
|
-
const value = error[field];
|
|
7
|
-
return void 0 === value ? void 0 : String(value);
|
|
8
|
-
}
|
|
5
|
+
if (error instanceof Error) return error[field];
|
|
9
6
|
};
|
|
10
7
|
const formatErrorLikeMessage = (error)=>{
|
|
11
8
|
if (!(error instanceof Error)) return;
|
|
@@ -52,7 +49,7 @@ function init(token, config, serverHost, serverPort, serverBase, liveReload, bro
|
|
|
52
49
|
const port = (fallback ? serverPort : config.port) || location1.port;
|
|
53
50
|
const protocol = config.protocol || ('https:' === location1.protocol ? 'wss' : 'ws');
|
|
54
51
|
const pathname = config.path;
|
|
55
|
-
if ("u" > typeof URL) {
|
|
52
|
+
if ("u" > typeof URL && 'searchParams' in URL.prototype) {
|
|
56
53
|
const url = new URL('http://localhost');
|
|
57
54
|
url.port = String(port);
|
|
58
55
|
url.hostname = hostname;
|