@empjs/cli 3.12.5-beta.3 → 4.0.0-alpha.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.
Files changed (61) hide show
  1. package/README.md +2 -2
  2. package/dist/346.js +10 -0
  3. package/dist/627.js +5 -0
  4. package/dist/build.js +1 -0
  5. package/dist/dev.js +2 -0
  6. package/dist/dev.js.LICENSE.txt +1 -0
  7. package/dist/helper/buildPrint.d.ts +41 -0
  8. package/dist/helper/chalk.d.ts +3 -0
  9. package/dist/helper/color.d.ts +31 -0
  10. package/dist/helper/compilerWatcher.d.ts +5 -0
  11. package/dist/helper/empRoot.d.ts +1 -0
  12. package/dist/helper/getPort.d.ts +6 -0
  13. package/dist/helper/hmr/client.d.ts +0 -0
  14. package/dist/helper/hmr/config.d.ts +0 -0
  15. package/dist/helper/hmr/index.d.ts +0 -0
  16. package/dist/helper/hmr/overlay.d.ts +0 -0
  17. package/dist/helper/hmr/process-update.d.ts +0 -0
  18. package/dist/helper/hono.d.ts +0 -0
  19. package/dist/helper/index.d.ts +6 -0
  20. package/dist/helper/ipAddress.d.ts +27 -0
  21. package/dist/helper/loadConfig.d.ts +5 -0
  22. package/dist/helper/logger.d.ts +27 -0
  23. package/dist/helper/nodePolyfill.d.ts +1 -0
  24. package/dist/helper/openBrowser.d.ts +2 -0
  25. package/dist/helper/utils.d.ts +15 -0
  26. package/dist/index.d.ts +16 -841
  27. package/dist/index.js +1 -22
  28. package/dist/script/base.d.ts +6 -0
  29. package/dist/script/build.d.ts +15 -0
  30. package/dist/script/dev.d.ts +30 -0
  31. package/dist/script/index.d.ts +1 -0
  32. package/dist/script/serve.d.ts +7 -0
  33. package/dist/serve.js +1 -0
  34. package/dist/server/connect/dev.d.ts +9 -0
  35. package/dist/server/connect/prod.d.ts +3 -0
  36. package/dist/server/express/dev.d.ts +0 -0
  37. package/dist/server/express/prod.d.ts +0 -0
  38. package/dist/server/hono/dev.d.ts +0 -0
  39. package/dist/server/hono/devServer/devMiddleware.d.ts +0 -0
  40. package/dist/server/hono/prod.d.ts +0 -0
  41. package/dist/server/index.d.ts +3 -0
  42. package/dist/server/types.d.ts +3 -0
  43. package/dist/server.js +1 -0
  44. package/dist/store/chain.d.ts +41 -0
  45. package/dist/store/empConfig.d.ts +75 -0
  46. package/dist/store/index.d.ts +179 -0
  47. package/dist/store/lifeCycle.d.ts +57 -0
  48. package/dist/store/rspack/builtInPlugin.d.ts +16 -0
  49. package/dist/store/rspack/common.d.ts +21 -0
  50. package/dist/store/rspack/css.d.ts +10 -0
  51. package/dist/store/rspack/entries.d.ts +44 -0
  52. package/dist/store/rspack/index.d.ts +7 -0
  53. package/dist/store/rspack/module.d.ts +22 -0
  54. package/dist/store/rspack/plugin.d.ts +19 -0
  55. package/dist/store/server.d.ts +39 -0
  56. package/dist/types/config.d.ts +413 -0
  57. package/dist/types/env.d.ts +3 -0
  58. package/dist/types/plugin.d.ts +6 -0
  59. package/package.json +14 -19
  60. package/dist/index.cjs +0 -22
  61. package/dist/index.d.cts +0 -841
