@party-stack/build-config 0.0.0-stage → 0.1.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Robert Fidler
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,41 @@
1
- # Temporary Holding Version
1
+ # Build config
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Shared Vite+, Vitest, and TypeScript settings for libraries and apps.
4
+
5
+ ```ts
6
+ import { defineLibraryConfig } from "@party-stack/build-config";
7
+
8
+ export default defineLibraryConfig();
9
+ ```
10
+
11
+ ```json
12
+ {
13
+ "extends": "@party-stack/build-config/tsconfig.json"
14
+ }
15
+ ```
16
+
17
+ React and Expo libraries use `@party-stack/build-config/react/tsconfig.json` for
18
+ JSX and bundler module resolution. They use the same Vite helper.
19
+
20
+ The preset provides:
21
+
22
+ - `check`, `build`, and `test` tasks, ordered after their prerequisites.
23
+ - Unbundled ESM, declarations, and source maps in `lib` through `vp pack`.
24
+ - Vitest discovery under `src`, with package-specific test options.
25
+ - TypeScript path resolution through `resolve.tsconfigPaths` for libraries and apps.
26
+ - Strict TypeScript settings targeting ES2022, with Node and DOM types.
27
+
28
+ Apps use `defineAppConfig` from the same package. It provides check/build/test/dev
29
+ tasks, browser targets, and `.test.ts`/`.test.tsx` discovery. Supply framework
30
+ plugins and app-specific settings in the caller. Apps can extend
31
+ `@party-stack/build-config/app/tsconfig.json` for strict checks without emitting.
32
+ TanStack Start apps use `@party-stack/tanstack-start-build-config` for framework
33
+ plugins, React Compiler, Tailwind, and the app TSConfig together.
34
+
35
+ Package options override the defaults. Resolve and individual task options are merged;
36
+ arrays and task cache options replace their defaults. Lint and formatting remain
37
+ in the workspace root.
38
+
39
+ The package builds during installation. After editing it, run
40
+ `vp run @party-stack/build-config#build`. If its `lib` output is missing, bootstrap
41
+ with `pnpm exec vp -C packages/build-config pack`.
package/lib/index.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import { ViteUserConfig } from "vite-plus";
2
+ //#region src/index.d.ts
3
+ type RunConfig = NonNullable<ViteUserConfig["run"]>;
4
+ type TaskDefinition = NonNullable<RunConfig["tasks"]>[string];
5
+ type TaskOptions = Exclude<TaskDefinition, string | string[]>;
6
+ /** Override individual task options without repeating their command or prerequisites. */
7
+ export type LibraryConfig = Omit<ViteUserConfig, "run"> & {
8
+ run?: Omit<RunConfig, "tasks"> & {
9
+ tasks?: Record<string, string | string[] | Partial<TaskOptions>>;
10
+ };
11
+ };
12
+ /**
13
+ * Configure an ESM library. Package overrides replace arrays and merge the
14
+ * pack, test, and individual task options with these defaults.
15
+ */
16
+ export declare function defineLibraryConfig(config?: LibraryConfig): ViteUserConfig;
17
+ export type AppConfig = LibraryConfig;
18
+ /** Configure app tasks while leaving framework plugins with the caller. */
19
+ export declare function defineAppConfig(config?: AppConfig): ViteUserConfig;
20
+ //#endregion
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;KAGK,YAAY,YAAY;KACxB,iBAAiB,YAAY;KAC7B,cAAc,QAAQ;;YAGf,gBAAgB,KAAK;EAC7B,MAAM,KAAK;IACP,QAAQ,mCAAmC,QAAQ;;;;;;;wBAQ3C,oBAAoB,SAAQ,gBAAqB;YA2CrD,YAAY;;wBAGR,gBAAgB,SAAQ,YAAiB"}
package/lib/index.js ADDED
@@ -0,0 +1,151 @@
1
+ import { defineConfig } from "vite-plus";
2
+ //#region src/index.ts
3
+ /**
4
+ * Configure an ESM library. Package overrides replace arrays and merge the
5
+ * pack, test, and individual task options with these defaults.
6
+ */
7
+ function defineLibraryConfig(config = {}) {
8
+ return composeConfig(defineConfig({
9
+ resolve: { tsconfigPaths: true },
10
+ run: { tasks: {
11
+ check: {
12
+ command: "vp check",
13
+ cache: { input: [
14
+ { auto: true },
15
+ "!.",
16
+ "*.{json,jsonc,ts,mts,js,mjs}"
17
+ ] },
18
+ dependsOn: [{
19
+ task: "build",
20
+ from: ["dependencies", "devDependencies"]
21
+ }]
22
+ },
23
+ build: {
24
+ command: "vp pack",
25
+ cache: { input: [
26
+ { auto: true },
27
+ "!.",
28
+ "*.{json,jsonc,ts,mts,js,mjs}",
29
+ "!lib/**"
30
+ ] },
31
+ dependsOn: ["check", {
32
+ task: "build",
33
+ from: ["dependencies", "devDependencies"]
34
+ }]
35
+ },
36
+ test: {
37
+ command: "vp test",
38
+ dependsOn: ["build"]
39
+ }
40
+ } },
41
+ pack: {
42
+ entry: [
43
+ "src/**/*.{ts,tsx}",
44
+ "!src/**/*.d.ts",
45
+ "!src/**/*.test.{ts,tsx}",
46
+ "!src/**/*.bench.{ts,tsx}"
47
+ ],
48
+ outDir: "lib",
49
+ root: "src",
50
+ target: "es2022",
51
+ unbundle: true,
52
+ fixedExtension: false,
53
+ deps: { neverBundle: true }
54
+ },
55
+ test: {
56
+ include: ["src/**/*.test.{ts,tsx}"],
57
+ passWithNoTests: true
58
+ }
59
+ }), config);
60
+ }
61
+ /** Configure app tasks while leaving framework plugins with the caller. */
62
+ function defineAppConfig(config = {}) {
63
+ return composeConfig(defineConfig({
64
+ resolve: { tsconfigPaths: true },
65
+ run: { tasks: {
66
+ check: {
67
+ command: "vp check",
68
+ dependsOn: [{
69
+ task: "build",
70
+ from: ["dependencies", "devDependencies"]
71
+ }]
72
+ },
73
+ build: {
74
+ command: "vp build",
75
+ cache: { untrackedEnv: ["SHLVL"] },
76
+ dependsOn: ["check", {
77
+ task: "build",
78
+ from: ["dependencies", "devDependencies"]
79
+ }]
80
+ },
81
+ test: {
82
+ command: "vp test",
83
+ dependsOn: ["build"]
84
+ },
85
+ dev: {
86
+ command: "vp dev",
87
+ dependsOn: [{
88
+ task: "build",
89
+ from: ["dependencies", "devDependencies"]
90
+ }],
91
+ cache: false
92
+ }
93
+ } },
94
+ build: { target: [
95
+ "chrome107",
96
+ "edge107",
97
+ "firefox104",
98
+ "safari16"
99
+ ] },
100
+ test: {
101
+ include: ["src/**/*.test.{ts,tsx}"],
102
+ passWithNoTests: true
103
+ }
104
+ }), config);
105
+ }
106
+ function composeConfig(base, config) {
107
+ const tasks = { ...base.run?.tasks };
108
+ for (const [name, override] of Object.entries(config.run?.tasks ?? {})) {
109
+ const original = tasks[name];
110
+ if (typeof override === "string" || Array.isArray(override)) tasks[name] = override;
111
+ else {
112
+ const inherited = typeof original === "object" && !Array.isArray(original) ? original : void 0;
113
+ const command = override.command ?? inherited?.command;
114
+ if (command === void 0) throw new Error(`Task "${name}" needs a command because it has no preset default.`);
115
+ tasks[name] = {
116
+ ...inherited,
117
+ ...override,
118
+ command
119
+ };
120
+ }
121
+ }
122
+ return {
123
+ ...base,
124
+ ...config,
125
+ resolve: {
126
+ ...base.resolve,
127
+ ...config.resolve
128
+ },
129
+ ...base.pack || config.pack ? { pack: Array.isArray(config.pack) ? config.pack : {
130
+ ...Array.isArray(base.pack) ? {} : base.pack,
131
+ ...config.pack
132
+ } } : {},
133
+ ...base.build || config.build ? { build: {
134
+ ...base.build,
135
+ ...config.build
136
+ } } : {},
137
+ test: {
138
+ ...base.test,
139
+ ...config.test
140
+ },
141
+ run: {
142
+ ...base.run,
143
+ ...config.run,
144
+ tasks
145
+ }
146
+ };
147
+ }
148
+ //#endregion
149
+ export { defineAppConfig, defineLibraryConfig };
150
+
151
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { defineConfig } from \"vite-plus\";\nimport type { ViteUserConfig } from \"vite-plus\";\n\ntype RunConfig = NonNullable<ViteUserConfig[\"run\"]>;\ntype TaskDefinition = NonNullable<RunConfig[\"tasks\"]>[string];\ntype TaskOptions = Exclude<TaskDefinition, string | string[]>;\n\n/** Override individual task options without repeating their command or prerequisites. */\nexport type LibraryConfig = Omit<ViteUserConfig, \"run\"> & {\n run?: Omit<RunConfig, \"tasks\"> & {\n tasks?: Record<string, string | string[] | Partial<TaskOptions>>;\n };\n};\n\n/**\n * Configure an ESM library. Package overrides replace arrays and merge the\n * pack, test, and individual task options with these defaults.\n */\nexport function defineLibraryConfig(config: LibraryConfig = {}): ViteUserConfig {\n const base = defineConfig({\n resolve: { tsconfigPaths: true },\n run: {\n tasks: {\n check: {\n command: \"vp check\",\n // Track root files without making generated directory entries inputs.\n cache: {\n input: [{ auto: true }, \"!.\", \"*.{json,jsonc,ts,mts,js,mjs}\"],\n },\n dependsOn: [{ task: \"build\", from: [\"dependencies\", \"devDependencies\"] }],\n },\n build: {\n command: \"vp pack\",\n // Generated outputs and package directory listings must not invalidate their own build.\n cache: {\n input: [{ auto: true }, \"!.\", \"*.{json,jsonc,ts,mts,js,mjs}\", \"!lib/**\"],\n },\n dependsOn: [\"check\", { task: \"build\", from: [\"dependencies\", \"devDependencies\"] }],\n },\n test: { command: \"vp test\", dependsOn: [\"build\"] },\n },\n },\n pack: {\n entry: [\n \"src/**/*.{ts,tsx}\",\n \"!src/**/*.d.ts\",\n \"!src/**/*.test.{ts,tsx}\",\n \"!src/**/*.bench.{ts,tsx}\",\n ],\n outDir: \"lib\",\n root: \"src\",\n target: \"es2022\",\n unbundle: true,\n fixedExtension: false,\n deps: { neverBundle: true },\n },\n test: { include: [\"src/**/*.test.{ts,tsx}\"], passWithNoTests: true },\n });\n return composeConfig(base, config);\n}\n\nexport type AppConfig = LibraryConfig;\n\n/** Configure app tasks while leaving framework plugins with the caller. */\nexport function defineAppConfig(config: AppConfig = {}): ViteUserConfig {\n return composeConfig(\n defineConfig({\n resolve: { tsconfigPaths: true },\n run: {\n tasks: {\n check: {\n command: \"vp check\",\n dependsOn: [{ task: \"build\", from: [\"dependencies\", \"devDependencies\"] }],\n },\n build: {\n command: \"vp build\",\n // Shell nesting changed cache fingerprints without changing app outputs.\n cache: { untrackedEnv: [\"SHLVL\"] },\n dependsOn: [\"check\", { task: \"build\", from: [\"dependencies\", \"devDependencies\"] }],\n },\n test: { command: \"vp test\", dependsOn: [\"build\"] },\n dev: {\n command: \"vp dev\",\n dependsOn: [{ task: \"build\", from: [\"dependencies\", \"devDependencies\"] }],\n cache: false,\n },\n },\n },\n // Preserve Vite 7 browser support after the Vite 8 default target change.\n build: { target: [\"chrome107\", \"edge107\", \"firefox104\", \"safari16\"] },\n test: { include: [\"src/**/*.test.{ts,tsx}\"], passWithNoTests: true },\n }),\n config\n );\n}\n\nfunction composeConfig(base: ViteUserConfig, config: LibraryConfig): ViteUserConfig {\n const tasks = { ...base.run?.tasks };\n for (const [name, override] of Object.entries(config.run?.tasks ?? {})) {\n const original = tasks[name];\n if (typeof override === \"string\" || Array.isArray(override)) {\n tasks[name] = override;\n } else {\n const inherited = typeof original === \"object\" && !Array.isArray(original) ? original : undefined;\n const command = override.command ?? inherited?.command;\n if (command === undefined) {\n throw new Error(`Task \"${name}\" needs a command because it has no preset default.`);\n }\n tasks[name] = { ...inherited, ...override, command };\n }\n }\n return {\n ...base,\n ...config,\n resolve: { ...base.resolve, ...config.resolve },\n ...(base.pack || config.pack\n ? {\n pack: Array.isArray(config.pack)\n ? config.pack\n : { ...(Array.isArray(base.pack) ? {} : base.pack), ...config.pack },\n }\n : {}),\n ...(base.build || config.build ? { build: { ...base.build, ...config.build } } : {}),\n test: { ...base.test, ...config.test },\n run: { ...base.run, ...config.run, tasks },\n };\n}\n"],"mappings":";;;;;;AAkBA,SAAgB,oBAAoB,SAAwB,CAAC,GAAmB;CAwC5E,OAAO,cAvCM,aAAa;EACtB,SAAS,EAAE,eAAe,KAAK;EAC/B,KAAK,EACD,OAAO;GACH,OAAO;IACH,SAAS;IAET,OAAO,EACH,OAAO;KAAC,EAAE,MAAM,KAAK;KAAG;KAAM;IAA8B,EAChE;IACA,WAAW,CAAC;KAAE,MAAM;KAAS,MAAM,CAAC,gBAAgB,iBAAiB;IAAE,CAAC;GAC5E;GACA,OAAO;IACH,SAAS;IAET,OAAO,EACH,OAAO;KAAC,EAAE,MAAM,KAAK;KAAG;KAAM;KAAgC;IAAS,EAC3E;IACA,WAAW,CAAC,SAAS;KAAE,MAAM;KAAS,MAAM,CAAC,gBAAgB,iBAAiB;IAAE,CAAC;GACrF;GACA,MAAM;IAAE,SAAS;IAAW,WAAW,CAAC,OAAO;GAAE;EACrD,EACJ;EACA,MAAM;GACF,OAAO;IACH;IACA;IACA;IACA;GACJ;GACA,QAAQ;GACR,MAAM;GACN,QAAQ;GACR,UAAU;GACV,gBAAgB;GAChB,MAAM,EAAE,aAAa,KAAK;EAC9B;EACA,MAAM;GAAE,SAAS,CAAC,wBAAwB;GAAG,iBAAiB;EAAK;CACvE,CACwB,GAAG,MAAM;AACrC;;AAKA,SAAgB,gBAAgB,SAAoB,CAAC,GAAmB;CACpE,OAAO,cACH,aAAa;EACT,SAAS,EAAE,eAAe,KAAK;EAC/B,KAAK,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AAO,OAClB,EACI,MAAM,MAAM,QAAQ,OAAO,IAAI,IACzB,OAAO,OACP;GAAE,GAAI,MAAM,QAAQ,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK;GAAO,GAAG,OAAO;EAAK,EAC3E,IACA,CAAC;EACP,GAAI,KAAK,SAAS,OAAO,QAAQ,EAAE,OAAO;GAAE,GAAG,KAAK;GAAO,GAAG,OAAO;EAAM,EAAE,IAAI,CAAC;EAClF,MAAM;GAAE,GAAG,KAAK;GAAM,GAAG,OAAO;EAAK;EACrC,KAAK;GAAE,GAAG,KAAK;GAAK,GAAG,OAAO;GAAK;EAAM;CAC7C;AACJ"}
package/package.json CHANGED
@@ -1,6 +1,27 @@
1
1
  {
2
2
  "name": "@party-stack/build-config",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.2",
4
+ "files": [
5
+ "lib",
6
+ "tsconfig"
7
+ ],
8
+ "type": "module",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./lib/index.d.ts",
12
+ "default": "./lib/index.js"
13
+ },
14
+ "./tsconfig.json": "./tsconfig/library.json",
15
+ "./react/tsconfig.json": "./tsconfig/react.json",
16
+ "./app/tsconfig.json": "./tsconfig/app.json"
17
+ },
18
+ "devDependencies": {
19
+ "@types/node": "^24.10.1",
20
+ "typescript": "~7.0.2",
21
+ "vite-plus": "1.1.0"
22
+ },
23
+ "peerDependencies": {
24
+ "vite-plus": "^1.1.0"
25
+ },
26
+ "scripts": {}
6
27
  }
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "./react.json",
3
+ "compilerOptions": {
4
+ "rootDir": "${configDir}",
5
+ "noEmit": true,
6
+ "noUncheckedIndexedAccess": false,
7
+ "lib": ["DOM", "DOM.Iterable", "ESNext"],
8
+ "types": ["node", "vite/client"],
9
+ "paths": {
10
+ "@/*": ["${configDir}/src/*"]
11
+ }
12
+ },
13
+ "include": ["${configDir}/src/**/*.ts", "${configDir}/src/**/*.tsx", "${configDir}/vite.config.ts"]
14
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "types": ["node"],
5
+ "outDir": "${configDir}/lib",
6
+ "rootDir": "${configDir}/src",
7
+ "declaration": true,
8
+ "declarationMap": true,
9
+ "sourceMap": true,
10
+ "isolatedModules": true,
11
+ "noUncheckedIndexedAccess": true,
12
+ "resolveJsonModule": true,
13
+ "strict": true,
14
+ "allowUnreachableCode": false,
15
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
16
+ "target": "ES2022",
17
+ "module": "NodeNext",
18
+ "moduleResolution": "NodeNext",
19
+ "skipLibCheck": true
20
+ },
21
+ "include": ["${configDir}/src/**/*.ts"]
22
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./library.json",
3
+ "compilerOptions": {
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "jsx": "react-jsx"
7
+ },
8
+ "include": ["${configDir}/src/**/*.ts", "${configDir}/src/**/*.tsx"]
9
+ }