@ikaros-cli/ikaros 2.0.0 → 2.1.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/index.d.mts +319 -12
- package/dist/index.mjs +8 -5
- package/package.json +24 -22
- package/readme.md +39 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _rspack_core0 from "@rspack/core";
|
|
2
|
-
import { DefinePluginOptions, LightningcssLoaderOptions, Loader, ModuleFederationPluginOptions, Plugin } from "@rspack/core";
|
|
2
|
+
import { Configuration, DefinePluginOptions, LightningcssLoaderOptions, Loader, ModuleFederationPluginOptions, Plugin, RuleSetRule, WatchOptions, rspack } from "@rspack/core";
|
|
3
3
|
import * as _rspack_dev_server0 from "@rspack/dev-server";
|
|
4
4
|
import * as https0 from "https";
|
|
5
5
|
|
|
@@ -10,20 +10,87 @@ interface ImportMetaBaseEnv {
|
|
|
10
10
|
/** 路径前缀 */
|
|
11
11
|
BASE?: string;
|
|
12
12
|
/** 平台 */
|
|
13
|
-
PLATFORM: 'web';
|
|
13
|
+
PLATFORM: 'web' | 'desktopClient';
|
|
14
14
|
}
|
|
15
15
|
type ImportMetaEnv = Record<string, any>;
|
|
16
16
|
interface ImportMeta {
|
|
17
17
|
readonly env: Readonly<ImportMetaEnv & ImportMetaBaseEnv>;
|
|
18
18
|
}
|
|
19
19
|
//#endregion
|
|
20
|
-
//#region src/node/compile/base-compile-service.d.ts
|
|
20
|
+
//#region src/node/compile/core/base-compile-service.d.ts
|
|
21
|
+
type PackageJson = {
|
|
22
|
+
name: string;
|
|
23
|
+
version: string;
|
|
24
|
+
};
|
|
21
25
|
/** 命令 */
|
|
22
|
-
declare
|
|
26
|
+
declare enum Command {
|
|
23
27
|
SERVER = "server",
|
|
24
28
|
BUILD = "build",
|
|
25
29
|
}
|
|
26
30
|
/** 命令选项 */
|
|
31
|
+
type CompileOptions = {
|
|
32
|
+
/** 模式 */
|
|
33
|
+
readonly mode?: string;
|
|
34
|
+
/** 平台 */
|
|
35
|
+
readonly platform: ImportMetaBaseEnv['PLATFORM'];
|
|
36
|
+
};
|
|
37
|
+
type CompileServeParame = {
|
|
38
|
+
command: Command;
|
|
39
|
+
options: CompileOptions;
|
|
40
|
+
configFile?: string;
|
|
41
|
+
onBuildStatus?: (status: {
|
|
42
|
+
success: boolean;
|
|
43
|
+
port?: number;
|
|
44
|
+
message?: string;
|
|
45
|
+
}) => void;
|
|
46
|
+
};
|
|
47
|
+
declare abstract class BaseCompileService {
|
|
48
|
+
/** 构建类型 */
|
|
49
|
+
readonly command: Command;
|
|
50
|
+
/** cli上下文空间 */
|
|
51
|
+
readonly context: string;
|
|
52
|
+
/** 选项 */
|
|
53
|
+
readonly options: CompileOptions;
|
|
54
|
+
/** 基于工作目录的Require */
|
|
55
|
+
readonly contextRequire: NodeRequire;
|
|
56
|
+
private _env;
|
|
57
|
+
/** 配置文件 */
|
|
58
|
+
readonly configFile?: string;
|
|
59
|
+
/** env */
|
|
60
|
+
private set env(value);
|
|
61
|
+
get env(): ConfigEnvPre["env"];
|
|
62
|
+
private _contextPkg?;
|
|
63
|
+
/** 用户配置 */
|
|
64
|
+
userConfig?: UserConfig;
|
|
65
|
+
/** 工作目录的 package.json */
|
|
66
|
+
private set contextPkg(value);
|
|
67
|
+
get contextPkg(): PackageJson | undefined;
|
|
68
|
+
/** 是否为electron环境 */
|
|
69
|
+
get isElectron(): boolean;
|
|
70
|
+
constructor(parame: CompileServeParame);
|
|
71
|
+
static create<T extends BaseCompileService, P extends CompileServeParame>(this: new (params: P) => T, params: P): Promise<T>;
|
|
72
|
+
private initialize;
|
|
73
|
+
protected onAfterConfigLoaded(): Promise<void>;
|
|
74
|
+
/** 基于工作目录的定位 */
|
|
75
|
+
protected resolveContext: (...paths: string[]) => string;
|
|
76
|
+
private initContextPkg;
|
|
77
|
+
private initEnv;
|
|
78
|
+
private loadUserConfig;
|
|
79
|
+
/** 检索工作目录的模块路径 */
|
|
80
|
+
protected resolveContextModule(id: string): string | undefined;
|
|
81
|
+
/** 加载模块工作目录的模块 */
|
|
82
|
+
protected loadContextModule<T>(id: string): T;
|
|
83
|
+
/**
|
|
84
|
+
* 获取配置文件
|
|
85
|
+
* @param configFile 配置文件路径
|
|
86
|
+
*/
|
|
87
|
+
protected getUserConfig(): Promise<UserConfig | undefined>;
|
|
88
|
+
protected startCompile(): Promise<void>;
|
|
89
|
+
/** 生命周期抽象方法:dev 启动 */
|
|
90
|
+
protected abstract dev(): unknown | Promise<unknown>;
|
|
91
|
+
/** 生命周期抽象方法:build 启动 */
|
|
92
|
+
protected abstract build(): unknown | Promise<unknown>;
|
|
93
|
+
}
|
|
27
94
|
//#endregion
|
|
28
95
|
//#region src/node/utils/css-loaders-helper.d.ts
|
|
29
96
|
interface CssLoaderOptions {
|
|
@@ -35,9 +102,56 @@ interface CssLoaderOptions {
|
|
|
35
102
|
}
|
|
36
103
|
//#endregion
|
|
37
104
|
//#region src/node/utils/loader-plugin-helper.d.ts
|
|
105
|
+
type ListItemType = RuleSetRule | Plugin;
|
|
38
106
|
type RspackExperiments = {
|
|
39
107
|
import: Record<string, unknown>[];
|
|
40
108
|
};
|
|
109
|
+
type OtherEnv = {
|
|
110
|
+
frameworkEnv?: DefinePluginOptions;
|
|
111
|
+
extEnv?: DefinePluginOptions;
|
|
112
|
+
env?: DefinePluginOptions;
|
|
113
|
+
};
|
|
114
|
+
declare class BaseCreate<T extends ListItemType> {
|
|
115
|
+
protected list: T[];
|
|
116
|
+
protected env: 'development' | 'none' | 'production';
|
|
117
|
+
protected mode: string;
|
|
118
|
+
protected isDev: boolean;
|
|
119
|
+
constructor({
|
|
120
|
+
env,
|
|
121
|
+
mode
|
|
122
|
+
}: {
|
|
123
|
+
env: 'development' | 'none' | 'production';
|
|
124
|
+
mode?: string;
|
|
125
|
+
});
|
|
126
|
+
add(item: T | T[] | undefined): this;
|
|
127
|
+
end(): T[];
|
|
128
|
+
}
|
|
129
|
+
declare class CreateLoader extends BaseCreate<RuleSetRule> {
|
|
130
|
+
constructor({
|
|
131
|
+
env,
|
|
132
|
+
mode
|
|
133
|
+
}: {
|
|
134
|
+
env: 'development' | 'none' | 'production';
|
|
135
|
+
mode?: string;
|
|
136
|
+
});
|
|
137
|
+
private defaultScriptLoader;
|
|
138
|
+
private defaultResourceLoader;
|
|
139
|
+
useDefaultCssLoader(options?: CssLoaderOptions): this;
|
|
140
|
+
useDefaultScriptLoader(options?: RspackExperiments): this;
|
|
141
|
+
useDefaultResourceLoader(): this;
|
|
142
|
+
}
|
|
143
|
+
declare class CreatePlugins extends BaseCreate<Plugin> {
|
|
144
|
+
constructor({
|
|
145
|
+
env,
|
|
146
|
+
mode
|
|
147
|
+
}: {
|
|
148
|
+
env: 'development' | 'none' | 'production';
|
|
149
|
+
mode?: string;
|
|
150
|
+
});
|
|
151
|
+
useDefaultEnvPlugin(otherEnv?: OtherEnv): this;
|
|
152
|
+
useCopyPlugin(): this;
|
|
153
|
+
useHtmlPlugin(templatePath?: string): this;
|
|
154
|
+
}
|
|
41
155
|
type Pages = {
|
|
42
156
|
[key: string]: {
|
|
43
157
|
html: string;
|
|
@@ -72,6 +186,30 @@ interface CdnPluginOptions {
|
|
|
72
186
|
}
|
|
73
187
|
//#endregion
|
|
74
188
|
//#region src/node/user-config.d.ts
|
|
189
|
+
type Bundler = 'rspack' | 'vite';
|
|
190
|
+
interface ElectronConfig {
|
|
191
|
+
main?: {
|
|
192
|
+
entry?: string;
|
|
193
|
+
output?: string;
|
|
194
|
+
plugins?: Plugin | Plugin[];
|
|
195
|
+
loaders?: Loader[];
|
|
196
|
+
};
|
|
197
|
+
preload?: {
|
|
198
|
+
entries?: string[] | Record<string, string>;
|
|
199
|
+
output?: string;
|
|
200
|
+
plugins?: Plugin | Plugin[];
|
|
201
|
+
loaders?: Loader[];
|
|
202
|
+
};
|
|
203
|
+
renderer?: {
|
|
204
|
+
plugins?: Plugin | Plugin[];
|
|
205
|
+
loaders?: Loader[];
|
|
206
|
+
};
|
|
207
|
+
build?: {
|
|
208
|
+
hotReload?: boolean;
|
|
209
|
+
debug?: boolean;
|
|
210
|
+
outDir?: string;
|
|
211
|
+
};
|
|
212
|
+
}
|
|
75
213
|
/**
|
|
76
214
|
* 这里复写了 ModuleFederationPluginOptions,因为 ModuleFederationPluginOptions 是从 module-federation/sdk 导入的,remoteType和rspack的remoteType不一样
|
|
77
215
|
*/
|
|
@@ -79,6 +217,13 @@ interface ModuleFederationOptions extends Omit<ModuleFederationPluginOptions, 'r
|
|
|
79
217
|
remoteType?: 'var' | 'module' | 'assign' | 'this' | 'window' | 'self' | 'global' | 'commonjs' | 'commonjs2' | 'commonjs-module' | 'commonjs-static' | 'amd' | 'amd-require' | 'umd' | 'umd2' | 'jsonp' | 'system' | 'promise' | 'import' | 'script' | 'module-import' | 'node-commonjs';
|
|
80
218
|
}
|
|
81
219
|
interface UserConfig {
|
|
220
|
+
/**
|
|
221
|
+
* 底层打包器
|
|
222
|
+
* - 'rspack': 维持现有行为(默认)
|
|
223
|
+
* - 'vite': 启用 Vite(当前主要用于 Web)
|
|
224
|
+
* @default 'rspack'
|
|
225
|
+
*/
|
|
226
|
+
bundler?: Bundler;
|
|
82
227
|
/**
|
|
83
228
|
* 编译的平台,该值影响底层优化逻辑
|
|
84
229
|
* @default 'pc'
|
|
@@ -97,8 +242,11 @@ interface UserConfig {
|
|
|
97
242
|
*/
|
|
98
243
|
pages?: Pages;
|
|
99
244
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
245
|
+
* 可选页面启动配置
|
|
246
|
+
* - string[]: 只启动指定的页面
|
|
247
|
+
* - false: 禁用页面选择功能,启动所有页面
|
|
248
|
+
* - undefined: 默认行为,启动所有页面
|
|
249
|
+
* @default undefined
|
|
102
250
|
*/
|
|
103
251
|
enablePages?: string[] | false;
|
|
104
252
|
/**
|
|
@@ -113,15 +261,26 @@ interface UserConfig {
|
|
|
113
261
|
*/
|
|
114
262
|
moduleFederation?: ModuleFederationOptions | ModuleFederationOptions[];
|
|
115
263
|
/**
|
|
116
|
-
*
|
|
264
|
+
* Rspack 插件(仅 bundler = 'rspack' 时生效)
|
|
117
265
|
* @see {@link https://rspack.dev/zh/guide/features/plugin}
|
|
118
266
|
*/
|
|
119
267
|
plugins?: Plugin | Plugin[];
|
|
120
268
|
/**
|
|
121
|
-
* loader
|
|
269
|
+
* Rspack loader(仅 bundler = 'rspack' 时生效)
|
|
122
270
|
* @see {@link https://rspack.dev/zh/guide/features/loader}
|
|
123
271
|
*/
|
|
124
272
|
loaders?: Loader[];
|
|
273
|
+
/**
|
|
274
|
+
* Vite 配置(仅 bundler = 'vite' 时生效)
|
|
275
|
+
* - 注意:Vite 没有 loader 概念;请通过插件/原生配置实现
|
|
276
|
+
*/
|
|
277
|
+
vite?: {
|
|
278
|
+
/**
|
|
279
|
+
* Vite 插件(仅 bundler = 'vite' 时生效)
|
|
280
|
+
* @see {@link https://vite.dev/guide/api-plugin}
|
|
281
|
+
*/
|
|
282
|
+
plugins?: unknown;
|
|
283
|
+
};
|
|
125
284
|
/**
|
|
126
285
|
* RspackExperiments
|
|
127
286
|
* @default undefined
|
|
@@ -145,11 +304,12 @@ interface UserConfig {
|
|
|
145
304
|
*/
|
|
146
305
|
port?: number;
|
|
147
306
|
/**
|
|
148
|
-
*
|
|
149
|
-
*
|
|
307
|
+
* 服务器代理
|
|
308
|
+
* - rspack 模式:同 @rspack/dev-server
|
|
309
|
+
* - vite 模式:同 Vite server.proxy
|
|
150
310
|
* @default undefined
|
|
151
311
|
*/
|
|
152
|
-
proxy?: _rspack_dev_server0.Configuration['proxy']
|
|
312
|
+
proxy?: _rspack_dev_server0.Configuration['proxy'] | Record<string, string | Record<string, unknown>>;
|
|
153
313
|
/**
|
|
154
314
|
* https
|
|
155
315
|
* @see {@link https://webpack.js.org/configuration/dev-server/#devserverhttps}
|
|
@@ -226,6 +386,11 @@ interface UserConfig {
|
|
|
226
386
|
*/
|
|
227
387
|
extensions?: string[];
|
|
228
388
|
};
|
|
389
|
+
/**
|
|
390
|
+
* Electron应用配置
|
|
391
|
+
* @default undefined
|
|
392
|
+
*/
|
|
393
|
+
electron?: ElectronConfig;
|
|
229
394
|
}
|
|
230
395
|
type ConfigEnvPre = Readonly<{
|
|
231
396
|
mode: string;
|
|
@@ -237,4 +402,146 @@ type UserConfigWebExport = UserConfig | Promise<UserConfig> | UserConfigFn<UserC
|
|
|
237
402
|
/** 辅助工具函数 */
|
|
238
403
|
declare const defineConfig: (config: UserConfigWebExport) => UserConfigWebExport;
|
|
239
404
|
//#endregion
|
|
240
|
-
|
|
405
|
+
//#region src/node/compile/web/web-compile-service.d.ts
|
|
406
|
+
declare class WebCompileService extends BaseCompileService {
|
|
407
|
+
private port;
|
|
408
|
+
private viteAdapter?;
|
|
409
|
+
private onBuildStatus?;
|
|
410
|
+
constructor(parame: CompileServeParame);
|
|
411
|
+
protected dev(): Promise<void>;
|
|
412
|
+
protected build(): Promise<void>;
|
|
413
|
+
private prepare;
|
|
414
|
+
getDevPort(): number;
|
|
415
|
+
}
|
|
416
|
+
//#endregion
|
|
417
|
+
//#region src/node/compile/web/resolve-web-preconfig.d.ts
|
|
418
|
+
type WebPreConfig = {
|
|
419
|
+
userConfig?: UserConfig;
|
|
420
|
+
base: string;
|
|
421
|
+
target: Exclude<UserConfig['target'], undefined>;
|
|
422
|
+
pages: Exclude<UserConfig['pages'], undefined>;
|
|
423
|
+
port: number;
|
|
424
|
+
browserslist: string;
|
|
425
|
+
isVue: boolean;
|
|
426
|
+
isReact: boolean;
|
|
427
|
+
};
|
|
428
|
+
//#endregion
|
|
429
|
+
//#region src/node/utils/optional-vite.d.ts
|
|
430
|
+
type OptionalViteAdapter = {
|
|
431
|
+
createWebViteConfig: (params: {
|
|
432
|
+
command: 'server' | 'build';
|
|
433
|
+
mode?: string;
|
|
434
|
+
env: Record<string, unknown>;
|
|
435
|
+
context: string;
|
|
436
|
+
userConfig?: Record<string, unknown>;
|
|
437
|
+
pages: Record<string, {
|
|
438
|
+
html: string;
|
|
439
|
+
entry: string;
|
|
440
|
+
}>;
|
|
441
|
+
base: string;
|
|
442
|
+
port: number;
|
|
443
|
+
isElectron: boolean;
|
|
444
|
+
resolveContext: (...paths: string[]) => string;
|
|
445
|
+
}) => unknown;
|
|
446
|
+
runViteBuild: (config: unknown, options?: {
|
|
447
|
+
onBuildStatus?: (status: {
|
|
448
|
+
success: boolean;
|
|
449
|
+
port?: number;
|
|
450
|
+
message?: string;
|
|
451
|
+
}) => void;
|
|
452
|
+
}) => Promise<string | undefined>;
|
|
453
|
+
startViteDevServer: (config: unknown, options?: {
|
|
454
|
+
port?: number;
|
|
455
|
+
onBuildStatus?: (status: {
|
|
456
|
+
success: boolean;
|
|
457
|
+
port?: number;
|
|
458
|
+
message?: string;
|
|
459
|
+
}) => void;
|
|
460
|
+
}) => Promise<unknown>;
|
|
461
|
+
};
|
|
462
|
+
declare const loadOptionalViteAdapter: (params: {
|
|
463
|
+
loadContextModule: <T>(id: string) => T;
|
|
464
|
+
}) => OptionalViteAdapter;
|
|
465
|
+
//#endregion
|
|
466
|
+
//#region src/node/compile/web/prepare-web-compile.d.ts
|
|
467
|
+
type PrepareWebCompileParams = {
|
|
468
|
+
command: Command;
|
|
469
|
+
options: CompileOptions;
|
|
470
|
+
env: DefinePluginOptions;
|
|
471
|
+
context: string;
|
|
472
|
+
contextPkg?: PackageJson;
|
|
473
|
+
userConfig?: UserConfig;
|
|
474
|
+
isElectron: boolean;
|
|
475
|
+
resolveContext: (...paths: string[]) => string;
|
|
476
|
+
loadViteAdapter?: () => OptionalViteAdapter;
|
|
477
|
+
};
|
|
478
|
+
type PrepareWebCompileResult = {
|
|
479
|
+
bundler: NonNullable<UserConfig['bundler']>;
|
|
480
|
+
config: Configuration | unknown;
|
|
481
|
+
pre: WebPreConfig;
|
|
482
|
+
};
|
|
483
|
+
declare const prepareWebCompile: (params: PrepareWebCompileParams) => Promise<PrepareWebCompileResult>;
|
|
484
|
+
//#endregion
|
|
485
|
+
//#region src/node/utils/logger.d.ts
|
|
486
|
+
declare const LoggerSystem: () => {
|
|
487
|
+
done: ({
|
|
488
|
+
text,
|
|
489
|
+
onlyText
|
|
490
|
+
}: {
|
|
491
|
+
text: string;
|
|
492
|
+
onlyText?: boolean;
|
|
493
|
+
}) => string | undefined;
|
|
494
|
+
error: ({
|
|
495
|
+
text,
|
|
496
|
+
onlyText
|
|
497
|
+
}: {
|
|
498
|
+
text: string;
|
|
499
|
+
onlyText?: boolean;
|
|
500
|
+
}) => string | undefined;
|
|
501
|
+
okay: ({
|
|
502
|
+
text,
|
|
503
|
+
onlyText
|
|
504
|
+
}: {
|
|
505
|
+
text: string;
|
|
506
|
+
onlyText?: boolean;
|
|
507
|
+
}) => string | undefined;
|
|
508
|
+
warning: ({
|
|
509
|
+
text,
|
|
510
|
+
onlyText
|
|
511
|
+
}: {
|
|
512
|
+
text: string;
|
|
513
|
+
onlyText?: boolean;
|
|
514
|
+
}) => string | undefined;
|
|
515
|
+
info: ({
|
|
516
|
+
text,
|
|
517
|
+
onlyText
|
|
518
|
+
}: {
|
|
519
|
+
text: string;
|
|
520
|
+
onlyText?: boolean;
|
|
521
|
+
}) => string | undefined;
|
|
522
|
+
emitEvent: (event: string) => void;
|
|
523
|
+
clearEventArray: () => void;
|
|
524
|
+
eventArray: string[];
|
|
525
|
+
};
|
|
526
|
+
//#endregion
|
|
527
|
+
//#region src/node/utils/rspack-runner.d.ts
|
|
528
|
+
type BuildStatus = {
|
|
529
|
+
success: boolean;
|
|
530
|
+
port?: number;
|
|
531
|
+
message?: string;
|
|
532
|
+
};
|
|
533
|
+
type WatchRspackBuildOptions = WatchOptions & {
|
|
534
|
+
onBuildStatus?: (status: BuildStatus) => void;
|
|
535
|
+
};
|
|
536
|
+
declare const runRspackBuild: (config: Configuration | Configuration[], options?: WatchRspackBuildOptions) => Promise<string | undefined>;
|
|
537
|
+
declare const watchRspackBuild: (config: Configuration | Configuration[], options?: WatchRspackBuildOptions) => Promise<string | undefined>;
|
|
538
|
+
//#endregion
|
|
539
|
+
//#region src/node/utils/const.d.ts
|
|
540
|
+
declare const extensions: string[];
|
|
541
|
+
/**
|
|
542
|
+
* 基于cli的绝对定位
|
|
543
|
+
* @param ...paths 子路径
|
|
544
|
+
*/
|
|
545
|
+
declare const resolveCLI: (...paths: string[]) => string;
|
|
546
|
+
//#endregion
|
|
547
|
+
export { BaseCompileService, Bundler, Command, type CompileOptions, type CompileServeParame, ConfigEnvPre, CreateLoader, CreatePlugins, ElectronConfig, LoggerSystem, ModuleFederationOptions, type OptionalViteAdapter, type PackageJson, UserConfig, UserConfigFn, UserConfigWebExport, WebCompileService, defineConfig, extensions, loadOptionalViteAdapter, prepareWebCompile, resolveCLI, runRspackBuild, watchRspackBuild };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import{createRequire as e}from"node:module";import{Option as t,program as n}from"commander";import r from"chalk";import{rspack as i}from"@rspack/core";import{RsdoctorRspackPlugin as a}from"@rsdoctor/rspack-plugin";import o from"compression-webpack-plugin";import{ModuleFederationPlugin as s}from"@module-federation/enhanced/rspack";import{isFunction as c,isString as l}from"es-toolkit";import{isArray as u,isEmpty as d,isObject as f}from"es-toolkit/compat";import{RspackDevServer as p}from"@rspack/dev-server";import m,{dirname as h,extname as g,join as _,resolve as ee}from"node:path";import{detect as te}from"detect-port";import v,{join as y}from"path";import ne from"node:fs";import b,{readFile as x}from"node:fs/promises";import S from"fs/promises";import{z as C}from"zod/v4";import w,{pathToFileURL as T}from"node:url";import{parse as re}from"yaml";import E from"fs-extra";import{transform as ie}from"oxc-transform";import{config as D}from"dotenv";import ae from"ora";import oe from"node:os";import O from"pretty-bytes";import se from"easy-table";import ce from"cli-cursor";import k from"node:process";var le=`@ikaros-cli/ikaros`,A=`2.0.0`;const j=(e,t)=>{for(let n in t)e[n]=f(t[n])&&n in e?j(e[n],t[n]):t[n];return e};async function M(e){try{let t=y(process.cwd(),`node_modules`,e);return await S.access(t,S.constants.F_OK),!0}catch(e){if(e.code===`ENOENT`)return!1;throw e}}const N=C.object({target:C.enum([`pc`,`mobile`]).optional().default(`pc`),pages:C.custom().optional(),enablePages:C.union([C.array(C.string())]).optional(),moduleFederation:C.union([C.custom(),C.array(C.custom())]).optional(),plugins:C.union([C.custom(),C.array(C.custom())]).optional(),loaders:C.array(C.custom()).optional(),experiments:C.custom().optional(),cdnOptions:C.custom().optional(),server:C.object({port:C.number().int().min(1024).max(65535).optional(),proxy:C.custom().optional(),https:C.union([C.boolean(),C.record(C.string(),C.any())]).optional().default(!1)}).optional(),css:C.object({lightningcssOptions:C.record(C.string(),C.any()).optional(),sourceMap:C.boolean().optional(),lessOptions:C.record(C.string(),C.any()).optional(),sassOptions:C.record(C.string(),C.any()).optional(),stylusOptions:C.record(C.string(),C.any()).optional()}).optional(),build:C.object({base:C.string().optional().default(`/`),assetsDir:C.string().optional(),gzip:C.boolean().optional().default(!1),sourceMap:C.boolean().optional().default(!1),outDirName:C.string().optional().default(`dist`),outReport:C.boolean().optional().default(!1),cache:C.boolean().optional().default(!1),dependencyCycleCheck:C.boolean().optional().default(!1)}).optional(),resolve:C.object({alias:C.record(C.string(),C.string()).optional(),extensions:C.array(C.string()).optional()}).optional()});async function ue(e,t){let n=e,r=await x(e,`utf-8`),{code:i,errors:a}=ie(n,r,{lang:t?`ts`:`js`});if(a.length>0)throw Error(`Transformation failed: `+a.map(e=>e.message).join(`, `));return{code:i}}async function de(e,t){let n=`${e}.timestamp-${Date.now()}-${Math.random().toString(16).slice(2)}`,r=`${n}.mjs`,i=`${T(n)}.mjs`;await b.writeFile(r,t);try{return(await import(i)).default}finally{await b.unlink(r)}}async function fe(e,t=!1){let{code:n}=await ue(e,t);return de(e,n)}const P=new Map;P.set(`.mjs`,async e=>(await import(T(e).href)).default),P.set(`.ts`,async e=>await fe(e,!0)),P.set(`.json`,async e=>await E.readJson(e)),P.set(`.yaml`,async e=>{let t=await b.readFile(e,`utf8`);return re(t)});async function pe({configFile:e}){let t,n=process.cwd(),r=`ikaros.config`,i=[`ts`,`mjs`,`json`,`yaml`].map(e=>`${_(n,r)}.${e}`),a=(await Promise.all(i.map(e=>E.pathExists(e)))).findIndex(Boolean);if(!(a<0)){if(t=g(i[a]),n=ee(n,`${r}${t}`),e&&(n=h(e),t=g(e)),!P.has(t))throw Error(`No configuration file ! `);return P.get(t)(n)}}const F=[],I=()=>{let e=(e,t)=>({DONE:r.bgGreen.white,ERROR:r.bgRed.white,OKAY:r.bgBlue.white,WARNING:r.bgYellow.white,INFO:r.bgCyan.white})[e](` ${e} `)+` ${t}`;return{done:({text:t,onlyText:n})=>{if(n)return e(`DONE`,t);console.log(e(`DONE`,t))},error:({text:t,onlyText:n})=>{if(n)return e(`ERROR`,t);console.error(e(`ERROR`,t))},okay:({text:t,onlyText:n})=>{if(n)return e(`OKAY`,t);console.log(e(`OKAY`,t))},warning:({text:t,onlyText:n})=>{if(n)return e(`WARNING`,t);console.warn(e(`WARNING`,t))},info:({text:t,onlyText:n})=>{if(n)return e(`INFO`,t);console.info(e(`INFO`,t))},emitEvent:e=>{let t=new Date().toLocaleTimeString(`en-US`,{hour12:!1}).split(` `)[0];F.push(`[${t}] ${e}`)},clearEventArray:()=>{F.length=0},eventArray:F}},L=e=>e?y(z,`env`,`.env.${e}`):y(z,`env`,`.env`),R=async e=>{let{warning:t,emitEvent:n}=I();if(!await E.pathExists(y(z,`env`)))return n(t({text:`env folder not found`,onlyText:!0})),!1;if(e){if(!await E.pathExists(L(e)))return n(t({text:`.env.${e} file not found`,onlyText:!0})),!1}else return await E.pathExists(L())?!0:(n(t({text:`.env file not found`,onlyText:!0})),!1);return!0},z=process.cwd(),B=async e=>await R(e)?e?D({path:L(e)}).parsed??{}:D({path:L()}).parsed??{}:{};let V=function(e){return e.SERVER=`server`,e.BUILD=`build`,e}({});var me=class{set env(e){this._env=e}get env(){return this._env}set contextPkg(e){this._contextPkg=e}get contextPkg(){return this._contextPkg}constructor(t){let{command:n,options:r,configFile:i}=t;this.command=n,this.options=r,this.configFile=i,this.context=y(process.cwd(),`./`),this.contextRequire=e(this.context),this.initialize()}async initialize(){await this.initContextPkg(),await this.initEnv(),this.startCompile()}resolveContext(...e){return y(this.context,...e)}async initContextPkg(){let e=this.resolveContext(`package.json`);try{await b.access(e,ne.constants.F_OK)}catch{return}this.contextPkg=JSON.parse(await b.readFile(e,{encoding:`utf8`}))}async initEnv(){let{platform:e,mode:t}=this.options,n={PLATFORM:e,MODE:t},r=await B(t);this.env={...n,...r}}resolveContextModule(e){try{return this.contextRequire.resolve(e)}catch{return}}loadContextModule(e){return this.contextRequire(e)}async getUserConfig(){let{configFile:e}=this,t=await pe({configFile:e});if(t){if(c(t)){let e={PLATFORM:this.options.platform},n={mode:this.options.mode??``,env:Object.assign(e,this.env),command:this.command};return N.parse(await t(n))}if(f(t))return N.parse(void 0)}}startCompile(){switch(this.command){case V.SERVER:this.dev?.();break;case V.BUILD:this.build?.();break;default:break}}};const H=y(process.cwd(),`./`),he=[`...`,`.mjs`,`.jsx`,`.ts`,`.tsx`];y(H,`tsconfig.json`);const U=w.fileURLToPath(new w.URL(`../`,import.meta.url)),ge=e(U),_e=(...e)=>y(U,...e),W=(e,t)=>({loader:e.includes(`builtin`)?e:ge.resolve(e),options:t}),ve=(e,t)=>{let{lightningcss:n,sourceMap:r}=t??{},i=W(`builtin:lightningcss-loader`,{...n}),a=(e,n)=>{let a=[i],o=t&&t[`${e}`];return e&&e!==`css`&&a.push(W(`${e}-loader`,Object.assign(o??{},n,{sourceMap:r}))),a};return{less:a(`less`),sass:a(`sass`,{sassOptions:{indentedSyntax:!0,api:`modern-compiler`}}),scss:a(`sass`,{sassOptions:{api:`modern-compiler`}}),stylus:a(`stylus`),styl:a(`stylus`),css:a(`css`)}},ye=(e,t)=>{let n=ve(e,t);return Object.entries(n).map(([e,t])=>({test:RegExp(`\\.${e}$`),use:t,type:`css/auto`}))};var G=class{constructor({env:e=`development`,mode:t=``}){this.list=[],this.env=`development`,this.mode=``,this.isDev=!0,this.env=e,this.mode=t,this.isDev=e===`development`}add(e){return e&&(u(e)?this.list=this.list.concat(e):this.list.push(e)),this}end(){return this.list}},be=class extends G{constructor({env:e=`development`,mode:t=``}){super({env:e,mode:t}),this.defaultScriptLoader=e=>[{test:/\.m?ts$/i,loader:`builtin:swc-loader`,options:{jsc:{parser:{syntax:`typescript`}}},type:`javascript/auto`,exclude:[y(H,`node_modules`)]},{test:/\.m?js$/i,loader:`builtin:swc-loader`,options:{isModule:`unknown`,rspackExperiments:e},type:`javascript/auto`,exclude:[y(H,`node_modules`)]}],this.defaultResourceLoader=[{test:/\.(png|jpe?g|gif|svg|ico)(\?.*)?$/,type:`asset/resource`,generator:{filename:this.isDev?`[id][ext]`:`assets/img/[contenthash][ext]`}},{test:/\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,type:`asset/resource`,generator:{filename:this.isDev?`[id][ext]`:`assets/media/[contenthash][ext]`}},{test:/\.(woff2?|eot|ttf|otf)(\?.*)?$/,type:`asset/resource`,generator:{filename:this.isDev?`[id][ext]`:`assets/fonts/[contenthash][ext]`}}]}useDefaultCssLoader(e){return ye(this.env,e).forEach(e=>this.add(e)),this}useDefaultScriptLoader(e){return this.add(this.defaultScriptLoader(e)),this}useDefaultResourceLoader(){return this.defaultResourceLoader.forEach(e=>this.add(e)),this}},xe=class extends G{constructor({env:e=`development`,mode:t=``}){super({env:e,mode:t})}useDefaultEnvPlugin(e){let{frameworkEnv:t={},extEnv:n={},env:r={}}=e??{};return this.add(Ce({frameworkEnv:t,extEnv:n,env:r})),this}useCopyPlugin(){return this.env===`production`&&this.add(new i.CopyRspackPlugin({patterns:[{context:y(H,`public`),from:`./`,noErrorOnMissing:!0,globOptions:{ignore:[`**/index.html`,`.*`]}}]})),this}useHtmlPlugin(e){return this.add(new i.HtmlRspackPlugin({template:e??y(H,`index.html`)})),this}},Se=class{constructor({pages:e,enablePages:t}){this.pages=e,this.enablePages=t,this.getEnablePages()}create(){let e={},t=[];return Object.keys(this.pages).forEach(n=>{e[n]={import:this.pages[n].entry,library:this.pages[n].library},t.push(new i.HtmlRspackPlugin({template:this.pages[n].html,filename:`${n}.html`,chunks:[n],scriptLoading:`blocking`,...this.pages[n].options}))}),{entry:e,plugins:t}}getEnablePages(){let{warning:e,emitEvent:t}=I();if(!d(this.pages)&&u(this.enablePages)){let n={},r=[];if(this.enablePages.forEach(e=>{this.pages[e]?n[e]=this.pages[e]:r.push(e)}),d(r)&&t(e({text:`当前设置页面${r.join()}不存在`,onlyText:!0})),d(n))return;this.pages=n}}};const Ce=({frameworkEnv:e={},extEnv:t={},env:n={}})=>{let r=Object.assign({},j(t,n)),a=Object.fromEntries(Object.entries(r).map(([e,t])=>[`import.meta.env.${e}`,JSON.stringify(t)])),o=Object.fromEntries(Object.entries({...a,...e}).map(([e,t])=>[e,t]));return new i.DefinePlugin(o)},K={name:le,version:A},q=`@rspack/ikaros-stats-plugin`,J=r.hex(`#222222`);var Y=class{constructor(e){this.startCompileHrtime=void 0,this.userConfig=e,this.ora=ae({color:`cyan`,prefixText:``,hideCursor:!1})}apply(e){this.compiler=e,this.isDev=e.options.mode===`development`,new i.ProgressPlugin(this.progressHandler.bind(this)).apply(e),ce.hide(),this.isDev?this.initDevHook():this.initProdHook()}progressHandler(e,t,...n){let i=`${(e*100).toFixed(2)}%`;i+=` ${t} `,i+=r.gray(n?.join(` `)),this.lastProgressText!==i&&(this.lastProgressText=i,this.isDev?this.ora.text=`${i}\n`:console.log(i))}updateStartCompileTime(){this.startCompileHrtime=k.hrtime()}getCurrentEndCompileTime(){let e=k.hrtime(this.startCompileHrtime);return(e[0]*1e9+e[1])/1e6}getError(e){let{errors:t,errorsCount:n=0}=e;if(!(!t||n===0))return t.map(e=>`${J.bgRed(` ERROR `)} ${e.message.trim()}`).join(`
|
|
1
|
+
import{createRequire as e}from"node:module";import{Option as t,program as n}from"commander";import r,{dirname as i,extname as a,join as o,resolve as s}from"node:path";import c,{pathToFileURL as l}from"node:url";import u from"node:fs";import d,{readFile as f}from"node:fs/promises";import{isFunction as p,isString as m}from"es-toolkit";import{isArray as h,isEmpty as g,isObject as _}from"es-toolkit/compat";import v from"fs/promises";import{z as y}from"zod/v4";import b,{join as x}from"path";import S from"fs-extra";import{config as C}from"dotenv";import w from"chalk";import{parse as ee}from"yaml";import{transform as te}from"oxc-transform";import{rspack as T}from"@rspack/core";import{RspackDevServer as ne}from"@rspack/dev-server";import re from"node:os";import E from"pretty-bytes";import ie from"easy-table";import ae from"cli-cursor";import oe from"node:process";import{RsdoctorRspackPlugin as se}from"@rsdoctor/rspack-plugin";import ce from"compression-webpack-plugin";import{ModuleFederationPlugin as le}from"@module-federation/enhanced/rspack";import{detect as ue}from"detect-port";var de=`@ikaros-cli/ikaros`,D=`2.1.1`;const O=(e,t)=>{let n=e,r=t;for(let e of Object.keys(r)){let t=r[e],i=n[e];_(t)&&_(i)?n[e]=O(i,t):n[e]=t}return e};async function k(e){try{let t=x(process.cwd(),`node_modules`,e);return await v.access(t,v.constants.F_OK),!0}catch(e){if(e.code===`ENOENT`)return!1;throw e}}const fe={target:y.enum([`pc`,`mobile`]).optional().default(`pc`),pages:y.custom().optional(),enablePages:y.union([y.array(y.string()),y.literal(!1)]).optional(),define:y.custom().optional(),build:y.object({base:y.string().optional().default(`/`),assetsDir:y.string().optional(),sourceMap:y.boolean().optional().default(!1),outDirName:y.string().optional().default(`dist`)}).optional(),resolve:y.object({alias:y.record(y.string(),y.string()).optional(),extensions:y.array(y.string()).optional()}).optional(),server:y.object({port:y.number().int().min(1024).max(65535).optional()}).optional(),electron:y.unknown().optional()},pe=y.object({bundler:y.custom().optional().default(`rspack`).refine(e=>e===`rspack`,{message:`bundler must be 'rspack' for rspack config`}),...fe,moduleFederation:y.union([y.custom(),y.array(y.custom())]).optional(),plugins:y.union([y.custom(),y.array(y.custom())]).optional(),loaders:y.array(y.custom()).optional(),experiments:y.custom().optional(),cdnOptions:y.custom().optional(),server:y.object({port:y.number().int().min(1024).max(65535).optional(),proxy:y.custom().optional(),https:y.union([y.boolean(),y.record(y.string(),y.unknown())]).optional().default(!1)}).optional(),css:y.object({lightningcssOptions:y.record(y.string(),y.unknown()).optional(),sourceMap:y.boolean().optional(),lessOptions:y.record(y.string(),y.unknown()).optional(),sassOptions:y.record(y.string(),y.unknown()).optional(),stylusOptions:y.record(y.string(),y.unknown()).optional()}).optional(),build:y.object({base:y.string().optional().default(`/`),assetsDir:y.string().optional(),gzip:y.boolean().optional().default(!1),sourceMap:y.boolean().optional().default(!1),outDirName:y.string().optional().default(`dist`),outReport:y.boolean().optional().default(!1),cache:y.boolean().optional().default(!1),dependencyCycleCheck:y.boolean().optional().default(!1)}).optional()}),me=y.object({bundler:y.literal(`vite`),...fe,server:y.object({port:y.number().int().min(1024).max(65535).optional(),proxy:y.record(y.string(),y.unknown()).optional(),https:y.union([y.boolean(),y.record(y.string(),y.unknown())]).optional()}).optional(),vite:y.object({plugins:y.unknown().optional()}).strict().optional()}).passthrough().superRefine((e,t)=>{for(let n of[`plugins`,`loaders`,`experiments`,`cdnOptions`,`moduleFederation`,`css`]){let r=e;n in r&&r[n]!==void 0&&t.addIssue({code:y.ZodIssueCode.custom,path:[n],message:`bundler='vite' 时不支持 ${String(n)},请使用 vite.plugins 或 Vite 原生配置能力`})}}),A=y.union([me,pe]),j=[],M=()=>{let e=(e,t)=>({DONE:w.bgGreen.white,ERROR:w.bgRed.white,OKAY:w.bgBlue.white,WARNING:w.bgYellow.white,INFO:w.bgCyan.white})[e](` ${e} `)+` ${t}`;return{done:({text:t,onlyText:n})=>{if(n)return e(`DONE`,t);console.log(e(`DONE`,t))},error:({text:t,onlyText:n})=>{if(n)return e(`ERROR`,t);console.error(e(`ERROR`,t))},okay:({text:t,onlyText:n})=>{if(n)return e(`OKAY`,t);console.log(e(`OKAY`,t))},warning:({text:t,onlyText:n})=>{if(n)return e(`WARNING`,t);console.warn(e(`WARNING`,t))},info:({text:t,onlyText:n})=>{if(n)return e(`INFO`,t);console.info(e(`INFO`,t))},emitEvent:e=>{let t=new Date().toLocaleTimeString(`en-US`,{hour12:!1}).split(` `)[0];j.push(`[${t}] ${e}`)},clearEventArray:()=>{j.length=0},eventArray:j}},N=e=>e?x(P,`env`,`.env.${e}`):x(P,`env`,`.env`),he=async e=>{let{warning:t,emitEvent:n}=M();if(!await S.pathExists(x(P,`env`)))return n(t({text:`env folder not found`,onlyText:!0})),!1;if(e){if(!await S.pathExists(N(e)))return n(t({text:`.env.${e} file not found`,onlyText:!0})),!1}else return await S.pathExists(N())?!0:(n(t({text:`.env file not found`,onlyText:!0})),!1);return!0},P=process.cwd(),ge=async e=>await he(e)?e?C({path:N(e),quiet:!0}).parsed??{}:C({path:N(),quiet:!0}).parsed??{}:{};async function _e(e,t){let{code:n,errors:r}=await te(e,await f(e,`utf-8`),{lang:t?`ts`:`js`});if(r.length>0)throw Error(`Transformation failed: `+r.map(e=>e.message).join(`, `));return{code:n}}async function ve(e,t){let n=`${e}.timestamp-${Date.now()}-${Math.random().toString(16).slice(2)}`,r=`${n}.mjs`,i=`${l(n)}.mjs`;await d.writeFile(r,t);try{return(await import(i)).default}finally{await d.unlink(r)}}async function ye(e,t=!1){let{code:n}=await _e(e,t);return ve(e,n)}const F=new Map;F.set(`.mjs`,async e=>(await import(l(e).href)).default),F.set(`.ts`,async e=>await ye(e,!0)),F.set(`.json`,async e=>await S.readJson(e)),F.set(`.yaml`,async e=>ee(await d.readFile(e,`utf8`)));async function be({configFile:e}){let t,n=process.cwd(),r=`ikaros.config`,c=[`ts`,`mjs`,`json`,`yaml`].map(e=>`${o(n,r)}.${e}`),l=(await Promise.all(c.map(e=>S.pathExists(e)))).findIndex(Boolean);if(!(l<0)){if(t=a(c[l]),n=s(n,`${r}${t}`),e&&(n=i(e),t=a(e)),!F.has(t))throw Error(`No configuration file ! `);return F.get(t)(n)}}let I=function(e){return e.SERVER=`server`,e.BUILD=`build`,e}({});var L=class{set env(e){this._env=e}get env(){return this._env}set contextPkg(e){this._contextPkg=e}get contextPkg(){return this._contextPkg}get isElectron(){return this.options.platform===`desktopClient`}constructor(t){this.resolveContext=(...e)=>o(this.context,...e);let{command:n,options:r,configFile:i}=t;this.command=n,this.options=r,this.configFile=i,this.context=process.cwd(),this.contextRequire=e(o(this.context,`./`))}static async create(e){let t=new this(e);return await t.initialize(),t}async initialize(){await this.initContextPkg(),await this.initEnv(),await this.loadUserConfig(),await this.onAfterConfigLoaded(),await this.startCompile()}async onAfterConfigLoaded(){}async initContextPkg(){let e=this.resolveContext(`package.json`);try{await d.access(e,u.constants.F_OK)}catch{return}this.contextPkg=JSON.parse(await d.readFile(e,{encoding:`utf8`}))}async initEnv(){let{platform:e,mode:t}=this.options,n={PLATFORM:e,MODE:t},r=await ge(t);this.env={...n,...r}}async loadUserConfig(){this.userConfig=await this.getUserConfig()}resolveContextModule(e){try{return this.contextRequire.resolve(e)}catch{return}}loadContextModule(e){return this.contextRequire(e)}async getUserConfig(){let{configFile:e}=this,t=await be({configFile:e});if(t){if(p(t)){let e={mode:this.options.mode??``,env:{...this.env,PLATFORM:this.options.platform,MODE:this.options.mode??this.env?.MODE},command:this.command};return A.parse(await t(e))}if(_(t))return A.parse(t)}}async startCompile(){switch(this.command){case I.SERVER:await this.dev();break;case I.BUILD:await this.build();break;default:break}}};const R=e=>{let t=`Build failed with errors.
|
|
2
|
+
`;return e.toString({chunks:!1,colors:!0}).split(/\r?\n/).forEach(e=>{t+=` ${e}\n`}),t},z=(e,t)=>{let{onBuildStatus:n}=t??{};return new Promise((t,r)=>{let i=T(e);i.run((e,a)=>{i.close(i=>{let o=e||i;if(o)return n?.({success:!1,message:o.message||`build error`}),r(o);if(a?.hasErrors()){let e=R(a);return n?.({success:!1,message:e}),r(Error(e))}let s=a?.toString({chunks:!1,colors:!0});return n?.({success:!0,message:s}),t(s)})})})},xe=async(e,t)=>{let{port:n,onBuildStatus:r}=t??{},i=T(e),a=new ne(e.devServer,i);await new Promise((e,t)=>{a.startCallback(i=>i?(r?.({success:!1,port:n,message:i.message}),t(i)):(r?.({success:!0,port:n}),e()))})},Se=(e,t)=>{let{onBuildStatus:n,...r}=t??{};return new Promise((t,i)=>{T(e).watch({ignored:/node_modules/,aggregateTimeout:300,poll:!1,...r},(e,r)=>{if(e)return n?.({success:!1,message:e.message||`watch build error`}),i(e);if(r?.hasErrors()){let e=R(r);return n?.({success:!1,message:e}),i(Error(e))}let a=r?.toString({chunks:!1,colors:!0});return n?.({success:!0,message:a}),t(a)})})},B=x(process.cwd(),`./`),V=[`...`,`.mjs`,`.jsx`,`.ts`,`.tsx`];x(B,`tsconfig.json`);const H=c.fileURLToPath(new c.URL(`../`,import.meta.url)),Ce=e(H),U=(...e)=>x(H,...e),W=(e,t)=>({loader:e.includes(`builtin`)?e:Ce.resolve(e),options:t}),we=(e,t)=>{let{lightningcss:n,sourceMap:r}=t??{},i=W(`builtin:lightningcss-loader`,{...n}),a=(e,n)=>{let a=[i],o=t&&t[`${e}`];return e&&e!==`css`&&a.push(W(`${e}-loader`,Object.assign(o??{},n,{sourceMap:r}))),a};return{less:a(`less`),sass:a(`sass`,{sassOptions:{indentedSyntax:!0,api:`modern-compiler`}}),scss:a(`sass`,{sassOptions:{api:`modern-compiler`}}),stylus:a(`stylus`),styl:a(`stylus`),css:a(`css`)}},Te=(e,t)=>{let n=we(e,t);return Object.entries(n).map(([e,t])=>({test:RegExp(`\\.${e}$`),use:t,type:`css/auto`}))};var G=class{constructor({env:e=`development`,mode:t=``}){this.list=[],this.env=`development`,this.mode=``,this.isDev=!0,this.env=e,this.mode=t,this.isDev=e===`development`}add(e){return e&&(h(e)?this.list=this.list.concat(e):this.list.push(e)),this}end(){return this.list}},K=class extends G{constructor({env:e=`development`,mode:t=``}){super({env:e,mode:t}),this.defaultScriptLoader=e=>[{test:/\.m?ts$/i,loader:`builtin:swc-loader`,options:{jsc:{parser:{syntax:`typescript`}}},type:`javascript/auto`,exclude:[x(B,`node_modules`)]},{test:/\.m?js$/i,loader:`builtin:swc-loader`,options:{isModule:`unknown`,rspackExperiments:e},type:`javascript/auto`,exclude:[x(B,`node_modules`)]}],this.defaultResourceLoader=[{test:/\.(png|jpe?g|gif|svg|ico)(\?.*)?$/,type:`asset/resource`,generator:{filename:this.isDev?`[id][ext]`:`assets/img/[contenthash][ext]`}},{test:/\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,type:`asset/resource`,generator:{filename:this.isDev?`[id][ext]`:`assets/media/[contenthash][ext]`}},{test:/\.(woff2?|eot|ttf|otf)(\?.*)?$/,type:`asset/resource`,generator:{filename:this.isDev?`[id][ext]`:`assets/fonts/[contenthash][ext]`}}]}useDefaultCssLoader(e){return Te(this.env,e).forEach(e=>this.add(e)),this}useDefaultScriptLoader(e){return this.add(this.defaultScriptLoader(e)),this}useDefaultResourceLoader(){return this.defaultResourceLoader.forEach(e=>this.add(e)),this}},q=class extends G{constructor({env:e=`development`,mode:t=``}){super({env:e,mode:t})}useDefaultEnvPlugin(e){let{frameworkEnv:t={},extEnv:n={},env:r={}}=e??{};return this.add(De({frameworkEnv:t,extEnv:n,env:r})),this}useCopyPlugin(){return this.env===`production`&&this.add(new T.CopyRspackPlugin({patterns:[{context:x(B,`public`),from:`./`,noErrorOnMissing:!0,globOptions:{ignore:[`**/index.html`,`.*`]}}]})),this}useHtmlPlugin(e){return this.add(new T.HtmlRspackPlugin({template:e??x(B,`index.html`)})),this}},Ee=class{constructor({pages:e,enablePages:t}){this.pages=e,this.enablePages=t,this.getEnablePages()}create(){let e={},t=[];return Object.keys(this.pages).forEach(n=>{e[n]={import:this.pages[n].entry,library:this.pages[n].library},t.push(new T.HtmlRspackPlugin({template:this.pages[n].html,filename:`${n}.html`,chunks:[n],scriptLoading:`blocking`,...this.pages[n].options}))}),{entry:e,plugins:t}}getEnablePages(){let{warning:e,emitEvent:t}=M();if(!g(this.pages)&&h(this.enablePages)){let n={},r=[];if(this.enablePages.forEach(e=>{this.pages[e]?n[e]=this.pages[e]:r.push(e)}),g(r)&&t(e({text:`当前设置页面${r.join()}不存在`,onlyText:!0})),g(n))return;this.pages=n}}};const De=({frameworkEnv:e={},extEnv:t={},env:n={}})=>{let r=Object.assign({},O(t,n)),i=Object.fromEntries(Object.entries(r).map(([e,t])=>[`import.meta.env.${e}`,JSON.stringify(t)])),a=Object.fromEntries(Object.entries({...i,...e}).map(([e,t])=>[e,t]));return new T.DefinePlugin(a)},J={name:de,version:D},Y=`@rspack/ikaros-stats-plugin`,X=w.hex(`#222222`);var Oe=class{constructor(e){this.startCompileHrtime=void 0,this.userConfig=e}apply(e){this.compiler=e,this.isDev=e.options.mode===`development`,new T.ProgressPlugin().apply(e),ae.hide(),this.isDev?this.initDevHook():this.initProdHook()}updateStartCompileTime(){this.startCompileHrtime=oe.hrtime()}getCurrentEndCompileTime(){let e=oe.hrtime(this.startCompileHrtime);return(e[0]*1e9+e[1])/1e6}getError(e){let{errors:t,errorsCount:n=0}=e;if(!(!t||n===0))return t.map(e=>`${X.bgRed(` ERROR `)} ${e.message.trim()}`).join(`
|
|
2
3
|
|
|
3
|
-
`)}getWarn(e){let{warnings:t,warningsCount:n=0}=e;if(!(!t||n===0))return t.map(e=>`${
|
|
4
|
+
`)}getWarn(e){let{warnings:t,warningsCount:n=0}=e;if(!(!t||n===0))return t.map(e=>`${X.bgYellow(` WARN `)} ${e.message.trim()}`).join(`
|
|
4
5
|
|
|
5
|
-
`)}getEndTips(e,t){let{gray:n,cyan:
|
|
6
|
-
`)),console.log());let{name:e,version:
|
|
7
|
-
|
|
6
|
+
`)}getEndTips(e,t){let{gray:n,cyan:r,red:i,green:a,yellow:o}=w,{errorsCount:s=-1,warningsCount:c=-1}=e,l=(t/1e3).toFixed(2);return n(s>0?`${r(J.name)} compiled with${i(` ${s} error`)}`:c>0?`compile ${a(`success`)} and with ${o(`${c} warning`)}, time: ${l}s`:`compile ${a(`success`)}, time: ${l}s.`)}getTableInfo(e){let{assets:t}=e;if(!t||t.length===0)return;let n=new ie,r=this.userConfig?.build?.gzip??!1,i=0,a=0,o=!1;for(let e=0;e<t.length;e++){let{name:s,size:c,related:l,info:u}=t[e];if(u.development)continue;let d=r&&h(l)?l.find(e=>e.type===`gzipped`).size:0;if(i+=c,a+=d,t.length>20&&e>=4&&e<t.length-1-4){o||(o=!0,n.cell(`name`,`....`),n.cell(`size`,`....`),r&&n.cell(`gzip`,`....`),n.newRow());continue}n.cell(`name`,s),n.cell(`size`,E(c)),r&&n.cell(`gzip`,E(d)),n.newRow()}return n.pushDelimeter(),n.cell(`name`,`There are ${t.length} files`),n.cell(`size`,E(i)),r&&n.cell(`gzip`,E(a)),n.newRow(),w.cyan.dim(n.toString().trim())}getHostList(){let{userConfig:e,compiler:t}=this,{devServer:n}=t.options,i=n?.server===`https`||typeof n?.server==`object`,a=Number(n?.port),o=[],s=``,c=Object.values(re.networkInterfaces());if(e){s=e.build?.base??``,(!s||s===`auto`)&&(s=`/`);let t=Object.keys(e?.pages||{})[0];t&&t!==`index`?s=r.join(s,`${t}.html`):s.endsWith(`/`)||(s+=`/`)}for(let e of c){let{address:t}=e?.find(e=>e.family===`IPv4`)||{};t&&o.push(t)}o.sort((e,t)=>{let n=e.split(`.`),r=t.split(`.`);for(let[t]of n.entries())if(e[t]!==r[t])return Number(r[t])-Number(e[t]);return 0});let l=o.indexOf(`127.0.0.1`);return l!==-1&&(o.splice(l,1),o.unshift(`localhost`)),o=o.map(e=>(i?(e=`https://${e}`,a!==443&&(e=e+`:`+a)):(e=`http://`+e,a!==80&&(e=e+`:`+a)),new URL(s,e).href)),o}initDevHook(){let{compiler:e}=this,t=this.getHostList(),{blue:n,cyan:r,gray:i}=w;e.hooks.environment.intercept({name:Y}),e.hooks.watchRun.intercept({name:Y,call:()=>{this.updateStartCompileTime()}}),e.hooks.done.intercept({name:Y,call:e=>{console.clear();let a=e.toJson({preset:`errors-warnings`,colors:!0}),{eventArray:o}=M(),{errorsCount:s=0,warningsCount:c=0}=a;if(s>0)console.log(this.getError(a)),console.log();else{c>0&&(console.log(this.getWarn(a)),console.log()),o.length>0&&(console.log(o.map(e=>e).join(`
|
|
7
|
+
`)),console.log());let{name:e,version:s}=J,l=`${r(`${e} v${s}`)} entry address:\n\n`;for(let e of t)l+=n(` ${e}\n`);console.log(i(l))}console.log(this.getEndTips(a,this.getCurrentEndCompileTime())),console.log()}})}initProdHook(){let{compiler:e}=this,t;e.hooks.environment.intercept({name:Y,call:()=>{console.log(w.gray(`start build...`)),this.updateStartCompileTime()}}),e.hooks.done.intercept({name:Y,call:e=>{t=e.toJson({preset:`normal`,colors:!0,assetsSort:`size`})}}),e.cache.hooks.shutdown.intercept({name:Y,done:()=>{let{errorsCount:e=0,warningsCount:n=0}=t;console.log(),e>0?(console.log(this.getError(t)),console.log()):(n>0&&(console.log(this.getWarn(t)),console.log()),console.log(this.getTableInfo(t)),console.log()),console.log(this.getEndTips(t,this.getCurrentEndCompileTime()))}})}};const Z=`@rspack/ikaros-cdn-plugin`,ke=/:([a-z]+)/gi;var Ae=class{constructor(e){this.isDev=!1,this.options={prodUrl:`https://unpkg.com/:name@:version/:path`,devUrl:`:name/:path`,crossOrigin:!1,...e}}apply(e){this.compiler=e,this.isDev=e.options.mode===`development`,this.handleExternals(),e.hooks.compilation.tap(Z,e=>{T.HtmlRspackPlugin.getCompilationHooks(e).alterAssetTags.tapAsync(Z,(e,t)=>{try{this.injectResources(e),t(null,e)}catch(e){t(e)}})})}handleExternals(){let e=this.compiler.options.externals||{};this.options.modules.filter(e=>!e.cssOnly).forEach(t=>{e[t.name]=t.var||t.name}),this.compiler.options.externals=e}injectResources(e){let t=this.options.modules,n=[];t.forEach(e=>{this.getStyles(e).forEach(e=>{n.push({tagName:`link`,voidTag:!0,attributes:{rel:`stylesheet`,href:e,...this.options.crossOrigin&&{crossorigin:this.options.crossOrigin}}})})}),t.filter(e=>!e.cssOnly).forEach(e=>{this.getScripts(e).forEach(e=>{n.push({tagName:`script`,voidTag:!0,attributes:{src:e,...this.options.crossOrigin&&{crossorigin:this.options.crossOrigin}}})})}),e.assetTags&&(e.assetTags.styles.unshift(...n.filter(e=>e.tagName===`link`)),e.assetTags.scripts.unshift(...n.filter(e=>e.tagName===`script`)))}getStyles(e){let t=[...e.styles||[]];return e.style&&t.unshift(e.style),t.map(t=>this.generateUrl(e,t))}getScripts(e){let t=[...e.paths||[]];return e.path&&t.unshift(e.path),t.map(t=>this.generateUrl(e,t))}joinUrl(e,t){return e=e.replace(/\/+$/,``),t=t.replace(/^\/+/,``),`${e}/${t}`}generateUrl(e,t){let n=this.isDev?e.devUrl||this.options.devUrl:e.prodUrl||this.options.prodUrl;return n.match(ke)?n.replace(ke,(n,r)=>{switch(r){case`name`:return e.name;case`version`:return e.version||this.getModuleVersion(e.name);case`path`:return t;default:return n}}):this.joinUrl(n,t)}getModuleVersion(t){try{return e(b.join(process.cwd(),`node_modules`))(b.join(t,`package.json`)).version}catch{return console.warn(w.yellow(`[${Z}] 无法获取模块 "${t}" 的版本信息`)),`latest`}}},je=class{constructor(e){this.options=e}createSourceMapPlugin(){let{isDev:e,userConfig:t}=this.options;if(e)return new T.EvalSourceMapDevToolPlugin({columns:!1,module:!0});if(t?.build?.sourceMap??!1)return new T.SourceMapDevToolPlugin({test:[/.js/,/.mjs/],filename:`[file].map[query]`})}createCssExtractPlugin(){if(!this.options.isDev)return new T.CssExtractRspackPlugin({filename:this.joinAssetsDir(`assets/css/[contenthash].css`),ignoreOrder:!0})}createDoctorPlugin(){let{isDev:e,userConfig:t}=this.options;if(!(e||!t?.build?.outReport))return new se}createGzipPlugin(){let{isDev:e,userConfig:t}=this.options;if(!(e||!t?.build?.gzip))return new ce}createCdnPlugin(){let{cdnOptions:e}=this.options.userConfig??{};if(!(!e||g(e.modules)))return new Ae(e)}createModuleFederationPlugin(){let e=this.options.userConfig?.moduleFederation;if(e)return h(e)?e.map(e=>new le(e)):new le(e)}createDependencyCyclePlugin(){let{isDev:e,userConfig:t}=this.options;if(!(e||!t?.build?.dependencyCycleCheck))return new T.CircularDependencyRspackPlugin({exclude:/node_modules/,failOnError:!1})}joinAssetsDir(...e){return[this.options.assetsDir,...e].join(`/`).replace(/\/+/g,`/`)}};const Me=e=>{let{isVue:t,isReact:n}=e;return t?{noParse:/^(vue|vue-router|vuex|vuex-router-sync)$/,env:{__VUE_OPTIONS_API__:!0,__VUE_PROD_DEVTOOLS__:!1,__VUE_PROD_HYDRATION_MISMATCH_DETAILS__:!1}}:n?{noParse:e=>/(react|react-dom|react-is)\.production\.min\.js$/.test(e),env:{REACT_APP_ENABLE_DEVTOOLS:!1}}:{env:void 0,noParse:void 0}},Ne=e=>e===I.SERVER?{minimize:!1,removeAvailableModules:!1,removeEmptyChunks:!1,splitChunks:!1}:{minimize:!0,minimizer:[new T.LightningCssMinimizerRspackPlugin,new T.SwcJsMinimizerRspackPlugin],splitChunks:{chunks:`all`,minSize:3e4,minChunks:1,maxAsyncRequests:5,maxInitialRequests:3,cacheGroups:{vendor:{test:/[\\/]node_modules[\\/]/,name:`vendors`,priority:10,chunks:`all`},common:{name:`common`,minChunks:2,priority:5,reuseExistingChunk:!0}}}},Pe=e=>{if(e.command!==I.SERVER&&e.userConfig?.build?.cache)return{cache:!0,experiments:{cache:{type:`persistent`}}}},Fe=e=>{let{userConfig:t,isElectron:n,resolveContext:r}=e,i=t?.build?.outDirName;if(n){let e=t?.electron,n=r(`dist/electron/renderer`);return e?.build?.outDir?o(r(e.build.outDir),`renderer`):n}return m(i)?r(i):r(`dist`)},Ie=(e,t)=>[e,t].filter(Boolean).join(`/`).replace(/\/+/g,`/`),Le=e=>{let{command:t,mode:n,env:r,context:i,contextPkg:a,userConfig:s,pages:c,browserslist:l,base:u,port:d,isElectron:f,resolveContext:p}=e,m=t===I.SERVER,h=m?`development`:`production`,g=new K({env:h,mode:n}),_=new q({env:h,mode:n}),{entry:v,plugins:y}=new Ee({pages:c,enablePages:s?.enablePages}).create(),{env:b,noParse:x}=Me({isVue:e.isVue,isReact:e.isReact}),S=g.useDefaultResourceLoader().useDefaultScriptLoader(s?.experiments).useDefaultCssLoader(s?.css).add(s?.loaders).end(),C=s?.build?.assetsDir??``,w=new je({command:t,userConfig:s,isDev:m,assetsDir:C}),ee=_.useDefaultEnvPlugin({extEnv:{...s?.define},frameworkEnv:b,env:r}).useCopyPlugin().add(y).add(new Oe).add(w.createSourceMapPlugin()).add(w.createCssExtractPlugin()).add(w.createDoctorPlugin()).add(w.createGzipPlugin()).add(w.createCdnPlugin()).add(w.createModuleFederationPlugin()).add(w.createDependencyCyclePlugin()).add(s?.plugins).end();return{mode:h,context:i,entry:v,target:f?`electron-renderer`:[`web`,`es2015`,`browserslist:${l}`],resolve:{alias:{"@":p(`src`),...s?.resolve?.alias},extensions:s?.resolve?.extensions||V,modules:[`node_modules`,p(`node_modules`),U(`node_modules`)]},output:{clean:!0,path:Fe({userConfig:s,isElectron:f,resolveContext:p}),publicPath:f?`./`:u,filename:m?`[name].[contenthash:8].js`:Ie(C,`assets/js/[contenthash:8].js`),chunkFilename:m?`[name].[contenthash:8].chunk.js`:Ie(C,`assets/js/[contenthash:8].chunk.js`),chunkLoadingGlobal:`${a?.name||`ikaros`}_chunk`,pathinfo:!1},optimization:Ne(t),stats:`none`,watchOptions:{aggregateTimeout:500,ignored:/node_modules/},module:{rules:S,noParse:x},plugins:ee,devServer:{hot:!0,port:d,server:(()=>{let e=s?.server?.https;return e?e===!0?`https`:{type:`https`,options:e}:`http`})(),allowedHosts:`all`,proxy:s?.server?.proxy,historyApiFallback:{rewrites:[{from:RegExp(`^${u}`),to:o(u,`index.html`)}]},headers:{"Access-Control-Allow-Origin":`*`},static:{directory:p(`public`),publicPath:u},client:{logging:`none`,overlay:{errors:!0,warnings:!1,runtimeErrors:!1},webSocketURL:`auto://0.0.0.0:${d}/ws`}},experiments:{css:!0},...Pe({command:t,userConfig:s})}},Re=e=>{let t=e===`mobile`,n=[`defaults`];return t?n.push(`IOS >= 16`,`Chrome >= 80`):n.push(`>0.2%`,`Chrome >= 90`,`Safari >= 16`,`last 2 versions`,`not dead`),n.join(`,`)},ze=(e,t)=>t?{index:{html:e(`src/renderer/index.html`),entry:e(`src/renderer/index`)}}:{index:{html:e(`index.html`),entry:e(`src/index`)}},Be=async e=>{let{command:t,resolveContext:n,getUserConfig:r,isElectron:i}=e,a=await r(),o=a?.build?.base??`/`;if(t===I.SERVER&&/^https?:/.test(o)){let e=w.cyan(`build.base`);throw Error(`本地开发时 ${e} 不应该为外部 Host!`)}let s=a?.target??`pc`,c=a?.pages??ze(n,!!i),l=a?.server?.port??await ue(`8080`),u=!1,d=!1;try{let[e,t]=await Promise.all([k(`react`),k(`vue`)]);u=t,d=e}catch{}return{userConfig:a,base:o,target:s,pages:c,port:l,browserslist:Re(s),isVue:u,isReact:d}},Ve=async e=>{let{command:t,options:n,env:r,context:i,contextPkg:a,userConfig:o,isElectron:s,resolveContext:c,loadViteAdapter:l}=e,u=await Be({command:t,resolveContext:c,getUserConfig:async()=>o,isElectron:s}),d=u.userConfig?.bundler??`rspack`;return{bundler:d,config:(()=>{switch(d){case`vite`:{let e=l?.();if(!e)throw Error(`bundler='vite' 需要安装可选依赖 @ikaros-cli/ikaros-bundler-vite`);return e.createWebViteConfig({command:t,mode:n.mode,env:r,context:i,userConfig:u.userConfig,pages:u.pages,base:u.base,port:u.port,isElectron:s,resolveContext:c})}case`rspack`:default:return Le({command:t,mode:n.mode,env:r,context:i,contextPkg:a,userConfig:u.userConfig,pages:u.pages,browserslist:u.browserslist,base:u.base,port:u.port,isElectron:s,isVue:u.isVue,isReact:u.isReact,resolveContext:c})}})(),pre:u}},He=()=>{let e=`@ikaros-cli/ikaros-bundler-vite`,t=[`你启用了 bundler='vite',但未安装可选依赖 ${e}。`,``,`请安装后重试:`,` pnpm add -D ${e}`];return Error(t.join(`
|
|
8
|
+
`))},Ue=()=>{let e=[`你启用了 bundler='vite',但当前 Node.js 版本过低。`,`当前版本:v${process.versions.node}`,`Vite 7 运行时通常需要 Node.js >= 22。`];return Error(e.join(`
|
|
9
|
+
`))},Q=e=>{let{loadContextModule:t}=e,n=Number(process.versions.node.split(`.`)[0]);if(Number.isFinite(n)&&n<22)throw Ue();try{let e=t(`@ikaros-cli/ikaros-bundler-vite`),n=e.default??e;if(typeof n?.createWebViteConfig!=`function`||typeof n?.runViteBuild!=`function`||typeof n?.startViteDevServer!=`function`)throw He();return n}catch(e){throw e instanceof Error,He()}},{error:We}=M();var Ge=class extends L{constructor(e){super(e),this.onBuildStatus=e.onBuildStatus}async dev(){let e=await this.prepare();if(e.bundler===`vite`){await e.vite.startViteDevServer(e.config,{port:this.port,onBuildStatus:this.onBuildStatus});return}await xe(e.config,{port:this.port,onBuildStatus:this.onBuildStatus})}async build(){let e=await this.prepare();if(e.bundler===`vite`){await e.vite.runViteBuild(e.config,{onBuildStatus:this.onBuildStatus});return}await z(e.config,{onBuildStatus:this.onBuildStatus})}async prepare(){try{let e=await Ve({command:this.command,options:this.options,env:this.env,context:this.context,contextPkg:this.contextPkg,userConfig:this.userConfig,isElectron:this.isElectron,resolveContext:this.resolveContext,loadViteAdapter:()=>this.viteAdapter??=Q({loadContextModule:this.loadContextModule.bind(this)})});return this.userConfig=e.pre.userConfig,this.port=e.pre.port,e.bundler===`vite`?{bundler:`vite`,config:e.config,vite:this.viteAdapter??=Q({loadContextModule:this.loadContextModule.bind(this)})}:{bundler:`rspack`,config:e.config}}catch(e){We({text:e instanceof Error?e.message:String(e)}),process.exit(0)}}getDevPort(){return this.port}};const Ke=()=>{let e=`@ikaros-cli/ikaros-platform-desktop-client`,t=[`你启用了 platform='desktopClient',但未安装可选依赖 ${e}。`,``,`请安装后重试:`,` pnpm add -D ${e}`];return Error(t.join(`
|
|
10
|
+
`))},qe=async()=>{try{let t=await import(l(e(o(process.cwd(),`./`)).resolve(`@ikaros-cli/ikaros-platform-desktop-client`)).href),n=t.default??t;if(typeof n?.startDesktopClientCompile!=`function`)throw Ke();return n}catch{throw Ke()}},$={WEB:`web`,DESKTOPCLIENT:`desktopClient`,ELECTRON:`desktopClient`},Je=[new t(`-m, --mode <name>`,`Environment variable`),new t(`-p, --platform <type>`,`build platform type`).default($.WEB).choices(Object.values($))],Ye=async e=>{try{switch(e.options.platform){case $.WEB:await Ge.create(e);return;case $.DESKTOPCLIENT:await(await qe()).startDesktopClientCompile(e);return;default:{let e=Object.values($).join(`,`);throw Error(`No corresponding compilation service was found, platform: ${e}`)}}}catch(e){let t=e instanceof Error?e.message:String(e);process.stderr.write(`${t}\n`),process.exit(1)}},Xe=e=>{let t=e.command(I.SERVER,{isDefault:!0}).description(`Start local develop serve`).action(async e=>{await Ye({command:I.SERVER,options:e})}),n=e.command(I.BUILD).description(`Start build`).action(async e=>{await Ye({command:I.BUILD,options:e})});for(let e of Je)t.addOption(e),n.addOption(e)},Ze=e=>e;if(Number(process.versions.node.split(`.`)[0])<22){let e=w.bgRed.white(` ERROR `);process.stderr.write(`${e} Node.js version must be greater than or equal to v22!\n\n`),process.exit(1)}n.version(D,`-v, --version`),Xe(n),n.parse();export{L as BaseCompileService,I as Command,K as CreateLoader,q as CreatePlugins,M as LoggerSystem,Ge as WebCompileService,Ze as defineConfig,V as extensions,Q as loadOptionalViteAdapter,Ve as prepareWebCompile,U as resolveCLI,z as runRspackBuild,Se as watchRspackBuild};
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikaros-cli/ikaros",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"publishConfig": {
|
|
6
7
|
"registry": "https://registry.npmjs.org/",
|
|
7
8
|
"access": "public"
|
|
@@ -14,6 +15,11 @@
|
|
|
14
15
|
"bugs": {
|
|
15
16
|
"url": "https://github.com/umbrella22/ikaros/issues"
|
|
16
17
|
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"dev": "tsdown --watch",
|
|
20
|
+
"dts": "tsdown --dts",
|
|
21
|
+
"build": "tsdown"
|
|
22
|
+
},
|
|
17
23
|
"keywords": [
|
|
18
24
|
"vue",
|
|
19
25
|
"rspack"
|
|
@@ -32,43 +38,39 @@
|
|
|
32
38
|
"readme.md"
|
|
33
39
|
],
|
|
34
40
|
"engines": {
|
|
35
|
-
"node": ">=
|
|
41
|
+
"node": ">=22.0.0",
|
|
36
42
|
"npm": ">=9.5.0"
|
|
37
43
|
},
|
|
38
44
|
"dependencies": {
|
|
39
|
-
"@module-federation/enhanced": "^0.
|
|
40
|
-
"@rsdoctor/rspack-plugin": "^1.
|
|
41
|
-
"@rspack/core": "^1.
|
|
45
|
+
"@module-federation/enhanced": "^0.21.6",
|
|
46
|
+
"@rsdoctor/rspack-plugin": "^1.3.15",
|
|
47
|
+
"@rspack/core": "^1.6.7",
|
|
42
48
|
"@rspack/dev-server": "^1.1.4",
|
|
43
49
|
"chalk": "^5.6.2",
|
|
44
50
|
"cli-cursor": "^5.0.0",
|
|
45
|
-
"commander": "^14.0.
|
|
51
|
+
"commander": "^14.0.2",
|
|
46
52
|
"compression-webpack-plugin": "^11.1.0",
|
|
47
53
|
"css-loader": "^7.1.2",
|
|
48
54
|
"detect-port": "^2.1.0",
|
|
49
|
-
"dotenv": "^17.2.
|
|
55
|
+
"dotenv": "^17.2.3",
|
|
50
56
|
"easy-table": "^1.2.0",
|
|
51
|
-
"es-toolkit": "^1.
|
|
52
|
-
"fs-extra": "^11.3.
|
|
53
|
-
"glob": "^
|
|
57
|
+
"es-toolkit": "^1.43.0",
|
|
58
|
+
"fs-extra": "^11.3.2",
|
|
59
|
+
"glob": "^13.0.0",
|
|
54
60
|
"less-loader": "^12.3.0",
|
|
55
|
-
"
|
|
56
|
-
"
|
|
61
|
+
"listr2": "^9.0.5",
|
|
62
|
+
"ora": "^9.0.0",
|
|
63
|
+
"oxc-transform": "^0.103.0",
|
|
57
64
|
"picocolors": "^1.1.1",
|
|
58
|
-
"pretty-bytes": "^7.0
|
|
59
|
-
"sass-loader": "^16.0.
|
|
65
|
+
"pretty-bytes": "^7.1.0",
|
|
66
|
+
"sass-loader": "^16.0.6",
|
|
60
67
|
"stylus-loader": "^8.1.2",
|
|
61
68
|
"vue-style-loader": "^4.1.3",
|
|
62
|
-
"yaml": "^2.8.
|
|
63
|
-
"zod": "^4.1.
|
|
69
|
+
"yaml": "^2.8.2",
|
|
70
|
+
"zod": "^4.1.13"
|
|
64
71
|
},
|
|
65
72
|
"devDependencies": {
|
|
66
73
|
"@types/fs-extra": "^11.0.4",
|
|
67
74
|
"vitest": "^3.2.4"
|
|
68
|
-
},
|
|
69
|
-
"scripts": {
|
|
70
|
-
"dev": "tsdown --watch",
|
|
71
|
-
"dts": "tsdown --dts",
|
|
72
|
-
"build": "tsdown"
|
|
73
75
|
}
|
|
74
|
-
}
|
|
76
|
+
}
|
package/readme.md
CHANGED
|
@@ -1,4 +1,42 @@
|
|
|
1
|
-
# ikaros-
|
|
1
|
+
# @ikaros-cli/ikaros 使用文档
|
|
2
|
+
|
|
3
|
+
## 平台
|
|
4
|
+
|
|
5
|
+
ikaros 支持多个运行平台:
|
|
6
|
+
|
|
7
|
+
- `web`:默认平台(本文件后续的大部分配置项均属于 web/Rspack 编译配置)
|
|
8
|
+
- `desktopClient`:Electron 平台(可选依赖,启用时才会从项目依赖中按需加载)
|
|
9
|
+
|
|
10
|
+
### desktopClient(Electron,可选依赖)
|
|
11
|
+
|
|
12
|
+
desktopClient 平台的编译实现位于独立包 `@ikaros-cli/ikaros-platform-desktop-client`。
|
|
13
|
+
|
|
14
|
+
当你使用 `--platform desktopClient` 运行时,请在你的业务项目中安装:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add -D @ikaros-cli/ikaros-platform-desktop-client electron
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
示例:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
ikaros --platform desktopClient --mode development
|
|
24
|
+
ikaros build --platform desktopClient --mode release
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
如果缺少该可选依赖,ikaros 会在运行时提示你安装它。
|
|
28
|
+
|
|
29
|
+
### bundler=vite(可选依赖)
|
|
30
|
+
|
|
31
|
+
如果你选择使用 Vite bundler,仍需要额外安装可选依赖(并遵循其 Node 版本要求):
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pnpm add -D @ikaros-cli/ikaros-bundler-vite
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## ikaros-web 配置项
|
|
2
40
|
|
|
3
41
|
## target
|
|
4
42
|
|