ts-builds 2.1.0 → 2.2.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/README.md CHANGED
@@ -65,8 +65,9 @@ npx ts-builds typecheck # TypeScript type checking
65
65
  npx ts-builds test # Run tests once
66
66
  npx ts-builds test:watch # Watch mode
67
67
  npx ts-builds test:coverage # With coverage
68
- npx ts-builds build # Production build
69
- npx ts-builds dev # Watch mode build
68
+ npx ts-builds build # Production build (tsdown or vite)
69
+ npx ts-builds dev # Dev mode (tsdown --watch or vite dev server)
70
+ npx ts-builds preview # Preview production build (vite preview)
70
71
  ```
71
72
 
72
73
  ## Package.json Scripts
@@ -119,6 +120,27 @@ If your project uses ESLint plugins not bundled with ts-builds (e.g., `eslint-pl
119
120
 
120
121
  This tells ts-builds to use your project's ESLint installation instead of the bundled version.
121
122
 
123
+ ### For SPAs/React Apps (Vite)
124
+
125
+ Use Vite instead of tsdown for SPA builds:
126
+
127
+ ```bash
128
+ pnpm add -D ts-builds vite
129
+ ```
130
+
131
+ ```json
132
+ {
133
+ "srcDir": "./src",
134
+ "buildMode": "vite"
135
+ }
136
+ ```
137
+
138
+ With `buildMode: "vite"`:
139
+
140
+ - `ts-builds build` → `vite build`
141
+ - `ts-builds dev` → `vite` (dev server with HMR)
142
+ - `ts-builds preview` → `vite preview`
143
+
122
144
  ### Advanced (Monorepos, Custom Commands)
123
145
 
124
146
  ```json
@@ -195,6 +217,20 @@ export default baseConfig
195
217
  }
196
218
  ```
197
219
 
220
+ ### Vite (for SPAs)
221
+
222
+ ```typescript
223
+ // vite.config.ts
224
+ import { vite } from "ts-builds/vite"
225
+ import { defineConfig, mergeConfig } from "vite"
226
+
227
+ export default defineConfig(
228
+ mergeConfig(vite, {
229
+ // your customizations
230
+ }),
231
+ )
232
+ ```
233
+
198
234
  ## Bundled Packages
199
235
 
200
236
  Run `npx ts-builds info` to see all bundled packages. You don't need to install:
