@deot/dev-builder 2.4.0 → 2.5.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.
- package/dist/index.cjs +52 -27
- package/dist/index.es.js +53 -28
- package/package.json +5 -3
- package/shared.config.ts +2 -2
package/dist/index.cjs
CHANGED
|
@@ -11,6 +11,8 @@ const chalk = require('chalk');
|
|
|
11
11
|
const ora = require('ora');
|
|
12
12
|
const node_url = require('node:url');
|
|
13
13
|
const vite = require('vite');
|
|
14
|
+
const sharedVueConfig = require('@deot/dev-vue');
|
|
15
|
+
const sharedReactConfig = require('@deot/dev-react');
|
|
14
16
|
const sass = require('sass');
|
|
15
17
|
const postcss = require('postcss');
|
|
16
18
|
const atImport = require('postcss-import');
|
|
@@ -45,41 +47,58 @@ const dirname$1 = path__namespace.dirname(node_url.fileURLToPath((typeof documen
|
|
|
45
47
|
const run$3 = async (options) => {
|
|
46
48
|
const locals = devShared.Locals.impl();
|
|
47
49
|
const { cwd, workspace } = locals;
|
|
48
|
-
const {
|
|
49
|
-
|
|
50
|
+
const {
|
|
51
|
+
packageSourceDir: srcDir,
|
|
52
|
+
packageOutDir: outDir,
|
|
53
|
+
packageName,
|
|
54
|
+
packageDir,
|
|
55
|
+
packageOptions,
|
|
56
|
+
commandOptions,
|
|
57
|
+
isNodePackage,
|
|
58
|
+
isVuePackage,
|
|
59
|
+
isReactPackage
|
|
60
|
+
} = options || {};
|
|
61
|
+
const { scriptFormats } = commandOptions;
|
|
50
62
|
const stats = [];
|
|
51
|
-
const srcDir = path__namespace.resolve(packageDir, "./src");
|
|
52
|
-
const outDir = path__namespace.resolve(packageDir, "./dist");
|
|
53
63
|
let files = fs.existsSync(srcDir) ? fs.readdirSync(srcDir).filter((i) => /^index\.(.*)\.?(t|j)s$/.test(i)) : [];
|
|
54
64
|
if (!files.length)
|
|
55
65
|
return stats;
|
|
56
66
|
const build = async (format) => {
|
|
57
|
-
|
|
67
|
+
const buildOptions = {
|
|
58
68
|
files,
|
|
59
69
|
format,
|
|
60
70
|
workspace,
|
|
61
71
|
packageName,
|
|
62
72
|
packageDir,
|
|
63
|
-
|
|
64
|
-
|
|
73
|
+
packageSourceDir: srcDir,
|
|
74
|
+
packageOptions,
|
|
75
|
+
// 这个是给外部调用(z.)?build.config.ts用的
|
|
76
|
+
useVue: false,
|
|
77
|
+
useReact: false
|
|
78
|
+
};
|
|
65
79
|
let options$ = {
|
|
66
80
|
build: {
|
|
67
81
|
write: false
|
|
68
82
|
}
|
|
69
83
|
};
|
|
84
|
+
buildOptions.useVue = !!isVuePackage;
|
|
85
|
+
buildOptions.useReact = !!isReactPackage;
|
|
70
86
|
if (fs.existsSync(`${cwd}/z.build.config.ts`)) {
|
|
71
87
|
options$.configFile = path__namespace.relative(cwd, path__namespace.resolve(cwd, "./z.build.config.ts"));
|
|
72
88
|
} else if (fs.existsSync(`${cwd}/build.config.ts`)) {
|
|
73
89
|
options$.configFile = path__namespace.relative(cwd, path__namespace.resolve(cwd, "./build.config.ts"));
|
|
74
90
|
} else {
|
|
91
|
+
process.env.USE_VUE = isVuePackage ? "1" : "";
|
|
92
|
+
process.env.USE_REACT = isReactPackage ? "1" : "";
|
|
75
93
|
options$.configFile = path__namespace.relative(cwd, path__namespace.resolve(dirname$1, "../shared.config.ts"));
|
|
94
|
+
options$ = isVuePackage ? vite.mergeConfig(sharedVueConfig, options$) : isReactPackage ? vite.mergeConfig(sharedReactConfig, options$) : options$;
|
|
76
95
|
}
|
|
96
|
+
process.env.BUILD_OPTIONS = encodeURIComponent(JSON.stringify(buildOptions));
|
|
77
97
|
let viteBuild = await vite.build(options$);
|
|
78
98
|
return viteBuild;
|
|
79
99
|
};
|
|
80
|
-
const needFilter = typeof nodePackage === "string" && (nodePackage === "*" || nodePackage.split(",").includes(packageName));
|
|
81
100
|
const formats = scriptFormats.split(",").filter((i) => {
|
|
82
|
-
return !
|
|
101
|
+
return !isNodePackage || ["es", "cjs"].includes(i);
|
|
83
102
|
});
|
|
84
103
|
await formats.reduce(
|
|
85
104
|
(preProcess, format) => {
|
|
@@ -114,8 +133,7 @@ const run$3 = async (options) => {
|
|
|
114
133
|
};
|
|
115
134
|
|
|
116
135
|
const run$2 = async (options) => {
|
|
117
|
-
const {
|
|
118
|
-
const srcDir = path__namespace.resolve(packageDir, "./src");
|
|
136
|
+
const { packageSourceDir: srcDir, packageOutDir: outDir } = options || {};
|
|
119
137
|
const styles = fs.existsSync(srcDir) ? fs.readdirSync(srcDir).filter((i) => /^index\.(.*)\.?s?css$/.test(i)) : [];
|
|
120
138
|
const stats = [];
|
|
121
139
|
await styles.reduce(
|
|
@@ -125,7 +143,7 @@ const run$2 = async (options) => {
|
|
|
125
143
|
const data = sass__namespace.compile(filepath, { style: "compressed" });
|
|
126
144
|
return postcss().use(atImport()).use(atUrl()).use(flexBugs()).use(cssnano()).use(autoprefixer({ remove: false })).process(data.css, { from: filepath });
|
|
127
145
|
}).then((source) => {
|
|
128
|
-
let output = path__namespace.resolve(
|
|
146
|
+
let output = path__namespace.resolve(outDir, `${file.replace(/\.scss$/g, ".css")}`);
|
|
129
147
|
fs.outputFileSync(output, source.css);
|
|
130
148
|
return fs.stat(output);
|
|
131
149
|
}).then((stat) => {
|
|
@@ -143,11 +161,11 @@ const run$2 = async (options) => {
|
|
|
143
161
|
|
|
144
162
|
const dirname = path__namespace.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href))));
|
|
145
163
|
const run$1 = async (options) => {
|
|
146
|
-
const { workspace } = devShared.Locals.impl();
|
|
147
|
-
const { packageDir,
|
|
164
|
+
const { workspace, packageDir: packageRootDir } = devShared.Locals.impl();
|
|
165
|
+
const { isVuePackage, packageDir, packageOutDir, packageSourceDir, packageOptions, commandOptions } = options;
|
|
148
166
|
const done = () => {
|
|
149
167
|
const stats = [];
|
|
150
|
-
let fullpath = `${
|
|
168
|
+
let fullpath = `${packageOutDir}/index.d.ts`;
|
|
151
169
|
if (fs.existsSync(fullpath)) {
|
|
152
170
|
let stat = fs.statSync(fullpath);
|
|
153
171
|
stats.push({
|
|
@@ -166,25 +184,26 @@ const run$1 = async (options) => {
|
|
|
166
184
|
});
|
|
167
185
|
return done();
|
|
168
186
|
}
|
|
169
|
-
let tempDir = `${
|
|
187
|
+
let tempDir = `${packageOutDir}/temp`;
|
|
170
188
|
let rootDir = path__namespace.relative(tempDir, process.cwd());
|
|
171
189
|
fs.outputFileSync(`${tempDir}/tsconfig.json`, JSON.stringify({
|
|
172
190
|
extends: `${rootDir}/tsconfig.json`,
|
|
173
191
|
compilerOptions: {
|
|
174
192
|
declaration: true,
|
|
175
193
|
emitDeclarationOnly: true,
|
|
194
|
+
allowJs: true,
|
|
176
195
|
rootDir,
|
|
177
196
|
outDir: "."
|
|
178
197
|
},
|
|
179
198
|
include: [
|
|
180
|
-
path__namespace.relative(tempDir, path__namespace.resolve(
|
|
199
|
+
path__namespace.relative(tempDir, path__namespace.resolve(packageSourceDir, `*`))
|
|
181
200
|
]
|
|
182
201
|
}, null, " "));
|
|
183
|
-
await devShared.Shell.spawn("tsc", ["-p", `${tempDir}/tsconfig.json`]);
|
|
202
|
+
await devShared.Shell.spawn(isVuePackage ? "vue-tsc" : "tsc", ["-p", `${tempDir}/tsconfig.json`]);
|
|
184
203
|
const configPath = `${tempDir}/api-extractor.json`;
|
|
185
204
|
fs.outputFileSync(configPath, JSON.stringify({
|
|
186
205
|
extends: path__namespace.relative(tempDir, path__namespace.resolve(dirname, "../api-extractor.shared.json")),
|
|
187
|
-
mainEntryPointFilePath:
|
|
206
|
+
mainEntryPointFilePath: (workspace ? `./${workspace}/` : "./") + path__namespace.relative(packageRootDir, `${packageSourceDir}/index.d.ts`),
|
|
188
207
|
// workspace、时以temp/packages/*/src结构,否则APIExtractor会报错
|
|
189
208
|
dtsRollup: {
|
|
190
209
|
publicTrimmedFilePath: "../index.d.ts"
|
|
@@ -220,7 +239,7 @@ const run$1 = async (options) => {
|
|
|
220
239
|
);
|
|
221
240
|
process.exitCode = 1;
|
|
222
241
|
}
|
|
223
|
-
await fs.remove(
|
|
242
|
+
await fs.remove(tempDir);
|
|
224
243
|
return done();
|
|
225
244
|
};
|
|
226
245
|
|
|
@@ -229,29 +248,38 @@ class Build {
|
|
|
229
248
|
packageDir;
|
|
230
249
|
packageFolderName;
|
|
231
250
|
packageSourceDir;
|
|
251
|
+
packageOutDir;
|
|
232
252
|
packageName;
|
|
233
253
|
packageOptions;
|
|
234
254
|
commandOptions;
|
|
255
|
+
isVuePackage;
|
|
256
|
+
isReactPackage;
|
|
257
|
+
isNodePackage;
|
|
235
258
|
constructor(packageFolderName, commandOptions) {
|
|
236
|
-
const { workspace, packageDir, packageName, packageFolderName: packageFolderName
|
|
259
|
+
const { workspace, packageDir, packageName, packageFolderName: packageFolderName$, subpackagesMap } = devShared.Locals.impl();
|
|
260
|
+
const subpackages = subpackagesMap[packageFolderName] || [];
|
|
237
261
|
this.packageFolderName = packageFolderName || "";
|
|
238
262
|
this.packageDir = path__namespace.resolve(packageDir, workspace ? `./${packageFolderName}` : "");
|
|
239
|
-
this.packageSourceDir = path__namespace.resolve(packageDir, "./src");
|
|
263
|
+
this.packageSourceDir = path__namespace.resolve(this.packageDir, subpackages.length ? "" : "./src");
|
|
264
|
+
this.packageOutDir = path__namespace.resolve(this.packageDir, "./dist");
|
|
240
265
|
this.packageName = packageFolderName === packageFolderName$ ? packageName : `${packageName}-${packageFolderName}`;
|
|
241
266
|
this.packageOptions = require$(`${this.packageDir}/package.json`);
|
|
242
267
|
this.commandOptions = commandOptions;
|
|
268
|
+
const { reactPackage, vuePackage, nodePackage } = commandOptions;
|
|
269
|
+
this.isVuePackage = typeof vuePackage === "string" && (vuePackage === "*" || vuePackage.split(",").includes(this.packageName));
|
|
270
|
+
this.isReactPackage = typeof vuePackage === "string" && (vuePackage === "*" || reactPackage.split(",").includes(this.packageName));
|
|
271
|
+
this.isNodePackage = typeof nodePackage === "string" && (nodePackage === "*" || nodePackage.split(",").includes(this.packageName));
|
|
243
272
|
}
|
|
244
273
|
async process() {
|
|
245
274
|
let start = Date.now();
|
|
246
275
|
const { cwd, workspace } = devShared.Locals.impl();
|
|
247
|
-
const { packageOptions, packageName, packageDir } = this;
|
|
276
|
+
const { packageSourceDir: srcDir, packageOptions, packageName, packageDir } = this;
|
|
248
277
|
if (workspace && packageOptions?.scripts?.build && packageDir !== cwd) {
|
|
249
278
|
await devShared.Shell.spawn(`npm`, ["run", "build"], {
|
|
250
279
|
cwd: packageDir
|
|
251
280
|
});
|
|
252
281
|
return;
|
|
253
282
|
}
|
|
254
|
-
const srcDir = path__namespace.resolve(packageDir, "./src");
|
|
255
283
|
let files = fs.existsSync(srcDir) ? fs.readdirSync(srcDir).filter((i) => /^index(.*)\.(ts|js|s?css)$/.test(i)) : [];
|
|
256
284
|
if (!files.length)
|
|
257
285
|
return;
|
|
@@ -296,9 +324,6 @@ const run = (options) => devShared.Utils.autoCatch(async () => {
|
|
|
296
324
|
...options
|
|
297
325
|
};
|
|
298
326
|
const locals = devShared.Locals.impl();
|
|
299
|
-
if (typeof options.dryRun === "undefined") {
|
|
300
|
-
options.dryRun = process.env.NODE_ENV === "UNIT";
|
|
301
|
-
}
|
|
302
327
|
let packageFolderName = devShared.Locals.getPackageFolderName(options.packageName || "*");
|
|
303
328
|
let inputs = [];
|
|
304
329
|
if (locals.workspace && packageFolderName === "*") {
|
package/dist/index.es.js
CHANGED
|
@@ -6,7 +6,9 @@ import fs$1 from 'fs-extra';
|
|
|
6
6
|
import chalk from 'chalk';
|
|
7
7
|
import ora from 'ora';
|
|
8
8
|
import { fileURLToPath } from 'node:url';
|
|
9
|
-
import { build as build$1 } from 'vite';
|
|
9
|
+
import { mergeConfig, build as build$1 } from 'vite';
|
|
10
|
+
import sharedVueConfig from '@deot/dev-vue';
|
|
11
|
+
import sharedReactConfig from '@deot/dev-react';
|
|
10
12
|
import * as sass from 'sass';
|
|
11
13
|
import postcss from 'postcss';
|
|
12
14
|
import atImport from 'postcss-import';
|
|
@@ -20,41 +22,58 @@ const dirname$1 = path.dirname(fileURLToPath(import.meta.url));
|
|
|
20
22
|
const run$3 = async (options) => {
|
|
21
23
|
const locals = Locals.impl();
|
|
22
24
|
const { cwd, workspace } = locals;
|
|
23
|
-
const {
|
|
24
|
-
|
|
25
|
+
const {
|
|
26
|
+
packageSourceDir: srcDir,
|
|
27
|
+
packageOutDir: outDir,
|
|
28
|
+
packageName,
|
|
29
|
+
packageDir,
|
|
30
|
+
packageOptions,
|
|
31
|
+
commandOptions,
|
|
32
|
+
isNodePackage,
|
|
33
|
+
isVuePackage,
|
|
34
|
+
isReactPackage
|
|
35
|
+
} = options || {};
|
|
36
|
+
const { scriptFormats } = commandOptions;
|
|
25
37
|
const stats = [];
|
|
26
|
-
const srcDir = path.resolve(packageDir, "./src");
|
|
27
|
-
const outDir = path.resolve(packageDir, "./dist");
|
|
28
38
|
let files = fs$1.existsSync(srcDir) ? fs$1.readdirSync(srcDir).filter((i) => /^index\.(.*)\.?(t|j)s$/.test(i)) : [];
|
|
29
39
|
if (!files.length)
|
|
30
40
|
return stats;
|
|
31
41
|
const build = async (format) => {
|
|
32
|
-
|
|
42
|
+
const buildOptions = {
|
|
33
43
|
files,
|
|
34
44
|
format,
|
|
35
45
|
workspace,
|
|
36
46
|
packageName,
|
|
37
47
|
packageDir,
|
|
38
|
-
|
|
39
|
-
|
|
48
|
+
packageSourceDir: srcDir,
|
|
49
|
+
packageOptions,
|
|
50
|
+
// 这个是给外部调用(z.)?build.config.ts用的
|
|
51
|
+
useVue: false,
|
|
52
|
+
useReact: false
|
|
53
|
+
};
|
|
40
54
|
let options$ = {
|
|
41
55
|
build: {
|
|
42
56
|
write: false
|
|
43
57
|
}
|
|
44
58
|
};
|
|
59
|
+
buildOptions.useVue = !!isVuePackage;
|
|
60
|
+
buildOptions.useReact = !!isReactPackage;
|
|
45
61
|
if (fs$1.existsSync(`${cwd}/z.build.config.ts`)) {
|
|
46
62
|
options$.configFile = path.relative(cwd, path.resolve(cwd, "./z.build.config.ts"));
|
|
47
63
|
} else if (fs$1.existsSync(`${cwd}/build.config.ts`)) {
|
|
48
64
|
options$.configFile = path.relative(cwd, path.resolve(cwd, "./build.config.ts"));
|
|
49
65
|
} else {
|
|
66
|
+
process.env.USE_VUE = isVuePackage ? "1" : "";
|
|
67
|
+
process.env.USE_REACT = isReactPackage ? "1" : "";
|
|
50
68
|
options$.configFile = path.relative(cwd, path.resolve(dirname$1, "../shared.config.ts"));
|
|
69
|
+
options$ = isVuePackage ? mergeConfig(sharedVueConfig, options$) : isReactPackage ? mergeConfig(sharedReactConfig, options$) : options$;
|
|
51
70
|
}
|
|
71
|
+
process.env.BUILD_OPTIONS = encodeURIComponent(JSON.stringify(buildOptions));
|
|
52
72
|
let viteBuild = await build$1(options$);
|
|
53
73
|
return viteBuild;
|
|
54
74
|
};
|
|
55
|
-
const needFilter = typeof nodePackage === "string" && (nodePackage === "*" || nodePackage.split(",").includes(packageName));
|
|
56
75
|
const formats = scriptFormats.split(",").filter((i) => {
|
|
57
|
-
return !
|
|
76
|
+
return !isNodePackage || ["es", "cjs"].includes(i);
|
|
58
77
|
});
|
|
59
78
|
await formats.reduce(
|
|
60
79
|
(preProcess, format) => {
|
|
@@ -89,8 +108,7 @@ const run$3 = async (options) => {
|
|
|
89
108
|
};
|
|
90
109
|
|
|
91
110
|
const run$2 = async (options) => {
|
|
92
|
-
const {
|
|
93
|
-
const srcDir = path.resolve(packageDir, "./src");
|
|
111
|
+
const { packageSourceDir: srcDir, packageOutDir: outDir } = options || {};
|
|
94
112
|
const styles = fs$1.existsSync(srcDir) ? fs$1.readdirSync(srcDir).filter((i) => /^index\.(.*)\.?s?css$/.test(i)) : [];
|
|
95
113
|
const stats = [];
|
|
96
114
|
await styles.reduce(
|
|
@@ -100,7 +118,7 @@ const run$2 = async (options) => {
|
|
|
100
118
|
const data = sass.compile(filepath, { style: "compressed" });
|
|
101
119
|
return postcss().use(atImport()).use(atUrl()).use(flexBugs()).use(cssnano()).use(autoprefixer({ remove: false })).process(data.css, { from: filepath });
|
|
102
120
|
}).then((source) => {
|
|
103
|
-
let output = path.resolve(
|
|
121
|
+
let output = path.resolve(outDir, `${file.replace(/\.scss$/g, ".css")}`);
|
|
104
122
|
fs$1.outputFileSync(output, source.css);
|
|
105
123
|
return fs$1.stat(output);
|
|
106
124
|
}).then((stat) => {
|
|
@@ -118,11 +136,11 @@ const run$2 = async (options) => {
|
|
|
118
136
|
|
|
119
137
|
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
120
138
|
const run$1 = async (options) => {
|
|
121
|
-
const { workspace } = Locals.impl();
|
|
122
|
-
const { packageDir,
|
|
139
|
+
const { workspace, packageDir: packageRootDir } = Locals.impl();
|
|
140
|
+
const { isVuePackage, packageDir, packageOutDir, packageSourceDir, packageOptions, commandOptions } = options;
|
|
123
141
|
const done = () => {
|
|
124
142
|
const stats = [];
|
|
125
|
-
let fullpath = `${
|
|
143
|
+
let fullpath = `${packageOutDir}/index.d.ts`;
|
|
126
144
|
if (fs$1.existsSync(fullpath)) {
|
|
127
145
|
let stat = fs$1.statSync(fullpath);
|
|
128
146
|
stats.push({
|
|
@@ -141,25 +159,26 @@ const run$1 = async (options) => {
|
|
|
141
159
|
});
|
|
142
160
|
return done();
|
|
143
161
|
}
|
|
144
|
-
let tempDir = `${
|
|
162
|
+
let tempDir = `${packageOutDir}/temp`;
|
|
145
163
|
let rootDir = path.relative(tempDir, process.cwd());
|
|
146
164
|
fs$1.outputFileSync(`${tempDir}/tsconfig.json`, JSON.stringify({
|
|
147
165
|
extends: `${rootDir}/tsconfig.json`,
|
|
148
166
|
compilerOptions: {
|
|
149
167
|
declaration: true,
|
|
150
168
|
emitDeclarationOnly: true,
|
|
169
|
+
allowJs: true,
|
|
151
170
|
rootDir,
|
|
152
171
|
outDir: "."
|
|
153
172
|
},
|
|
154
173
|
include: [
|
|
155
|
-
path.relative(tempDir, path.resolve(
|
|
174
|
+
path.relative(tempDir, path.resolve(packageSourceDir, `*`))
|
|
156
175
|
]
|
|
157
176
|
}, null, " "));
|
|
158
|
-
await Shell.spawn("tsc", ["-p", `${tempDir}/tsconfig.json`]);
|
|
177
|
+
await Shell.spawn(isVuePackage ? "vue-tsc" : "tsc", ["-p", `${tempDir}/tsconfig.json`]);
|
|
159
178
|
const configPath = `${tempDir}/api-extractor.json`;
|
|
160
179
|
fs$1.outputFileSync(configPath, JSON.stringify({
|
|
161
180
|
extends: path.relative(tempDir, path.resolve(dirname, "../api-extractor.shared.json")),
|
|
162
|
-
mainEntryPointFilePath:
|
|
181
|
+
mainEntryPointFilePath: (workspace ? `./${workspace}/` : "./") + path.relative(packageRootDir, `${packageSourceDir}/index.d.ts`),
|
|
163
182
|
// workspace、时以temp/packages/*/src结构,否则APIExtractor会报错
|
|
164
183
|
dtsRollup: {
|
|
165
184
|
publicTrimmedFilePath: "../index.d.ts"
|
|
@@ -195,7 +214,7 @@ const run$1 = async (options) => {
|
|
|
195
214
|
);
|
|
196
215
|
process.exitCode = 1;
|
|
197
216
|
}
|
|
198
|
-
await fs$1.remove(
|
|
217
|
+
await fs$1.remove(tempDir);
|
|
199
218
|
return done();
|
|
200
219
|
};
|
|
201
220
|
|
|
@@ -204,29 +223,38 @@ class Build {
|
|
|
204
223
|
packageDir;
|
|
205
224
|
packageFolderName;
|
|
206
225
|
packageSourceDir;
|
|
226
|
+
packageOutDir;
|
|
207
227
|
packageName;
|
|
208
228
|
packageOptions;
|
|
209
229
|
commandOptions;
|
|
230
|
+
isVuePackage;
|
|
231
|
+
isReactPackage;
|
|
232
|
+
isNodePackage;
|
|
210
233
|
constructor(packageFolderName, commandOptions) {
|
|
211
|
-
const { workspace, packageDir, packageName, packageFolderName: packageFolderName
|
|
234
|
+
const { workspace, packageDir, packageName, packageFolderName: packageFolderName$, subpackagesMap } = Locals.impl();
|
|
235
|
+
const subpackages = subpackagesMap[packageFolderName] || [];
|
|
212
236
|
this.packageFolderName = packageFolderName || "";
|
|
213
237
|
this.packageDir = path.resolve(packageDir, workspace ? `./${packageFolderName}` : "");
|
|
214
|
-
this.packageSourceDir = path.resolve(packageDir, "./src");
|
|
238
|
+
this.packageSourceDir = path.resolve(this.packageDir, subpackages.length ? "" : "./src");
|
|
239
|
+
this.packageOutDir = path.resolve(this.packageDir, "./dist");
|
|
215
240
|
this.packageName = packageFolderName === packageFolderName$ ? packageName : `${packageName}-${packageFolderName}`;
|
|
216
241
|
this.packageOptions = require$(`${this.packageDir}/package.json`);
|
|
217
242
|
this.commandOptions = commandOptions;
|
|
243
|
+
const { reactPackage, vuePackage, nodePackage } = commandOptions;
|
|
244
|
+
this.isVuePackage = typeof vuePackage === "string" && (vuePackage === "*" || vuePackage.split(",").includes(this.packageName));
|
|
245
|
+
this.isReactPackage = typeof vuePackage === "string" && (vuePackage === "*" || reactPackage.split(",").includes(this.packageName));
|
|
246
|
+
this.isNodePackage = typeof nodePackage === "string" && (nodePackage === "*" || nodePackage.split(",").includes(this.packageName));
|
|
218
247
|
}
|
|
219
248
|
async process() {
|
|
220
249
|
let start = Date.now();
|
|
221
250
|
const { cwd, workspace } = Locals.impl();
|
|
222
|
-
const { packageOptions, packageName, packageDir } = this;
|
|
251
|
+
const { packageSourceDir: srcDir, packageOptions, packageName, packageDir } = this;
|
|
223
252
|
if (workspace && packageOptions?.scripts?.build && packageDir !== cwd) {
|
|
224
253
|
await Shell.spawn(`npm`, ["run", "build"], {
|
|
225
254
|
cwd: packageDir
|
|
226
255
|
});
|
|
227
256
|
return;
|
|
228
257
|
}
|
|
229
|
-
const srcDir = path.resolve(packageDir, "./src");
|
|
230
258
|
let files = fs$1.existsSync(srcDir) ? fs$1.readdirSync(srcDir).filter((i) => /^index(.*)\.(ts|js|s?css)$/.test(i)) : [];
|
|
231
259
|
if (!files.length)
|
|
232
260
|
return;
|
|
@@ -271,9 +299,6 @@ const run = (options) => Utils.autoCatch(async () => {
|
|
|
271
299
|
...options
|
|
272
300
|
};
|
|
273
301
|
const locals = Locals.impl();
|
|
274
|
-
if (typeof options.dryRun === "undefined") {
|
|
275
|
-
options.dryRun = process.env.NODE_ENV === "UNIT";
|
|
276
|
-
}
|
|
277
302
|
let packageFolderName = Locals.getPackageFolderName(options.packageName || "*");
|
|
278
303
|
let inputs = [];
|
|
279
304
|
if (locals.workspace && packageFolderName === "*") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deot/dev-builder",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.es.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -29,14 +29,16 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@deot/dev-
|
|
32
|
+
"@deot/dev-react": "^2.5.0",
|
|
33
|
+
"@deot/dev-shared": "^2.5.0",
|
|
34
|
+
"@deot/dev-vue": "^2.5.1",
|
|
33
35
|
"@microsoft/api-extractor": "^7.36.4",
|
|
34
36
|
"autoprefixer": "^10.4.15",
|
|
35
37
|
"chalk": "^5.3.0",
|
|
36
38
|
"cssnano": "^6.0.1",
|
|
37
39
|
"fs-extra": "^11.1.1",
|
|
38
40
|
"ora": "^7.0.1",
|
|
39
|
-
"postcss": "^8.4.
|
|
41
|
+
"postcss": "^8.4.29",
|
|
40
42
|
"postcss-flexbugs-fixes": "^5.0.2",
|
|
41
43
|
"postcss-import": "^15.1.0",
|
|
42
44
|
"postcss-url": "^10.1.3",
|
package/shared.config.ts
CHANGED
|
@@ -18,7 +18,7 @@ const {
|
|
|
18
18
|
workspace,
|
|
19
19
|
files = [],
|
|
20
20
|
packageName,
|
|
21
|
-
|
|
21
|
+
packageSourceDir,
|
|
22
22
|
packageOptions = {}
|
|
23
23
|
} = buildOptions;
|
|
24
24
|
|
|
@@ -73,7 +73,7 @@ export default defineConfig({
|
|
|
73
73
|
minify: false,
|
|
74
74
|
target: 'esnext',
|
|
75
75
|
lib: {
|
|
76
|
-
entry: files.map((file: string) => path.resolve(
|
|
76
|
+
entry: files.map((file: string) => path.resolve(packageSourceDir, file)),
|
|
77
77
|
formats: [format],
|
|
78
78
|
name: packageName.replace(/(_|-|^|.*\/)([^-_\/@])/g, (_match: any, _$1: any, $2: string) => $2.toUpperCase())
|
|
79
79
|
},
|