@jayfong/x-server 2.75.1 → 2.76.1

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.
@@ -137,6 +137,21 @@ class BuildUtil {
137
137
  loader: 'js'
138
138
  };
139
139
  });
140
+
141
+ // 支持构建时排除文件
142
+ if (options.excludeFiles?.length) {
143
+ const excludeRegExps = options.excludeFiles.map(item => new RegExp(item));
144
+ build.onLoad({
145
+ filter: /\.ts$/
146
+ }, async args => {
147
+ if (excludeRegExps.some(re => re.test(args.path))) {
148
+ return {
149
+ contents: 'export {}',
150
+ loader: 'js'
151
+ };
152
+ }
153
+ });
154
+ }
140
155
  }
141
156
  },
142
157
  // @ts-ignore
@@ -151,6 +151,11 @@ _yargs.default.command('dev', '开始开发', _ => _.positional('index', {
151
151
  describe: '构建完是否部署',
152
152
  type: 'boolean',
153
153
  default: false
154
+ }).positional('exclude', {
155
+ alias: 'x',
156
+ describe: '构建时排除的文件',
157
+ type: 'string',
158
+ array: true
154
159
  }), async argv => {
155
160
  await _env_util.EnvUtil.withChannel({
156
161
  cwd: process.cwd(),
@@ -179,7 +184,14 @@ _yargs.default.command('dev', '开始开发', _ => _.positional('index', {
179
184
  inlineEnvs: envMap,
180
185
  minify: argv.minify,
181
186
  noInstall: argv['no-install'],
182
- channel: channel
187
+ channel: channel,
188
+ excludeFiles: (argv.exclude ? (0, _vtils.castArray)(argv.exclude) : []).map(item => {
189
+ return _vtils.StringTemplate.render(item, envMap, {
190
+ code: true,
191
+ onlyCode: true,
192
+ beforeReplace: v => (0, _vtils.escapeRegExp)(v)
193
+ });
194
+ })
183
195
  });
184
196
  console.log('构建成功');
185
197
  if (argv.deploy) {
@@ -5,6 +5,7 @@ export interface BuildOptions {
5
5
  minify?: boolean;
6
6
  noInstall?: boolean;
7
7
  channel?: string;
8
+ excludeFiles?: string[];
8
9
  }
9
10
  export declare class BuildUtil {
10
11
  static build(options: BuildOptions): Promise<void>;
@@ -131,6 +131,21 @@ export class BuildUtil {
131
131
  loader: 'js'
132
132
  };
133
133
  });
134
+
135
+ // 支持构建时排除文件
136
+ if (options.excludeFiles?.length) {
137
+ const excludeRegExps = options.excludeFiles.map(item => new RegExp(item));
138
+ build.onLoad({
139
+ filter: /\.ts$/
140
+ }, async args => {
141
+ if (excludeRegExps.some(re => re.test(args.path))) {
142
+ return {
143
+ contents: 'export {}',
144
+ loader: 'js'
145
+ };
146
+ }
147
+ });
148
+ }
134
149
  }
135
150
  },
136
151
  // @ts-ignore
package/lib/cli/cli.js CHANGED
@@ -4,7 +4,8 @@ import chokidar from 'chokidar';
4
4
  import execa from 'execa';
5
5
  import fs from 'fs-extra';
6
6
  import { generateManyIndex } from 'vscode-generate-index-standalone';
7
- import { castArray, debounce } from 'vtils';
7
+ import { castArray, debounce, escapeRegExp } from 'vtils';
8
+ import { StringTemplate } from 'vtils';
8
9
  import yargs from 'yargs';
9
10
  import { ApiGenerator } from "./api_generator";
10
11
  import { BuildUtil } from "./build_util";
@@ -148,6 +149,11 @@ yargs.command('dev', '开始开发', _ => _.positional('index', {
148
149
  describe: '构建完是否部署',
149
150
  type: 'boolean',
150
151
  default: false
152
+ }).positional('exclude', {
153
+ alias: 'x',
154
+ describe: '构建时排除的文件',
155
+ type: 'string',
156
+ array: true
151
157
  }), async argv => {
152
158
  await EnvUtil.withChannel({
153
159
  cwd: process.cwd(),
@@ -176,7 +182,14 @@ yargs.command('dev', '开始开发', _ => _.positional('index', {
176
182
  inlineEnvs: envMap,
177
183
  minify: argv.minify,
178
184
  noInstall: argv['no-install'],
179
- channel: channel
185
+ channel: channel,
186
+ excludeFiles: (argv.exclude ? castArray(argv.exclude) : []).map(item => {
187
+ return StringTemplate.render(item, envMap, {
188
+ code: true,
189
+ onlyCode: true,
190
+ beforeReplace: v => escapeRegExp(v)
191
+ });
192
+ })
180
193
  });
181
194
  console.log('构建成功');
182
195
  if (argv.deploy) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayfong/x-server",
3
- "version": "2.75.1",
3
+ "version": "2.76.1",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",
@@ -71,7 +71,7 @@
71
71
  "unplugin-macros": "^0.16.0",
72
72
  "utf-8-validate": "^5.0.9",
73
73
  "vscode-generate-index-standalone": "^1.7.1",
74
- "vtils": "^4.128.0",
74
+ "vtils": "^4.130.1",
75
75
  "yaml": "^2.3.1",
76
76
  "yargs": "^17.4.1"
77
77
  },