package/dist/index.d.cts DELETED
@@ -1,841 +0,0 @@
1
- import { InspectOptions } from 'node:util';
2
- import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
3
- import * as _rspack_core from '@rspack/core';
4
- import { Output, Configuration, RspackOptions, SourceMapDevToolPluginOptions, SwcJsMinimizerRspackPluginOptions, HtmlRspackPluginOptions, DevServer, RuleSetRule, ExperimentCacheOptions, Externals, Resolve } from '@rspack/core';
5
- export { Compilation, Compiler, LoaderContext, RspackOptions, rspack } from '@rspack/core';
6
- import { HtmlTagObject } from 'html-webpack-plugin';
7
- import { Options } from 'sass-embedded';
8
- import Chain from '@empjs/chain';
9
- import { TsCheckerRspackPluginOptions } from 'ts-checker-rspack-plugin/lib/plugin-options';
10
- import * as node_modules__rspack_core_dist_exports from 'node_modules/@rspack/core/dist/exports';
11
- import * as node_modules__rspack_core_dist_rspack from 'node_modules/@rspack/core/dist/rspack';
12
- export { program } from 'commander';
13
- import * as chalk from 'chalk';
14
- import chalk__default from 'chalk';
15
- import { glob } from 'glob';
16
-
17
- type LifeCycleOptions = Partial<LifeCycle>;
18
- declare class LifeCycle {
19
- op: LifeCycleOptions;
20
- constructor(op?: LifeCycleOptions);
21
- /**
22
- * 获取 empOptions 之后、初始化 empConfig 之前
23
- */
24
- afterGetEmpOptions(): Promise<void>;
25
- /**
26
- * RspackPlugin 插件执行之前
27
- */
28
- beforePlugin(): Promise<void>;
29
- /**
30
- * RspackPlugin 插件执行之后
31
- */
32
- afterPlugin(): Promise<void>;
33
- /**
34
- * RspackModule 插件执行之后
35
- */
36
- beforeModule(): Promise<void>;
37
- /**
38
- * RspackModule 插件执行之后
39
- */
40
- afterModule(): Promise<void>;
41
- /**
42
- * empPlugin 插件执行之前
43
- */
44
- beforeEmpPlugin(): Promise<void>;
45
- /**
46
- * empPlugin 插件执行之后
47
- */
48
- afterEmpPlugin(): Promise<void>;
49
- /**
50
- * 产物构建完成前
51
- */
52
- beforeBuild(): Promise<void>;
53
- /**
54
- * 产物构建完成后
55
- */
56
- afterBulid(): Promise<void>;
57
- /**
58
- * devServer启动前
59
- */
60
- beforeDevServe(): Promise<void>;
61
- /**
62
- * devServer启动后
63
- */
64
- afterDevServe(): Promise<void>;
65
- /**
66
- * server启动前
67
- */
68
- beforeServe(): Promise<void>;
69
- /**
70
- * server启动后
71
- */
72
- afterServe(): Promise<void>;
73
- }
74
-
75
- declare const getLanIp: () => string;
76
- declare const getPkgVersion: (pkgPath: string) => any;
77
- declare function clearConsole(): void;
78
- declare function deepAssign<T>(target: any, ...sources: any): T;
79
- declare const ensureArray: <T>(params: T | T[]) => T[];
80
- /**
81
- * json Filter
82
- * @param d
83
- * @param keys
84
- * @returns
85
- */
86
- declare const jsonFilter: (d?: any, notIncludeKeys?: string[]) => any;
87
- declare const vCompare: (preVersion?: string, lastVersion?: string) => number;
88
- declare const timeFormat: (seconds: number) => string;
89
- declare const importJsVm: (content: string) => string;
90
-
91
- declare const utils_clearConsole: typeof clearConsole;
92
- declare const utils_deepAssign: typeof deepAssign;
93
- declare const utils_ensureArray: typeof ensureArray;
94
- declare const utils_getLanIp: typeof getLanIp;
95
- declare const utils_getPkgVersion: typeof getPkgVersion;
96
- declare const utils_importJsVm: typeof importJsVm;
97
- declare const utils_jsonFilter: typeof jsonFilter;
98
- declare const utils_timeFormat: typeof timeFormat;
99
- declare const utils_vCompare: typeof vCompare;
100
- declare namespace utils {
101
- export { utils_clearConsole as clearConsole, utils_deepAssign as deepAssign, utils_ensureArray as ensureArray, utils_getLanIp as getLanIp, utils_getPkgVersion as getPkgVersion, utils_importJsVm as importJsVm, utils_jsonFilter as jsonFilter, utils_timeFormat as timeFormat, utils_vCompare as vCompare };
102
- }
103
-
104
- declare class EmpConfig {
105
- private store;
106
- /**
107
- * 项目代码路径
108
- * @default 'src'
109
- */
110
- appSrc: string;
111
- /**
112
- * 项目代码入口文件 如 `src/index.js`
113
- * (*)entries 设置后 该选项失效
114
- * @default 'index.js'
115
- */
116
- appEntry: string;
117
- /**
118
- * publicPath 根路径 可参考webpack,业务模式默认为 auto
119
- * html 部分 publicPath 默认为 undefined,可设置全量域名或子目录适配,也可以单独在html设置 Public
120
- *
121
- * @default undefined
122
- */
123
- base: string;
124
- target: RsTarget;
125
- private assign;
126
- /**
127
- * 是否启动 esm 模块
128
- * @default true
129
- */
130
- get isESM(): boolean;
131
- lifeCycle: LifeCycle;
132
- setup(store: GlobalStore): Promise<void>;
133
- /**
134
- * 同步完所有配置后的处理
135
- */
136
- private setupEmpOptions;
137
- chain(): Promise<void>;
138
- plugins(): Promise<void>;
139
- get debug(): Required<DebugType>;
140
- get build(): Required<BuildType> & {
141
- sourcemap: SourceMapType;
142
- };
143
- get html(): HtmlType;
144
- get entries(): EntriesType;
145
- get server(): ServerType;
146
- get css(): Required<{
147
- sass?: CssSassOptionsType & {
148
- webpackImporter?: boolean;
149
- warnRuleAsWarning?: boolean;
150
- additionalData?: string;
151
- };
152
- less?: CssLessOptionsType;
153
- prifixName?: string;
154
- }>;
155
- get output(): Output;
156
- get define(): {
157
- [k: string]: string;
158
- };
159
- get tsCheckerRspackPlugin(): {};
160
- private setDefine;
161
- get externals(): {};
162
- get resolve(): _rspack_core.ResolveOptions;
163
- private syncEmpOptions;
164
- get moduleTransformRule(): any;
165
- get cacheDir(): string;
166
- get cache(): boolean | "persistent" | {
167
- type: "memory";
168
- } | {
169
- type: "persistent";
170
- buildDependencies?: string[];
171
- version?: string;
172
- snapshot?: {
173
- immutablePaths?: (string | RegExp)[];
174
- unmanagedPaths?: (string | RegExp)[];
175
- managedPaths?: (string | RegExp)[];
176
- };
177
- storage?: {
178
- type: "filesystem";
179
- directory?: string;
180
- };
181
- };
182
- get ignoreWarnings(): _rspack_core.IgnoreWarnings;
183
- get autoPages(): {
184
- path: string;
185
- } | undefined;
186
- showLogTitle(o: any): void;
187
- }
188
-
189
- declare class StoreServer {
190
- ip: string;
191
- host: string;
192
- isAutoDevBase: boolean;
193
- isHttps: boolean;
194
- httpsType: 'default' | 'h2' | 'h3';
195
- protocol: string;
196
- port: number;
197
- store: GlobalStore;
198
- publicPath: any;
199
- publicHasHttp: boolean;
200
- isOpenBrower: boolean;
201
- url: string;
202
- urls: {
203
- localUrlForBrowser: string;
204
- localUrlForTerminal: string;
205
- lanUrlForTerminal: string;
206
- lanUrlForConfig: string;
207
- };
208
- constructor(store: GlobalStore);
209
- /**
210
- * 获取config后重新适配 server 配置信息
211
- */
212
- setupOnEmpOptionSync(): Promise<void>;
213
- /**
214
- * 获取 server 所有配置信息
215
- */
216
- get config(): {};
217
- /**
218
- * setupOnEmpOptionSync 之后,store setup 之后
219
- */
220
- setupOnStore(): Promise<void>;
221
- startOpen(): void;
222
- getcert(): Promise<any>;
223
- private setHttps;
224
- private setAutoDevBase;
225
- private get isHttpBase();
226
- }
227
-
228
- type EMPModeType = 'development' | 'production';
229
- type CliActionType = 'dev' | 'build' | 'serve';
230
- type CliOptionsType = any;
231
-
232
- declare class GlobalStore {
233
- rspack: typeof node_modules__rspack_core_dist_rspack.rspack & typeof node_modules__rspack_core_dist_exports & {
234
- rspack: typeof node_modules__rspack_core_dist_rspack.rspack & typeof node_modules__rspack_core_dist_exports & /*elided*/ any;
235
- webpack: typeof node_modules__rspack_core_dist_rspack.rspack & typeof node_modules__rspack_core_dist_exports & /*elided*/ any;
236
- };
237
- rspackVersion: string;
238
- isOldRspack: boolean;
239
- /**
240
- * EMP Version
241
- * @default package version
242
- */
243
- empPkg: any;
244
- /**
245
- * 项目pkg信息
246
- */
247
- pkg: any;
248
- /**
249
- * 项目根目录绝对路径
250
- * @default process.cwd()
251
- */
252
- root: string;
253
- /**
254
- * emp 内部根路径
255
- * @default empRoot
256
- */
257
- empRoot: string;
258
- /**
259
- * emp 执行代码路径
260
- */
261
- empSource: string;
262
- /**
263
- * 获取项目 根目录绝对路径
264
- * (*) relativePath 可以是绝对路径
265
- * @param relativePath
266
- * @returns
267
- */
268
- resolve: (relativePath: string) => string;
269
- /**
270
- * 获取项目 emp内部根目录绝对路径
271
- * @param relativePath
272
- * @returns
273
- */
274
- empResolve: (relativePath: string) => string;
275
- /**
276
- * 源码地址 绝对路径
277
- */
278
- appSrc: string;
279
- /**
280
- * 源码生成目录 绝对路径
281
- */
282
- outDir: string;
283
- /**
284
- * 静态文件目录 绝对路径
285
- */
286
- publicDir: string;
287
- /**
288
- * 静态资源
289
- */
290
- resource: {
291
- dir: string;
292
- key: string;
293
- cert: string;
294
- };
295
- /**
296
- * chain 配置相关
297
- */
298
- chainName: {
299
- rule: {
300
- mjs: string;
301
- typescript: string;
302
- javascript: string;
303
- sourceMap: string;
304
- inline: string;
305
- raw: string;
306
- svg: string;
307
- image: string;
308
- font: string;
309
- svga: string;
310
- sass: string;
311
- less: string;
312
- css: string;
313
- };
314
- use: {
315
- swc: string;
316
- sourceMap: string;
317
- sass: string;
318
- less: string;
319
- };
320
- plugin: {
321
- tsCheckerRspackPlugin: string;
322
- bundleAnalyzer: string;
323
- define: string;
324
- copy: string;
325
- progress: string;
326
- html: {
327
- prefix: string;
328
- };
329
- rsdoctor: string;
330
- sourceMapDevTool: string;
331
- };
332
- minimizer: {
333
- minJs: string;
334
- minCss: string;
335
- };
336
- };
337
- /**
338
- * server 配置相关
339
- */
340
- server: StoreServer;
341
- /**
342
- * 缓存目录 绝对路径
343
- */
344
- cacheDir: string;
345
- mode: EMPModeType;
346
- cliMode: 'dev' | 'prod';
347
- isDev: boolean;
348
- /**
349
- * 项目配置
350
- */
351
- chain: Chain;
352
- rsConfig: Configuration;
353
- empOptions: EmpOptions;
354
- empConfig: EmpConfig;
355
- entries: {
356
- [chunkName: string]: RspackOptions['entry'];
357
- };
358
- debug: EmpConfig['debug'];
359
- cliAction: CliActionType;
360
- cliOptions: CliOptionsType;
361
- rootPaths: StoreRootPaths;
362
- beforeSetup?: () => Promise<void> | void;
363
- afterSetup?: () => Promise<void> | void;
364
- setup(cliAction?: CliActionType, cliOptions?: any): Promise<void>;
365
- /**
366
- * 初始化 基础变量
367
- * @param mode cli名称
368
- * @param cliOptions cli配置
369
- */
370
- private initVars;
371
- /**
372
- * 初始化 基础路径
373
- */
374
- private initPaths;
375
- /**
376
- * 设置 日志等级
377
- */
378
- private loggerExtensionName;
379
- setLoggerExtensionName(name: string): void;
380
- setLogger(): void;
381
- merge(o: RspackOptions): void;
382
- /**
383
- * 同步 chain 配置到 rsConfig
384
- */
385
- toConfig(): void;
386
- /**
387
- * 打印 config
388
- */
389
- logConfig(): void;
390
- get browserslistOptions(): {
391
- default: string[];
392
- h5: string[];
393
- node: string[];
394
- };
395
- get uniqueName(): string;
396
- encodeVarName(name: string): string;
397
- vCompare: (preVersion?: string, lastVersion?: string) => number;
398
- deepAssign: typeof deepAssign;
399
- getLanIp: () => string;
400
- injectTags(o?: InjectTagsType, name?: string, chunk?: string): void;
401
- }
402
- declare const _default$2: GlobalStore;
403
-
404
- type EMP3PluginType = {
405
- name: string;
406
- rsConfig: (store: GlobalStore) => Promise<void>;
407
- };
408
- type EMP3PluginFnType = (o: any) => EMP3PluginType;
409
-
410
- type LoggerType = 'debug' | 'info' | 'warn' | 'error';
411
- type RsdoctorRspackPluginOptions = ConstructorParameters<typeof RsdoctorRspackPlugin>[0];
412
- type CssminOptionsType = any;
413
- type DebugType = {
414
- loggerLevel?: LoggerType;
415
- clearLog?: boolean;
416
- progress?: boolean;
417
- showRsconfig?: boolean | string | InspectOptions;
418
- /**
419
- * 已经弃用
420
- */
421
- showPerformance?: boolean;
422
- showScriptDebug?: boolean;
423
- rsdoctor?: boolean | RsdoctorRspackPluginOptions;
424
- newTreeshaking?: boolean;
425
- devShowAllLog?: boolean;
426
- warnRuleAsWarning?: boolean;
427
- /**
428
- * 是否显示执行日志
429
- * @default false
430
- */
431
- infrastructureLogging?: Configuration['infrastructureLogging'];
432
- /**
433
- * 开启并行 code spitting
434
- * @default true
435
- */
436
- /**
437
- * https://rspack.rs/zh/plugins/rspack/css-chunking-plugin
438
- * 启用 CssChunkingPlugin 后,SplitChunksPlugin 将不再处理 CSS 模块。 这意味着 optimization.splitChunks 等配置对 CSS 模块将不再生效,所有 CSS 模块的代码分割逻辑完全由 CssChunkingPlugin 处理。
439
- */
440
- cssChunkingPlugin?: boolean;
441
- };
442
- type ServerType = DevServer & {
443
- /**
444
- * 访问 host
445
- * @default '0.0.0.0'
446
- */
447
- host?: string;
448
- /**
449
- * 访问 端口
450
- * @default 8000
451
- */
452
- port?: number;
453
- /**
454
- * 自动打开
455
- * @default false
456
- */
457
- open?: DevServer['open'];
458
- /**
459
- * 热重载
460
- * @default true
461
- */
462
- hot?: DevServer['hot'];
463
- http2?: boolean;
464
- https?: boolean;
465
- };
466
- type PolyfillType = {
467
- /**
468
- * 注入兼容代码
469
- * module federation 入口 建议使用 entry
470
- * @default false
471
- */
472
- mode?: 'entry' | 'usage';
473
- /**
474
- * 当 mode=entry时,注入cdn替代 entry chunk
475
- */
476
- entryCdn?: string;
477
- splitChunks?: boolean;
478
- /**
479
- * 手动注入兼容代码,避免usage出现分析纰漏问题
480
- * @default ['es.object.values', 'es.object.entries', 'es.array.flat']
481
- */
482
- include?: string[];
483
- /**
484
- * 选择core-js的兼容版本有助于切换适当的代码体积
485
- * @default stable
486
- */
487
- coreJsFeatures?: 'full' | 'actual' | 'stable' | 'es';
488
- /**
489
- * @swc/helpers 外置
490
- * @default false
491
- */
492
- externalHelpers?: boolean;
493
- /**
494
- * 浏览器 兼容版本
495
- */
496
- browserslist?: string[];
497
- };
498
- type SourceMapType = {
499
- js: Configuration['devtool'] | false;
500
- css: boolean;
501
- devToolPluginOptions?: SourceMapDevToolPluginOptions;
502
- };
503
- type BuildType = {
504
- /**
505
- * 生成代码目录
506
- * @default 'dist'
507
- */
508
- outDir?: string;
509
- /**
510
- * 生成静态目录
511
- * @default 'assets'
512
- */
513
- assetsDir?: string;
514
- /**
515
- * 生成包含 js,css,asset 合集目录
516
- * @default ''
517
- */
518
- staticDir?: string;
519
- /**
520
- * 静态文件路径
521
- * @default 'public'
522
- */
523
- publicDir?: string;
524
- /**
525
- * named 使用有意义、方便调试的内容当作模块 id。此选项会在开发环境下默认开启。
526
- * deterministic 使用对模块标识符哈希后的数字当作模块 id,有益于长期缓存。此选项会在生产环境下默认开启。
527
- */
528
- moduleIds?: 'named' | 'deterministic';
529
- /**
530
- * chunkIds
531
- * @default named|deterministic
532
- */
533
- chunkIds?: false | 'natural' | 'named' | 'deterministic' | 'size' | 'total-size';
534
- /**
535
- * 是否生成 source map
536
- * @default true
537
- */
538
- sourcemap?: boolean | SourceMapType;
539
- /**
540
- * sourcemap 类型
541
- * 默认 source-map
542
- * @deprecated 请使用 build.sourcemap.js 设置
543
- */
544
- devtool?: Configuration['devtool'];
545
- /**
546
- * 是否压缩
547
- * @default true
548
- */
549
- minify?: boolean;
550
- /**
551
- * 设置内置压缩器配置
552
- * @default {}
553
- */
554
- minOptions?: SwcJsMinimizerRspackPluginOptions;
555
- cssminOptions?: CssminOptionsType;
556
- /**
557
- * 生成代码 参考 https://swc.rs/docs/configuring-swc#jsctarget
558
- */
559
- target?: JscTarget;
560
- /**
561
- * 是否用 ESM
562
- */
563
- useESM?: boolean;
564
- /**
565
- * 注入兼容代码
566
- * module federation 入口 建议使用 entry
567
- * @default false
568
- */
569
- polyfill?: PolyfillType;
570
- /**
571
- * swc 配置
572
- */
573
- swcConfig?: {
574
- transform?: {
575
- useDefineForClassFields?: boolean;
576
- };
577
- preserveAllComments?: boolean;
578
- };
579
- };
580
- type JscTarget = 'es3' | 'es5' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022';
581
- interface HtmlType extends HtmlRspackPluginOptions {
582
- /**
583
- * 基于项目的根目录 index.html url
584
- * @default src/index.html
585
- */
586
- template?: string;
587
- /**
588
- * 基于项目的根目录 favicon url
589
- * @default src/favicon.ico
590
- */
591
- favicon?: string;
592
- /**
593
- * 自定义挂载节点的 id,默认为 'emp-root'
594
- * @default 'emp-root'
595
- */
596
- mountId?: string;
597
- /**
598
- * 网站语言
599
- */
600
- lang?: string;
601
- /**
602
- * externals 文件插入到html
603
- */
604
- tags?: InjectTagsTypeItem[];
605
- templateParameters?: any;
606
- cache?: boolean;
607
- }
608
- type EntriesType = {
609
- [entryFilename: string]: HtmlType;
610
- };
611
- interface ModuleTransform {
612
- exclude?: RuleSetRule['exclude'][];
613
- include?: RuleSetRule['include'][];
614
- /**
615
- * 默认exclude /(node_modules|bower_components)/
616
- * @default false
617
- */
618
- defaultExclude?: boolean;
619
- }
620
- type CssSassOptionsType = {
621
- api?: 'modern' | 'modern-compiler';
622
- sassOptions?: Options<'async'>;
623
- mode?: 'default' | 'modern' | 'legacy';
624
- implementation?: object | string;
625
- };
626
- /**
627
- * Less 配置项
628
- *
629
- * 将 less-loader 的常用选项暴露到 empConfig.css.less,并提供 TS 提示。
630
- */
631
- type CssLessOptionsType = {
632
- /**
633
- * 传递给 less-loader 的 lessOptions。
634
- *
635
- * - `javascriptEnabled`: 允许在 Less 中使用 JS 表达式与函数。
636
- * 许多第三方 UI 库(如 Ant Design)在主题构建或函数型变量计算中需要开启。
637
- * 若关闭,可能导致变量计算/函数调用失败(构建报错或样式异常)。
638
- * 默认值:`true`。
639
- *
640
- * - `math`: 控制数学表达式解析策略(Less v4)。
641
- * - `'always'`: 始终解析数学表达式(兼容旧 Less 裸除法写法,升级更平滑)。
642
- * - `'parens-division'`: 仅在括号内解析除法,更安全的中间策略。
643
- * - `'strict'`: 更严格的解析方式,需显式括号。
644
- * 默认值:`'always'`,用于提升对旧代码及部分生态的兼容性。
645
- */
646
- lessOptions?: {
647
- javascriptEnabled?: boolean;
648
- math?: 'always' | 'parens-division' | 'strict';
649
- };
650
- };
651
- type RsTarget = Configuration['target'];
652
- type AutoPagesType = {
653
- /**
654
- * 基于src寻找入口目录
655
- * @default pages
656
- */
657
- path?: string;
658
- };
659
- type EmpOptions = {
660
- /**
661
- * publicPath 根路径 可参考webpack,业务模式默认为 auto
662
- * html 部分 publicPath 默认为 undefined,可设置全量域名或子目录适配,也可以单独在html设置 Public
663
- *
664
- * @default undefined
665
- */
666
- base?: string;
667
- /**
668
- * 构建target
669
- */
670
- target?: Configuration['target'];
671
- /**
672
- * 启动后 自动设置 base 为当前 Ip+port的路径如 base = http://127.0.0.1:8080/ 并且固定 ws 方便代理调试
673
- */
674
- autoDevBase?: boolean;
675
- /**
676
- * 启动后 进入自动搜寻入口的方式
677
- * 可以通过 html 或 entries 设置 模版配置
678
- */
679
- autoPages?: boolean | AutoPagesType;
680
- /**
681
- * 项目代码路径
682
- * @default 'src'
683
- */
684
- appSrc?: string;
685
- /**
686
- * 项目代码入口文件 如 `src/index.js`
687
- * (*)entries 设置后 该选项失效
688
- * @default 'index.js'
689
- */
690
- appEntry?: string;
691
- build?: BuildType;
692
- plugins?: EMP3PluginType[];
693
- html?: HtmlType;
694
- entries?: EntriesType;
695
- server?: ServerType;
696
- debug?: DebugType;
697
- chain?: (chain: Chain) => void;
698
- /**
699
- * css 相关设置
700
- * @argument sass default {mode: 'modern'}
701
- */
702
- css?: {
703
- sass?: CssSassOptionsType & {
704
- webpackImporter?: boolean;
705
- warnRuleAsWarning?: boolean;
706
- additionalData?: string;
707
- };
708
- /**
709
- * Less 配置
710
- *
711
- * 默认:`{ lessOptions: { javascriptEnabled: true, math: 'always' } }`
712
- * 如项目严格遵循 Less v4 新语法且不依赖 JS 表达式,可考虑:
713
- * - 将 `math` 调整为 `'parens-division'` 或 `'strict'`;
714
- * - 将 `javascriptEnabled` 设为 `false`。
715
- */
716
- less?: CssLessOptionsType;
717
- prifixName?: string;
718
- };
719
- /**
720
- * 模块编译
721
- * 如 node_modules 模块 是否加入编译
722
- */
723
- moduleTransform?: ModuleTransform;
724
- /**
725
- * 缓存目录
726
- * @default 'node_modules/.emp-cache'
727
- */
728
- cacheDir?: string;
729
- /**
730
- * 启用缓存
731
- * @default persistent 为 内存缓存 false 关闭 persistent 持久缓存
732
- */
733
- cache?: boolean | 'persistent' | ExperimentCacheOptions;
734
- /**
735
- * 全局环境替换
736
- */
737
- define?: Record<string, any>;
738
- /**
739
- * 是否创建 cjs 的 process.env 或者 esm 的 import.meta.env
740
- * all 两者创建
741
- * esm 创建 import.meta.env
742
- * cjs 创建 process.env
743
- * none 不创建
744
- * @default cjs
745
- */
746
- defineFix?: 'all' | 'esm' | 'cjs' | 'none';
747
- /**
748
- * externals
749
- */
750
- externals?: Externals;
751
- /**
752
- * resolve
753
- */
754
- resolve?: Resolve;
755
- /**
756
- * output
757
- */
758
- output?: Output;
759
- /**
760
- * emp 执行周期
761
- */
762
- lifeCycle?: LifeCycleOptions;
763
- /**
764
- * ignoreWarnings
765
- * @default [/Conflicting order/, /Failed to parse source map/]
766
- */
767
- ignoreWarnings?: Configuration['ignoreWarnings'];
768
- /**
769
- * 详情 https://github.com/rspack-contrib/ts-checker-rspack-plugin
770
- */
771
- tsCheckerRspackPlugin?: TsCheckerRspackPluginOptions | boolean;
772
- /**
773
- * 是否显示日志标题
774
- * @default undefined
775
- */
776
- showLogTitle?: (o?: any) => void;
777
- };
778
- type InjectTagsType = InjectTagsTypeItem[];
779
- type InjectTagsTypeItem = {
780
- pos?: 'head' | 'body';
781
- } & Partial<HtmlTagObject>;
782
- type StoreRootPaths = {
783
- tsConfig?: string;
784
- empConfig?: string;
785
- pkg?: string;
786
- };
787
-
788
- declare function runScript(): Promise<void>;
789
-
790
- declare const _default$1: {
791
- lightGreen: chalk.ChalkInstance;
792
- green: chalk.ChalkInstance;
793
- lightCyan: chalk.ChalkInstance;
794
- cyan: chalk.ChalkInstance;
795
- lightRed: chalk.ChalkInstance;
796
- red: chalk.ChalkInstance;
797
- yellow: chalk.ChalkInstance;
798
- orange: chalk.ChalkInstance;
799
- lightBlue: chalk.ChalkInstance;
800
- blue: chalk.ChalkInstance;
801
- white: chalk.ChalkInstance;
802
- lightMagenta: chalk.ChalkInstance;
803
- magenta: chalk.ChalkInstance;
804
- gray: chalk.ChalkInstance;
805
- };
806
-
807
- declare class Logger {
808
- brandName: string;
809
- fullName: string;
810
- logLevel: string;
811
- isLogTime: boolean;
812
- setup({ brandName, logLevel, fullName }: any): void;
813
- time: (...args: any[]) => false | void;
814
- timeEnd: (...args: any[]) => false | void;
815
- debug: (...args: any[]) => false | void;
816
- info: (...args: any[]) => false | void;
817
- warn: (...args: any[]) => false | void;
818
- error: (...args: any[]) => false | void;
819
- blue: (msg: string) => void;
820
- cyan: (msg: string) => void;
821
- magenta: (msg: string) => void;
822
- green: (msg: string) => void;
823
- yellow: (msg: string) => void;
824
- red: (msg: string) => void;
825
- sysError: (msg: string) => void;
826
- link: (msg: string) => string;
827
- title: (msg: string) => void;
828
- }
829
- declare const _default: Logger;
830
-
831
- declare const index_glob: typeof glob;
832
- declare const index_utils: typeof utils;
833
- declare namespace index {
834
- export { chalk__default as chalk, _default$1 as color, index_glob as glob, _default as logger, index_utils as utils };
835
- }
836
-
837
- type EMPConfigFn = (store: GlobalStore) => EmpOptions | Promise<EmpOptions>;
838
- type EMPConfigExport = EmpOptions | EMPConfigFn;
839
- declare function defineConfig(config: EMPConfigExport): EMPConfigExport;
840
-
841
- export { type EMP3PluginFnType, type EMP3PluginType, type EMPConfigExport, type EMPConfigFn, type EmpOptions, GlobalStore, Logger, _default$1 as color, defineConfig, index as empHelper, runScript, _default$2 as store };