@empjs/cli 3.0.0-beta.9 → 3.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,8 +7,7 @@ declare class RspackPlugin {
7
7
  copy(): Promise<void>;
8
8
  progress(): Promise<void>;
9
9
  empShare(): Promise<void>;
10
- minJs(): void;
11
- minCss(): void;
10
+ minify(): void;
12
11
  }
13
12
  declare const _default: RspackPlugin;
14
13
  export default _default;
@@ -1,13 +1,25 @@
1
+ /// <reference types="node" />
2
+ import type { Configuration as RsConfig } from '@rspack/core';
1
3
  import { Configuration as devServerConfig } from '@rspack/dev-server';
2
4
  import Chain from 'webpack-chain';
3
- import { Externals, HtmlRspackPluginOptions, ModuleFederationPluginOptions, Output, Resolve, RuleSetRule, SwcJsMinimizerRspackPluginOptions } from '@rspack/core';
5
+ import { Externals, HtmlRspackPluginOptions, Output, Resolve, RuleSetRule, SwcJsMinimizerRspackPluginOptions } from '@rspack/core';
4
6
  import { EMP3PluginType } from './plugin';
7
+ import { InspectOptions } from 'node:util';
8
+ import type { LifeCycle } from '../store/lifeCycle';
9
+ import type { ModuleFederationPluginOptions } from '../store/empShareLib';
5
10
  export type LoggerType = 'debug' | 'info' | 'warn' | 'error';
6
11
  export type DebugType = {
7
12
  loggerLevel: LoggerType;
8
13
  clearLog: boolean;
9
14
  progress: boolean;
10
- showRsconfig: boolean;
15
+ showRsconfig: boolean | string | InspectOptions;
16
+ showPerformance: boolean;
17
+ rspackCache: boolean;
18
+ /**
19
+ * 是否显示执行日志
20
+ * @default false
21
+ */
22
+ infrastructureLogging: RsConfig['infrastructureLogging'];
11
23
  };
12
24
  export type ServerType = devServerConfig & {
13
25
  /**
@@ -52,6 +64,11 @@ export type BuildType = {
52
64
  * @default 'public'
53
65
  */
54
66
  publicDir?: string;
67
+ /**
68
+ * named 使用有意义、方便调试的内容当作模块 id。此选项会在开发环境下默认开启。
69
+ * deterministic 使用对模块标识符哈希后的数字当作模块 id,有益于长期缓存。此选项会在生产环境下默认开启。
70
+ */
71
+ moduleIds?: 'named' | 'deterministic';
55
72
  /**
56
73
  * chunkIds
57
74
  * @default named|deterministic
@@ -72,7 +89,32 @@ export type BuildType = {
72
89
  * @default {}
73
90
  */
74
91
  minOptions?: SwcJsMinimizerRspackPluginOptions;
92
+ /**
93
+ * 生成代码 参考 https://swc.rs/docs/configuring-swc#jsctarget
94
+ */
95
+ target?: JscTarget;
96
+ /**
97
+ * 注入兼容代码
98
+ * module federation 入口 建议使用 entry
99
+ * @default false
100
+ */
101
+ polyfill?: 'entry' | 'usage' | false;
102
+ /**
103
+ * 选择core-js的兼容版本有助于切换适当的代码体积
104
+ * @default stable
105
+ */
106
+ coreJsFeatures?: 'full' | 'actual' | 'stable' | 'es';
107
+ /**
108
+ * @swc/helpers 外置
109
+ * @default false
110
+ */
111
+ externalHelpers: boolean;
112
+ /**
113
+ * 浏览器 兼容版本
114
+ */
115
+ browserslist: string[];
75
116
  };
117
+ export type JscTarget = 'es3' | 'es5' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022';
76
118
  export interface HtmlType extends HtmlRspackPluginOptions {
77
119
  /**
78
120
  * 基于项目的根目录 index.html url
@@ -112,22 +154,17 @@ export interface HtmlType extends HtmlRspackPluginOptions {
112
154
  export type EntriesType = {
113
155
  [entryFilename: string]: HtmlType;
114
156
  };
115
- export type ReactType = {
116
- /**
117
- * 是否启动 热更 默认为 true
118
- */
119
- hmr: boolean;
120
- /**
121
- * 是否启动 Svg React Component 默认为 false
122
- */
123
- svgr: boolean;
124
- };
125
157
  export type CSSOptions = {
126
158
  postcss?: [string, any][];
127
159
  };
128
160
  export interface ModuleTransform {
129
161
  exclude?: RuleSetRule['exclude'][];
130
162
  include?: RuleSetRule['include'][];
163
+ /**
164
+ * 默认exclude /(node_modules|bower_components)/
165
+ * @default false
166
+ */
167
+ defaultExclude?: boolean;
131
168
  }
132
169
  export type EMPShareType = ModuleFederationPluginOptions & {
133
170
  /**
@@ -135,9 +172,15 @@ export type EMPShareType = ModuleFederationPluginOptions & {
135
172
  */
136
173
  shareLib?: EMPshareLibItemType;
137
174
  /**
175
+ * TODO
138
176
  * 是否使用 importMap
139
177
  */
140
178
  useImportMap?: boolean;
179
+ /**
180
+ * module federation 版本
181
+ * @default 1
182
+ */
183
+ mfVersion?: 1 | 1.5;
141
184
  };