package/dist/cli.js CHANGED
@@ -29,6 +29,7 @@ function loadConfig() {
29
29
  return {
30
30
  srcDir: userConfig.srcDir ?? "./src",
31
31
  testDir: userConfig.testDir ?? "./test",
32
+ buildMode: userConfig.buildMode ?? "tsdown",
32
33
  lint: { useProjectEslint: userConfig.lint?.useProjectEslint ?? false },
33
34
  commands,
34
35
  chains
@@ -136,9 +137,10 @@ SCRIPT COMMANDS:
136
137
  test:watch Run tests in watch mode
137
138
  test:coverage Run tests with coverage
138
139
  test:ui Launch Vitest UI
139
- build Production build (rimraf dist && tsdown)
140
+ build Production build (tsdown or vite build, based on buildMode)
140
141
  build:watch Watch mode build
141
- dev Alias for build:watch
142
+ dev Development mode (tsdown --watch or vite dev server)
143
+ preview Preview production build (vite preview)
142
144
 
143
145
  CONFIGURATION:
144
146
  Create ts-builds.config.json in your project root:
@@ -149,6 +151,12 @@ CONFIGURATION:
149
151
  "validateChain": ["format", "lint", "typecheck", "test", "build"]
150
152
  }
151
153
 
154
+ For SPAs/React apps using Vite:
155
+ {
156
+ "srcDir": "./src",
157
+ "buildMode": "vite"
158
+ }
159
+
152
160
  With custom ESLint plugins (e.g., eslint-plugin-functional):
153
161
  {
154
162
  "srcDir": "./src",
@@ -198,13 +206,22 @@ ${bundledPackages.map((pkg) => ` - ${pkg}`).join("\n")}
198
206
 
199
207
  You ONLY need to install:
200
208
  - ts-builds (this package)
201
- - tsdown (peer dependency, optional)
209
+ - tsdown (peer dependency, for library builds - optional)
210
+ - vite (peer dependency, for SPA builds - optional)
211
+
212
+ Example minimal package.json for libraries:
213
+ {
214
+ "devDependencies": {
215
+ "ts-builds": "^3.0.0",
216
+ "tsdown": "^0.19.0"
217
+ }
218
+ }
202
219
 
203
- Example minimal package.json devDependencies:
220
+ Example minimal package.json for SPAs/React apps:
204
221
  {
205
222
  "devDependencies": {
206
223
  "ts-builds": "^3.0.0",
207
- "tsdown": "^0.12.0"
224
+ "vite": "^7.0.0"
208
225
  }
209
226
  }
210
227
  `);
@@ -289,6 +306,7 @@ function createConfig(force = false) {
289
306
  Configuration options:
290
307
  srcDir Source directory for linting (default: "./src")
291
308
  testDir Test directory (default: "./test")
309
+ buildMode "tsdown" (default, libraries) or "vite" (SPAs/React apps)
292
310
  lint Lint settings: { "useProjectEslint": true }
293
311
  validateChain Commands to run for validate (default shown above)
294
312
  commands Custom commands: { "name": "shell command" }
@@ -335,13 +353,25 @@ async function runTest(mode = "run") {
335
353
  }
336
354
  }
337
355
  async function runBuild(watch = false) {
356
+ if (loadConfig().buildMode === "vite") {
357
+ if (watch) return runCommand("vite", ["build", "--watch"]);
358
+ const cleanCode$1 = await runCommand("rimraf", ["dist"]);
359
+ if (cleanCode$1 !== 0) return cleanCode$1;
360
+ return runCommand("vite", ["build"]);
361
+ }
338
362
  if (watch) return runCommand("tsdown", ["--watch"]);
339
363
  const cleanCode = await runCommand("rimraf", ["dist"]);
340
364
  if (cleanCode !== 0) return cleanCode;
341
365
  return runCommand("cross-env", ["NODE_ENV=production", "tsdown"]);
342
366
  }
367
+ async function runDev() {
368
+ return loadConfig().buildMode === "vite" ? runCommand("vite", []) : runCommand("tsdown", ["--watch"]);
369
+ }
343
370
  function getBuiltinCommands(config) {
344
371
  const eslintCmd = config.lint.useProjectEslint ? "npx eslint" : "eslint";
372
+ const buildCmd = config.buildMode === "vite" ? { run: "rimraf dist && vite build" } : { run: "rimraf dist && cross-env NODE_ENV=production tsdown" };
373
+ const buildWatchCmd = config.buildMode === "vite" ? { run: "vite build --watch" } : { run: "tsdown --watch" };
374
+ const devCmd = config.buildMode === "vite" ? { run: "vite" } : { run: "tsdown --watch" };
345
375
  return {
346
376
  format: { run: "prettier --write ." },
347
377
  "format:check": { run: "prettier --check ." },
@@ -353,9 +383,10 @@ function getBuiltinCommands(config) {
353
383
  "test:watch": { run: "vitest" },
354
384
  "test:coverage": { run: "vitest run --coverage" },
355
385
  "test:ui": { run: "vitest --ui" },
356
- build: { run: "rimraf dist && cross-env NODE_ENV=production tsdown" },
357
- "build:watch": { run: "tsdown --watch" },
358
- dev: { run: "tsdown --watch" },
386
+ build: buildCmd,
387
+ "build:watch": buildWatchCmd,
388
+ dev: devCmd,
389
+ preview: { run: "vite preview" },
359
390
  compile: { run: "tsc" }
360
391
  };
361
392
  }
@@ -445,9 +476,14 @@ switch (command) {
445
476
  process.exit(await runBuild(subCommand === "watch"));
446
477
  break;
447
478
  case "build:watch":
448
- case "dev":
449
479
  process.exit(await runBuild(true));
450
480
  break;
481
+ case "dev":
482
+ process.exit(await runDev());
483
+ break;
484
+ case "preview":
485
+ process.exit(await runCommand("vite", ["preview"]));
486
+ break;
451
487
  case "validate":
452
488
  process.exit(await runValidate());
453
489
  break;
@@ -0,0 +1,17 @@
1
+ import { resolve } from "node:path";
2
+
3
+ //#region src/vite.config.base.ts
4
+ /** Base Vite config for SPAs */
5
+ const vite = {
6
+ build: {
7
+ outDir: "dist",
8
+ sourcemap: true,
9
+ target: "es2020",
10
+ minify: process.env.NODE_ENV === "production"
11
+ },
12
+ resolve: { alias: { "@": resolve(process.cwd(), "src") } }
13
+ };
14
+ var vite_config_base_default = vite;
15
+
16
+ //#endregion
17
+ export { vite_config_base_default as default, vite };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-builds",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Shared TypeScript configuration files for library templates. Provides standardized ESLint, Prettier, Vitest, TypeScript, and build configs.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -10,6 +10,7 @@
10
10
  "prettier",
11
11
  "vitest",
12
12
  "tsdown",
13
+ "vite",
13
14
  "shared-config"
14
15
  ],
15
16
  "author": "jordan.burke@gmail.com",
@@ -32,6 +33,7 @@
32
33
  "./vitest": "./dist/vitest.config.base.js",
33
34
  "./tsconfig": "./tsconfig.base.json",
34
35
  "./tsdown": "./dist/tsdown.config.base.js",
36
+ "./vite": "./dist/vite.config.base.js",
35
37
  "./scripts": "./package-scripts.json",
36
38
  "./package.json": "./package.json"
37
39
  },
@@ -49,33 +51,37 @@
49
51
  "dependencies": {
50
52
  "@eslint/eslintrc": "^3.3.3",
51
53
  "@eslint/js": "^9.39.2",
52
- "@types/node": "~24.10.4",
53
- "@typescript-eslint/eslint-plugin": "^8.51.0",
54
- "@typescript-eslint/parser": "^8.51.0",
55
- "@vitest/coverage-v8": "^4.0.16",
56
- "@vitest/ui": "^4.0.16",
54
+ "@types/node": "~24.10.9",
55
+ "@typescript-eslint/eslint-plugin": "^8.53.0",
56
+ "@typescript-eslint/parser": "^8.53.0",
57
+ "@vitest/coverage-v8": "^4.0.17",
58
+ "@vitest/ui": "^4.0.17",
57
59
  "cross-env": "^10.1.0",
58
60
  "eslint": "^9.39.2",
59
61
  "eslint-config-prettier": "^10.1.8",
60
62
  "eslint-plugin-import": "^2.32.0",
61
- "eslint-plugin-prettier": "^5.5.4",
63
+ "eslint-plugin-prettier": "^5.5.5",
62
64
  "eslint-plugin-simple-import-sort": "^12.1.1",
63
- "globals": "^16.5.0",
64
- "prettier": "^3.7.4",
65
+ "globals": "^17.0.0",
66
+ "prettier": "^3.8.0",
65
67
  "rimraf": "^6.1.2",
66
68
  "ts-node": "^10.9.2",
67
69
  "typescript": "^5.9.3",
68
- "vitest": "^4.0.16"
70
+ "vitest": "^4.0.17"
69
71
  },
70
72
  "devDependencies": {
71
- "tsdown": "^0.18.4"
73
+ "tsdown": "^0.19.0"
72
74
  },
73
75
  "peerDependencies": {
74
- "tsdown": "^0.x"
76
+ "tsdown": "^0.x",
77
+ "vite": "^7.x"
75
78
  },
76
79
  "peerDependenciesMeta": {
77
80
  "tsdown": {
78
81
  "optional": true
82
+ },
83
+ "vite": {
84
+ "optional": true
79
85
  }
80
86
  },
81
87
  "scripts": {
@@ -93,5 +99,5 @@
93
99
  "dev": "node dist/cli.js dev",
94
100
  "prepublishOnly": "pnpm validate:bootstrap"
95
101
  },
96
- "packageManager": "pnpm@10.27.0+sha512.72d699da16b1179c14ba9e64dc71c9a40988cbdc65c264cb0e489db7de917f20dcf4d64d8723625f2969ba52d4b7e2a1170682d9ac2a5dcaeaab732b7e16f04a"
102
+ "packageManager": "pnpm@10.28.0+sha512.05df71d1421f21399e053fde567cea34d446fa02c76571441bfc1c7956e98e363088982d940465fd34480d4d90a0668bc12362f8aa88000a64e83d0b0e47be48"
97
103
  }