@deot/dev-builder 2.7.1 → 2.8.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 CHANGED
@@ -61,7 +61,7 @@ const run$3 = async (options) => {
61
61
  } = options || {};
62
62
  const { scriptFormats, external, globals } = commandOptions;
63
63
  const stats = [];
64
- let files = fs.existsSync(srcDir) ? fs.readdirSync(srcDir).filter((i) => /^index\.(.*)\.?(t|j)s$/.test(i)) : [];
64
+ const files = fs.existsSync(srcDir) ? fs.readdirSync(srcDir).filter((i) => /^index\.(.*)\.?(t|j)s$/.test(i)) : [];
65
65
  if (!files.length)
66
66
  return stats;
67
67
  const build = async (format, filepath) => {
@@ -97,11 +97,11 @@ const run$3 = async (options) => {
97
97
  options$ = isVuePackage ? vite.mergeConfig(sharedVueConfig, options$) : isReactPackage ? vite.mergeConfig(sharedReactConfig, options$) : options$;
98
98
  }
99
99
  process.env.BUILD_OPTIONS = encodeURIComponent(JSON.stringify(buildOptions));
100
- let outputs2 = await vite.build(options$);
100
+ const outputs2 = await vite.build(options$);
101
101
  outputs2.forEach((i) => {
102
102
  i.output.forEach((j) => {
103
103
  if (j.type === "asset") {
104
- let fileName = filepath.replace(/^(.*)((\..*\.js)|\.cjs|\.ts)/, `$1.${j.fileName}`);
104
+ const fileName = filepath.replace(/^(.*)((\..*\.js)|\.cjs|\.ts)/, `$1.${j.fileName}`);
105
105
  fs.outputFileSync(`${outDir}/${fileName}`, j.source);
106
106
  return;
107
107
  }
@@ -123,9 +123,9 @@ const run$3 = async (options) => {
123
123
  });
124
124
  });
125
125
  await serial;
126
- let outputs = fs.readdirSync(outDir).filter((i) => /^index(.*)(?!=(\.d))\.(cjs|js|style\.css)$/.test(i));
126
+ const outputs = fs.readdirSync(outDir).filter((i) => /^index(.*)(?!=(\.d))\.(cjs|js|style\.css)$/.test(i));
127
127
  outputs.forEach((file) => {
128
- let stat = fs.statSync(path__namespace.resolve(outDir, file));
128
+ const stat = fs.statSync(path__namespace.resolve(outDir, file));
129
129
  stats.push({
130
130
  file: file.replace(/^(.*)(\.umd\.cjs|\.iife\.js)/, "$1.ts").replace(/^(.*)(\.js|\.cjs)/, "$1.ts"),
131
131
  format: /\.style\.css$/.test(file) ? "css" : /\.umd\.cjs$/.test(file) ? "umd" : /\.cjs$/.test(file) ? "cjs" : /\.iife\.js$/.test(file) ? "iife" : "es",
@@ -142,11 +142,11 @@ const run$2 = async (options) => {
142
142
  await styles.reduce(
143
143
  (preProcess, file) => {
144
144
  preProcess = preProcess.then(() => {
145
- let filepath = path__namespace.resolve(srcDir, file);
145
+ const filepath = path__namespace.resolve(srcDir, file);
146
146
  const data = sass__namespace.compile(filepath, { style: "compressed" });
147
147
  return postcss().use(atImport()).use(atUrl()).use(flexBugs()).use(cssnano()).use(autoprefixer({ remove: false })).process(data.css, { from: filepath });
148
148
  }).then((source) => {
149
- let output = path__namespace.resolve(outDir, `${file.replace(/\.scss$/g, ".css")}`);
149
+ const output = path__namespace.resolve(outDir, `${file.replace(/\.scss$/g, ".css")}`);
150
150
  fs.outputFileSync(output, source.css);
151
151
  return fs.stat(output);
152
152
  }).then((stat) => {
@@ -168,9 +168,9 @@ const run$1 = async (options) => {
168
168
  const { isVuePackage, packageDir, packageOutDir, packageSourceDir, packageOptions, commandOptions } = options;
169
169
  const done = () => {
170
170
  const stats = [];
171
- let fullpath = `${packageOutDir}/index.d.ts`;
171
+ const fullpath = `${packageOutDir}/index.d.ts`;
172
172
  if (fs.existsSync(fullpath)) {
173
- let stat = fs.statSync(fullpath);
173
+ const stat = fs.statSync(fullpath);
174
174
  stats.push({
175
175
  file: "index.d.ts",
176
176
  size: stat.size
@@ -187,22 +187,30 @@ const run$1 = async (options) => {
187
187
  });
188
188
  return done();
189
189
  }
190
- let tempDir = `${packageOutDir}/temp`;
191
- let rootDir = path__namespace.relative(tempDir, process.cwd());
192
- fs.outputFileSync(`${tempDir}/tsconfig.json`, JSON.stringify({
193
- extends: `${rootDir}/tsconfig.json`,
194
- compilerOptions: {
195
- declaration: true,
196
- emitDeclarationOnly: true,
197
- allowJs: true,
198
- rootDir,
199
- outDir: "."
200
- },
201
- include: [
202
- path__namespace.relative(tempDir, path__namespace.resolve(packageSourceDir, `*`))
203
- ]
204
- }, null, " "));
205
- await devShared.Shell.spawn(isVuePackage ? "vue-tsc" : "tsc", ["-p", `${tempDir}/tsconfig.json`]);
190
+ const tempDir = `${packageOutDir}/temp`;
191
+ const rootDir = path__namespace.relative(tempDir, process.cwd());
192
+ const tsc = async (skipLibCheck) => {
193
+ fs.outputFileSync(`${tempDir}/tsconfig.json`, JSON.stringify({
194
+ extends: `${rootDir}/tsconfig.json`,
195
+ compilerOptions: {
196
+ declaration: true,
197
+ emitDeclarationOnly: true,
198
+ allowJs: true,
199
+ outDir: ".",
200
+ skipLibCheck,
201
+ rootDir
202
+ },
203
+ include: [
204
+ path__namespace.relative(tempDir, path__namespace.resolve(packageSourceDir, `*`))
205
+ ]
206
+ }, null, " "));
207
+ await devShared.Shell.spawn(isVuePackage ? "vue-tsc" : "tsc", ["-p", `${tempDir}/tsconfig.json`]);
208
+ };
209
+ try {
210
+ await tsc(false);
211
+ } catch (e) {
212
+ await tsc(true);
213
+ }
206
214
  const configPath = `${tempDir}/api-extractor.json`;
207
215
  fs.outputFileSync(configPath, JSON.stringify({
208
216
  extends: path__namespace.relative(tempDir, path__namespace.resolve(dirname, "../api-extractor.shared.json")),
@@ -224,7 +232,7 @@ const run$1 = async (options) => {
224
232
  *
225
233
  * 版本提示:
226
234
  * 2. console-compiler-version-notice
227
- * *** The target project appears to use TypeScript 5.1.6 which is newer
235
+ * *** The target project appears to use TypeScript 5.1.6 which is newer
228
236
  * than the bundled compiler engine; consider upgrading API Extractor.
229
237
  * 3. console-preamble
230
238
  * Analysis will use the bundled TypeScript version 5.0.4
@@ -282,7 +290,7 @@ class Build {
282
290
  this.isNodePackage = typeof nodePackage === "string" && (nodePackage === "*" || nodePackage.split(",").includes(this.packageName));
283
291
  }
284
292
  async process() {
285
- let start = Date.now();
293
+ const start = Date.now();
286
294
  const { cwd, workspace } = devShared.Locals.impl();
287
295
  const { packageSourceDir: srcDir, packageOptions, packageName, packageDir } = this;
288
296
  if (workspace && packageOptions?.scripts?.build && packageDir !== cwd) {
@@ -291,7 +299,7 @@ class Build {
291
299
  });
292
300
  return;
293
301
  }
294
- let files = fs.existsSync(srcDir) ? fs.readdirSync(srcDir).filter((i) => /^index(.*)\.(ts|js|s?css)$/.test(i)) : [];
302
+ const files = fs.existsSync(srcDir) ? fs.readdirSync(srcDir).filter((i) => /^index(.*)\.(ts|js|s?css)$/.test(i)) : [];
295
303
  if (!files.length)
296
304
  return;
297
305
  const spinner = ora(`${packageName} Build ...`);
@@ -339,7 +347,7 @@ const run = (options) => devShared.Utils.autoCatch(async () => {
339
347
  options.vuePackage = devShared.Locals.getRealPackageName(options.vuePackage);
340
348
  options.reactPackage = devShared.Locals.getRealPackageName(options.reactPackage);
341
349
  options.nodePackage = devShared.Locals.getRealPackageName(options.nodePackage);
342
- let packageFolderName = devShared.Locals.getPackageFolderName(options.packageName || "*");
350
+ const packageFolderName = devShared.Locals.getPackageFolderName(options.packageName || "*");
343
351
  let inputs = [];
344
352
  if (locals.workspace && packageFolderName === "*") {
345
353
  inputs = locals.normalizePackageFolderNames;
package/dist/index.js CHANGED
@@ -35,7 +35,7 @@ const run$3 = async (options) => {
35
35
  } = options || {};
36
36
  const { scriptFormats, external, globals } = commandOptions;
37
37
  const stats = [];
38
- let files = fs$1.existsSync(srcDir) ? fs$1.readdirSync(srcDir).filter((i) => /^index\.(.*)\.?(t|j)s$/.test(i)) : [];
38
+ const files = fs$1.existsSync(srcDir) ? fs$1.readdirSync(srcDir).filter((i) => /^index\.(.*)\.?(t|j)s$/.test(i)) : [];
39
39
  if (!files.length)
40
40
  return stats;
41
41
  const build = async (format, filepath) => {
@@ -71,11 +71,11 @@ const run$3 = async (options) => {
71
71
  options$ = isVuePackage ? mergeConfig(sharedVueConfig, options$) : isReactPackage ? mergeConfig(sharedReactConfig, options$) : options$;
72
72
  }
73
73
  process.env.BUILD_OPTIONS = encodeURIComponent(JSON.stringify(buildOptions));
74
- let outputs2 = await build$1(options$);
74
+ const outputs2 = await build$1(options$);
75
75
  outputs2.forEach((i) => {
76
76
  i.output.forEach((j) => {
77
77
  if (j.type === "asset") {
78
- let fileName = filepath.replace(/^(.*)((\..*\.js)|\.cjs|\.ts)/, `$1.${j.fileName}`);
78
+ const fileName = filepath.replace(/^(.*)((\..*\.js)|\.cjs|\.ts)/, `$1.${j.fileName}`);
79
79
  fs$1.outputFileSync(`${outDir}/${fileName}`, j.source);
80
80
  return;
81
81
  }
@@ -97,9 +97,9 @@ const run$3 = async (options) => {
97
97
  });
98
98
  });
99
99
  await serial;
100
- let outputs = fs$1.readdirSync(outDir).filter((i) => /^index(.*)(?!=(\.d))\.(cjs|js|style\.css)$/.test(i));
100
+ const outputs = fs$1.readdirSync(outDir).filter((i) => /^index(.*)(?!=(\.d))\.(cjs|js|style\.css)$/.test(i));
101
101
  outputs.forEach((file) => {
102
- let stat = fs$1.statSync(path.resolve(outDir, file));
102
+ const stat = fs$1.statSync(path.resolve(outDir, file));
103
103
  stats.push({
104
104
  file: file.replace(/^(.*)(\.umd\.cjs|\.iife\.js)/, "$1.ts").replace(/^(.*)(\.js|\.cjs)/, "$1.ts"),
105
105
  format: /\.style\.css$/.test(file) ? "css" : /\.umd\.cjs$/.test(file) ? "umd" : /\.cjs$/.test(file) ? "cjs" : /\.iife\.js$/.test(file) ? "iife" : "es",
@@ -116,11 +116,11 @@ const run$2 = async (options) => {
116
116
  await styles.reduce(
117
117
  (preProcess, file) => {
118
118
  preProcess = preProcess.then(() => {
119
- let filepath = path.resolve(srcDir, file);
119
+ const filepath = path.resolve(srcDir, file);
120
120
  const data = sass.compile(filepath, { style: "compressed" });
121
121
  return postcss().use(atImport()).use(atUrl()).use(flexBugs()).use(cssnano()).use(autoprefixer({ remove: false })).process(data.css, { from: filepath });
122
122
  }).then((source) => {
123
- let output = path.resolve(outDir, `${file.replace(/\.scss$/g, ".css")}`);
123
+ const output = path.resolve(outDir, `${file.replace(/\.scss$/g, ".css")}`);
124
124
  fs$1.outputFileSync(output, source.css);
125
125
  return fs$1.stat(output);
126
126
  }).then((stat) => {
@@ -142,9 +142,9 @@ const run$1 = async (options) => {
142
142
  const { isVuePackage, packageDir, packageOutDir, packageSourceDir, packageOptions, commandOptions } = options;
143
143
  const done = () => {
144
144
  const stats = [];
145
- let fullpath = `${packageOutDir}/index.d.ts`;
145
+ const fullpath = `${packageOutDir}/index.d.ts`;
146
146
  if (fs$1.existsSync(fullpath)) {
147
- let stat = fs$1.statSync(fullpath);
147
+ const stat = fs$1.statSync(fullpath);
148
148
  stats.push({
149
149
  file: "index.d.ts",
150
150
  size: stat.size
@@ -161,22 +161,30 @@ const run$1 = async (options) => {
161
161
  });
162
162
  return done();
163
163
  }
164
- let tempDir = `${packageOutDir}/temp`;
165
- let rootDir = path.relative(tempDir, process.cwd());
166
- fs$1.outputFileSync(`${tempDir}/tsconfig.json`, JSON.stringify({
167
- extends: `${rootDir}/tsconfig.json`,
168
- compilerOptions: {
169
- declaration: true,
170
- emitDeclarationOnly: true,
171
- allowJs: true,
172
- rootDir,
173
- outDir: "."
174
- },
175
- include: [
176
- path.relative(tempDir, path.resolve(packageSourceDir, `*`))
177
- ]
178
- }, null, " "));
179
- await Shell.spawn(isVuePackage ? "vue-tsc" : "tsc", ["-p", `${tempDir}/tsconfig.json`]);
164
+ const tempDir = `${packageOutDir}/temp`;
165
+ const rootDir = path.relative(tempDir, process.cwd());
166
+ const tsc = async (skipLibCheck) => {
167
+ fs$1.outputFileSync(`${tempDir}/tsconfig.json`, JSON.stringify({
168
+ extends: `${rootDir}/tsconfig.json`,
169
+ compilerOptions: {
170
+ declaration: true,
171
+ emitDeclarationOnly: true,
172
+ allowJs: true,
173
+ outDir: ".",
174
+ skipLibCheck,
175
+ rootDir
176
+ },
177
+ include: [
178
+ path.relative(tempDir, path.resolve(packageSourceDir, `*`))
179
+ ]
180
+ }, null, " "));
181
+ await Shell.spawn(isVuePackage ? "vue-tsc" : "tsc", ["-p", `${tempDir}/tsconfig.json`]);
182
+ };
183
+ try {
184
+ await tsc(false);
185
+ } catch (e) {
186
+ await tsc(true);
187
+ }
180
188
  const configPath = `${tempDir}/api-extractor.json`;
181
189
  fs$1.outputFileSync(configPath, JSON.stringify({
182
190
  extends: path.relative(tempDir, path.resolve(dirname, "../api-extractor.shared.json")),
@@ -198,7 +206,7 @@ const run$1 = async (options) => {
198
206
  *
199
207
  * 版本提示:
200
208
  * 2. console-compiler-version-notice
201
- * *** The target project appears to use TypeScript 5.1.6 which is newer
209
+ * *** The target project appears to use TypeScript 5.1.6 which is newer
202
210
  * than the bundled compiler engine; consider upgrading API Extractor.
203
211
  * 3. console-preamble
204
212
  * Analysis will use the bundled TypeScript version 5.0.4
@@ -256,7 +264,7 @@ class Build {
256
264
  this.isNodePackage = typeof nodePackage === "string" && (nodePackage === "*" || nodePackage.split(",").includes(this.packageName));
257
265
  }
258
266
  async process() {
259
- let start = Date.now();
267
+ const start = Date.now();
260
268
  const { cwd, workspace } = Locals.impl();
261
269
  const { packageSourceDir: srcDir, packageOptions, packageName, packageDir } = this;
262
270
  if (workspace && packageOptions?.scripts?.build && packageDir !== cwd) {
@@ -265,7 +273,7 @@ class Build {
265
273
  });
266
274
  return;
267
275
  }
268
- let files = fs$1.existsSync(srcDir) ? fs$1.readdirSync(srcDir).filter((i) => /^index(.*)\.(ts|js|s?css)$/.test(i)) : [];
276
+ const files = fs$1.existsSync(srcDir) ? fs$1.readdirSync(srcDir).filter((i) => /^index(.*)\.(ts|js|s?css)$/.test(i)) : [];
269
277
  if (!files.length)
270
278
  return;
271
279
  const spinner = ora(`${packageName} Build ...`);
@@ -313,7 +321,7 @@ const run = (options) => Utils.autoCatch(async () => {
313
321
  options.vuePackage = Locals.getRealPackageName(options.vuePackage);
314
322
  options.reactPackage = Locals.getRealPackageName(options.reactPackage);
315
323
  options.nodePackage = Locals.getRealPackageName(options.nodePackage);
316
- let packageFolderName = Locals.getPackageFolderName(options.packageName || "*");
324
+ const packageFolderName = Locals.getPackageFolderName(options.packageName || "*");
317
325
  let inputs = [];
318
326
  if (locals.workspace && packageFolderName === "*") {
319
327
  inputs = locals.normalizePackageFolderNames;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deot/dev-builder",
3
- "version": "2.7.1",
3
+ "version": "2.8.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -29,10 +29,10 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@deot/dev-react": "^2.7.0",
33
- "@deot/dev-shared": "^2.7.0",
34
- "@deot/dev-vue": "^2.7.0",
35
- "@microsoft/api-extractor": "^7.38.4",
32
+ "@deot/dev-react": "^2.8.0",
33
+ "@deot/dev-shared": "^2.8.0",
34
+ "@deot/dev-vue": "^2.8.0",
35
+ "@microsoft/api-extractor": "^7.38.5",
36
36
  "autoprefixer": "^10.4.16",
37
37
  "chalk": "^5.3.0",
38
38
  "cssnano": "^6.0.1",
@@ -43,9 +43,9 @@
43
43
  "postcss-import": "^15.1.0",
44
44
  "postcss-url": "^10.1.3",
45
45
  "sass": "^1.69.5",
46
- "vite": "^5.0.5"
46
+ "vite": "^5.0.8"
47
47
  },
48
48
  "devDependencies": {
49
- "typescript": "^5.3.2"
49
+ "typescript": "^5.3.3"
50
50
  }
51
51
  }
package/shared.config.ts CHANGED
@@ -1,41 +1,41 @@
1
- import { createRequire } from "node:module";
1
+ import { createRequire } from 'node:module';
2
2
  import * as path from 'node:path';
3
3
  import { defineConfig } from 'vite';
4
- import atImport from "postcss-import";
5
- import atUrl from "postcss-url";
6
- import flexBugs from "postcss-flexbugs-fixes";
7
- import cssnano from "cssnano";
8
- import autoprefixer from "autoprefixer";
9
- import type { UserConfig } from "vite";
4
+ import atImport from 'postcss-import';
5
+ import atUrl from 'postcss-url';
6
+ import flexBugs from 'postcss-flexbugs-fixes';
7
+ import cssnano from 'cssnano';
8
+ import autoprefixer from 'autoprefixer';
9
+ import type { UserConfig } from 'vite';
10
10
 
11
11
  const cwd = process.cwd();
12
12
 
13
13
  // options
14
14
  const buildOptions = JSON.parse(decodeURIComponent(process.env.BUILD_OPTIONS || '{}'));
15
15
 
16
- const {
17
- format,
16
+ const {
17
+ format,
18
18
  external = '',
19
19
  globals = '',
20
20
  workspace,
21
- files = [],
22
- packageName,
23
- packageSourceDir,
24
- packageOptions = {}
21
+ files = [],
22
+ packageName,
23
+ packageSourceDir,
24
+ packageOptions = {}
25
25
  } = buildOptions;
26
26
 
27
27
  const usedForBrowser = /(iife|umd)/.test(format);
28
28
  const external$ = !usedForBrowser
29
29
  ? [
30
- /^node:/,
31
- /^[a-zA-Z@]/,
32
- ...Object
33
- .keys({
34
- ...packageOptions.dependencies,
35
- ...packageOptions.peerDependencies
36
- })
37
- .map(i => new RegExp(`^${i}$`))
38
- ]
30
+ /^node:/,
31
+ /^[a-zA-Z@]/,
32
+ ...Object
33
+ .keys({
34
+ ...packageOptions.dependencies,
35
+ ...packageOptions.peerDependencies
36
+ })
37
+ .map(i => new RegExp(`^${i}$`))
38
+ ]
39
39
  : external.split(',')
40
40
  .filter((i: string) => !!i)
41
41
  .map((i: string) => new RegExp(`^${i}$`));
@@ -46,25 +46,25 @@ const { name } = createRequire(cwd)(path.resolve(cwd, workspace ? `${workspace}/
46
46
 
47
47
  const alias = workspace && usedForBrowser
48
48
  ? [
49
- {
50
- find: new RegExp(`^${name}$`),
51
- replacement: replacement('index')
52
- },
53
- {
49
+ {
50
+ find: new RegExp(`^${name}$`),
51
+ replacement: replacement('index')
52
+ },
53
+ {
54
54
 
55
- find: new RegExp(`^${name}-(.*?)$`),
56
- replacement: replacement('$1')
57
- }
58
- ]
55
+ find: new RegExp(`^${name}-(.*?)$`),
56
+ replacement: replacement('$1')
57
+ }
58
+ ]
59
59
  : [];
60
60
 
61
61
  const getGlobalName = (name$: string) => name$.replace(/(_|-|^|.*\/)([^-_\/@])/g, (_match: any, _$1: any, $2: string) => $2.toUpperCase());
62
62
 
63
63
  export default defineConfig({
64
- define: usedForBrowser
64
+ define: usedForBrowser
65
65
  ? {
66
- "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV)
67
- }
66
+ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
67
+ }
68
68
  : {},
69
69
  logLevel: 'silent',
70
70
  plugins: [],
@@ -88,19 +88,20 @@ export default defineConfig({
88
88
  formats: [format],
89
89
  name: getGlobalName(packageName)
90
90
  },
91
- rollupOptions: {
91
+ rollupOptions: {
92
92
  external: external$,
93
93
  output: {
94
- globals: usedForBrowser
94
+ exports: 'named',
95
+ globals: usedForBrowser
95
96
  ? (globals || external).split(',')
96
- .filter((i: string) => !!i)
97
- .reduce((pre: any, cur: string) => {
98
- const [key, value] = cur.split(':');
99
- if (key) {
100
- pre[key] = value || getGlobalName(key);
101
- }
102
- return pre;
103
- }, {})
97
+ .filter((i: string) => !!i)
98
+ .reduce((pre: any, cur: string) => {
99
+ const [key, value] = cur.split(':');
100
+ if (key) {
101
+ pre[key] = value || getGlobalName(key);
102
+ }
103
+ return pre;
104
+ }, {})
104
105
  : {}
105
106
 
106
107
  }