🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

@rspack/cli

Package Overview
Dependencies
Maintainers
2
Versions
1195
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rspack/cli - npm Package Compare versions

Comparing version
2.0.0
to
2.0.1
+2
-2
dist/162.js

@@ -827,3 +827,3 @@ import node_path from "node:path";

hot: false,
port: options.port ?? 8080,
port: options.port ?? devServer?.port ?? 8080,
proxy: devServer?.proxy,

@@ -1136,3 +1136,3 @@ host: options.host ?? devServer?.host,

program.help();
program.version("2.0.0");
program.version("2.0.1");
}

@@ -1139,0 +1139,0 @@ wrapAction(fn) {

@@ -1,2 +0,301 @@

export { defineConfig, definePlugin, RspackCLI } from './cli';
export * from './types';
import type { Compiler } from '@rspack/core';
import { Configuration } from '@rspack/core';
import type { MultiCompiler } from '@rspack/core';
import type { MultiRspackOptions } from '@rspack/core';
import type { MultiStats } from '@rspack/core';
import type { RspackOptions } from '@rspack/core';
import type { RspackPluginFunction } from '@rspack/core';
import type { RspackPluginInstance } from '@rspack/core';
import type { Stats } from '@rspack/core';
declare class CAC extends EventTarget {
/** The program name to display in help and version message */
name: string;
commands: Command[];
globalCommand: GlobalCommand;
matchedCommand?: Command;
matchedCommandName?: string;
/**
* Raw CLI arguments
*/
rawArgs: string[];
/**
* Parsed CLI arguments
*/
args: ParsedArgv["args"];
/**
* Parsed CLI options, camelCased
*/
options: ParsedArgv["options"];
showHelpOnExit?: boolean;
showVersionOnExit?: boolean;
/**
* @param name The program name to display in help and version message
*/
constructor(name?: string);
/**
* Add a global usage text.
*
* This is not used by sub-commands.
*/
usage(text: string): this;
/**
* Add a sub-command
*/
command(rawName: string, description?: string, config?: CommandConfig): Command;
/**
* Add a global CLI option.
*
* Which is also applied to sub-commands.
*/
option(rawName: string, description: string, config?: OptionConfig): this;
/**
* Show help message when `-h, --help` flags appear.
*
*/
help(callback?: HelpCallback): this;
/**
* Show version number when `-v, --version` flags appear.
*
*/
version(version: string, customFlags?: string): this;
/**
* Add a global example.
*
* This example added here will not be used by sub-commands.
*/
example(example: CommandExample): this;
/**
* Output the corresponding help message
* When a sub-command is matched, output the help message for the command
* Otherwise output the global one.
*
*/
outputHelp(): void;
/**
* Output the version number.
*
*/
outputVersion(): void;
private setParsedInfo;
unsetMatchedCommand(): void;
/**
* Parse argv
*/
parse(argv?: string[], {
run
}?: {
/** Whether to run the action for matched command */run?: boolean | undefined;
}): ParsedArgv;
private mri;
runMatchedCommand(): any;
}
declare class Command {
rawName: string;
description: string;
config: CommandConfig;
cli: CAC;
options: Option_2[];
aliasNames: string[];
name: string;
args: CommandArg[];
commandAction?: (...args: any[]) => any;
usageText?: string;
versionNumber?: string;
examples: CommandExample[];
helpCallback?: HelpCallback;
globalCommand?: GlobalCommand;
constructor(rawName: string, description: string, config: CommandConfig | undefined, cli: CAC);
usage(text: string): this;
allowUnknownOptions(): this;
ignoreOptionDefaultValue(): this;
version(version: string, customFlags?: string): this;
example(example: CommandExample): this;
/**
* Add a option for this command
* @param rawName Raw option name(s)
* @param description Option description
* @param config Option config
*/
option(rawName: string, description: string, config?: OptionConfig): this;
alias(name: string): this;
action(callback: (...args: any[]) => any): this;
/**
* Check if a command name is matched by this command
* @param name Command name
*/
isMatched(name: string): boolean;
get isDefaultCommand(): boolean;
get isGlobalCommand(): boolean;
/**
* Check if an option is registered in this command
* @param name Option name
*/
hasOption(name: string): Option_2 | undefined;
outputHelp(): void;
outputVersion(): void;
checkRequiredArgs(): void;
/**
* Check if the parsed options contain any unknown options
*
* Exit and output error when true
*/
checkUnknownOptions(): void;
/**
* Check if the required string-type options exist
*/
checkOptionValue(): void;
/**
* Check if the number of args is more than expected
*/
checkUnusedArgs(): void;
}
declare type Command_2 = 'serve' | 'build';
declare interface CommandArg {
required: boolean;
value: string;
variadic: boolean;
}
declare interface CommandConfig {
allowUnknownOptions?: boolean;
ignoreOptionDefaultValue?: boolean;
}
declare type CommandExample = ((bin: string) => string) | string;
declare type CommonOptions = {
config?: string;
configName?: string[];
configLoader?: ConfigLoader;
env?: Record<string, unknown> | string[];
nodeEnv?: string;
};
declare type CommonOptionsForBuildAndServe = CommonOptions & {
devtool?: string | boolean;
entry?: string[];
mode?: string;
outputPath?: string;
watch?: boolean;
};
declare type ConfigLoader = 'auto' | 'jiti' | 'native';
export { Configuration }
/**
* This function helps you to autocomplete configuration types.
* It accepts a Rspack config object, or a function that returns a config.
*/
export declare function defineConfig(config: RspackOptions): RspackOptions;
export declare function defineConfig(config: MultiRspackOptions): MultiRspackOptions;
export declare function defineConfig(config: RspackConfigFn): RspackConfigFn;
export declare function defineConfig(config: RspackConfigAsyncFn): RspackConfigAsyncFn;
export declare function defineConfig(config: RspackConfigExport): RspackConfigExport;
export declare function definePlugin(plugin: RspackPluginFunction): RspackPluginFunction;
export declare function definePlugin(plugin: RspackPluginInstance): RspackPluginInstance;
declare class GlobalCommand extends Command {
constructor(cli: CAC);
}
declare type HelpCallback = (sections: HelpSection[]) => void | HelpSection[];
declare interface HelpSection {
title?: string;
body: string;
}
export declare type LogHandler = (value: any) => void;
declare class Option_2 {
rawName: string;
description: string;
/** Option name */
name: string;
/** Option name and aliases */
names: string[];
isBoolean?: boolean;
required?: boolean;
config: OptionConfig;
negated: boolean;
constructor(rawName: string, description: string, config?: OptionConfig);
}
declare interface OptionConfig {
default?: any;
type?: any[];
}
declare interface ParsedArgv {
args: ReadonlyArray<string>;
options: {
[k: string]: any;
};
}
export declare class RspackCLI {
colors: RspackCLIColors;
program: CAC;
_actionPromise: Promise<void> | undefined;
constructor();
/**
* Wraps an async action handler so its promise is captured and can be
* awaited in `run()`. CAC's `parse()` does not await async actions,
* so without this wrapper, rejections become unhandled.
*/
wrapAction<T extends (...args: any[]) => Promise<void>>(fn: T): T;
buildCompilerConfig(options: CommonOptionsForBuildAndServe, rspackCommand: Command_2): Promise<RspackOptions | MultiRspackOptions>;
createCompiler(config: RspackOptions | MultiRspackOptions, callback?: (e: Error | null, res?: Stats | MultiStats) => void): Promise<MultiCompiler | Compiler | null>;
private createColors;
getLogger(): RspackCLILogger;
run(argv: string[]): Promise<void>;
private registerCommands;
private buildConfig;
loadConfig(options: CommonOptions): Promise<{
config: RspackOptions | MultiRspackOptions;
pathMap: WeakMap<RspackOptions, string[]>;
}>;
private filterConfig;
isMultipleCompiler(compiler: Compiler | MultiCompiler): compiler is MultiCompiler;
isWatch(compiler: Compiler | MultiCompiler): boolean;
}
export declare interface RspackCLIColors {
isColorSupported: boolean;
red(text: string): string;
yellow(text: string): string;
cyan(text: string): string;
green(text: string): string;
}
export declare interface RspackCLILogger {
error: LogHandler;
warn: LogHandler;
info: LogHandler;
success: LogHandler;
log: LogHandler;
raw: LogHandler;
}
export declare interface RspackCommand {
apply(cli: RspackCLI): Promise<void>;
}
declare type RspackConfigAsyncFn = (env: Record<string, any>, argv: Record<string, any>) => Promise<RspackOptions | MultiRspackOptions>;
declare type RspackConfigExport = RspackOptions | MultiRspackOptions | RspackConfigFn | RspackConfigAsyncFn;
declare type RspackConfigFn = (env: Record<string, any>, argv: Record<string, any>) => RspackOptions | MultiRspackOptions;
export { }
{
"name": "@rspack/cli",
"version": "2.0.0",
"version": "2.0.1",
"description": "CLI for rspack",

@@ -32,4 +32,5 @@ "homepage": "https://rspack.rs",

"@discoveryjs/json-ext": "^0.5.7",
"@rslib/core": "0.21.2",
"@rspack/dev-server": "^2.0.0",
"@microsoft/api-extractor": "^7.58.7",
"@rslib/core": "0.21.3",
"@rspack/dev-server": "^2.0.1",
"cac": "^7.0.0",

@@ -43,4 +44,4 @@ "concat-stream": "^2.0.0",

"typescript": "^6.0.3",
"@rspack/core": "2.0.0",
"@rspack/test-tools": "2.0.0"
"@rspack/core": "2.0.1",
"@rspack/test-tools": "2.0.1"
},

@@ -47,0 +48,0 @@ "peerDependencies": {

import type { Compiler, MultiCompiler, MultiRspackOptions, MultiStats, RspackOptions, RspackPluginFunction, RspackPluginInstance, Stats } from '@rspack/core';
import { type CAC } from 'cac';
import type { RspackCLIColors, RspackCLILogger } from './types';
import type { CommonOptions, CommonOptionsForBuildAndServe } from './utils/options';
type Command = 'serve' | 'build';
declare global {
const RSPACK_CLI_VERSION: string;
}
export declare class RspackCLI {
colors: RspackCLIColors;
program: CAC;
_actionPromise: Promise<void> | undefined;
constructor();
/**
* Wraps an async action handler so its promise is captured and can be
* awaited in `run()`. CAC's `parse()` does not await async actions,
* so without this wrapper, rejections become unhandled.
*/
wrapAction<T extends (...args: any[]) => Promise<void>>(fn: T): T;
buildCompilerConfig(options: CommonOptionsForBuildAndServe, rspackCommand: Command): Promise<RspackOptions | MultiRspackOptions>;
createCompiler(config: RspackOptions | MultiRspackOptions, callback?: (e: Error | null, res?: Stats | MultiStats) => void): Promise<MultiCompiler | Compiler | null>;
private createColors;
getLogger(): RspackCLILogger;
run(argv: string[]): Promise<void>;
private registerCommands;
private buildConfig;
loadConfig(options: CommonOptions): Promise<{
config: RspackOptions | MultiRspackOptions;
pathMap: WeakMap<RspackOptions, string[]>;
}>;
private filterConfig;
isMultipleCompiler(compiler: Compiler | MultiCompiler): compiler is MultiCompiler;
isWatch(compiler: Compiler | MultiCompiler): boolean;
}
export type RspackConfigFn = (env: Record<string, any>, argv: Record<string, any>) => RspackOptions | MultiRspackOptions;
export type RspackConfigAsyncFn = (env: Record<string, any>, argv: Record<string, any>) => Promise<RspackOptions | MultiRspackOptions>;
export type RspackConfigExport = RspackOptions | MultiRspackOptions | RspackConfigFn | RspackConfigAsyncFn;
/**
* This function helps you to autocomplete configuration types.
* It accepts a Rspack config object, or a function that returns a config.
*/
export declare function defineConfig(config: RspackOptions): RspackOptions;
export declare function defineConfig(config: MultiRspackOptions): MultiRspackOptions;
export declare function defineConfig(config: RspackConfigFn): RspackConfigFn;
export declare function defineConfig(config: RspackConfigAsyncFn): RspackConfigAsyncFn;
export declare function defineConfig(config: RspackConfigExport): RspackConfigExport;
export declare function definePlugin(plugin: RspackPluginFunction): RspackPluginFunction;
export declare function definePlugin(plugin: RspackPluginInstance): RspackPluginInstance;
export {};
import type { RspackCLI } from '../cli';
import type { RspackCommand } from '../types';
export declare class BuildCommand implements RspackCommand {
apply(cli: RspackCLI): Promise<void>;
}
import type { RspackCLI } from '../cli';
import type { RspackCommand } from '../types';
export declare class PreviewCommand implements RspackCommand {
apply(cli: RspackCLI): Promise<void>;
}
import type { RspackCLI } from '../cli';
import type { RspackCommand } from '../types';
export declare class ServeCommand implements RspackCommand {
apply(cli: RspackCLI): Promise<void>;
}
export declare const DEFAULT_CONFIG_NAME: "rspack.config";
export declare const DEFAULT_EXTENSIONS: readonly [".ts", ".js", ".mts", ".mjs", ".cts", ".cjs"];
export declare const DEFAULT_SERVER_HOT = true;
import type { RspackCLI } from './cli';
export type { Configuration } from '@rspack/core';
export type LogHandler = (value: any) => void;
export interface RspackCLIColors {
isColorSupported: boolean;
red(text: string): string;
yellow(text: string): string;
cyan(text: string): string;
green(text: string): string;
}
export interface RspackCLILogger {
error: LogHandler;
warn: LogHandler;
info: LogHandler;
success: LogHandler;
log: LogHandler;
raw: LogHandler;
}
export interface RspackCommand {
apply(cli: RspackCLI): Promise<void>;
}
/**
* Takes a basePath like `webpack.config`, return `webpack.config.{ext}` if
* exists. returns undefined if none of them exists
*/
declare const findConfig: (basePath: string) => string | undefined;
export default findConfig;
export declare const TS_EXTENSION: string[];
declare const isTsFile: (configPath: string) => boolean;
export default isTsFile;
import type { MultiRspackOptions, RspackOptions } from '@rspack/core';
import type { CommonOptions } from './options';
export type LoadedRspackConfig = undefined | RspackOptions | MultiRspackOptions | ((env: Record<string, any>, argv?: Record<string, any>) => RspackOptions | MultiRspackOptions | Promise<RspackOptions | MultiRspackOptions>);
export declare const resolveRspackConfigExport: (configExport: LoadedRspackConfig, options: CommonOptions) => Promise<RspackOptions | MultiRspackOptions>;
/**
* Loads and merges configurations from the 'extends' property
* @param config The configuration object that may contain an 'extends' property
* @param configPath The path to the configuration file
* @param cwd The current working directory
* @param options CLI options
* @returns The merged configuration
*/
export declare function loadExtendedConfig(config: RspackOptions, configPath: string, cwd: string, options: CommonOptions): Promise<{
config: RspackOptions;
pathMap: WeakMap<RspackOptions, string[]>;
}>;
export declare function loadExtendedConfig(config: MultiRspackOptions, configPath: string, cwd: string, options: CommonOptions): Promise<{
config: MultiRspackOptions;
pathMap: WeakMap<RspackOptions, string[]>;
}>;
export declare function loadExtendedConfig(config: RspackOptions | MultiRspackOptions, configPath: string, cwd: string, options: CommonOptions): Promise<{
config: RspackOptions | MultiRspackOptions;
pathMap: WeakMap<RspackOptions, string[]>;
}>;
export declare function loadRspackConfig(options: CommonOptions, cwd?: string): Promise<{
loadedConfig: LoadedRspackConfig;
configPath: string;
} | null>;
import type { Command } from 'cac';
export type ConfigLoader = 'auto' | 'jiti' | 'native';
/**
* Apply common options for all commands
*/
export declare const commonOptions: (command: Command) => Command;
export type CommonOptions = {
config?: string;
configName?: string[];
configLoader?: ConfigLoader;
env?: Record<string, unknown> | string[];
nodeEnv?: string;
};
export declare const normalizeCommonOptions: (options: CommonOptions | CommonOptionsForBuildAndServe, action: "serve" | "build" | "preview") => void;
/**
* Apply common options for `build` and `serve` commands
*/
export declare const commonOptionsForBuildAndServe: (command: Command) => Command;
export type CommonOptionsForBuildAndServe = CommonOptions & {
devtool?: string | boolean;
entry?: string[];
mode?: string;
outputPath?: string;
watch?: boolean;
};
export declare function setDefaultNodeEnv(options: {
nodeEnv?: unknown;
}, defaultEnv: string): void;
export declare function applyProfile(filterValue: string, traceLayer?: string, traceOutput?: string): Promise<void>;