xshell 1.0.128 → 1.0.130
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/builder.d.ts +15 -4
- package/builder.js +37 -6
- package/package.json +2 -1
package/builder.d.ts
CHANGED
|
@@ -3,23 +3,31 @@ import { Lock } from './utils.js';
|
|
|
3
3
|
export interface BundlerOptions {
|
|
4
4
|
source_map?: boolean;
|
|
5
5
|
production?: boolean;
|
|
6
|
-
|
|
6
|
+
external_dayjs?: boolean;
|
|
7
|
+
externals?: Record<string, string | string[]>;
|
|
7
8
|
sass?: typeof import('sass');
|
|
8
9
|
dynamic_import?: boolean;
|
|
9
10
|
commonjs2?: boolean;
|
|
10
11
|
assets_stats?: boolean;
|
|
11
12
|
globals?: Record<string, string>;
|
|
13
|
+
resolve_alias?: Record<string, string>;
|
|
12
14
|
analyzer?: boolean;
|
|
13
15
|
dts?: boolean;
|
|
14
16
|
cache_version?: string;
|
|
15
17
|
single_chunk?: boolean;
|
|
16
18
|
exclude_modules?: RegExp;
|
|
19
|
+
license?: {
|
|
20
|
+
ignores?: string[];
|
|
21
|
+
};
|
|
17
22
|
}
|
|
18
23
|
export declare class Bundler {
|
|
19
24
|
name: string;
|
|
20
25
|
fpd_root: string;
|
|
21
26
|
config: Webpack.Configuration;
|
|
22
27
|
analyzer: boolean;
|
|
28
|
+
license?: {
|
|
29
|
+
ignores?: string[];
|
|
30
|
+
};
|
|
23
31
|
lcompiler: Lock<Webpack.Compiler>;
|
|
24
32
|
/** 通过 webpack 从入口文件打包所有依赖生成单个 index.{mjs,cjs} 文件
|
|
25
33
|
- name: 项目名称
|
|
@@ -31,18 +39,21 @@ export declare class Bundler {
|
|
|
31
39
|
- options?: 打包配置, 按常用顺序排列
|
|
32
40
|
- source_map?: `true` 启用源码映射 .map 文件
|
|
33
41
|
- globals?: 全局变量定义
|
|
42
|
+
- external_dayjs?: `false` 配置 dayjs 为 external 来配合 antd 使用, 减小一点体积
|
|
34
43
|
- externals?: 配置外部模块
|
|
35
44
|
- commonjs2?: `false` 打包为 commonjs2 (.cjs) 的文件
|
|
36
45
|
- single_chunk?: `true` 输出为单个文件,将依赖也打包到其中,不要生成多个 chunk
|
|
37
|
-
- dynamic_import
|
|
46
|
+
- dynamic_import?: `true` 对于 await import('...') 要不要打包外部模块到输出文件中
|
|
47
|
+
- resolve_alias?: 配置 resolve alias
|
|
38
48
|
- assets_stats?: `true` 打印输出的文件信息
|
|
39
49
|
- analyzer?: `false` 启用 WebpackBundleAnalyzer 插件分析构建产物大小
|
|
40
50
|
- dts?: `false` 生成 .d.ts 文件
|
|
41
51
|
- exclude_modules?: 传入正则表达式 ,匹配时使用 IgnorePlugin 强制不打包这个模块,但是一旦导入就会报错
|
|
42
52
|
- cache_version?: webpack cache version, 用于区分同一个 name 的不同版本
|
|
43
53
|
- production?: `true` webpack mode 设置为 'production'
|
|
44
|
-
- sass?: 传入 sass 实例避免 webpack 重复加载 .cjs 版本
|
|
45
|
-
|
|
54
|
+
- sass?: 传入 sass 实例避免 webpack 重复加载 .cjs 版本
|
|
55
|
+
- license?: 使用 license-webpack-plugin 构建 ThirdPartyNotice.txt */
|
|
56
|
+
constructor(name: string, target: 'web' | 'nodejs', fpd_root: string, fpd_out: string, fpdt_cache: string, entry: Record<string, string>, { source_map, globals, external_dayjs, externals, commonjs2, single_chunk, dynamic_import, resolve_alias, assets_stats, analyzer, dts, exclude_modules, cache_version, production, sass, license, }?: BundlerOptions);
|
|
46
57
|
build(print?: boolean): Promise<void>;
|
|
47
58
|
close(): Promise<void>;
|
|
48
59
|
build_and_close(print?: boolean): Promise<void>;
|
package/builder.js
CHANGED
|
@@ -6,6 +6,7 @@ export class Bundler {
|
|
|
6
6
|
fpd_root;
|
|
7
7
|
config;
|
|
8
8
|
analyzer;
|
|
9
|
+
license;
|
|
9
10
|
lcompiler;
|
|
10
11
|
/** 通过 webpack 从入口文件打包所有依赖生成单个 index.{mjs,cjs} 文件
|
|
11
12
|
- name: 项目名称
|
|
@@ -17,20 +18,24 @@ export class Bundler {
|
|
|
17
18
|
- options?: 打包配置, 按常用顺序排列
|
|
18
19
|
- source_map?: `true` 启用源码映射 .map 文件
|
|
19
20
|
- globals?: 全局变量定义
|
|
21
|
+
- external_dayjs?: `false` 配置 dayjs 为 external 来配合 antd 使用, 减小一点体积
|
|
20
22
|
- externals?: 配置外部模块
|
|
21
23
|
- commonjs2?: `false` 打包为 commonjs2 (.cjs) 的文件
|
|
22
24
|
- single_chunk?: `true` 输出为单个文件,将依赖也打包到其中,不要生成多个 chunk
|
|
23
|
-
- dynamic_import
|
|
25
|
+
- dynamic_import?: `true` 对于 await import('...') 要不要打包外部模块到输出文件中
|
|
26
|
+
- resolve_alias?: 配置 resolve alias
|
|
24
27
|
- assets_stats?: `true` 打印输出的文件信息
|
|
25
28
|
- analyzer?: `false` 启用 WebpackBundleAnalyzer 插件分析构建产物大小
|
|
26
29
|
- dts?: `false` 生成 .d.ts 文件
|
|
27
30
|
- exclude_modules?: 传入正则表达式 ,匹配时使用 IgnorePlugin 强制不打包这个模块,但是一旦导入就会报错
|
|
28
31
|
- cache_version?: webpack cache version, 用于区分同一个 name 的不同版本
|
|
29
32
|
- production?: `true` webpack mode 设置为 'production'
|
|
30
|
-
- sass?: 传入 sass 实例避免 webpack 重复加载 .cjs 版本
|
|
31
|
-
|
|
33
|
+
- sass?: 传入 sass 实例避免 webpack 重复加载 .cjs 版本
|
|
34
|
+
- license?: 使用 license-webpack-plugin 构建 ThirdPartyNotice.txt */
|
|
35
|
+
constructor(name, target, fpd_root, fpd_out, fpdt_cache, entry, { source_map = true, globals, external_dayjs = false, externals, commonjs2 = false, single_chunk = true, dynamic_import = true, resolve_alias, assets_stats = true, analyzer = false, dts = false, exclude_modules, cache_version, production = true, sass, license, } = {}) {
|
|
32
36
|
this.name = name;
|
|
33
37
|
this.analyzer = analyzer;
|
|
38
|
+
this.license = license;
|
|
34
39
|
// let smp = new SpeedMeasurePlugin()
|
|
35
40
|
// const config: Webpack.Configuration = smp.wrap({
|
|
36
41
|
let resolve_cache = {};
|
|
@@ -64,6 +69,8 @@ export class Bundler {
|
|
|
64
69
|
target: [target === 'web' ? 'web' : 'node22', 'es2024'],
|
|
65
70
|
// 结合 output.globalObject, 会生成 globalThis['React'] 这样的引用
|
|
66
71
|
externalsType: target === 'nodejs' ? 'commonjs2' : 'global',
|
|
72
|
+
// 以 react: 'React', 为例,含义为
|
|
73
|
+
// 取全局变量 window.React 的值作为 import { useState } from 'react' 中 { ... } 这部分的结果,再解构里面的 useState 属性
|
|
67
74
|
externals: filter_values({
|
|
68
75
|
react: 'React',
|
|
69
76
|
'react-dom': 'ReactDOM',
|
|
@@ -77,6 +84,7 @@ export class Bundler {
|
|
|
77
84
|
// 实际上 Terminal 直接暴露在了 window 上,而不是 window.Terminal.Terminal
|
|
78
85
|
xterm: 'window',
|
|
79
86
|
swiper: 'Swiper',
|
|
87
|
+
...external_dayjs ? { dayjs: 'dayjs' } : {},
|
|
80
88
|
antd: 'antd',
|
|
81
89
|
'@ant-design/icons': 'icons',
|
|
82
90
|
'@ant-design/plots': 'Plots',
|
|
@@ -90,6 +98,7 @@ export class Bundler {
|
|
|
90
98
|
extensionAlias: {
|
|
91
99
|
'.js': ['.js', '.ts', '.tsx']
|
|
92
100
|
},
|
|
101
|
+
...resolve_alias ? { alias: resolve_alias } : {},
|
|
93
102
|
// modules: [
|
|
94
103
|
// '',
|
|
95
104
|
// ],
|
|
@@ -177,9 +186,7 @@ export class Bundler {
|
|
|
177
186
|
test: /\.icon\.svg$/,
|
|
178
187
|
issuer: /\.[jt]sx?$/,
|
|
179
188
|
loader: get_loader('@svgr/webpack'),
|
|
180
|
-
options: {
|
|
181
|
-
icon: true,
|
|
182
|
-
}
|
|
189
|
+
options: { icon: true }
|
|
183
190
|
},
|
|
184
191
|
{
|
|
185
192
|
test: /\.(svg|ico|png|jpe?g|gif|woff2?|ttf|eot|otf|mp4|webm|ogg|mp3|wav|flac|aac)$/,
|
|
@@ -264,6 +271,30 @@ export class Bundler {
|
|
|
264
271
|
openAnalyzer: false,
|
|
265
272
|
}));
|
|
266
273
|
}
|
|
274
|
+
if (this.license) {
|
|
275
|
+
const { LicenseWebpackPlugin } = await import('license-webpack-plugin');
|
|
276
|
+
const ignores = new Set([
|
|
277
|
+
'xshell',
|
|
278
|
+
'react-object-model',
|
|
279
|
+
'@ant-design/icons-svg',
|
|
280
|
+
'@ant-design/pro-layout',
|
|
281
|
+
'@ant-design/pro-provider',
|
|
282
|
+
'@ant-design/pro-table',
|
|
283
|
+
'@ant-design/pro-utils',
|
|
284
|
+
'@ant-design/pro-form',
|
|
285
|
+
'@ant-design/pro-card',
|
|
286
|
+
'@ant-design/pro-field',
|
|
287
|
+
'toggle-selection',
|
|
288
|
+
'ahooks',
|
|
289
|
+
'size-sensor',
|
|
290
|
+
...this.license.ignores || []
|
|
291
|
+
]);
|
|
292
|
+
this.config.plugins.push(new LicenseWebpackPlugin({
|
|
293
|
+
perChunkOutput: false,
|
|
294
|
+
outputFilename: 'ThirdPartyNotice.txt',
|
|
295
|
+
excludedPackageTest: pkgname => ignores.has(pkgname),
|
|
296
|
+
}));
|
|
297
|
+
}
|
|
267
298
|
this.lcompiler = new Lock(Webpack(this.config));
|
|
268
299
|
}
|
|
269
300
|
const stats = await this.lcompiler.request(async (compiler) => new Promise((resolve, reject) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xshell",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.130",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -84,6 +84,7 @@
|
|
|
84
84
|
"i18next-scanner": "^4.4.0",
|
|
85
85
|
"koa": "^2.15.3",
|
|
86
86
|
"koa-compress": "^5.1.1",
|
|
87
|
+
"license-webpack-plugin": "^4.0.2",
|
|
87
88
|
"lodash": "^4.17.21",
|
|
88
89
|
"map-stream": "^0.0.7",
|
|
89
90
|
"mime-types": "^2.1.35",
|