xshell 1.0.173 → 1.0.174
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 +6 -1
- package/builder.js +16 -7
- package/package.json +1 -1
package/builder.d.ts
CHANGED
|
@@ -73,6 +73,7 @@ export interface BundlerOptions {
|
|
|
73
73
|
single_chunk?: boolean;
|
|
74
74
|
exclude_modules?: RegExp;
|
|
75
75
|
assets?: Assets;
|
|
76
|
+
assets_root?: string;
|
|
76
77
|
license?: {
|
|
77
78
|
ignores?: string[];
|
|
78
79
|
};
|
|
@@ -90,6 +91,7 @@ export declare class Bundler {
|
|
|
90
91
|
config: Webpack.Configuration;
|
|
91
92
|
htmls?: Record<string, HtmlOptions>;
|
|
92
93
|
assets?: Assets;
|
|
94
|
+
assets_root?: string;
|
|
93
95
|
globals?: BundlerOptions['globals'];
|
|
94
96
|
exclude_modules?: BundlerOptions['exclude_modules'];
|
|
95
97
|
license?: {
|
|
@@ -112,6 +114,9 @@ export declare class Bundler {
|
|
|
112
114
|
- assets?: 项目中需要直接复制到输出目录的资源,有 productions 但无 devs 时 (是同一套),
|
|
113
115
|
在 dev 模式下会用 productions 中的资源,如果不需要 productions 资源, devs 可以设置为 [ ],
|
|
114
116
|
每一项是 string 或者 { src: '...', out: '...' },路径相对于 fpd_root 和 fpd_out
|
|
117
|
+
- assets_root?: `''` 生成的 html 中是否使用 / 开头的绝对路径,以支持 browser router 路由能力
|
|
118
|
+
启用后 assets, html 中的 icon, scripts 路径直接在前面添加 assets_root 来生成最终 html href
|
|
119
|
+
未启用时使用相对 html 路径来生成最终 html href
|
|
115
120
|
- local_loaders?: `true` true 时使用项目 node_modules/ 中的 loader; false 时使用 D:/0/ 下面的
|
|
116
121
|
- commonjs2?: `false` 打包为 commonjs2 (.cjs) 的文件
|
|
117
122
|
- single_chunk?: `true` 输出为单个文件,将依赖也打包到其中,不要生成多个 chunk
|
|
@@ -126,7 +131,7 @@ export declare class Bundler {
|
|
|
126
131
|
- production?: `true` webpack mode 设置为 'production'
|
|
127
132
|
- sass?: 传入 sass 实例避免 webpack 重复加载 .cjs 版本
|
|
128
133
|
- license?: 使用 license-webpack-plugin 构建 ThirdPartyNotice.txt */
|
|
129
|
-
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, htmls, assets, commonjs2, single_chunk, dynamic_import, resolve_alias, resolve_fallback, assets_stats, analyzer, dts, exclude_modules, cache_version, production, sass, dependencies, license, }?: BundlerOptions);
|
|
134
|
+
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, htmls, assets, assets_root, commonjs2, single_chunk, dynamic_import, resolve_alias, resolve_fallback, assets_stats, analyzer, dts, exclude_modules, cache_version, production, sass, dependencies, license, }?: BundlerOptions);
|
|
130
135
|
build(print?: boolean): Promise<void>;
|
|
131
136
|
close(): Promise<void>;
|
|
132
137
|
build_all(print?: boolean): Promise<void>;
|
package/builder.js
CHANGED
|
@@ -111,6 +111,7 @@ export class Bundler {
|
|
|
111
111
|
config;
|
|
112
112
|
htmls;
|
|
113
113
|
assets;
|
|
114
|
+
assets_root;
|
|
114
115
|
globals;
|
|
115
116
|
exclude_modules;
|
|
116
117
|
license;
|
|
@@ -131,6 +132,9 @@ export class Bundler {
|
|
|
131
132
|
- assets?: 项目中需要直接复制到输出目录的资源,有 productions 但无 devs 时 (是同一套),
|
|
132
133
|
在 dev 模式下会用 productions 中的资源,如果不需要 productions 资源, devs 可以设置为 [ ],
|
|
133
134
|
每一项是 string 或者 { src: '...', out: '...' },路径相对于 fpd_root 和 fpd_out
|
|
135
|
+
- assets_root?: `''` 生成的 html 中是否使用 / 开头的绝对路径,以支持 browser router 路由能力
|
|
136
|
+
启用后 assets, html 中的 icon, scripts 路径直接在前面添加 assets_root 来生成最终 html href
|
|
137
|
+
未启用时使用相对 html 路径来生成最终 html href
|
|
134
138
|
- local_loaders?: `true` true 时使用项目 node_modules/ 中的 loader; false 时使用 D:/0/ 下面的
|
|
135
139
|
- commonjs2?: `false` 打包为 commonjs2 (.cjs) 的文件
|
|
136
140
|
- single_chunk?: `true` 输出为单个文件,将依赖也打包到其中,不要生成多个 chunk
|
|
@@ -145,7 +149,7 @@ export class Bundler {
|
|
|
145
149
|
- production?: `true` webpack mode 设置为 'production'
|
|
146
150
|
- sass?: 传入 sass 实例避免 webpack 重复加载 .cjs 版本
|
|
147
151
|
- license?: 使用 license-webpack-plugin 构建 ThirdPartyNotice.txt */
|
|
148
|
-
constructor(name, target, fpd_root, fpd_out, fpdt_cache, entry, { source_map = true, globals, external_dayjs = false, externals, htmls, assets, commonjs2 = false, single_chunk = true, dynamic_import = true, resolve_alias, resolve_fallback, assets_stats = true, analyzer = false, dts = false, exclude_modules, cache_version, production = true, sass, dependencies, license, } = {}) {
|
|
152
|
+
constructor(name, target, fpd_root, fpd_out, fpdt_cache, entry, { source_map = true, globals, external_dayjs = false, externals, htmls, assets, assets_root = '', commonjs2 = false, single_chunk = true, dynamic_import = true, resolve_alias, resolve_fallback, assets_stats = true, analyzer = false, dts = false, exclude_modules, cache_version, production = true, sass, dependencies, license, } = {}) {
|
|
149
153
|
this.name = name;
|
|
150
154
|
this.analyzer = analyzer;
|
|
151
155
|
this.production = production;
|
|
@@ -155,6 +159,7 @@ export class Bundler {
|
|
|
155
159
|
this.source_map = source_map;
|
|
156
160
|
this.htmls = htmls;
|
|
157
161
|
this.assets = assets;
|
|
162
|
+
this.assets_root = assets_root;
|
|
158
163
|
this.globals = globals;
|
|
159
164
|
this.exclude_modules = exclude_modules;
|
|
160
165
|
if (dependencies) {
|
|
@@ -483,7 +488,11 @@ export class Bundler {
|
|
|
483
488
|
}
|
|
484
489
|
async build_htmls(print = { info: true, files: false }) {
|
|
485
490
|
await Promise.all(Object.entries(this.htmls).map(async ([fp_html, { fp_entry = './index.js', device_viewport: device_width = false, icon, manifest, dependencies: _dependencies = this.dependencies, title, scripts, mscripts, notice = false, heads, }]) => {
|
|
486
|
-
const
|
|
491
|
+
const fpd_html = `${this.fpd_out}${fp_html}`.fdir;
|
|
492
|
+
const resolve = (asset) => this.assets_root ?
|
|
493
|
+
`${this.assets_root}${typeof asset === 'string' ? asset : asset.out}`
|
|
494
|
+
:
|
|
495
|
+
path.relative(fpd_html, `${this.fpd_out}${typeof asset === 'string' ? asset : asset.out}`);
|
|
487
496
|
const html = '<!doctype html>\n' +
|
|
488
497
|
'<html>\n' +
|
|
489
498
|
' <head>\n' +
|
|
@@ -491,13 +500,13 @@ export class Bundler {
|
|
|
491
500
|
" <meta charset='utf-8' />\n" +
|
|
492
501
|
(heads ? heads.map(head => ` ${head}`).join_lines() : '') +
|
|
493
502
|
(device_width ? " <meta name='viewport' content='width=device-width, initial-scale=1.0' />\n" : '') +
|
|
494
|
-
(icon ? ` <link rel='icon' href='${
|
|
495
|
-
(manifest ? ` <link rel='manifest' href='${
|
|
503
|
+
(icon ? ` <link rel='icon' href='${resolve(icon)}' />\n` : '') +
|
|
504
|
+
(manifest ? ` <link rel='manifest' href='${resolve(manifest)}' />\n` : '') +
|
|
496
505
|
this.resolve_dependency_files(_dependencies, false, { production: this.production }).map(fp => ` <script src='./vendors/${fp}' defer></script>`).join_lines() +
|
|
497
|
-
(scripts?.before ? scripts.before.map(asset => ` <script src='${
|
|
498
|
-
(mscripts ? mscripts.map(mscript => ` <script src='${
|
|
506
|
+
(scripts?.before ? scripts.before.map(asset => ` <script src='${resolve(asset)}' defer></script>`).join_lines() : '') +
|
|
507
|
+
(mscripts ? mscripts.map(mscript => ` <script src='${resolve(mscript)}' type='module'></script>`).join_lines() : '') +
|
|
499
508
|
` <script src='${fp_entry}' type='module'></script>\n` +
|
|
500
|
-
(scripts?.after ? scripts.after.map(asset => ` <script src='${
|
|
509
|
+
(scripts?.after ? scripts.after.map(asset => ` <script src='${resolve(asset)}' defer></script>`).join_lines() : '') +
|
|
501
510
|
' </head>\n' +
|
|
502
511
|
' <body>\n' +
|
|
503
512
|
" <div class='root'>\n" +
|