xshell 1.0.123 → 1.0.125
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 +5 -3
- package/builder.js +18 -11
- package/package.json +1 -1
package/builder.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export interface BundlerOptions {
|
|
|
5
5
|
production?: boolean;
|
|
6
6
|
externals?: Record<string, string>;
|
|
7
7
|
sass?: typeof import('sass');
|
|
8
|
-
|
|
8
|
+
dynamic_import?: boolean;
|
|
9
9
|
commonjs2?: boolean;
|
|
10
10
|
assets_stats?: boolean;
|
|
11
11
|
globals?: Record<string, string>;
|
|
@@ -13,6 +13,7 @@ export interface BundlerOptions {
|
|
|
13
13
|
dts?: boolean;
|
|
14
14
|
cache_version?: string;
|
|
15
15
|
single_chunk?: boolean;
|
|
16
|
+
exclude_modules?: RegExp;
|
|
16
17
|
}
|
|
17
18
|
export declare class Bundler {
|
|
18
19
|
name: string;
|
|
@@ -33,14 +34,15 @@ export declare class Bundler {
|
|
|
33
34
|
- externals?: 配置外部模块
|
|
34
35
|
- commonjs2?: `false` 打包为 commonjs2 (.cjs) 的文件
|
|
35
36
|
- single_chunk?: `true` 输出为单个文件,将依赖也打包到其中,不要生成多个 chunk
|
|
36
|
-
-
|
|
37
|
+
- dynamic_import: `true` 对于 await import('...') 要不要打包外部模块到输出文件中
|
|
37
38
|
- assets_stats?: `true` 打印输出的文件信息
|
|
38
39
|
- analyzer?: `false` 启用 WebpackBundleAnalyzer 插件分析构建产物大小
|
|
39
40
|
- dts?: `false` 生成 .d.ts 文件
|
|
41
|
+
- exclude_modules?: 传入正则表达式 ,匹配时使用 IgnorePlugin 强制不打包这个模块,但是一旦导入就会报错
|
|
40
42
|
- cache_version?: webpack cache version, 用于区分同一个 name 的不同版本
|
|
41
43
|
- production?: `true` webpack mode 设置为 'production'
|
|
42
44
|
- sass?: 传入 sass 实例避免 webpack 重复加载 .cjs 版本 */
|
|
43
|
-
constructor(name: string, target: 'web' | 'nodejs', fpd_root: string, fpd_out: string, fpdt_cache: string, entry: Record<string, string>, { source_map, globals, externals, commonjs2, single_chunk,
|
|
45
|
+
constructor(name: string, target: 'web' | 'nodejs', fpd_root: string, fpd_out: string, fpdt_cache: string, entry: Record<string, string>, { source_map, globals, externals, commonjs2, single_chunk, dynamic_import, assets_stats, analyzer, dts, exclude_modules, cache_version, production, sass, }?: BundlerOptions);
|
|
44
46
|
build(print?: boolean): Promise<void>;
|
|
45
47
|
close(): Promise<void>;
|
|
46
48
|
}
|
package/builder.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fileURLToPath } from 'url';
|
|
1
2
|
import Webpack from 'webpack';
|
|
2
3
|
import { Lock, Timer, filter_values } from './utils.js';
|
|
3
4
|
export class Bundler {
|
|
@@ -19,20 +20,22 @@ export class Bundler {
|
|
|
19
20
|
- externals?: 配置外部模块
|
|
20
21
|
- commonjs2?: `false` 打包为 commonjs2 (.cjs) 的文件
|
|
21
22
|
- single_chunk?: `true` 输出为单个文件,将依赖也打包到其中,不要生成多个 chunk
|
|
22
|
-
-
|
|
23
|
+
- dynamic_import: `true` 对于 await import('...') 要不要打包外部模块到输出文件中
|
|
23
24
|
- assets_stats?: `true` 打印输出的文件信息
|
|
24
25
|
- analyzer?: `false` 启用 WebpackBundleAnalyzer 插件分析构建产物大小
|
|
25
26
|
- dts?: `false` 生成 .d.ts 文件
|
|
27
|
+
- exclude_modules?: 传入正则表达式 ,匹配时使用 IgnorePlugin 强制不打包这个模块,但是一旦导入就会报错
|
|
26
28
|
- cache_version?: webpack cache version, 用于区分同一个 name 的不同版本
|
|
27
29
|
- production?: `true` webpack mode 设置为 'production'
|
|
28
30
|
- sass?: 传入 sass 实例避免 webpack 重复加载 .cjs 版本 */
|
|
29
|
-
constructor(name, target, fpd_root, fpd_out, fpdt_cache, entry, { source_map = true, globals, externals, commonjs2 = false, single_chunk = true,
|
|
31
|
+
constructor(name, target, fpd_root, fpd_out, fpdt_cache, entry, { source_map = true, globals, externals, commonjs2 = false, single_chunk = true, dynamic_import = true, assets_stats = true, analyzer = false, dts = false, exclude_modules, cache_version, production = true, sass, } = {}) {
|
|
30
32
|
this.name = name;
|
|
31
33
|
this.analyzer = analyzer;
|
|
32
34
|
// let smp = new SpeedMeasurePlugin()
|
|
33
35
|
// const config: Webpack.Configuration = smp.wrap({
|
|
36
|
+
const fpd_node_modules = fileURLToPath(import.meta.resolve('ts-loader')).fdir.fdir;
|
|
34
37
|
function get_loader(name) {
|
|
35
|
-
return name
|
|
38
|
+
return `${fpd_node_modules}${name}/`;
|
|
36
39
|
}
|
|
37
40
|
this.config = {
|
|
38
41
|
name,
|
|
@@ -98,7 +101,7 @@ export class Bundler {
|
|
|
98
101
|
loader: { sass }
|
|
99
102
|
} : {},
|
|
100
103
|
module: {
|
|
101
|
-
...
|
|
104
|
+
...dynamic_import === false ? {
|
|
102
105
|
parser: {
|
|
103
106
|
javascript: {
|
|
104
107
|
// 保留 await import() 这样的引用
|
|
@@ -197,12 +200,15 @@ export class Bundler {
|
|
|
197
200
|
...globals
|
|
198
201
|
// process: { env: { }, argv: [] }
|
|
199
202
|
})
|
|
200
|
-
] : []
|
|
203
|
+
] : [],
|
|
201
204
|
// 使用 IgnorePlugin 能够不打包,但是一旦导入就会报错
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
205
|
+
...exclude_modules ? [
|
|
206
|
+
new Webpack.IgnorePlugin({
|
|
207
|
+
resourceRegExp: exclude_modules,
|
|
208
|
+
// checkResource: (resource, context) =>
|
|
209
|
+
// resource.startsWith('./vendors/') && !context.fp.startsWith(fpd_node_modules) ,
|
|
210
|
+
})
|
|
211
|
+
] : [],
|
|
206
212
|
],
|
|
207
213
|
optimization: {
|
|
208
214
|
minimize: false
|
|
@@ -220,8 +226,9 @@ export class Bundler {
|
|
|
220
226
|
...target === 'nodejs' ? [
|
|
221
227
|
/Can't resolve '(bufferutil|utf-8-validate)'/
|
|
222
228
|
] : [],
|
|
223
|
-
//
|
|
224
|
-
|
|
229
|
+
// 打包 ali-oss 时可能的报错
|
|
230
|
+
warning => warning.message.includes('the request of a dependency is an expression') &&
|
|
231
|
+
warning.module?.context?.endsWith('any-promise')
|
|
225
232
|
],
|
|
226
233
|
performance: {
|
|
227
234
|
hints: false,
|