142
185
  export type EMPshareLibItemType = {
143
186
  [module: string]: {
@@ -172,6 +215,7 @@ export type ExternalsItemType = {
172
215
  */
173
216
  type?: string;
174
217
  };
218
+ export type RsTarget = RsConfig['target'];
175
219
  export type EmpOptions = {
176
220
  /**
177
221
  * publicPath 根路径 可参考webpack,业务模式默认为 auto
@@ -180,6 +224,14 @@ export type EmpOptions = {
180
224
  * @default undefined
181
225
  */
182
226
  base?: string;
227
+ /**
228
+ * 构建target
229
+ */
230
+ target?: RsConfig['target'];
231
+ /**
232
+ * 启动后 自动设置 base 为当前 Ip+port的路径如 base = http://127.0.0.1:8080/ 并且固定 ws 方便代理调试
233
+ */
234
+ autoDevBase?: boolean;
183
235
  /**
184
236
  * 项目代码路径
185
237
  * @default 'src'
@@ -198,7 +250,6 @@ export type EmpOptions = {
198
250
  server?: ServerType;
199
251
  debug?: DebugType;
200
252
  chain?: (chain: Chain) => void;
201
- react?: ReactType;
202
253
  empShare?: EMPShareType;
203
254
  /**
204
255
  * css 相关设置
@@ -240,10 +291,7 @@ export type EmpOptions = {
240
291
  */
241
292
  output?: Output;
242
293
  /**
243
- * React Runtime 手动切换jsx模式
244
- * 当 external react时需要设置
245
- * 本地安装时会自动判断 不需要设置
246
- * @default undefined
294
+ * emp 执行周期
247
295
  */
248
- reactRuntime?: 'automatic' | 'classic';
296
+ lifeCycle?: LifeCycle;
249
297
  };
package/package.json CHANGED
@@ -1,116 +1,113 @@
1
1
  {
2
- "name": "@empjs/cli",
3
- "version": "3.0.0-beta.9",
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
- "react",
29
- "rspack",
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": "^9.0.13",
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
- "@rspack/core": "^0.5.7",
85
- "@rspack/dev-server": "^0.5.7",
86
- "@rspack/plugin-react-refresh": "^0.5.7",
87
- "@svgr/webpack": "^8.1.0",
88
- "@types/node": "^20.8.7",
89
- "@types/react": "^18.2.30",
90
- "address": "^2.0.1",
91
- "ansi-html-community": "^0.0.8",
92
- "chalk": "^5.3.0",
93
- "commander": "^11.1.0",
94
- "compression": "^1.7.4",
95
- "cors": "^2.8.5",
96
- "default-gateway": "^7.2.2",
97
- "express": "^4.18.2",
98
- "fast-glob": "^3.3.1",
99
- "gzip-size": "^7.0.0",
100
- "html-entities": "^2.5.2",
101
- "html-webpack-plugin": "^5.6.0",
102
- "less-loader": "^11.1.3",
103
- "open": "^10.1.0",
104
- "postcss": "^8.4.33",
105
- "postcss-loader": "^7.3.4",
106
- "react-refresh": "^0.14.0",
107
- "sass-loader": "^13.3.2",
108
- "strip-ansi": "^7.1.0",
109
- "table": "^6.8.1",
110
- "typescript-plugin-css-modules": "^5.0.2",
111
- "webpack-bundle-analyzer": "^4.9.1",
112
- "webpack-chain": "^6.5.1",
113
- "webpack-dev-middleware": "^7.0.0",
114
- "webpack-hot-middleware": "^2.26.1"
115
- }
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
+ }
116
113
  }
@@ -1,20 +1,14 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="<%= htmlWebpackPlugin.options.lang %>">
3
- <head>
4
- <!-- EMP inject title -->
5
- <title><%= htmlWebpackPlugin.options.title %></title>
6
- <meta name="keywords" content="<%= htmlWebpackPlugin.options.keywords %>" />
7
- <meta name="description" content="<%= htmlWebpackPlugin.options.description %>" />
8
- <!-- EMP inject css -->
9
- <% for (let i in htmlWebpackPlugin.options.files.css) { %>
10
- <link rel="stylesheet" href="<%= htmlWebpackPlugin.options.files.css[i] %>" />
11
- <% } %>
12
- </head>
13
- <body>
14
- <div id="emp-root"></div>
15
- <!-- EMP inject js -->
16
- <% for (let i in htmlWebpackPlugin.options.files.js) { %>
17
- <script src="<%= htmlWebpackPlugin.options.files.js[i] %>"></script>
18
- <% } %>
19
- </body>
20
- </html>
3
+
4
+ <head>
5
+ <title>
6
+ <%= htmlWebpackPlugin.options.title %>
7
+ </title>
8
+ </head>
9
+
10
+ <body>
11
+ <div id="emp-root"></div>
12
+ </body>
13
+
14
+ </html>
@@ -1,6 +0,0 @@
1
- export declare function prepareUrls(protocol: any, host: string, port: number, pathname?: string): {
2
- lanUrlForConfig: string | undefined;
3
- lanUrlForTerminal: string;
4
- localUrlForTerminal: string;
5
- localUrlForBrowser: string;
6
- };
@@ -1,12 +0,0 @@
1
- declare class RuntimePlugins {
2
- constructor();
3
- beforeInit(): void;
4
- beforeLoadingRemote(): void;
5
- loadRemoteMatch(): void;
6
- loadRemote(): void;
7
- errorLoadRemote(): void;
8
- beforeLoadShare(): void;
9
- beforePreloadRemote(): void;
10
- }
11
- declare const _default: RuntimePlugins;
12
- export default _default;
@@ -1,6 +0,0 @@
1
- import { GlobalStore } from '../../store';
2
- declare class Script {
3
- js(store: GlobalStore): void;
4
- }
5
- declare const _default: Script;
6
- export default _default;