@empjs/cli 3.0.0-rc.0 → 3.0.0-rc.10

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.
@@ -1,4 +1,4 @@
1
- import { RspackOptions } from '@rspack/core';
1
+ import { type RspackOptions } from '@rspack/core';
2
2
  import { BaseScript } from '../script/base';
3
3
  declare class DevScript extends BaseScript {
4
4
  get rspackDevConfig(): RspackOptions;
@@ -1,4 +1,4 @@
1
- import { Express } from 'express';
1
+ import { type Express } from 'express';
2
2
  import { BaseScript } from '../script/base';
3
3
  export declare class HttpServer extends BaseScript {
4
4
  app: Express;
@@ -1,7 +1,8 @@
1
- import { GlobalStore } from '../store';
2
- import { BuildType, DebugType, EMPShareType, HtmlType, RsTarget, ServerType } from '../types/config';
3
- import { Output } from '@rspack/core';
4
- import { EMPShareLib } from '../store/empShareLib';
1
+ import type { GlobalStore } from '../store';
2
+ import type { BuildType, DebugType, EMPShareType, HtmlType, RsTarget, ServerType } from '../types/config';
3
+ import type { Output } from '@rspack/core';
4
+ import { EMPShareLib } from '../store/empShare';
5
+ import { EmpShareFastMode } from '../store/empShare/fastMode';
5
6
  import { LifeCycle } from '../store/lifeCycle';
6
7
  export declare class EmpConfig {
7
8
  private store;
@@ -25,6 +26,7 @@ export declare class EmpConfig {
25
26
  base: string;
26
27
  target: RsTarget;
27
28
  private assign;
29
+ empShareFastMode: EmpShareFastMode;
28
30
  empShareLib: EMPShareLib;
29
31
  /**
30
32
  * 是否启动 esm 模块
@@ -56,6 +58,10 @@ export declare class EmpConfig {
56
58
  syncEmpOptions(): Promise<void>;
57
59
  get moduleTransformRule(): any;
58
60
  get cacheDir(): string;
61
+ get ignoreWarnings(): (RegExp | ((args_0: Error, args_1: import("@rspack/core").Compilation, ...args_2: unknown[]) => boolean))[];
62
+ get autoPages(): {
63
+ path: string;
64
+ } | undefined;
59
65
  }
60
66
  declare const _default: EmpConfig;
61
67
  export default _default;
@@ -0,0 +1,18 @@
1
+ import type { EMPShareFastModeType } from '../../types/config';
2
+ export declare class EmpShareFastMode {
3
+ fastMode: Required<EMPShareFastModeType>;
4
+ externalMF: {
5
+ '@module-federation/runtime': string;
6
+ '@module-federation/sdk': string;
7
+ };
8
+ externalReact: {
9
+ react: string;
10
+ 'react-dom': string;
11
+ 'react-router-dom': string;
12
+ };
13
+ externals: any;
14
+ getRuntimeLib(runtimeHost: string): string;
15
+ setup(): void;
16
+ injectLib(): void;
17
+ setExternals(): void;
18
+ }
@@ -1,6 +1,6 @@
1
- import { Configuration } from '@rspack/core';
2
- import type { EMPShareType } from '../types/config';
3
- import { ModuleFederationPlugin } from '@module-federation/enhanced/rspack';
1
+ import type { ModuleFederationPlugin } from '@module-federation/enhanced/rspack';
2
+ import type { Configuration } from '@rspack/core';
3
+ import type { EMPShareType } from '../../types/config';
4
4
  export type externalAssetsType = {
5
5
  js: string[];
6
6
  css: string[];
@@ -17,7 +17,6 @@ export declare class EMPShareLib {
17
17
  private exp;
18
18
  config: EMPShareType;
19
19
  importMap: ImportMapType;
20
- version: EMPShareType['mfVersion'];
21
20
  isEmpshare: boolean;
22
21
  setup(): Promise<void>;
23
22
  /**
@@ -1,9 +1,9 @@
1
- import { EMPModeType } from '../types/env';
2
- import WPChain from 'webpack-chain';
3
1
  import type { Configuration as RsConfig, RspackOptions } from '@rspack/core';
4
- import type { EmpOptions } from '../types/config';
5
- import { EmpConfig } from '../store/empConfig';
6
2
  import { deepAssign } from '../helper/utils';
3
+ import { type EmpConfig } from '../store/empConfig';
4
+ import type { EmpOptions } from '../types/config';
5
+ import type { EMPModeType } from '../types/env';
6
+ import WPChain from 'webpack-chain';
7
7
  export declare class GlobalStore {
8
8
  /**
9
9
  * EMP Version
@@ -79,6 +79,10 @@ export declare class GlobalStore {
79
79
  vCompare: (preVersion?: string, lastVersion?: string) => number;
80
80
  deepAssign: typeof deepAssign;
81
81
  getLanIp: () => string;
82
+ entries: {
83
+ [chunkName: string]: RspackOptions['entry'];
84
+ };
85
+ debug: EmpConfig['debug'];
82
86
  setup(mode: string, cliOptions: any): Promise<void>;
83
87
  /**
84
88
  * 初始化 基础变量
@@ -5,6 +5,10 @@ export declare class LifeCycle {
5
5
  afterGetEmpOptions(): Promise<void>;
6
6
  beforePlugin(): Promise<void>;
7
7
  afterPlugin(): Promise<void>;
8
+ beforeModule(): Promise<void>;
9
+ afterModule(): Promise<void>;
10
+ beforeEmpPlugin(): Promise<void>;
11
+ afterEmpPlugin(): Promise<void>;
8
12
  beforeBuild(): Promise<void>;
9
13
  afterBulid(): Promise<void>;
10
14
  beforeDevServe(): Promise<void>;
@@ -3,6 +3,7 @@ declare class RspackCommon {
3
3
  store: GlobalStore;
4
4
  setup(store: GlobalStore): Promise<void>;
5
5
  common(): Promise<void>;
6
+ checkTsconfig(): Promise<void>;
6
7
  stats(): Promise<void>;
7
8
  devServer(): Promise<void>;
8
9
  optimization(): Promise<void>;
@@ -1,6 +1,6 @@
1
+ import type { RspackOptions } from '@rspack/core';
1
2
  import type { GlobalStore } from '../../store';
2
- import { EmpConfig } from '../empConfig';
3
- import { RspackOptions } from '@rspack/core';
3
+ import type { EmpConfig } from '../empConfig';
4
4
  type EntriesConfigType = {
5
5
  [chunk: string]: {
6
6
  html: EmpConfig['html'];
@@ -12,13 +12,27 @@ declare class RspackEntries {
12
12
  entriesConfig: EntriesConfigType;
13
13
  setup(store: GlobalStore): Promise<void>;
14
14
  private setHtmlConfig;
15
+ /**
16
+ * chunk name 格式化 去除 后缀
17
+ * @param filename
18
+ * @returns
19
+ */
15
20
  private setChunk;
16
21
  private setTemplate;
17
22
  private setFavicion;
23
+ /**
24
+ *
25
+ * @param filename 文件名
26
+ * @param op html plugin 配置
27
+ * @param absPath 文件 绝对路径
28
+ */
18
29
  private setEntryItem;
19
30
  setRspackHtmlPlugin(config: EmpConfig['html'], chunk: string): void;
20
31
  setRspackEntry(entry: RspackOptions['entry']): void;
21
32
  init(): Promise<void>;
33
+ setAutoPage(): Promise<void>;
34
+ setDefaultEntry(): Promise<void>;
35
+ setEntryByConfig(): void;
22
36
  toConfig(): void;
23
37
  }
24
38
  declare const _default: RspackEntries;
@@ -1,19 +1,21 @@
1
- import { HtmlType } from '../../types/config';
2
- import { EMPShareLib } from '../empShareLib';
3
- import { type Compiler } from '@rspack/core';
1
+ import type { Compiler } from '@rspack/core';
2
+ import type { EMPShareLib } from '../../store/empShare';
3
+ import type { HtmlType } from '../../types/config';
4
4
  export declare const HtmlImportMapPluginName = "HtmlImportMapPlugin";
5
5
  export declare class HtmlImportMapPlugin {
6
6
  importMap: EMPShareLib['importMap'];
7
- constructor(importMap: EMPShareLib['importMap']);
7
+ chunk: string;
8
+ constructor(importMap: EMPShareLib['importMap'], chunk: string);
8
9
  apply(compiler: any): void;
9
10
  }
10
11
  export declare const HtmlEmpShareLibPluginName = "HtmlEmpShareLibPlugin";
11
12
  export declare class HtmlEmpShareLibPlugin {
13
+ chunk: string;
12
14
  files: {
13
15
  css: string[];
14
16
  js: string[];
15
17
  };
16
- constructor(files: HtmlType['files']);
18
+ constructor(files: HtmlType['files'], chunk: string);
17
19
  apply(compiler: any): void;
18
20
  }
19
21
  export declare class EmpPolyfillPlugin {
@@ -1,12 +1,12 @@
1
1
  /// <reference types="node" />
2
+ import type { InspectOptions } from 'node:util';
2
3
  import type { Configuration as RsConfig } from '@rspack/core';
3
- import { Configuration as devServerConfig } from '@rspack/dev-server';
4
- import Chain from 'webpack-chain';
5
- import { Externals, HtmlRspackPluginOptions, Output, Resolve, RuleSetRule, SwcJsMinimizerRspackPluginOptions } from '@rspack/core';
6
- import { EMP3PluginType } from './plugin';
7
- import { InspectOptions } from 'node:util';
4
+ import type { Externals, HtmlRspackPluginOptions, Output, Resolve, RuleSetRule, SwcJsMinimizerRspackPluginOptions } from '@rspack/core';
5
+ import type { Configuration as devServerConfig } from '@rspack/dev-server';
6
+ import type { ModuleFederationPluginOptions } from '../store/empShare';
8
7
  import type { LifeCycle } from '../store/lifeCycle';
9
- import type { ModuleFederationPluginOptions } from '../store/empShareLib';
8
+ import type Chain from 'webpack-chain';
9
+ import type { EMP3PluginType } from './plugin';
10
10
  export type LoggerType = 'debug' | 'info' | 'warn' | 'error';
11
11
  export type DebugType = {
12
12
  loggerLevel: LoggerType;
@@ -15,6 +15,7 @@ export type DebugType = {
15
15
  showRsconfig: boolean | string | InspectOptions;
16
16
  showPerformance: boolean;
17
17
  rspackCache: boolean;
18
+ newTreeshaking: boolean;
18
19
  /**
19
20
  * 是否显示执行日志
20
21
  * @default false
@@ -99,6 +100,11 @@ export type BuildType = {
99
100
  * @default false
100
101
  */
101
102
  polyfill?: 'entry' | 'usage' | false;
103
+ /**
104
+ * 手动注入兼容代码,避免usage出现分析纰漏问题
105
+ * @default ['es.object.values', 'es.object.entries', 'es.array.flat']
106
+ */
107
+ polyfillInclude?: string[];
102
108
  /**
103
109
  * 选择core-js的兼容版本有助于切换适当的代码体积
104
110
  * @default stable
@@ -113,6 +119,15 @@ export type BuildType = {
113
119
  * 浏览器 兼容版本
114
120
  */
115
121
  browserslist: string[];
122
+ /**
123
+ * swc 配置
124
+ */
125
+ swcConfig: {
126
+ transform?: {
127
+ useDefineForClassFields?: boolean;
128
+ };
129
+ preserveAllComments?: boolean;
130
+ };
116
131
  };
117
132
  export type JscTarget = 'es3' | 'es5' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022';
118
133
  export interface HtmlType extends HtmlRspackPluginOptions {
@@ -166,6 +181,28 @@ export interface ModuleTransform {
166
181
  */
167
182
  defaultExclude?: boolean;
168
183
  }
184
+ export type EMPShareFastModeType = {
185
+ /**
186
+ * 共享库目录 优先读取 runtimeLib
187
+ */
188
+ runtimeHost?: string;
189
+ /**
190
+ * 共享库全路径
191
+ */
192
+ runtimeLib?: string;
193
+ /**
194
+ * 额外的库添加
195
+ */
196
+ externals?: any;
197
+ /**
198
+ * 当为 UMD时 暴露到 window 的全局变量
199
+ */
200
+ globalVal?: string;
201
+ /**
202
+ * 默认支持React
203
+ */
204
+ framework?: 'react';
205
+ };
169
206
  export type EMPShareType = ModuleFederationPluginOptions & {
170
207
  /**
171
208
  * emp 基于库共享模块
@@ -177,10 +214,9 @@ export type EMPShareType = ModuleFederationPluginOptions & {
177
214
  */
178
215
  useImportMap?: boolean;
179
216
  /**
180
- * module federation 版本
181
- * @default 1
217
+ * 快速模式
182
218
  */
183
- mfVersion?: 1 | 1.5;
219
+ fastMode?: EMPShareFastModeType;
184
220
  };
185
221
  export type EMPshareLibItemType = {
186
222
  [module: string]: {
@@ -216,6 +252,13 @@ export type ExternalsItemType = {
216
252
  type?: string;
217
253
  };
218
254
  export type RsTarget = RsConfig['target'];
255
+ export type AutoPagesType = {
256
+ /**
257
+ * 基于src寻找入口目录
258
+ * @default pages
259
+ */
260
+ path?: string;
261
+ };
219
262
  export type EmpOptions = {
220
263
  /**
221
264
  * publicPath 根路径 可参考webpack,业务模式默认为 auto
@@ -232,6 +275,11 @@ export type EmpOptions = {
232
275
  * 启动后 自动设置 base 为当前 Ip+port的路径如 base = http://127.0.0.1:8080/ 并且固定 ws 方便代理调试
233
276
  */
234
277
  autoDevBase?: boolean;
278
+ /**
279
+ * 启动后 进入自动搜寻入口的方式
280
+ * 可以通过 html 或 entries 设置 模版配置
281
+ */
282
+ autoPages?: boolean | AutoPagesType;
235
283
  /**
236
284
  * 项目代码路径
237
285
  * @default 'src'
@@ -294,4 +342,9 @@ export type EmpOptions = {
294
342
  * emp 执行周期
295
343
  */
296
344
  lifeCycle?: LifeCycle;
345
+ /**
346
+ * ignoreWarnings
347
+ * @default [/Conflicting order/]
348
+ */
349
+ ignoreWarnings?: RsConfig['ignoreWarnings'];
297
350
  };
package/emp-tsconfig.json CHANGED
@@ -3,11 +3,7 @@
3
3
  "types": ["@empjs/cli/client"],
4
4
  "plugins": [{ "name": "typescript-plugin-css-modules" }],
5
5
  "target": "ESNext",
6
- "lib": [
7
- "DOM",
8
- "DOM.Iterable",
9
- "ESNext"
10
- ],
6
+ "lib": ["DOM", "DOM.Iterable", "ESNext"],
11
7
  "allowJs": true,
12
8
  "skipLibCheck": true,
13
9
  "esModuleInterop": true,
@@ -23,11 +19,6 @@
23
19
  "jsx": "preserve",
24
20
  "verbatimModuleSyntax": true
25
21
  },
26
- "include": [
27
- "src"
28
- ],
29
- "exclude": [
30
- "dist",
31
- "nodule_modules"
32
- ]
33
- }
22
+ "include": ["src"],
23
+ "exclude": ["dist", "nodule_modules"]
24
+ }
package/package.json CHANGED
@@ -1,113 +1,96 @@
1
1
  {
2
- "name": "@empjs/cli",
3
- "version": "3.0.0-rc.0",
4
- "description": "emp",
5
- "license": "MIT",
6
- "type": "module",
7
- "files": [
8
- "dist",
9
- "bin",
10
- "resource",
11
- "template",
12
- "client.d.ts",
13
- "emp-tsconfig.json"
14
- ],
15
- "maintainers": [
16
- "xuhongbin",
17
- "ckken"
18
- ],
19
- "repository": {
20
- "type": "git",
21
- "url": "git+https://github.com/empjs/emp.git",
22
- "directory": "packages/cli"
23
- },
24
- "publishConfig": {
25
- "access": "public"
26
- },
27
- "keywords": [
28
- "rspack",
29
- "rust",
30
- "typescript"
31
- ],
32
- "bin": {
33
- "emp": "./bin/emp.js"
34
- },
35
- "main": "dist/index.js",
36
- "module": "dist/index.js",
37
- "types": "dist/index.d.ts",
38
- "exports": {
39
- ".": {
40
- "import": {
41
- "default": "./dist/index.js",
42
- "types": "./dist/index.d.ts"
43
- },
44
- "require": {
45
- "default": "./dist/index.js",
46
- "types": "./dist/index.d.ts"
47
- }
48
- },
49
- "./emp-tsconfig.json": "./emp-tsconfig.json"
50
- },
51
- "scripts": {
52
- "d": "rimraf dist && pnpm run esdev:build",
53
- "b": "rimraf dist && pnpm run esbuild:build",
54
- "dev": "rimraf dist && pnpm run /^esdev:.*/",
55
- "esdev:build": "cross-env ENV=dev node esbuild.js",
56
- "esdev:tsc": "tsc -w",
57
- "esdev:tsc-alias": "tsc-alias -w",
58
- "build": "rimraf dist && pnpm run /^esbuild:.*/",
59
- "esbuild:build": "cross-env ENV=prod node esbuild.js",
60
- "esbuild:tsc": "tsc && tsc-alias",
61
- "dts": "node dts-bundle.js"
62
- },
63
- "engines": {
64
- "node": ">=20.0.0"
65
- },
66
- "author": "Ken",
67
- "devDependencies": {
68
- "@types/compression": "^1.7.2",
69
- "@types/cors": "^2.8.12",
70
- "@types/default-gateway": "^7.2.1",
71
- "@types/express": "^4.17.13",
72
- "@types/fs-extra": "^11.0.4",
73
- "@types/watchpack": "^2.4.3",
74
- "@types/webpack": "^5.28.4",
75
- "@types/webpack-bundle-analyzer": "^4.6.2",
76
- "@types/webpack-hot-middleware": "^2.25.9",
77
- "@types/webpack-sources": "^3.2.2",
78
- "cross-env": "^7.0.3",
79
- "esbuild": "^0.19.5",
80
- "rimraf": "^5.0.5",
81
- "tsc-alias": "^1.8.8"
82
- },
83
- "dependencies": {
84
- "@module-federation/enhanced": "^0.1.3",
85
- "@rspack/core": "0.6.1",
86
- "@rspack/dev-server": "0.6.1",
87
- "@swc/helpers": "^0.5.7",
88
- "@types/node": "^20.8.7",
89
- "address": "^2.0.1",
90
- "ansi-html-community": "^0.0.8",
91
- "chalk": "^5.3.0",
92
- "commander": "^11.1.0",
93
- "compression": "^1.7.4",
94
- "core-js": "^3.36.1",
95
- "cors": "^2.8.5",
96
- "default-gateway": "^7.2.2",
97
- "express": "^4.18.2",
98
- "fast-glob": "^3.3.1",
99
- "fs-extra": "^11.2.0",
100
- "gzip-size": "^7.0.0",
101
- "html-entities": "^2.5.2",
102
- "html-webpack-plugin": "^5.6.0",
103
- "less-loader": "^11.1.3",
104
- "open": "^10.1.0",
105
- "postcss": "^8.4.33",
106
- "postcss-loader": "^7.3.4",
107
- "sass-loader": "^13.3.2",
108
- "strip-ansi": "^7.1.0",
109
- "typescript-plugin-css-modules": "^5.0.2",
110
- "webpack-bundle-analyzer": "^4.9.1",
111
- "webpack-chain": "^6.5.1"
112
- }
113
- }
2
+ "name": "@empjs/cli",
3
+ "version": "3.0.0-rc.10",
4
+ "description": "emp",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "files": ["dist", "bin", "resource", "template", "client.d.ts", "emp-tsconfig.json"],
8
+ "maintainers": ["xuhongbin", "ckken", "doerme"],
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/empjs/emp.git",
12
+ "directory": "packages/cli"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "keywords": ["rspack", "rust", "typescript"],
18
+ "bin": {
19
+ "emp": "./bin/emp.js"
20
+ },
21
+ "main": "dist/index.js",
22
+ "module": "dist/index.js",
23
+ "types": "dist/index.d.ts",
24
+ "exports": {
25
+ ".": {
26
+ "import": {
27
+ "default": "./dist/index.js",
28
+ "types": "./dist/index.d.ts"
29
+ },
30
+ "require": {
31
+ "default": "./dist/index.js",
32
+ "types": "./dist/index.d.ts"
33
+ }
34
+ },
35
+ "./emp-tsconfig.json": "./emp-tsconfig.json"
36
+ },
37
+ "scripts": {
38
+ "d": "rimraf dist && pnpm run esdev:build",
39
+ "b": "rimraf dist && pnpm run esbuild:build",
40
+ "dev": "rimraf dist && pnpm run /^esdev:.*/",
41
+ "esdev:build": "cross-env ENV=dev node esbuild.js",
42
+ "esdev:tsc": "tsc -w",
43
+ "esdev:tsc-alias": "tsc-alias -w",
44
+ "build": "rimraf dist && pnpm run /^esbuild:.*/",
45
+ "esbuild:build": "cross-env ENV=prod node esbuild.js",
46
+ "esbuild:tsc": "tsc && tsc-alias",
47
+ "dts": "node dts-bundle.js"
48
+ },
49
+ "engines": {
50
+ "node": ">=20.0.0"
51
+ },
52
+ "author": "Ken",
53
+ "devDependencies": {
54
+ "@types/compression": "^1.7.2",
55
+ "@types/cors": "^2.8.12",
56
+ "@types/default-gateway": "^7.2.1",
57
+ "@types/express": "^4.17.13",
58
+ "@types/fs-extra": "^11.0.4",
59
+ "@types/node": "^20.8.7",
60
+ "@types/watchpack": "^2.4.3",
61
+ "@types/webpack": "^5.28.4",
62
+ "@types/webpack-bundle-analyzer": "^4.6.2",
63
+ "@types/webpack-hot-middleware": "^2.25.9",
64
+ "@types/webpack-sources": "^3.2.2",
65
+ "cross-env": "^7.0.3",
66
+ "esbuild": "^0.19.5",
67
+ "rimraf": "^5.0.5",
68
+ "tsc-alias": "^1.8.8"
69
+ },
70
+ "dependencies": {
71
+ "@module-federation/enhanced": "^0.1.12",
72
+ "@rspack/core": "0.6.4",
73
+ "@rspack/dev-server": "0.6.4",
74
+ "@swc/helpers": "^0.5.11",
75
+ "address": "^2.0.2",
76
+ "ansi-html-community": "^0.0.8",
77
+ "chalk": "^5.3.0",
78
+ "commander": "^11.1.0",
79
+ "compression": "^1.7.4",
80
+ "core-js": "^3.37.0",
81
+ "cors": "^2.8.5",
82
+ "default-gateway": "^7.2.2",
83
+ "express": "^4.18.2",
84
+ "fast-glob": "^3.3.1",
85
+ "fs-extra": "^11.2.0",
86
+ "gzip-size": "^7.0.0",
87
+ "html-webpack-plugin": "^5.6.0",
88
+ "less-loader": "^12.2.0",
89
+ "open": "^10.1.0",
90
+ "sass-loader": "^14.2.0",
91
+ "strip-ansi": "^7.1.0",
92
+ "typescript-plugin-css-modules": "^5.1.0",
93
+ "webpack-bundle-analyzer": "^4.10.2",
94
+ "webpack-chain": "^6.5.1"
95
+ }
96
+ }
Binary file
Binary file
Binary file
Binary file