xshell 1.0.129 → 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 +13 -4
- package/builder.js +35 -6
- package/package.json +2 -1
package/builder.d.ts
CHANGED
|
@@ -4,23 +4,30 @@ export interface BundlerOptions {
|
|
|
4
4
|
source_map?: boolean;
|
|
5
5
|
production?: boolean;
|
|
6
6
|
external_dayjs?: boolean;
|
|
7
|
-
externals?: Record<string, string>;
|
|
7
|
+
externals?: Record<string, string | string[]>;
|
|
8
8
|
sass?: typeof import('sass');
|
|
9
9
|
dynamic_import?: boolean;
|
|
10
10
|
commonjs2?: boolean;
|
|
11
11
|
assets_stats?: boolean;
|
|
12
12
|
globals?: Record<string, string>;
|
|
13
|
+
resolve_alias?: Record<string, string>;
|
|
13
14
|
analyzer?: boolean;
|
|
14
15
|
dts?: boolean;
|
|
15
16
|
cache_version?: string;
|
|
16
17
|
single_chunk?: boolean;
|
|
17
18
|
exclude_modules?: RegExp;
|
|
19
|
+
license?: {
|
|
20
|
+
ignores?: string[];
|
|
21
|
+
};
|
|
18
22
|
}
|
|
19
23
|
export declare class Bundler {
|
|
20
24
|
name: string;
|
|
21
25
|
fpd_root: string;
|
|
22
26
|
config: Webpack.Configuration;
|
|
23
27
|
analyzer: boolean;
|
|
28
|
+
license?: {
|
|
29
|
+
ignores?: string[];
|
|
30
|
+
};
|
|
24
31
|
lcompiler: Lock<Webpack.Compiler>;
|
|
25
32
|
/** 通过 webpack 从入口文件打包所有依赖生成单个 index.{mjs,cjs} 文件
|
|
26
33
|
- name: 项目名称
|
|
@@ -36,15 +43,17 @@ export declare class Bundler {
|
|
|
36
43
|
- externals?: 配置外部模块
|
|
37
44
|
- commonjs2?: `false` 打包为 commonjs2 (.cjs) 的文件
|
|
38
45
|
- single_chunk?: `true` 输出为单个文件,将依赖也打包到其中,不要生成多个 chunk
|
|
39
|
-
- dynamic_import
|
|
46
|
+
- dynamic_import?: `true` 对于 await import('...') 要不要打包外部模块到输出文件中
|
|
47
|
+
- resolve_alias?: 配置 resolve alias
|
|
40
48
|
- assets_stats?: `true` 打印输出的文件信息
|
|
41
49
|
- analyzer?: `false` 启用 WebpackBundleAnalyzer 插件分析构建产物大小
|
|
42
50
|
- dts?: `false` 生成 .d.ts 文件
|
|
43
51
|
- exclude_modules?: 传入正则表达式 ,匹配时使用 IgnorePlugin 强制不打包这个模块,但是一旦导入就会报错
|
|
44
52
|
- cache_version?: webpack cache version, 用于区分同一个 name 的不同版本
|
|
45
53
|
- production?: `true` webpack mode 设置为 'production'
|
|
46
|
-
- sass?: 传入 sass 实例避免 webpack 重复加载 .cjs 版本
|
|
47
|
-
|
|
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);
|
|
48
57
|
build(print?: boolean): Promise<void>;
|
|
49
58
|
close(): Promise<void>;
|
|
50
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: 项目名称
|
|
@@ -21,17 +22,20 @@ export class Bundler {
|
|
|
21
22
|
- externals?: 配置外部模块
|
|
22
23
|
- commonjs2?: `false` 打包为 commonjs2 (.cjs) 的文件
|
|
23
24
|
- single_chunk?: `true` 输出为单个文件,将依赖也打包到其中,不要生成多个 chunk
|
|
24
|
-
- dynamic_import
|
|
25
|
+
- dynamic_import?: `true` 对于 await import('...') 要不要打包外部模块到输出文件中
|
|
26
|
+
- resolve_alias?: 配置 resolve alias
|
|
25
27
|
- assets_stats?: `true` 打印输出的文件信息
|
|
26
28
|
- analyzer?: `false` 启用 WebpackBundleAnalyzer 插件分析构建产物大小
|
|
27
29
|
- dts?: `false` 生成 .d.ts 文件
|
|
28
30
|
- exclude_modules?: 传入正则表达式 ,匹配时使用 IgnorePlugin 强制不打包这个模块,但是一旦导入就会报错
|
|
29
31
|
- cache_version?: webpack cache version, 用于区分同一个 name 的不同版本
|
|
30
32
|
- production?: `true` webpack mode 设置为 'production'
|
|
31
|
-
- sass?: 传入 sass 实例避免 webpack 重复加载 .cjs 版本
|
|
32
|
-
|
|
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, } = {}) {
|
|
33
36
|
this.name = name;
|
|
34
37
|
this.analyzer = analyzer;
|
|
38
|
+
this.license = license;
|
|
35
39
|
// let smp = new SpeedMeasurePlugin()
|
|
36
40
|
// const config: Webpack.Configuration = smp.wrap({
|
|
37
41
|
let resolve_cache = {};
|
|
@@ -65,6 +69,8 @@ export class Bundler {
|
|
|
65
69
|
target: [target === 'web' ? 'web' : 'node22', 'es2024'],
|
|
66
70
|
// 结合 output.globalObject, 会生成 globalThis['React'] 这样的引用
|
|
67
71
|
externalsType: target === 'nodejs' ? 'commonjs2' : 'global',
|
|
72
|
+
// 以 react: 'React', 为例,含义为
|
|
73
|
+
// 取全局变量 window.React 的值作为 import { useState } from 'react' 中 { ... } 这部分的结果,再解构里面的 useState 属性
|
|
68
74
|
externals: filter_values({
|
|
69
75
|
react: 'React',
|
|
70
76
|
'react-dom': 'ReactDOM',
|
|
@@ -92,6 +98,7 @@ export class Bundler {
|
|
|
92
98
|
extensionAlias: {
|
|
93
99
|
'.js': ['.js', '.ts', '.tsx']
|
|
94
100
|
},
|
|
101
|
+
...resolve_alias ? { alias: resolve_alias } : {},
|
|
95
102
|
// modules: [
|
|
96
103
|
// '',
|
|
97
104
|
// ],
|
|
@@ -179,9 +186,7 @@ export class Bundler {
|
|
|
179
186
|
test: /\.icon\.svg$/,
|
|
180
187
|
issuer: /\.[jt]sx?$/,
|
|
181
188
|
loader: get_loader('@svgr/webpack'),
|
|
182
|
-
options: {
|
|
183
|
-
icon: true,
|
|
184
|
-
}
|
|
189
|
+
options: { icon: true }
|
|
185
190
|
},
|
|
186
191
|
{
|
|
187
192
|
test: /\.(svg|ico|png|jpe?g|gif|woff2?|ttf|eot|otf|mp4|webm|ogg|mp3|wav|flac|aac)$/,
|
|
@@ -266,6 +271,30 @@ export class Bundler {
|
|
|
266
271
|
openAnalyzer: false,
|
|
267
272
|
}));
|
|
268
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
|
+
}
|
|
269
298
|
this.lcompiler = new Lock(Webpack(this.config));
|
|
270
299
|
}
|
|
271
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",
|