@rspack/cli 1.3.14 → 1.4.0-beta.0
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 +11 -11
- package/dist/index.mjs +20 -20
- package/package.json +4 -4
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_);
|
|
@@ -490,7 +490,7 @@ var __webpack_exports__ = {};
|
|
|
490
490
|
}
|
|
491
491
|
}
|
|
492
492
|
const external_node_url_namespaceObject = require("node:url");
|
|
493
|
-
const
|
|
493
|
+
const readPackageUp = (cwd = process.cwd())=>{
|
|
494
494
|
let currentDir = external_node_path_default().resolve(cwd);
|
|
495
495
|
let packageJsonPath = external_node_path_default().join(currentDir, "package.json");
|
|
496
496
|
while(!external_node_fs_default().existsSync(packageJsonPath)){
|
|
@@ -505,12 +505,12 @@ var __webpack_exports__ = {};
|
|
|
505
505
|
return null;
|
|
506
506
|
}
|
|
507
507
|
};
|
|
508
|
-
const
|
|
508
|
+
const utils_readPackageUp = readPackageUp;
|
|
509
509
|
const isEsmFile = (filePath, cwd = process.cwd())=>{
|
|
510
510
|
const ext = external_node_path_default().extname(filePath);
|
|
511
511
|
if (/\.(mjs|mts)$/.test(ext)) return true;
|
|
512
512
|
if (/\.(cjs|cts)/.test(ext)) return false;
|
|
513
|
-
const packageJson =
|
|
513
|
+
const packageJson = utils_readPackageUp(external_node_path_default().dirname(filePath));
|
|
514
514
|
return (null == packageJson ? void 0 : packageJson.type) === "module";
|
|
515
515
|
};
|
|
516
516
|
const utils_isEsmFile = isEsmFile;
|
|
@@ -534,15 +534,15 @@ var __webpack_exports__ = {};
|
|
|
534
534
|
];
|
|
535
535
|
const findConfig = (basePath)=>DEFAULT_EXTENSIONS.map((ext)=>basePath + ext).find(external_node_fs_default().existsSync);
|
|
536
536
|
const utils_findConfig = findConfig;
|
|
537
|
-
const
|
|
537
|
+
const isTsFile_isTsFile = (configPath)=>{
|
|
538
538
|
const ext = external_node_path_default().extname(configPath);
|
|
539
539
|
return /\.(c|m)?ts$/.test(ext);
|
|
540
540
|
};
|
|
541
|
-
const
|
|
541
|
+
const isTsFile = isTsFile_isTsFile;
|
|
542
542
|
const loadConfig_DEFAULT_CONFIG_NAME = "rspack.config";
|
|
543
543
|
const registerLoader = async (configPath)=>{
|
|
544
544
|
const ext = external_node_path_default().extname(configPath);
|
|
545
|
-
if (utils_isEsmFile(configPath) &&
|
|
545
|
+
if (utils_isEsmFile(configPath) && isTsFile(configPath)) return;
|
|
546
546
|
const { default: interpret } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "interpret"));
|
|
547
547
|
const extensions = Object.fromEntries(Object.entries(interpret.extensions).filter(([key])=>key === ext));
|
|
548
548
|
if (0 === Object.keys(extensions).length) throw new Error(`config file "${configPath}" is not supported.`);
|
|
@@ -586,7 +586,7 @@ var __webpack_exports__ = {};
|
|
|
586
586
|
throw new Error(`Cannot find module '${extendPath}' to extend from.`);
|
|
587
587
|
}
|
|
588
588
|
if (!external_node_fs_default().existsSync(resolvedPath)) throw new Error(`Extended configuration file "${resolvedPath}" not found.`);
|
|
589
|
-
if (
|
|
589
|
+
if (isTsFile(resolvedPath) && "register" === options.configLoader) await registerLoader(resolvedPath);
|
|
590
590
|
let extendedConfig = await crossImport(resolvedPath, cwd);
|
|
591
591
|
if ("function" == typeof extendedConfig) {
|
|
592
592
|
var _options_argv;
|
|
@@ -604,13 +604,13 @@ var __webpack_exports__ = {};
|
|
|
604
604
|
if (options.config) {
|
|
605
605
|
configPath = external_node_path_default().resolve(cwd, options.config);
|
|
606
606
|
if (!external_node_fs_default().existsSync(configPath)) throw new Error(`config file "${configPath}" not found.`);
|
|
607
|
-
if (
|
|
607
|
+
if (isTsFile(configPath) && "register" === options.configLoader) await registerLoader(configPath);
|
|
608
608
|
loadedConfig = await crossImport(configPath, cwd);
|
|
609
609
|
} else {
|
|
610
610
|
const defaultConfig = utils_findConfig(external_node_path_default().resolve(cwd, loadConfig_DEFAULT_CONFIG_NAME));
|
|
611
611
|
if (!defaultConfig) return {};
|
|
612
612
|
configPath = defaultConfig;
|
|
613
|
-
if (
|
|
613
|
+
if (isTsFile(defaultConfig) && "register" === options.configLoader) await registerLoader(defaultConfig);
|
|
614
614
|
loadedConfig = await crossImport(defaultConfig, cwd);
|
|
615
615
|
}
|
|
616
616
|
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__;
|
|
@@ -454,7 +454,7 @@ class ServeCommand {
|
|
|
454
454
|
});
|
|
455
455
|
}
|
|
456
456
|
}
|
|
457
|
-
const
|
|
457
|
+
const readPackageUp = (cwd = process.cwd())=>{
|
|
458
458
|
let currentDir = external_node_path_["default"].resolve(cwd);
|
|
459
459
|
let packageJsonPath = external_node_path_["default"].join(currentDir, "package.json");
|
|
460
460
|
while(!external_node_fs_["default"].existsSync(packageJsonPath)){
|
|
@@ -469,18 +469,18 @@ const readPackageUp_readPackageUp = (cwd = process.cwd())=>{
|
|
|
469
469
|
return null;
|
|
470
470
|
}
|
|
471
471
|
};
|
|
472
|
-
const
|
|
472
|
+
const utils_readPackageUp = readPackageUp;
|
|
473
473
|
const isEsmFile = (filePath, cwd = process.cwd())=>{
|
|
474
474
|
const ext = external_node_path_["default"].extname(filePath);
|
|
475
475
|
if (/\.(mjs|mts)$/.test(ext)) return true;
|
|
476
476
|
if (/\.(cjs|cts)/.test(ext)) return false;
|
|
477
|
-
const packageJson =
|
|
477
|
+
const packageJson = utils_readPackageUp(external_node_path_["default"].dirname(filePath));
|
|
478
478
|
return (null == packageJson ? void 0 : packageJson.type) === "module";
|
|
479
479
|
};
|
|
480
480
|
const utils_isEsmFile = isEsmFile;
|
|
481
481
|
const crossImport = async (path, cwd = process.cwd())=>{
|
|
482
482
|
if (utils_isEsmFile(path, cwd)) {
|
|
483
|
-
const url =
|
|
483
|
+
const url = pathToFileURL(path).href;
|
|
484
484
|
const { default: config } = await import(url);
|
|
485
485
|
return config;
|
|
486
486
|
}
|
|
@@ -498,15 +498,15 @@ const DEFAULT_EXTENSIONS = [
|
|
|
498
498
|
];
|
|
499
499
|
const findConfig = (basePath)=>DEFAULT_EXTENSIONS.map((ext)=>basePath + ext).find(external_node_fs_["default"].existsSync);
|
|
500
500
|
const utils_findConfig = findConfig;
|
|
501
|
-
const
|
|
501
|
+
const isTsFile_isTsFile = (configPath)=>{
|
|
502
502
|
const ext = external_node_path_["default"].extname(configPath);
|
|
503
503
|
return /\.(c|m)?ts$/.test(ext);
|
|
504
504
|
};
|
|
505
|
-
const
|
|
505
|
+
const isTsFile = isTsFile_isTsFile;
|
|
506
506
|
const loadConfig_DEFAULT_CONFIG_NAME = "rspack.config";
|
|
507
507
|
const registerLoader = async (configPath)=>{
|
|
508
508
|
const ext = external_node_path_["default"].extname(configPath);
|
|
509
|
-
if (utils_isEsmFile(configPath) &&
|
|
509
|
+
if (utils_isEsmFile(configPath) && isTsFile(configPath)) return;
|
|
510
510
|
const { default: interpret } = await import("interpret");
|
|
511
511
|
const extensions = Object.fromEntries(Object.entries(interpret.extensions).filter(([key])=>key === ext));
|
|
512
512
|
if (0 === Object.keys(extensions).length) throw new Error(`config file "${configPath}" is not supported.`);
|
|
@@ -550,7 +550,7 @@ async function loadExtendedConfig(config, configPath, cwd, options) {
|
|
|
550
550
|
throw new Error(`Cannot find module '${extendPath}' to extend from.`);
|
|
551
551
|
}
|
|
552
552
|
if (!external_node_fs_["default"].existsSync(resolvedPath)) throw new Error(`Extended configuration file "${resolvedPath}" not found.`);
|
|
553
|
-
if (
|
|
553
|
+
if (isTsFile(resolvedPath) && "register" === options.configLoader) await registerLoader(resolvedPath);
|
|
554
554
|
let extendedConfig = await crossImport(resolvedPath, cwd);
|
|
555
555
|
if ("function" == typeof extendedConfig) {
|
|
556
556
|
var _options_argv;
|
|
@@ -568,13 +568,13 @@ async function loadRspackConfig(options, cwd = process.cwd()) {
|
|
|
568
568
|
if (options.config) {
|
|
569
569
|
configPath = external_node_path_["default"].resolve(cwd, options.config);
|
|
570
570
|
if (!external_node_fs_["default"].existsSync(configPath)) throw new Error(`config file "${configPath}" not found.`);
|
|
571
|
-
if (
|
|
571
|
+
if (isTsFile(configPath) && "register" === options.configLoader) await registerLoader(configPath);
|
|
572
572
|
loadedConfig = await crossImport(configPath, cwd);
|
|
573
573
|
} else {
|
|
574
574
|
const defaultConfig = utils_findConfig(external_node_path_["default"].resolve(cwd, loadConfig_DEFAULT_CONFIG_NAME));
|
|
575
575
|
if (!defaultConfig) return {};
|
|
576
576
|
configPath = defaultConfig;
|
|
577
|
-
if (
|
|
577
|
+
if (isTsFile(defaultConfig) && "register" === options.configLoader) await registerLoader(defaultConfig);
|
|
578
578
|
loadedConfig = await crossImport(defaultConfig, cwd);
|
|
579
579
|
}
|
|
580
580
|
if ("function" != typeof loadedConfig && configPath) loadedConfig = await loadExtendedConfig(loadedConfig, configPath, cwd, options);
|
|
@@ -613,9 +613,9 @@ class RspackCLI {
|
|
|
613
613
|
return compiler;
|
|
614
614
|
}
|
|
615
615
|
createColors(useColor) {
|
|
616
|
-
const shouldUseColor = useColor ||
|
|
616
|
+
const shouldUseColor = useColor || isColorSupported;
|
|
617
617
|
return {
|
|
618
|
-
...
|
|
618
|
+
...createColors({
|
|
619
619
|
useColor: shouldUseColor
|
|
620
620
|
}),
|
|
621
621
|
isColorSupported: shouldUseColor
|
|
@@ -623,7 +623,7 @@ class RspackCLI {
|
|
|
623
623
|
}
|
|
624
624
|
getLogger() {
|
|
625
625
|
return {
|
|
626
|
-
error: (val)=>console.error(`[rspack-cli] ${this.colors.red(
|
|
626
|
+
error: (val)=>console.error(`[rspack-cli] ${this.colors.red(external_node_util_default.format(val))}`),
|
|
627
627
|
warn: (val)=>console.warn(`[rspack-cli] ${this.colors.yellow(val)}`),
|
|
628
628
|
info: (val)=>console.info(`[rspack-cli] ${this.colors.cyan(val)}`),
|
|
629
629
|
success: (val)=>console.log(`[rspack-cli] ${this.colors.green(val)}`),
|
|
@@ -638,7 +638,7 @@ class RspackCLI {
|
|
|
638
638
|
this.program.strictCommands(true).strict(true);
|
|
639
639
|
this.program.middleware(normalizeEnv);
|
|
640
640
|
this.registerCommands();
|
|
641
|
-
await this.program.parseAsync(
|
|
641
|
+
await this.program.parseAsync(hideBin(argv));
|
|
642
642
|
}
|
|
643
643
|
async registerCommands() {
|
|
644
644
|
const builtinCommands = [
|
|
@@ -736,7 +736,7 @@ class RspackCLI {
|
|
|
736
736
|
_define_property(this, "colors", void 0);
|
|
737
737
|
_define_property(this, "program", void 0);
|
|
738
738
|
this.colors = this.createColors();
|
|
739
|
-
this.program = (
|
|
739
|
+
this.program = external_yargs_default();
|
|
740
740
|
}
|
|
741
741
|
}
|
|
742
742
|
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.0",
|
|
4
4
|
"description": "CLI for rspack",
|
|
5
5
|
"homepage": "https://rspack.rs",
|
|
6
6
|
"bugs": "https://github.com/web-infra-dev/rspack/issues",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@discoveryjs/json-ext": "^0.5.7",
|
|
32
|
-
"@rspack/dev-server": "1.1.
|
|
32
|
+
"@rspack/dev-server": "~1.1.3",
|
|
33
33
|
"colorette": "2.0.20",
|
|
34
34
|
"exit-hook": "^4.0.0",
|
|
35
35
|
"interpret": "^3.1.1",
|
|
@@ -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.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@rspack/core": "^1.0.0-alpha || ^1.x"
|