@rspack/cli 1.3.15 → 1.4.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/556.js +9 -7
- package/dist/556.mjs +9 -7
- package/dist/index.js +21 -24
- package/dist/index.mjs +30 -33
- package/package.json +3 -3
package/dist/556.js
CHANGED
|
@@ -14,7 +14,7 @@ exports.modules = {
|
|
|
14
14
|
var _rspack_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("@rspack/core");
|
|
15
15
|
const overviewTraceFilter = "info";
|
|
16
16
|
const allTraceFilter = "trace";
|
|
17
|
-
const defaultRustTraceLayer = "
|
|
17
|
+
const defaultRustTraceLayer = "perfetto";
|
|
18
18
|
function resolveLayer(value) {
|
|
19
19
|
if ("OVERVIEW" === value) return overviewTraceFilter;
|
|
20
20
|
if ("ALL" === value) return allTraceFilter;
|
|
@@ -22,13 +22,15 @@ exports.modules = {
|
|
|
22
22
|
}
|
|
23
23
|
async function applyProfile(filterValue, traceLayer = defaultRustTraceLayer, traceOutput) {
|
|
24
24
|
const { asyncExitHook } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "exit-hook"));
|
|
25
|
-
if ("
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
if ("logger" !== traceLayer && "perfetto" !== traceLayer) throw new Error(`unsupported trace layer: ${traceLayer}`);
|
|
26
|
+
const timestamp = Date.now();
|
|
27
|
+
const defaultOutputDir = node_path__WEBPACK_IMPORTED_MODULE_1___default().resolve(`.rspack-profile-${timestamp}-${process.pid}`);
|
|
28
|
+
if (traceOutput) {
|
|
29
|
+
if ("stdout" !== traceOutput && "stderr" !== traceOutput) traceOutput = node_path__WEBPACK_IMPORTED_MODULE_1___default().resolve(defaultOutputDir, traceOutput);
|
|
30
|
+
} else {
|
|
31
|
+
const defaultRustTracePerfettoOutput = node_path__WEBPACK_IMPORTED_MODULE_1___default().resolve(defaultOutputDir, "rspack.pftrace");
|
|
30
32
|
const defaultRustTraceLoggerOutput = "stdout";
|
|
31
|
-
const defaultTraceOutput = "
|
|
33
|
+
const defaultTraceOutput = "perfetto" === traceLayer ? defaultRustTracePerfettoOutput : defaultRustTraceLoggerOutput;
|
|
32
34
|
traceOutput = defaultTraceOutput;
|
|
33
35
|
}
|
|
34
36
|
const filter = resolveLayer(filterValue);
|
package/dist/556.mjs
CHANGED
|
@@ -11,7 +11,7 @@ export const __webpack_modules__ = {
|
|
|
11
11
|
var _rspack_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("@rspack/core");
|
|
12
12
|
const overviewTraceFilter = "info";
|
|
13
13
|
const allTraceFilter = "trace";
|
|
14
|
-
const defaultRustTraceLayer = "
|
|
14
|
+
const defaultRustTraceLayer = "perfetto";
|
|
15
15
|
function resolveLayer(value) {
|
|
16
16
|
if ("OVERVIEW" === value) return overviewTraceFilter;
|
|
17
17
|
if ("ALL" === value) return allTraceFilter;
|
|
@@ -19,13 +19,15 @@ export const __webpack_modules__ = {
|
|
|
19
19
|
}
|
|
20
20
|
async function applyProfile(filterValue, traceLayer = defaultRustTraceLayer, traceOutput) {
|
|
21
21
|
const { asyncExitHook } = await import("exit-hook");
|
|
22
|
-
if ("
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
if ("logger" !== traceLayer && "perfetto" !== traceLayer) throw new Error(`unsupported trace layer: ${traceLayer}`);
|
|
23
|
+
const timestamp = Date.now();
|
|
24
|
+
const defaultOutputDir = node_path__WEBPACK_IMPORTED_MODULE_1__["default"].resolve(`.rspack-profile-${timestamp}-${process.pid}`);
|
|
25
|
+
if (traceOutput) {
|
|
26
|
+
if ("stdout" !== traceOutput && "stderr" !== traceOutput) traceOutput = node_path__WEBPACK_IMPORTED_MODULE_1__["default"].resolve(defaultOutputDir, traceOutput);
|
|
27
|
+
} else {
|
|
28
|
+
const defaultRustTracePerfettoOutput = node_path__WEBPACK_IMPORTED_MODULE_1__["default"].resolve(defaultOutputDir, "rspack.pftrace");
|
|
27
29
|
const defaultRustTraceLoggerOutput = "stdout";
|
|
28
|
-
const defaultTraceOutput = "
|
|
30
|
+
const defaultTraceOutput = "perfetto" === traceLayer ? defaultRustTracePerfettoOutput : defaultRustTraceLoggerOutput;
|
|
29
31
|
traceOutput = defaultTraceOutput;
|
|
30
32
|
}
|
|
31
33
|
const filter = resolveLayer(filterValue);
|
package/dist/index.js
CHANGED
|
@@ -109,9 +109,9 @@ var __webpack_exports__ = {};
|
|
|
109
109
|
(()=>{
|
|
110
110
|
__webpack_require__.r(__webpack_exports__);
|
|
111
111
|
__webpack_require__.d(__webpack_exports__, {
|
|
112
|
+
defineConfig: ()=>defineConfig,
|
|
112
113
|
definePlugin: ()=>definePlugin,
|
|
113
|
-
RspackCLI: ()=>RspackCLI
|
|
114
|
-
defineConfig: ()=>defineConfig
|
|
114
|
+
RspackCLI: ()=>RspackCLI
|
|
115
115
|
});
|
|
116
116
|
var external_node_path_ = __webpack_require__("node:path");
|
|
117
117
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_);
|
|
@@ -443,19 +443,16 @@ var __webpack_exports__ = {};
|
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
445
|
const result = compilerForDevServer.options.devServer ??= {};
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
];
|
|
457
|
-
};
|
|
458
|
-
}
|
|
446
|
+
const setupMiddlewares = result.setupMiddlewares;
|
|
447
|
+
const lazyCompileMiddleware = core_.rspack.experiments.lazyCompilationMiddleware(compiler);
|
|
448
|
+
result.setupMiddlewares = (middlewares, server)=>{
|
|
449
|
+
let finalMiddlewares = middlewares;
|
|
450
|
+
if (setupMiddlewares) finalMiddlewares = setupMiddlewares(finalMiddlewares, server);
|
|
451
|
+
return [
|
|
452
|
+
lazyCompileMiddleware,
|
|
453
|
+
...finalMiddlewares
|
|
454
|
+
];
|
|
455
|
+
};
|
|
459
456
|
result.hot = options.hot ?? result.hot ?? true;
|
|
460
457
|
result.host = options.host || result.host;
|
|
461
458
|
result.port = options.port || result.port;
|
|
@@ -490,7 +487,7 @@ var __webpack_exports__ = {};
|
|
|
490
487
|
}
|
|
491
488
|
}
|
|
492
489
|
const external_node_url_namespaceObject = require("node:url");
|
|
493
|
-
const
|
|
490
|
+
const readPackageUp = (cwd = process.cwd())=>{
|
|
494
491
|
let currentDir = external_node_path_default().resolve(cwd);
|
|
495
492
|
let packageJsonPath = external_node_path_default().join(currentDir, "package.json");
|
|
496
493
|
while(!external_node_fs_default().existsSync(packageJsonPath)){
|
|
@@ -505,12 +502,12 @@ var __webpack_exports__ = {};
|
|
|
505
502
|
return null;
|
|
506
503
|
}
|
|
507
504
|
};
|
|
508
|
-
const
|
|
505
|
+
const utils_readPackageUp = readPackageUp;
|
|
509
506
|
const isEsmFile = (filePath, cwd = process.cwd())=>{
|
|
510
507
|
const ext = external_node_path_default().extname(filePath);
|
|
511
508
|
if (/\.(mjs|mts)$/.test(ext)) return true;
|
|
512
509
|
if (/\.(cjs|cts)/.test(ext)) return false;
|
|
513
|
-
const packageJson =
|
|
510
|
+
const packageJson = utils_readPackageUp(external_node_path_default().dirname(filePath));
|
|
514
511
|
return (null == packageJson ? void 0 : packageJson.type) === "module";
|
|
515
512
|
};
|
|
516
513
|
const utils_isEsmFile = isEsmFile;
|
|
@@ -534,15 +531,15 @@ var __webpack_exports__ = {};
|
|
|
534
531
|
];
|
|
535
532
|
const findConfig = (basePath)=>DEFAULT_EXTENSIONS.map((ext)=>basePath + ext).find(external_node_fs_default().existsSync);
|
|
536
533
|
const utils_findConfig = findConfig;
|
|
537
|
-
const
|
|
534
|
+
const isTsFile_isTsFile = (configPath)=>{
|
|
538
535
|
const ext = external_node_path_default().extname(configPath);
|
|
539
536
|
return /\.(c|m)?ts$/.test(ext);
|
|
540
537
|
};
|
|
541
|
-
const
|
|
538
|
+
const isTsFile = isTsFile_isTsFile;
|
|
542
539
|
const loadConfig_DEFAULT_CONFIG_NAME = "rspack.config";
|
|
543
540
|
const registerLoader = async (configPath)=>{
|
|
544
541
|
const ext = external_node_path_default().extname(configPath);
|
|
545
|
-
if (utils_isEsmFile(configPath) &&
|
|
542
|
+
if (utils_isEsmFile(configPath) && isTsFile(configPath)) return;
|
|
546
543
|
const { default: interpret } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "interpret"));
|
|
547
544
|
const extensions = Object.fromEntries(Object.entries(interpret.extensions).filter(([key])=>key === ext));
|
|
548
545
|
if (0 === Object.keys(extensions).length) throw new Error(`config file "${configPath}" is not supported.`);
|
|
@@ -586,7 +583,7 @@ var __webpack_exports__ = {};
|
|
|
586
583
|
throw new Error(`Cannot find module '${extendPath}' to extend from.`);
|
|
587
584
|
}
|
|
588
585
|
if (!external_node_fs_default().existsSync(resolvedPath)) throw new Error(`Extended configuration file "${resolvedPath}" not found.`);
|
|
589
|
-
if (
|
|
586
|
+
if (isTsFile(resolvedPath) && "register" === options.configLoader) await registerLoader(resolvedPath);
|
|
590
587
|
let extendedConfig = await crossImport(resolvedPath, cwd);
|
|
591
588
|
if ("function" == typeof extendedConfig) {
|
|
592
589
|
var _options_argv;
|
|
@@ -604,13 +601,13 @@ var __webpack_exports__ = {};
|
|
|
604
601
|
if (options.config) {
|
|
605
602
|
configPath = external_node_path_default().resolve(cwd, options.config);
|
|
606
603
|
if (!external_node_fs_default().existsSync(configPath)) throw new Error(`config file "${configPath}" not found.`);
|
|
607
|
-
if (
|
|
604
|
+
if (isTsFile(configPath) && "register" === options.configLoader) await registerLoader(configPath);
|
|
608
605
|
loadedConfig = await crossImport(configPath, cwd);
|
|
609
606
|
} else {
|
|
610
607
|
const defaultConfig = utils_findConfig(external_node_path_default().resolve(cwd, loadConfig_DEFAULT_CONFIG_NAME));
|
|
611
608
|
if (!defaultConfig) return {};
|
|
612
609
|
configPath = defaultConfig;
|
|
613
|
-
if (
|
|
610
|
+
if (isTsFile(defaultConfig) && "register" === options.configLoader) await registerLoader(defaultConfig);
|
|
614
611
|
loadedConfig = await crossImport(defaultConfig, cwd);
|
|
615
612
|
}
|
|
616
613
|
if ("function" != typeof loadedConfig && configPath) loadedConfig = await loadExtendedConfig(loadedConfig, configPath, cwd, options);
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__ from "@rspack/core";
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
4
|
+
import external_node_util_default from "node:util";
|
|
5
|
+
import { createColors, isColorSupported } from "colorette";
|
|
6
|
+
import external_yargs_default from "yargs";
|
|
7
|
+
import { hideBin } from "yargs/helpers";
|
|
8
|
+
import { pathToFileURL } from "node:url";
|
|
9
9
|
var __webpack_modules__ = {
|
|
10
10
|
"@rspack/core": function(module) {
|
|
11
11
|
module.exports = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__;
|
|
@@ -408,19 +408,16 @@ class ServeCommand {
|
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
const result = compilerForDevServer.options.devServer ??= {};
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
];
|
|
422
|
-
};
|
|
423
|
-
}
|
|
411
|
+
const setupMiddlewares = result.setupMiddlewares;
|
|
412
|
+
const lazyCompileMiddleware = core_.rspack.experiments.lazyCompilationMiddleware(compiler);
|
|
413
|
+
result.setupMiddlewares = (middlewares, server)=>{
|
|
414
|
+
let finalMiddlewares = middlewares;
|
|
415
|
+
if (setupMiddlewares) finalMiddlewares = setupMiddlewares(finalMiddlewares, server);
|
|
416
|
+
return [
|
|
417
|
+
lazyCompileMiddleware,
|
|
418
|
+
...finalMiddlewares
|
|
419
|
+
];
|
|
420
|
+
};
|
|
424
421
|
result.hot = options.hot ?? result.hot ?? true;
|
|
425
422
|
result.host = options.host || result.host;
|
|
426
423
|
result.port = options.port || result.port;
|
|
@@ -454,7 +451,7 @@ class ServeCommand {
|
|
|
454
451
|
});
|
|
455
452
|
}
|
|
456
453
|
}
|
|
457
|
-
const
|
|
454
|
+
const readPackageUp = (cwd = process.cwd())=>{
|
|
458
455
|
let currentDir = external_node_path_["default"].resolve(cwd);
|
|
459
456
|
let packageJsonPath = external_node_path_["default"].join(currentDir, "package.json");
|
|
460
457
|
while(!external_node_fs_["default"].existsSync(packageJsonPath)){
|
|
@@ -469,18 +466,18 @@ const readPackageUp_readPackageUp = (cwd = process.cwd())=>{
|
|
|
469
466
|
return null;
|
|
470
467
|
}
|
|
471
468
|
};
|
|
472
|
-
const
|
|
469
|
+
const utils_readPackageUp = readPackageUp;
|
|
473
470
|
const isEsmFile = (filePath, cwd = process.cwd())=>{
|
|
474
471
|
const ext = external_node_path_["default"].extname(filePath);
|
|
475
472
|
if (/\.(mjs|mts)$/.test(ext)) return true;
|
|
476
473
|
if (/\.(cjs|cts)/.test(ext)) return false;
|
|
477
|
-
const packageJson =
|
|
474
|
+
const packageJson = utils_readPackageUp(external_node_path_["default"].dirname(filePath));
|
|
478
475
|
return (null == packageJson ? void 0 : packageJson.type) === "module";
|
|
479
476
|
};
|
|
480
477
|
const utils_isEsmFile = isEsmFile;
|
|
481
478
|
const crossImport = async (path, cwd = process.cwd())=>{
|
|
482
479
|
if (utils_isEsmFile(path, cwd)) {
|
|
483
|
-
const url =
|
|
480
|
+
const url = pathToFileURL(path).href;
|
|
484
481
|
const { default: config } = await import(url);
|
|
485
482
|
return config;
|
|
486
483
|
}
|
|
@@ -498,15 +495,15 @@ const DEFAULT_EXTENSIONS = [
|
|
|
498
495
|
];
|
|
499
496
|
const findConfig = (basePath)=>DEFAULT_EXTENSIONS.map((ext)=>basePath + ext).find(external_node_fs_["default"].existsSync);
|
|
500
497
|
const utils_findConfig = findConfig;
|
|
501
|
-
const
|
|
498
|
+
const isTsFile_isTsFile = (configPath)=>{
|
|
502
499
|
const ext = external_node_path_["default"].extname(configPath);
|
|
503
500
|
return /\.(c|m)?ts$/.test(ext);
|
|
504
501
|
};
|
|
505
|
-
const
|
|
502
|
+
const isTsFile = isTsFile_isTsFile;
|
|
506
503
|
const loadConfig_DEFAULT_CONFIG_NAME = "rspack.config";
|
|
507
504
|
const registerLoader = async (configPath)=>{
|
|
508
505
|
const ext = external_node_path_["default"].extname(configPath);
|
|
509
|
-
if (utils_isEsmFile(configPath) &&
|
|
506
|
+
if (utils_isEsmFile(configPath) && isTsFile(configPath)) return;
|
|
510
507
|
const { default: interpret } = await import("interpret");
|
|
511
508
|
const extensions = Object.fromEntries(Object.entries(interpret.extensions).filter(([key])=>key === ext));
|
|
512
509
|
if (0 === Object.keys(extensions).length) throw new Error(`config file "${configPath}" is not supported.`);
|
|
@@ -550,7 +547,7 @@ async function loadExtendedConfig(config, configPath, cwd, options) {
|
|
|
550
547
|
throw new Error(`Cannot find module '${extendPath}' to extend from.`);
|
|
551
548
|
}
|
|
552
549
|
if (!external_node_fs_["default"].existsSync(resolvedPath)) throw new Error(`Extended configuration file "${resolvedPath}" not found.`);
|
|
553
|
-
if (
|
|
550
|
+
if (isTsFile(resolvedPath) && "register" === options.configLoader) await registerLoader(resolvedPath);
|
|
554
551
|
let extendedConfig = await crossImport(resolvedPath, cwd);
|
|
555
552
|
if ("function" == typeof extendedConfig) {
|
|
556
553
|
var _options_argv;
|
|
@@ -568,13 +565,13 @@ async function loadRspackConfig(options, cwd = process.cwd()) {
|
|
|
568
565
|
if (options.config) {
|
|
569
566
|
configPath = external_node_path_["default"].resolve(cwd, options.config);
|
|
570
567
|
if (!external_node_fs_["default"].existsSync(configPath)) throw new Error(`config file "${configPath}" not found.`);
|
|
571
|
-
if (
|
|
568
|
+
if (isTsFile(configPath) && "register" === options.configLoader) await registerLoader(configPath);
|
|
572
569
|
loadedConfig = await crossImport(configPath, cwd);
|
|
573
570
|
} else {
|
|
574
571
|
const defaultConfig = utils_findConfig(external_node_path_["default"].resolve(cwd, loadConfig_DEFAULT_CONFIG_NAME));
|
|
575
572
|
if (!defaultConfig) return {};
|
|
576
573
|
configPath = defaultConfig;
|
|
577
|
-
if (
|
|
574
|
+
if (isTsFile(defaultConfig) && "register" === options.configLoader) await registerLoader(defaultConfig);
|
|
578
575
|
loadedConfig = await crossImport(defaultConfig, cwd);
|
|
579
576
|
}
|
|
580
577
|
if ("function" != typeof loadedConfig && configPath) loadedConfig = await loadExtendedConfig(loadedConfig, configPath, cwd, options);
|
|
@@ -613,9 +610,9 @@ class RspackCLI {
|
|
|
613
610
|
return compiler;
|
|
614
611
|
}
|
|
615
612
|
createColors(useColor) {
|
|
616
|
-
const shouldUseColor = useColor ||
|
|
613
|
+
const shouldUseColor = useColor || isColorSupported;
|
|
617
614
|
return {
|
|
618
|
-
...
|
|
615
|
+
...createColors({
|
|
619
616
|
useColor: shouldUseColor
|
|
620
617
|
}),
|
|
621
618
|
isColorSupported: shouldUseColor
|
|
@@ -623,7 +620,7 @@ class RspackCLI {
|
|
|
623
620
|
}
|
|
624
621
|
getLogger() {
|
|
625
622
|
return {
|
|
626
|
-
error: (val)=>console.error(`[rspack-cli] ${this.colors.red(
|
|
623
|
+
error: (val)=>console.error(`[rspack-cli] ${this.colors.red(external_node_util_default.format(val))}`),
|
|
627
624
|
warn: (val)=>console.warn(`[rspack-cli] ${this.colors.yellow(val)}`),
|
|
628
625
|
info: (val)=>console.info(`[rspack-cli] ${this.colors.cyan(val)}`),
|
|
629
626
|
success: (val)=>console.log(`[rspack-cli] ${this.colors.green(val)}`),
|
|
@@ -638,7 +635,7 @@ class RspackCLI {
|
|
|
638
635
|
this.program.strictCommands(true).strict(true);
|
|
639
636
|
this.program.middleware(normalizeEnv);
|
|
640
637
|
this.registerCommands();
|
|
641
|
-
await this.program.parseAsync(
|
|
638
|
+
await this.program.parseAsync(hideBin(argv));
|
|
642
639
|
}
|
|
643
640
|
async registerCommands() {
|
|
644
641
|
const builtinCommands = [
|
|
@@ -736,7 +733,7 @@ class RspackCLI {
|
|
|
736
733
|
_define_property(this, "colors", void 0);
|
|
737
734
|
_define_property(this, "program", void 0);
|
|
738
735
|
this.colors = this.createColors();
|
|
739
|
-
this.program = (
|
|
736
|
+
this.program = external_yargs_default();
|
|
740
737
|
}
|
|
741
738
|
}
|
|
742
739
|
function defineConfig(config) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0-beta.1",
|
|
4
4
|
"description": "CLI for rspack",
|
|
5
5
|
"homepage": "https://rspack.rs",
|
|
6
6
|
"bugs": "https://github.com/web-infra-dev/rspack/issues",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"yargs": "17.7.2"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@rslib/core": "0.9.
|
|
41
|
+
"@rslib/core": "0.9.2",
|
|
42
42
|
"@types/interpret": "^1.1.3",
|
|
43
43
|
"@types/rechoir": "^0.6.4",
|
|
44
44
|
"@types/webpack-bundle-analyzer": "^4.7.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"execa": "^5.1.1",
|
|
49
49
|
"ts-node": "^10.9.2",
|
|
50
50
|
"typescript": "^5.8.3",
|
|
51
|
-
"@rspack/core": "1.
|
|
51
|
+
"@rspack/core": "1.4.0-beta.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@rspack/core": "^1.0.0-alpha || ^1.x"
|