@jayfong/x-server 2.75.1 → 2.76.0
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/lib/_cjs/cli/build_util.js +15 -0
- package/lib/_cjs/cli/cli.js +12 -1
- package/lib/cli/build_util.d.ts +1 -0
- package/lib/cli/build_util.js +15 -0
- package/lib/cli/cli.js +14 -2
- package/package.json +1 -1
|
@@ -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
|
package/lib/_cjs/cli/cli.js
CHANGED
|
@@ -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,13 @@ _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?.map(item => {
|
|
189
|
+
return (0, _vtils.escapeRegExp)(_vtils.StringTemplate.render(item, envMap, {
|
|
190
|
+
code: true,
|
|
191
|
+
onlyCode: true
|
|
192
|
+
}));
|
|
193
|
+
})
|
|
183
194
|
});
|
|
184
195
|
console.log('构建成功');
|
|
185
196
|
if (argv.deploy) {
|
package/lib/cli/build_util.d.ts
CHANGED
package/lib/cli/build_util.js
CHANGED
|
@@ -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,13 @@ 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?.map(item => {
|
|
187
|
+
return escapeRegExp(StringTemplate.render(item, envMap, {
|
|
188
|
+
code: true,
|
|
189
|
+
onlyCode: true
|
|
190
|
+
}));
|
|
191
|
+
})
|
|
180
192
|
});
|
|
181
193
|
console.log('构建成功');
|
|
182
194
|
if (argv.deploy) {
|