@rsbuild/core 1.2.11 → 1.2.12
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/chokidar/index.d.ts +61 -23
- package/compiled/chokidar/index.js +71 -56
- package/compiled/css-loader/index.js +309 -195
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/http-proxy-middleware/index.d.ts +1 -1
- package/compiled/launch-editor-middleware/index.js +9 -6
- package/compiled/mrmime/index.js +4 -0
- package/compiled/mrmime/package.json +1 -1
- package/compiled/postcss/index.js +194 -194
- package/compiled/postcss/package.json +1 -1
- package/compiled/postcss-load-config/index.js +11 -11
- package/compiled/postcss-loader/index.js +9 -9
- package/compiled/rsbuild-dev-middleware/index.js +25 -25
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/compiled/sirv/index.js +8 -4
- package/compiled/sirv/package.json +1 -1
- package/compiled/style-loader/index.js +10 -10
- package/compiled/tinyglobby/index.d.ts +1 -0
- package/compiled/tinyglobby/index.js +266 -142
- package/compiled/tinyglobby/package.json +1 -1
- package/compiled/webpack-bundle-analyzer/index.js +6 -2
- package/compiled/ws/index.js +50 -49
- package/compiled/ws/package.json +1 -1
- package/dist/client/hmr.js +2 -2
- package/dist/index.cjs +86 -53
- package/dist/index.js +82 -49
- package/dist-types/helpers/index.d.ts +3 -3
- package/dist-types/index.d.ts +1 -1
- package/dist-types/loadEnv.d.ts +16 -4
- package/dist-types/logger.d.ts +14 -0
- package/dist-types/server/devServer.d.ts +2 -1
- package/dist-types/server/socketServer.d.ts +4 -2
- package/dist-types/types/config.d.ts +79 -43
- package/dist-types/types/rspack.d.ts +1 -1
- package/package.json +11 -11
- package/compiled/jiti/index.d.ts +0 -1
- package/compiled/jiti/index.js +0 -416
- package/compiled/jiti/license +0 -21
- package/compiled/jiti/package.json +0 -1
package/dist/index.cjs
CHANGED
|
@@ -268,10 +268,6 @@ var __webpack_modules__ = {
|
|
|
268
268
|
"use strict";
|
|
269
269
|
module.exports = import("../compiled/http-proxy-middleware/index.js");
|
|
270
270
|
},
|
|
271
|
-
"../compiled/jiti/index.js": function(module) {
|
|
272
|
-
"use strict";
|
|
273
|
-
module.exports = import("../compiled/jiti/index.js");
|
|
274
|
-
},
|
|
275
271
|
"../../compiled/launch-editor-middleware/index.js": function(module) {
|
|
276
272
|
"use strict";
|
|
277
273
|
module.exports = import("../compiled/launch-editor-middleware/index.js");
|
|
@@ -316,6 +312,10 @@ var __webpack_modules__ = {
|
|
|
316
312
|
"use strict";
|
|
317
313
|
module.exports = import("../compiled/ws/index.js");
|
|
318
314
|
},
|
|
315
|
+
jiti: function(module) {
|
|
316
|
+
"use strict";
|
|
317
|
+
module.exports = import("jiti");
|
|
318
|
+
},
|
|
319
319
|
"node:http": function(module) {
|
|
320
320
|
"use strict";
|
|
321
321
|
module.exports = import("node:http");
|
|
@@ -525,7 +525,7 @@ var __webpack_exports__ = {};
|
|
|
525
525
|
!keep.some((reg)=>reg.test(toPosixPath(fullPath))) && (entry.isDirectory() ? (await emptyDir(fullPath, keep, !1), keep.length || await external_node_fs_default().promises.rmdir(fullPath)) : await external_node_fs_default().promises.unlink(fullPath));
|
|
526
526
|
}));
|
|
527
527
|
} catch (err) {
|
|
528
|
-
rslog_index_js_namespaceObject.logger.debug(`
|
|
528
|
+
rslog_index_js_namespaceObject.logger.debug(`failed to empty dir: ${dir}`), rslog_index_js_namespaceObject.logger.debug(err);
|
|
529
529
|
}
|
|
530
530
|
}
|
|
531
531
|
let hintNodePolyfill = (message)=>{
|
|
@@ -775,7 +775,7 @@ var __webpack_exports__ = {};
|
|
|
775
775
|
}, isTTY = (type = 'stdout')=>('stdin' === type ? process.stdin.isTTY : process.stdout.isTTY) && !process.env.CI;
|
|
776
776
|
function loadEnv({ cwd = process.cwd(), mode = getNodeEnv(), prefixes = [
|
|
777
777
|
'PUBLIC_'
|
|
778
|
-
] } = {}) {
|
|
778
|
+
], processEnv = process.env } = {}) {
|
|
779
779
|
if ('local' === mode) throw Error("[rsbuild:loadEnv] 'local' cannot be used as a value for env mode, because \".env.local\" represents a temporary local file. Please use another value.");
|
|
780
780
|
let filePaths = [
|
|
781
781
|
'.env',
|
|
@@ -783,13 +783,14 @@ var __webpack_exports__ = {};
|
|
|
783
783
|
`.env.${mode}`,
|
|
784
784
|
`.env.${mode}.local`
|
|
785
785
|
].map((filename)=>(0, external_node_path_namespaceObject.join)(cwd, filename)).filter(isFileSync), parsed = {};
|
|
786
|
-
for (let envPath of filePaths)Object.assign(parsed, (0, main.parse)(external_node_fs_default().readFileSync(envPath)));
|
|
787
|
-
parsed.NODE_ENV && (
|
|
788
|
-
parsed
|
|
786
|
+
for (let envPath of filePaths)Object.assign(parsed, (0, main.parse)(external_node_fs_default().readFileSync(envPath))), rslog_index_js_namespaceObject.logger.debug('loaded env file:', envPath);
|
|
787
|
+
parsed.NODE_ENV && (processEnv.NODE_ENV = parsed.NODE_ENV), (0, lib_main.expand)({
|
|
788
|
+
parsed,
|
|
789
|
+
processEnv
|
|
789
790
|
});
|
|
790
791
|
let publicVars = {}, rawPublicVars = {};
|
|
791
|
-
for (let key of Object.keys(
|
|
792
|
-
let val =
|
|
792
|
+
for (let key of Object.keys(processEnv))if (prefixes.some((prefix)=>key.startsWith(prefix))) {
|
|
793
|
+
let val = processEnv[key];
|
|
793
794
|
publicVars[`import.meta.env.${key}`] = JSON.stringify(val), publicVars[`process.env.${key}`] = JSON.stringify(val), rawPublicVars[key] = val;
|
|
794
795
|
}
|
|
795
796
|
let cleaned = !1;
|
|
@@ -797,7 +798,7 @@ var __webpack_exports__ = {};
|
|
|
797
798
|
parsed,
|
|
798
799
|
cleanup: ()=>{
|
|
799
800
|
if (!cleaned) {
|
|
800
|
-
for (let key of Object.keys(parsed))'NODE_ENV' !== key &&
|
|
801
|
+
for (let key of Object.keys(parsed))'NODE_ENV' !== key && processEnv[key] === parsed[key] && delete processEnv[key];
|
|
801
802
|
cleaned = !0;
|
|
802
803
|
}
|
|
803
804
|
},
|
|
@@ -972,8 +973,8 @@ var __webpack_exports__ = {};
|
|
|
972
973
|
}, beforeRestart = async ({ filePath, clear = !0, id })=>{
|
|
973
974
|
if (clear && clearConsole(), filePath) {
|
|
974
975
|
let filename = external_node_path_default().basename(filePath);
|
|
975
|
-
rslog_index_js_namespaceObject.logger.info(`
|
|
976
|
-
} else rslog_index_js_namespaceObject.logger.info(`
|
|
976
|
+
rslog_index_js_namespaceObject.logger.info(`restarting ${id} because ${index_js_default().yellow(filename)} has changed\n`);
|
|
977
|
+
} else rslog_index_js_namespaceObject.logger.info(`restarting ${id}...\n`);
|
|
977
978
|
for (let cleaner of cleaners)await cleaner();
|
|
978
979
|
cleaners = [];
|
|
979
980
|
}, restartDevServer = async ({ filePath, clear = !0 } = {})=>{
|
|
@@ -1080,7 +1081,8 @@ var __webpack_exports__ = {};
|
|
|
1080
1081
|
compress: !0,
|
|
1081
1082
|
printUrls: !0,
|
|
1082
1083
|
strictPort: !1,
|
|
1083
|
-
cors: !1
|
|
1084
|
+
cors: !1,
|
|
1085
|
+
middlewareMode: !1
|
|
1084
1086
|
}), getDefaultSourceConfig = ()=>({
|
|
1085
1087
|
alias: {},
|
|
1086
1088
|
define: {},
|
|
@@ -1250,7 +1252,7 @@ var __webpack_exports__ = {};
|
|
|
1250
1252
|
async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta, loader = 'jiti' } = {}) {
|
|
1251
1253
|
let configExport;
|
|
1252
1254
|
let configFilePath = resolveConfigPath(cwd, path);
|
|
1253
|
-
if (!configFilePath) return {
|
|
1255
|
+
if (!configFilePath) return rslog_index_js_namespaceObject.logger.debug('no config file found.'), {
|
|
1254
1256
|
content: {},
|
|
1255
1257
|
filePath: configFilePath
|
|
1256
1258
|
};
|
|
@@ -1262,16 +1264,17 @@ var __webpack_exports__ = {};
|
|
|
1262
1264
|
configExport = exportModule.default ? exportModule.default : exportModule;
|
|
1263
1265
|
} catch (err) {
|
|
1264
1266
|
if ('native' === loader) throw rslog_index_js_namespaceObject.logger.error(`Failed to load file with native loader: ${index_js_default().dim(configFilePath)}`), err;
|
|
1265
|
-
rslog_index_js_namespaceObject.logger.debug(`
|
|
1267
|
+
rslog_index_js_namespaceObject.logger.debug(`failed to load file with dynamic import: ${index_js_default().dim(configFilePath)}`);
|
|
1266
1268
|
}
|
|
1267
1269
|
try {
|
|
1268
1270
|
if (void 0 === configExport) {
|
|
1269
|
-
let {
|
|
1270
|
-
|
|
1271
|
-
esmResolve: !0,
|
|
1272
|
-
requireCache: !1,
|
|
1271
|
+
let { createJiti } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "jiti")), jiti = createJiti(constants_filename, {
|
|
1272
|
+
moduleCache: !1,
|
|
1273
1273
|
interopDefault: !0
|
|
1274
|
-
})
|
|
1274
|
+
});
|
|
1275
|
+
configExport = await jiti.import(configFilePath, {
|
|
1276
|
+
default: !0
|
|
1277
|
+
});
|
|
1275
1278
|
}
|
|
1276
1279
|
} catch (err) {
|
|
1277
1280
|
throw rslog_index_js_namespaceObject.logger.error(`Failed to load file with jiti: ${index_js_default().dim(configFilePath)}`), err;
|
|
@@ -1290,7 +1293,7 @@ var __webpack_exports__ = {};
|
|
|
1290
1293
|
};
|
|
1291
1294
|
}
|
|
1292
1295
|
if (!isObject(configExport)) throw Error(`[rsbuild:loadConfig] The config must be an object or a function that returns an object, get ${index_js_default().yellow(configExport)}`);
|
|
1293
|
-
return {
|
|
1296
|
+
return rslog_index_js_namespaceObject.logger.debug('loaded config file:', configFilePath), {
|
|
1294
1297
|
content: applyMetaInfo(configExport),
|
|
1295
1298
|
filePath: configFilePath
|
|
1296
1299
|
};
|
|
@@ -1330,13 +1333,13 @@ var __webpack_exports__ = {};
|
|
|
1330
1333
|
...rawEnvironmentConfigs.map(({ name, content })=>{
|
|
1331
1334
|
if (1 === rawEnvironmentConfigs.length) return {
|
|
1332
1335
|
path: (0, external_node_path_namespaceObject.join)(outputPath, 'rsbuild.config.mjs'),
|
|
1333
|
-
label: 'Rsbuild
|
|
1336
|
+
label: 'Rsbuild config',
|
|
1334
1337
|
content
|
|
1335
1338
|
};
|
|
1336
1339
|
let outputFile = `rsbuild.config.${name}.mjs`;
|
|
1337
1340
|
return {
|
|
1338
1341
|
path: (0, external_node_path_namespaceObject.join)(outputPath, outputFile),
|
|
1339
|
-
label: `Rsbuild
|
|
1342
|
+
label: `Rsbuild config (${name})`,
|
|
1340
1343
|
content
|
|
1341
1344
|
};
|
|
1342
1345
|
}),
|
|
@@ -1353,7 +1356,7 @@ var __webpack_exports__ = {};
|
|
|
1353
1356
|
recursive: !0
|
|
1354
1357
|
}), await Promise.all(files.map(async (item)=>external_node_fs_default().promises.writeFile(item.path, `export default ${item.content}`)));
|
|
1355
1358
|
let fileInfos = files.map((item)=>` - ${index_js_default().bold(index_js_default().yellow(item.label))}: ${index_js_default().underline(item.path)}`).join('\n');
|
|
1356
|
-
rslog_index_js_namespaceObject.logger.success(`
|
|
1359
|
+
rslog_index_js_namespaceObject.logger.success(`config inspection completed, generated files: \n\n${fileInfos}\n`);
|
|
1357
1360
|
}
|
|
1358
1361
|
function stringifyConfig(config, verbose) {
|
|
1359
1362
|
return (0, rspack_chain_index_js_default().toString)(config, {
|
|
@@ -1739,7 +1742,7 @@ var __webpack_exports__ = {};
|
|
|
1739
1742
|
async function createContext(options, userConfig, bundlerType) {
|
|
1740
1743
|
let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_namespaceObject.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
|
|
1741
1744
|
return {
|
|
1742
|
-
version: "1.2.
|
|
1745
|
+
version: "1.2.12",
|
|
1743
1746
|
rootPath,
|
|
1744
1747
|
distPath: '',
|
|
1745
1748
|
cachePath,
|
|
@@ -1970,7 +1973,10 @@ var __webpack_exports__ = {};
|
|
|
1970
1973
|
api.modifyBundlerChain((chain, { isProd, environment })=>{
|
|
1971
1974
|
let { config } = environment, getMergedFilename = (assetType)=>{
|
|
1972
1975
|
let distDir = config.output.distPath[assetType], filename = getFilename(config, assetType, isProd);
|
|
1973
|
-
return
|
|
1976
|
+
return 'function' == typeof filename ? (...args)=>{
|
|
1977
|
+
let name = filename(...args);
|
|
1978
|
+
return external_node_path_default().posix.join(distDir, name);
|
|
1979
|
+
} : external_node_path_default().posix.join(distDir, filename);
|
|
1974
1980
|
}, createAssetRule = (assetType, exts, emit)=>{
|
|
1975
1981
|
let regExp = function(exts) {
|
|
1976
1982
|
let matcher = exts.map((ext)=>ext.trim()).map((ext)=>ext.startsWith('.') ? ext.slice(1) : ext).join('|');
|
|
@@ -2055,7 +2061,7 @@ var __webpack_exports__ = {};
|
|
|
2055
2061
|
try {
|
|
2056
2062
|
prevBuildDependencies = JSON.parse(rawConfigFile);
|
|
2057
2063
|
} catch (e) {
|
|
2058
|
-
rslog_index_js_namespaceObject.logger.debug('
|
|
2064
|
+
rslog_index_js_namespaceObject.logger.debug('failed to parse the previous buildDependencies.json', e);
|
|
2059
2065
|
}
|
|
2060
2066
|
if (JSON.stringify(prevBuildDependencies) === JSON.stringify(buildDependencies)) return;
|
|
2061
2067
|
await external_node_fs_default().promises.rm(cacheDirectory, {
|
|
@@ -3265,7 +3271,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3265
3271
|
host,
|
|
3266
3272
|
port: originalPort,
|
|
3267
3273
|
strictPort: config.server.strictPort || !1
|
|
3268
|
-
}), https = !!config.server.https, portTip = port !== originalPort ? `
|
|
3274
|
+
}), https = !!config.server.https, portTip = port !== originalPort ? `port ${originalPort} is in use, ${index_js_default().yellow(`using port ${port}.`)}` : void 0;
|
|
3269
3275
|
return {
|
|
3270
3276
|
port,
|
|
3271
3277
|
host,
|
|
@@ -3366,9 +3372,9 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3366
3372
|
if (targetBrowser) return await execAsync(`osascript openChrome.applescript "${encodeURI(url)}" "${targetBrowser}"`, {
|
|
3367
3373
|
cwd: STATIC_PATH
|
|
3368
3374
|
}), !0;
|
|
3369
|
-
rslog_index_js_namespaceObject.logger.debug('
|
|
3375
|
+
rslog_index_js_namespaceObject.logger.debug('failed to find the target browser.');
|
|
3370
3376
|
} catch (err) {
|
|
3371
|
-
rslog_index_js_namespaceObject.logger.debug("
|
|
3377
|
+
rslog_index_js_namespaceObject.logger.debug("failed to open start URL with apple script."), rslog_index_js_namespaceObject.logger.debug(err);
|
|
3372
3378
|
}
|
|
3373
3379
|
try {
|
|
3374
3380
|
let { default: open } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/open/index.js"));
|
|
@@ -3653,7 +3659,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3653
3659
|
}({
|
|
3654
3660
|
href,
|
|
3655
3661
|
file
|
|
3656
|
-
}), 'font' === attributes.as && (attributes.crossorigin = ''), ("script" === attributes.as || 'style' === attributes.as) && crossOriginLoading &&
|
|
3662
|
+
}), 'font' === attributes.as && (attributes.crossorigin = ''), ("script" === attributes.as || 'style' === attributes.as) && crossOriginLoading && ('use-credentials' === crossOriginLoading || '/' !== publicPath) && (attributes.crossorigin = 'anonymous' === crossOriginLoading ? '' : crossOriginLoading)), links.push({
|
|
3657
3663
|
tagName: 'link',
|
|
3658
3664
|
attributes,
|
|
3659
3665
|
voidTag: !0,
|
|
@@ -3799,7 +3805,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3799
3805
|
}), api.onExit(()=>{
|
|
3800
3806
|
enableProfileTrace && core_default().experiments.globalTrace.cleanup();
|
|
3801
3807
|
let profileDir = external_node_path_default().join(api.context.distPath, profileDirName);
|
|
3802
|
-
stopProfiler(external_node_path_default().join(profileDir, 'jscpuprofile.json'), profileSession), rslog_index_js_namespaceObject.logger.info(`
|
|
3808
|
+
stopProfiler(external_node_path_default().join(profileDir, 'jscpuprofile.json'), profileSession), rslog_index_js_namespaceObject.logger.info(`saved Rspack profile file to ${profileDir}`);
|
|
3803
3809
|
});
|
|
3804
3810
|
}
|
|
3805
3811
|
}), pluginServer = ()=>({
|
|
@@ -4623,17 +4629,19 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4623
4629
|
this.wsServer.emit('connection', connection, req);
|
|
4624
4630
|
});
|
|
4625
4631
|
}
|
|
4632
|
+
clearHeartbeatTimer() {
|
|
4633
|
+
this.heartbeatTimer && (clearInterval(this.heartbeatTimer), this.heartbeatTimer = null);
|
|
4634
|
+
}
|
|
4626
4635
|
async prepare() {
|
|
4627
4636
|
var _this_options_client;
|
|
4637
|
+
this.clearHeartbeatTimer();
|
|
4628
4638
|
let { default: ws } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/ws/index.js"));
|
|
4629
4639
|
this.wsServer = new ws.Server({
|
|
4630
4640
|
noServer: !0,
|
|
4631
4641
|
path: null === (_this_options_client = this.options.client) || void 0 === _this_options_client ? void 0 : _this_options_client.path
|
|
4632
4642
|
}), this.wsServer.on('error', (err)=>{
|
|
4633
4643
|
rslog_index_js_namespaceObject.logger.error(err);
|
|
4634
|
-
}), this.
|
|
4635
|
-
for (let socket of this.wsServer.clients)socket.isAlive ? (socket.isAlive = !1, socket.ping(()=>{})) : socket.terminate();
|
|
4636
|
-
}, 30000), this.wsServer.on('connection', (socket, req)=>{
|
|
4644
|
+
}), this.heartbeatTimer = setTimeout(this.checkSockets, 30000), this.wsServer.on('connection', (socket, req)=>{
|
|
4637
4645
|
let queryStr = req.url ? req.url.split('?')[1] : '';
|
|
4638
4646
|
this.onConnect(socket, queryStr ? (0, external_node_querystring_namespaceObject.parse)(queryStr) : {});
|
|
4639
4647
|
});
|
|
@@ -4658,23 +4666,28 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4658
4666
|
compilationId
|
|
4659
4667
|
}));
|
|
4660
4668
|
}
|
|
4661
|
-
close() {
|
|
4669
|
+
async close() {
|
|
4670
|
+
for (let socket of (this.clearHeartbeatTimer(), this.wsServer.removeAllListeners(), this.wsServer.clients))socket.terminate();
|
|
4662
4671
|
for (let socket of this.sockets)socket.close();
|
|
4663
|
-
this.
|
|
4672
|
+
return this.stats = {}, this.initialChunks = {}, this.sockets.length = 0, new Promise((resolve, reject)=>{
|
|
4673
|
+
this.wsServer.close((err)=>{
|
|
4674
|
+
err ? reject(err) : resolve();
|
|
4675
|
+
});
|
|
4676
|
+
});
|
|
4664
4677
|
}
|
|
4665
4678
|
onConnect(socket, params) {
|
|
4666
4679
|
socket.isAlive = !0, socket.on('pong', ()=>{
|
|
4667
4680
|
socket.isAlive = !0;
|
|
4668
|
-
}),
|
|
4669
|
-
let
|
|
4670
|
-
|
|
4681
|
+
}), this.sockets.push(socket), socket.on('close', ()=>{
|
|
4682
|
+
let index = this.sockets.indexOf(socket);
|
|
4683
|
+
index >= 0 && this.sockets.splice(index, 1);
|
|
4671
4684
|
}), (this.options.hmr || this.options.liveReload) && this.singleWrite(socket, {
|
|
4672
4685
|
type: 'hot',
|
|
4673
4686
|
compilationId: params.compilationId
|
|
4674
4687
|
}), this.stats && this.sendStats({
|
|
4675
4688
|
force: !0,
|
|
4676
4689
|
compilationId: params.compilationId
|
|
4677
|
-
})
|
|
4690
|
+
});
|
|
4678
4691
|
}
|
|
4679
4692
|
getStats(name) {
|
|
4680
4693
|
let curStats = this.stats[name];
|
|
@@ -4879,7 +4892,10 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4879
4892
|
1 === connection.readyState && connection.send(message);
|
|
4880
4893
|
}
|
|
4881
4894
|
constructor(options){
|
|
4882
|
-
socketServer_define_property(this, "wsServer", void 0), socketServer_define_property(this, "sockets", []), socketServer_define_property(this, "options", void 0), socketServer_define_property(this, "stats", void 0), socketServer_define_property(this, "initialChunks", void 0), socketServer_define_property(this, "
|
|
4895
|
+
socketServer_define_property(this, "wsServer", void 0), socketServer_define_property(this, "sockets", []), socketServer_define_property(this, "options", void 0), socketServer_define_property(this, "stats", void 0), socketServer_define_property(this, "initialChunks", void 0), socketServer_define_property(this, "heartbeatTimer", null), socketServer_define_property(this, "checkSockets", ()=>{
|
|
4896
|
+
for (let socket of this.wsServer.clients)socket.isAlive ? (socket.isAlive = !1, socket.ping(()=>{})) : socket.terminate();
|
|
4897
|
+
null !== this.heartbeatTimer && (this.heartbeatTimer = setTimeout(this.checkSockets, 30000));
|
|
4898
|
+
}), this.options = options, this.stats = {}, this.initialChunks = {};
|
|
4883
4899
|
}
|
|
4884
4900
|
}
|
|
4885
4901
|
function compilerDevMiddleware_define_property(obj, key, value) {
|
|
@@ -4912,7 +4928,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4912
4928
|
this.socketServer.upgrade(req, sock, head);
|
|
4913
4929
|
}
|
|
4914
4930
|
async close() {
|
|
4915
|
-
this.socketServer.close(), this.middleware && await new Promise((resolve)=>{
|
|
4931
|
+
await this.socketServer.close(), this.middleware && await new Promise((resolve)=>{
|
|
4916
4932
|
this.middleware.close(()=>{
|
|
4917
4933
|
resolve();
|
|
4918
4934
|
});
|
|
@@ -5607,7 +5623,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5607
5623
|
environment
|
|
5608
5624
|
}))
|
|
5609
5625
|
}
|
|
5610
|
-
])), { default: connect } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/connect/index.js")), middlewares = connect(), httpServer = await createHttpServer({
|
|
5626
|
+
])), { default: connect } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/connect/index.js")), middlewares = connect(), httpServer = config.server.middlewareMode ? null : await createHttpServer({
|
|
5611
5627
|
serverConfig: config.server,
|
|
5612
5628
|
middlewares
|
|
5613
5629
|
}), devServerAPI = {
|
|
@@ -5616,6 +5632,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5616
5632
|
environments: environmentAPI,
|
|
5617
5633
|
httpServer,
|
|
5618
5634
|
listen: async ()=>{
|
|
5635
|
+
if (!httpServer) throw Error('[rsbuild:server] Can not listen dev server as `server.middlewareMode` is enabled.');
|
|
5619
5636
|
let serverTerminator = getServerTerminator(httpServer);
|
|
5620
5637
|
return rslog_index_js_namespaceObject.logger.debug('listen dev server'), options.context.hooks.onCloseDevServer.tap(serverTerminator), new Promise((resolve)=>{
|
|
5621
5638
|
httpServer.listen({
|
|
@@ -5671,6 +5688,12 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5671
5688
|
})).middlewares))Array.isArray(item) ? middlewares.use(...item) : middlewares.use(item);
|
|
5672
5689
|
return rslog_index_js_namespaceObject.logger.debug('create dev server done'), devServerAPI;
|
|
5673
5690
|
}
|
|
5691
|
+
function cutPath(filePath, root) {
|
|
5692
|
+
let prefix = root.endsWith(external_node_path_namespaceObject.sep) ? root : root + external_node_path_namespaceObject.sep;
|
|
5693
|
+
if (filePath.startsWith(prefix)) return filePath.slice(prefix.length);
|
|
5694
|
+
let parts = filePath.split(external_node_path_namespaceObject.sep).filter(Boolean);
|
|
5695
|
+
return parts.length > 3 ? parts.slice(-3).join(external_node_path_namespaceObject.sep) : parts.join(external_node_path_namespaceObject.sep);
|
|
5696
|
+
}
|
|
5674
5697
|
async function createCompiler_createCompiler(options) {
|
|
5675
5698
|
rslog_index_js_namespaceObject.logger.debug('create compiler');
|
|
5676
5699
|
let { context } = options, { rspackConfigs } = await initConfigs(options);
|
|
@@ -5679,10 +5702,20 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5679
5702
|
environments: context.environments
|
|
5680
5703
|
}), !await isSatisfyRspackVersion(core_namespaceObject.rspack.rspackVersion)) throw Error(`[rsbuild] The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${index_js_default().green(rspackMinVersion)}`);
|
|
5681
5704
|
let compiler = 1 === rspackConfigs.length ? (0, core_namespaceObject.rspack)(rspackConfigs[0]) : (0, core_namespaceObject.rspack)(rspackConfigs), isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
|
|
5682
|
-
isVersionLogged || (rslog_index_js_namespaceObject.logger.debug(`
|
|
5705
|
+
isVersionLogged || (rslog_index_js_namespaceObject.logger.debug(`use Rspack v${core_namespaceObject.rspack.rspackVersion}`), isVersionLogged = !0);
|
|
5683
5706
|
};
|
|
5684
|
-
compiler.hooks.watchRun.tap('rsbuild:compiling', ()=>{
|
|
5685
|
-
logRspackVersion(), isCompiling
|
|
5707
|
+
compiler.hooks.watchRun.tap('rsbuild:compiling', (compiler)=>{
|
|
5708
|
+
if (logRspackVersion(), !isCompiling) {
|
|
5709
|
+
let changedFiles = compiler.modifiedFiles ? Array.from(compiler.modifiedFiles) : [], removedFiles = compiler.removedFiles ? Array.from(compiler.removedFiles) : [];
|
|
5710
|
+
if (changedFiles.length) {
|
|
5711
|
+
let fileInfo = index_js_default().dim(changedFiles.map((file)=>cutPath(file, context.rootPath)).join(', '));
|
|
5712
|
+
rslog_index_js_namespaceObject.logger.start(`building ${fileInfo}`);
|
|
5713
|
+
} else if (removedFiles.length) {
|
|
5714
|
+
let fileInfo = removedFiles.map((file)=>cutPath(file, context.rootPath)).join(', ');
|
|
5715
|
+
rslog_index_js_namespaceObject.logger.start(`building ${index_js_default().dim(`removed ${fileInfo}`)}`);
|
|
5716
|
+
} else rslog_index_js_namespaceObject.logger.start('build started...');
|
|
5717
|
+
}
|
|
5718
|
+
isCompiling = !0;
|
|
5686
5719
|
}), 'build' === context.command && compiler.hooks.run.tap('rsbuild:run', logRspackVersion);
|
|
5687
5720
|
let done = (stats)=>{
|
|
5688
5721
|
let statsOptions = getStatsOptions(compiler), statsJson = stats.toJson({
|
|
@@ -5694,7 +5727,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5694
5727
|
}), printTime = (c, index)=>{
|
|
5695
5728
|
if (c.time) {
|
|
5696
5729
|
let time = prettyTime(c.time / 1000), { name } = rspackConfigs[index], suffix = name ? index_js_default().gray(` (${name})`) : '';
|
|
5697
|
-
rslog_index_js_namespaceObject.logger.ready(`
|
|
5730
|
+
rslog_index_js_namespaceObject.logger.ready(`built in ${time}${suffix}`);
|
|
5698
5731
|
}
|
|
5699
5732
|
}, hasErrors = stats.hasErrors();
|
|
5700
5733
|
if (!hasErrors) {
|
|
@@ -6690,12 +6723,12 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
6690
6723
|
}
|
|
6691
6724
|
}(), process.title = 'rsbuild-node';
|
|
6692
6725
|
let { npm_execpath } = process.env;
|
|
6693
|
-
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.2.
|
|
6726
|
+
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.2.12\n`);
|
|
6694
6727
|
}();
|
|
6695
6728
|
try {
|
|
6696
6729
|
!function() {
|
|
6697
6730
|
let cli = dist('rsbuild');
|
|
6698
|
-
cli.help(), cli.version("1.2.
|
|
6731
|
+
cli.help(), cli.version("1.2.12"), applyCommonOptions(cli);
|
|
6699
6732
|
let devCommand = cli.command('dev', 'starting the dev server'), buildCommand = cli.command('build', 'build the app for production'), previewCommand = cli.command('preview', 'preview the production build locally'), inspectCommand = cli.command('inspect', 'inspect the Rspack and Rsbuild configs');
|
|
6700
6733
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
6701
6734
|
try {
|
|
@@ -6746,7 +6779,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
6746
6779
|
rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
|
|
6747
6780
|
}
|
|
6748
6781
|
}
|
|
6749
|
-
let src_rslib_entry_version = "1.2.
|
|
6782
|
+
let src_rslib_entry_version = "1.2.12";
|
|
6750
6783
|
})();
|
|
6751
6784
|
var __webpack_export_target__ = exports;
|
|
6752
6785
|
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|