@kasoa/vite-plus-config 0.2.0 → 0.3.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.
Files changed (40) hide show
  1. package/README.md +211 -42
  2. package/dist/compose-Cichpffs.d.mts +14 -0
  3. package/dist/compose-Cichpffs.d.mts.map +1 -0
  4. package/dist/constants-D2PDomKY.mjs +33 -0
  5. package/dist/constants-D2PDomKY.mjs.map +1 -0
  6. package/dist/src/cloudflare-workers/index.d.mts +6 -10
  7. package/dist/src/cloudflare-workers/index.d.mts.map +1 -1
  8. package/dist/src/cloudflare-workers/index.mjs +11 -9
  9. package/dist/src/cloudflare-workers/index.mjs.map +1 -1
  10. package/dist/src/index.d.mts +47 -0
  11. package/dist/src/index.d.mts.map +1 -0
  12. package/dist/{base-7cyIJaBC.mjs → src/index.mjs} +425 -252
  13. package/dist/src/index.mjs.map +1 -0
  14. package/package.json +6 -25
  15. package/dist/base-7cyIJaBC.mjs.map +0 -1
  16. package/dist/config-Cxe-N0iS.d.mts +0 -16
  17. package/dist/config-Cxe-N0iS.d.mts.map +0 -1
  18. package/dist/src/base/index.d.mts +0 -7
  19. package/dist/src/base/index.d.mts.map +0 -1
  20. package/dist/src/base/index.mjs +0 -2
  21. package/dist/src/library/index.d.mts +0 -7
  22. package/dist/src/library/index.d.mts.map +0 -1
  23. package/dist/src/library/index.mjs +0 -15
  24. package/dist/src/library/index.mjs.map +0 -1
  25. package/dist/src/monorepo/index.d.mts +0 -7
  26. package/dist/src/monorepo/index.d.mts.map +0 -1
  27. package/dist/src/monorepo/index.mjs +0 -16
  28. package/dist/src/monorepo/index.mjs.map +0 -1
  29. package/dist/src/node/index.d.mts +0 -7
  30. package/dist/src/node/index.d.mts.map +0 -1
  31. package/dist/src/node/index.mjs +0 -10
  32. package/dist/src/node/index.mjs.map +0 -1
  33. package/dist/src/react/index.d.mts +0 -7
  34. package/dist/src/react/index.d.mts.map +0 -1
  35. package/dist/src/react/index.mjs +0 -13
  36. package/dist/src/react/index.mjs.map +0 -1
  37. package/dist/src/react-native/index.d.mts +0 -7
  38. package/dist/src/react-native/index.d.mts.map +0 -1
  39. package/dist/src/react-native/index.mjs +0 -13
  40. package/dist/src/react-native/index.mjs.map +0 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @kasoa/vite-plus-config
2
2
 
3
- Strict Vite+ presets for formatting, linting, type checking, testing, packaging, and staged checks. Requires Node.js 24.11 or newer, Vite+ 0.2.8 or newer, and TypeScript 7.
3
+ Strict, composable Vite+ configuration fragments. Requires Node.js 24.11 or newer, Vite+ 0.2.8 or newer, and TypeScript 7.
4
4
 
5
5
  ## Installation
6
6
 
@@ -8,37 +8,176 @@ Strict Vite+ presets for formatting, linting, type checking, testing, packaging,
8
8
  pnpm add -D @kasoa/vite-plus-config vite-plus typescript@^7
9
9
  ```
10
10
 
11
- ## Presets
11
+ The `*Config` exports are plain Vite+ configuration fragments; lint profiles, file patterns, and pack defaults are plain data. `composeConfig()` applies Vite's `mergeConfig()` from left to right and calls `defineConfig()` once. Arrays therefore retain Vite's normal concatenation behavior. Use it once at the final config boundary rather than nesting composed results. The separate Cloudflare export contains the only other function because its test plugin requires consumer options.
12
12
 
13
- | Export | Use |
14
- | -------------------- | ----------------------------------------------- |
15
- | `base` | TypeScript applications and custom compositions |
16
- | `react` | Browser React applications |
17
- | `react-native` | React Native and Expo applications |
18
- | `node` | Node.js applications and tools |
19
- | `library` | ESM libraries built with `vp pack` |
20
- | `monorepo` | Workspace roots using Vite+ tasks |
21
- | `cloudflare-workers` | Node preset plus workerd-based Vitest wiring |
13
+ ## Node
22
14
 
23
- Create `vite.config.ts` with the matching factory:
15
+ ```ts
16
+ import {
17
+ baseToolingConfig,
18
+ composeConfig,
19
+ nodeRuntimeConfig,
20
+ nodeTestLintConfig,
21
+ } from "@kasoa/vite-plus-config";
22
+
23
+ export default composeConfig(baseToolingConfig, nodeRuntimeConfig, nodeTestLintConfig);
24
+ ```
25
+
26
+ ## React web
27
+
28
+ ```ts
29
+ import {
30
+ baseToolingConfig,
31
+ browserRuntimeConfig,
32
+ composeConfig,
33
+ nodeTestLintConfig,
34
+ reactCoreConfig,
35
+ reactDomConfig,
36
+ } from "@kasoa/vite-plus-config";
37
+
38
+ export default composeConfig(
39
+ baseToolingConfig,
40
+ browserRuntimeConfig,
41
+ reactCoreConfig,
42
+ reactDomConfig,
43
+ nodeTestLintConfig,
44
+ );
45
+ ```
46
+
47
+ The source runtime and test runtime are independent. The example uses Vitest's default Node runtime. For DOM-emulated tests, compose `browserTestLintConfig` instead and configure the matching Vitest environment explicitly. Test discovery uses Vite+/Vitest defaults; set `test.include` in a final fragment when a project needs a narrower scope.
48
+
49
+ ## React Native and Expo
50
+
51
+ ```ts
52
+ import {
53
+ baseToolingConfig,
54
+ composeConfig,
55
+ nodeTestLintConfig,
56
+ reactCoreConfig,
57
+ reactNativeGeneratedConfig,
58
+ reactNativeRuntimeConfig,
59
+ } from "@kasoa/vite-plus-config";
60
+
61
+ export default composeConfig(
62
+ baseToolingConfig,
63
+ reactCoreConfig,
64
+ reactNativeRuntimeConfig,
65
+ reactNativeGeneratedConfig,
66
+ nodeTestLintConfig,
67
+ );
68
+ ```
69
+
70
+ The native fragment permits React Native's `__DEV__` and Expo's statically replaced `process.env`, rejects DOM and Worker globals, excludes DOM accessibility rules, and ignores `.expo` output.
71
+
72
+ ## Libraries and workspaces
73
+
74
+ Packaging and workspace behavior are independent fragments:
75
+
76
+ ```ts
77
+ import {
78
+ baseToolingConfig,
79
+ composeConfig,
80
+ libraryPackConfig,
81
+ nodeRuntimeConfig,
82
+ nodeTestLintConfig,
83
+ } from "@kasoa/vite-plus-config";
84
+
85
+ export default composeConfig(
86
+ baseToolingConfig,
87
+ nodeRuntimeConfig,
88
+ nodeTestLintConfig,
89
+ libraryPackConfig,
90
+ {
91
+ pack: {
92
+ entry: {
93
+ "src/index": "./src/index.ts",
94
+ },
95
+ },
96
+ },
97
+ );
98
+ ```
99
+
100
+ Use `workspaceRunConfig` at a workspace root. Vite+ applies the root lint configuration to workspace-wide checks, so model package runtimes with the exported lint profiles in root `lint.overrides`:
24
101
 
25
102
  ```ts
26
- import { createConfig } from "@kasoa/vite-plus-config/react";
103
+ import {
104
+ RUNTIME_OVERRIDE_EXCLUDE_FILES,
105
+ baseToolingConfig,
106
+ cloudflareWorkerGeneratedConfig,
107
+ cloudflareWorkerLint,
108
+ composeConfig,
109
+ nodeTestLintConfig,
110
+ reactNativeGeneratedConfig,
111
+ reactNativeLint,
112
+ reactWebLint,
113
+ workspaceRunConfig,
114
+ } from "@kasoa/vite-plus-config";
27
115
 
28
- export default createConfig();
116
+ export default composeConfig(
117
+ baseToolingConfig,
118
+ reactNativeGeneratedConfig,
119
+ cloudflareWorkerGeneratedConfig,
120
+ nodeTestLintConfig,
121
+ workspaceRunConfig,
122
+ {
123
+ lint: {
124
+ overrides: [
125
+ {
126
+ files: ["apps/mobile/**"],
127
+ excludeFiles: [...RUNTIME_OVERRIDE_EXCLUDE_FILES],
128
+ ...reactNativeLint,
129
+ },
130
+ {
131
+ files: ["apps/server/**"],
132
+ excludeFiles: [...RUNTIME_OVERRIDE_EXCLUDE_FILES],
133
+ ...cloudflareWorkerLint,
134
+ },
135
+ {
136
+ files: ["packages/web/**"],
137
+ excludeFiles: [...RUNTIME_OVERRIDE_EXCLUDE_FILES],
138
+ ...reactWebLint,
139
+ },
140
+ ],
141
+ },
142
+ },
143
+ );
29
144
  ```
30
145
 
31
- ### React Native and Expo
146
+ `reactWebLint` and `reactNativeLint` are complete, plain Oxlint profiles for the common single-override case. Their lower-level runtime and React profiles remain available when a workspace needs separate scopes. Package configs still own local test, build, and pack wiring. For multiple pack operations, spread `libraryPackDefaults` into each entry instead of composing `libraryPackConfig` with a pack array.
147
+
148
+ ## Mixed runtimes
149
+
150
+ The exported lint profiles are ordinary Oxlint override objects:
32
151
 
33
152
  ```ts
34
- import { createConfig } from "@kasoa/vite-plus-config/react-native";
153
+ import {
154
+ baseToolingConfig,
155
+ cloudflareWorkerGeneratedConfig,
156
+ cloudflareWorkerRuntimeConfig,
157
+ composeConfig,
158
+ nodeLint,
159
+ } from "@kasoa/vite-plus-config";
35
160
 
36
- export default createConfig();
161
+ export default composeConfig(
162
+ baseToolingConfig,
163
+ cloudflareWorkerRuntimeConfig,
164
+ cloudflareWorkerGeneratedConfig,
165
+ {
166
+ lint: {
167
+ overrides: [
168
+ {
169
+ files: ["scripts/**", "evals/**"],
170
+ ...nodeLint,
171
+ },
172
+ ],
173
+ },
174
+ },
175
+ );
37
176
  ```
38
177
 
39
- The native preset rejects DOM globals, permits Expo's statically replaced `process.env` and React Native's `__DEV__`, excludes DOM accessibility rules, and ignores `.expo` output. It does not ignore `android` or `ios`, which may be project-owned source.
178
+ Configuration and CommonJS files receive the Node profile from `baseToolingConfig` automatically. A broad workspace override should use `RUNTIME_OVERRIDE_EXCLUDE_FILES` so those files and tests remain under their narrower execution boundaries.
40
179
 
41
- ### Cloudflare Workers tests
180
+ ## Cloudflare Workers tests
42
181
 
43
182
  Install the optional peers:
44
183
 
@@ -47,47 +186,79 @@ pnpm add -D @cloudflare/vitest-pool-workers wrangler
47
186
  ```
48
187
 
49
188
  ```ts
50
- import { createConfig } from "@kasoa/vite-plus-config/cloudflare-workers";
189
+ import {
190
+ baseToolingConfig,
191
+ cloudflareWorkerGeneratedConfig,
192
+ cloudflareWorkerRuntimeConfig,
193
+ cloudflareWorkerTestLintConfig,
194
+ composeConfig,
195
+ } from "@kasoa/vite-plus-config";
196
+ import { createCloudflareTestConfig } from "@kasoa/vite-plus-config/cloudflare-workers";
51
197
 
52
- export default createConfig({
53
- miniflare: {
54
- bindings: {
55
- CORS_ALLOWED_ORIGINS: "",
198
+ export default composeConfig(
199
+ baseToolingConfig,
200
+ cloudflareWorkerRuntimeConfig,
201
+ cloudflareWorkerGeneratedConfig,
202
+ cloudflareWorkerTestLintConfig,
203
+ createCloudflareTestConfig({
204
+ miniflare: {
205
+ bindings: {
206
+ CORS_ALLOWED_ORIGINS: "",
207
+ },
56
208
  },
57
- },
58
- test: {
59
- provide: {
60
- d1Migrations: [],
209
+ }),
210
+ {
211
+ test: {
212
+ provide: {
213
+ d1Migrations: [],
214
+ },
61
215
  },
62
216
  },
63
- });
217
+ );
64
218
  ```
65
219
 
66
- Wrangler owns Worker development, builds, type generation, and deployment. Vite+ owns static checks and workerd tests. Consumers retain ownership of bindings, migrations, setup files, coverage, and `test.provide` values.
220
+ Wrangler owns Worker development, builds, type generation, and deployment. Vite+ owns checks and workerd tests.
67
221
 
68
222
  ## Overrides
69
223
 
70
- Pass project-specific overrides to the factory. Lint rule tuples are replaced atomically; other arrays follow Vite's merge behavior.
224
+ Preset rules are inherited through Oxlint, so an ordinary final rule replaces a preset tuple atomically:
71
225
 
72
226
  ```ts
73
- import { createConfig } from "@kasoa/vite-plus-config/react";
227
+ import { baseToolingConfig, composeConfig, nodeRuntimeConfig } from "@kasoa/vite-plus-config";
74
228
 
75
- export default createConfig({
229
+ export default composeConfig(baseToolingConfig, nodeRuntimeConfig, {
76
230
  lint: {
77
231
  rules: {
78
232
  complexity: "off",
79
233
  "max-params": ["warn", { max: 5 }],
80
234
  },
81
235
  },
82
- test: {
83
- coverage: {
84
- reporter: ["text", "html"],
85
- },
86
- },
87
236
  });
88
237
  ```
89
238
 
90
- The React presets report React Compiler violations, but linting does not install or enable compiler transforms. Configure the compiler separately in applications that use it.
239
+ To change a scoped test rule, construct that test fragment directly instead of composing the default one:
240
+
241
+ ```ts
242
+ import type { ConfigFragment } from "@kasoa/vite-plus-config";
243
+ import { TEST_FILES, nodeTestLint } from "@kasoa/vite-plus-config";
244
+
245
+ const testLintConfig = {
246
+ lint: {
247
+ overrides: [
248
+ {
249
+ files: [...TEST_FILES],
250
+ ...nodeTestLint,
251
+ rules: {
252
+ ...nodeTestLint.rules,
253
+ "vitest/padding-around-test-blocks": "off",
254
+ },
255
+ },
256
+ ],
257
+ },
258
+ } satisfies ConfigFragment;
259
+ ```
260
+
261
+ React fragments report React Compiler violations but do not install or enable compiler transforms.
91
262
 
92
263
  ## Commands
93
264
 
@@ -97,9 +268,7 @@ vp check --fix
97
268
  vp test
98
269
  ```
99
270
 
100
- Use path arguments for focused iteration and run the complete command before committing. Import Vitest APIs from `vite-plus/test`.
101
-
102
- `vp config` generates commit hooks from the preset's staged-check configuration.
271
+ Import Vitest APIs from `vite-plus/test`. Use `vp config` to generate commit hooks from the staged-check fragment.
103
272
 
104
273
  ## License
105
274
 
@@ -0,0 +1,14 @@
1
+ import { UserConfig } from "vite-plus";
2
+ //#region src/compose.d.ts
3
+ interface NamedPlugin {
4
+ readonly name: string;
5
+ }
6
+ type PluginValue = NamedPlugin | false | null | undefined;
7
+ type PluginInput = PluginValue | readonly PluginValue[];
8
+ type ConfigFragment = Omit<UserConfig, "plugins"> & {
9
+ readonly plugins?: readonly PluginInput[];
10
+ };
11
+ declare function composeConfig(...fragments: readonly ConfigFragment[]): UserConfig;
12
+ //#endregion
13
+ export { PluginInput as n, composeConfig as r, ConfigFragment as t };
14
+ //# sourceMappingURL=compose-Cichpffs.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose-Cichpffs.d.mts","names":[],"sources":["../src/compose.ts"],"mappings":";;UAGU;WACC;;KAGN,cAAc;KAEP,cAAc,uBAAuB;KAErC,iBAAiB,KAAK;WACvB,mBAAmB;;iBAQd,iBAAiB,oBAAoB,mBAAmB"}
@@ -0,0 +1,33 @@
1
+ //#region src/constants.ts
2
+ const CODE_FILES = ["**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts}"];
3
+ const COMMONJS_FILES = ["**/*.{cjs,cts}"];
4
+ const CONFIG_FILES = ["**/*.config.{js,jsx,ts,tsx,mjs,cjs,mts,cts}"];
5
+ const TEST_FILES = [
6
+ "**/test/**",
7
+ "**/tests/**",
8
+ "**/__tests__/**",
9
+ "**/*.{test,spec}.{js,jsx,ts,tsx,mjs,cjs,mts,cts}"
10
+ ];
11
+ const RUNTIME_OVERRIDE_EXCLUDE_FILES = [
12
+ ...COMMONJS_FILES,
13
+ ...CONFIG_FILES,
14
+ ...TEST_FILES
15
+ ];
16
+ const DEFAULT_IGNORE_PATTERNS = [
17
+ "node_modules/**",
18
+ "dist/**",
19
+ "dist-ssr/**",
20
+ "**/.wrangler/**",
21
+ "**/migrations/**",
22
+ "**/drizzle/migrations.js",
23
+ "**/drizzle/meta/*.json"
24
+ ];
25
+ const CLOUDFLARE_WORKER_IGNORE_PATTERNS = ["**/worker-configuration.d.ts"];
26
+ const REACT_NATIVE_IGNORE_PATTERNS = ["**/.expo/**"];
27
+ const DEFAULT_STAGED_CHECK_GLOB = "*.{js,jsx,ts,tsx,mjs,cjs,mts,cts}";
28
+ const DEFAULT_STAGED_CHECK_COMMAND = "vp check --fix";
29
+ const DEFAULT_WRANGLER_CONFIG_PATH = "./wrangler.jsonc";
30
+ //#endregion
31
+ export { DEFAULT_IGNORE_PATTERNS as a, DEFAULT_WRANGLER_CONFIG_PATH as c, TEST_FILES as d, CONFIG_FILES as i, REACT_NATIVE_IGNORE_PATTERNS as l, CODE_FILES as n, DEFAULT_STAGED_CHECK_COMMAND as o, COMMONJS_FILES as r, DEFAULT_STAGED_CHECK_GLOB as s, CLOUDFLARE_WORKER_IGNORE_PATTERNS as t, RUNTIME_OVERRIDE_EXCLUDE_FILES as u };
32
+
33
+ //# sourceMappingURL=constants-D2PDomKY.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants-D2PDomKY.mjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["export const CODE_FILES = [\"**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts}\"] as const;\nexport const COMMONJS_FILES = [\"**/*.{cjs,cts}\"] as const;\nexport const CONFIG_FILES = [\"**/*.config.{js,jsx,ts,tsx,mjs,cjs,mts,cts}\"] as const;\nexport const TEST_FILES = [\n \"**/test/**\",\n \"**/tests/**\",\n \"**/__tests__/**\",\n \"**/*.{test,spec}.{js,jsx,ts,tsx,mjs,cjs,mts,cts}\",\n] as const;\nexport const RUNTIME_OVERRIDE_EXCLUDE_FILES: readonly string[] = [\n ...COMMONJS_FILES,\n ...CONFIG_FILES,\n ...TEST_FILES,\n] as const;\n\nexport const DEFAULT_IGNORE_PATTERNS = [\n \"node_modules/**\",\n \"dist/**\",\n \"dist-ssr/**\",\n \"**/.wrangler/**\",\n \"**/migrations/**\",\n \"**/drizzle/migrations.js\",\n \"**/drizzle/meta/*.json\",\n] as const;\nexport const CLOUDFLARE_WORKER_IGNORE_PATTERNS = [\"**/worker-configuration.d.ts\"] as const;\nexport const REACT_NATIVE_IGNORE_PATTERNS = [\"**/.expo/**\"] as const;\n\nexport const DEFAULT_STAGED_CHECK_GLOB = \"*.{js,jsx,ts,tsx,mjs,cjs,mts,cts}\";\nexport const DEFAULT_STAGED_CHECK_COMMAND = \"vp check --fix\";\nexport const DEFAULT_WRANGLER_CONFIG_PATH = \"./wrangler.jsonc\";\n"],"mappings":";AAAA,MAAa,aAAa,CAAC,sCAAsC;AACjE,MAAa,iBAAiB,CAAC,gBAAgB;AAC/C,MAAa,eAAe,CAAC,6CAA6C;AAC1E,MAAa,aAAa;CACxB;CACA;CACA;CACA;AACF;AACA,MAAa,iCAAoD;CAC/D,GAAG;CACH,GAAG;CACH,GAAG;AACL;AAEA,MAAa,0BAA0B;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AACA,MAAa,oCAAoC,CAAC,8BAA8B;AAChF,MAAa,+BAA+B,CAAC,aAAa;AAE1D,MAAa,4BAA4B;AACzC,MAAa,+BAA+B;AAC5C,MAAa,+BAA+B"}
@@ -1,15 +1,11 @@
1
- import { t as ConfigInput } from "../../config-Cxe-N0iS.mjs";
2
- import { UserConfig } from "vite-plus";
1
+ import { t as ConfigFragment } from "../../compose-Cichpffs.mjs";
3
2
  import { cloudflareTest } from "@cloudflare/vitest-pool-workers";
4
3
  //#region src/cloudflare-workers/index.d.ts
5
- type CloudflareWorkersPluginOptions = Exclude<NonNullable<Parameters<typeof cloudflareTest>[0]>, (...args: readonly never[]) => unknown>;
6
- interface CloudflareWorkersConfigOptions extends Omit<CloudflareWorkersPluginOptions, "wrangler"> {
7
- readonly config?: ConfigInput;
8
- readonly include?: readonly string[];
9
- readonly test?: UserConfig["test"];
10
- readonly wrangler?: CloudflareWorkersPluginOptions["wrangler"];
4
+ type CloudflareTestOptions = Exclude<NonNullable<Parameters<typeof cloudflareTest>[0]>, (...args: readonly never[]) => unknown>;
5
+ interface CloudflareTestConfigOptions extends Omit<CloudflareTestOptions, "wrangler"> {
6
+ readonly wrangler?: CloudflareTestOptions["wrangler"];
11
7
  }
12
- declare function createCloudflareWorkersConfig(options?: CloudflareWorkersConfigOptions): UserConfig;
8
+ declare function createCloudflareTestConfig(options?: CloudflareTestConfigOptions): ConfigFragment;
13
9
  //#endregion
14
- export { CloudflareWorkersConfigOptions, createCloudflareWorkersConfig, createCloudflareWorkersConfig as createConfig };
10
+ export { CloudflareTestConfigOptions, createCloudflareTestConfig };
15
11
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/cloudflare-workers/index.ts"],"mappings":";;;;KAWK,iCAAiC,QACpC,YAAY,kBAAkB,yBAC1B;UAGW,uCAAuC,KACtD;WAGS,SAAS;WACT;WACA,OAAO;WACP,WAAW;;iBAGN,8BACd,UAAS,iCACR"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/cloudflare-workers/index.ts"],"mappings":";;;KAOK,wBAAwB,QAC3B,YAAY,kBAAkB,yBAC1B;UAGW,oCAAoC,KAAK;WAC/C,WAAW;;iBAUN,2BACd,UAAS,8BACR"}
@@ -1,19 +1,21 @@
1
- import { c as createDefinedConfig, l as createLazyPluginInputs, s as DEFAULT_WRANGLER_CONFIG_PATH, u as mergeConfigFragments } from "../../base-7cyIJaBC.mjs";
2
- import { createConfig as createNodeConfig } from "../node/index.mjs";
1
+ import { c as DEFAULT_WRANGLER_CONFIG_PATH } from "../../constants-D2PDomKY.mjs";
2
+ import { lazyPlugins } from "vite-plus";
3
3
  import { cloudflareTest } from "@cloudflare/vitest-pool-workers";
4
4
  //#region src/cloudflare-workers/index.ts
5
- function createCloudflareWorkersConfig(options = {}) {
6
- const { config = {}, include, test, wrangler, ...testPluginOptions } = options;
7
- const cloudflareTestConfig = createDefinedConfig({ plugins: createLazyPluginInputs(() => [cloudflareTest({
8
- ...testPluginOptions,
5
+ function createLazyPluginInputs(factory) {
6
+ return lazyPlugins(factory);
7
+ }
8
+ function createCloudflareTestConfig(options = {}) {
9
+ const { wrangler, ...pluginOptions } = options;
10
+ return { plugins: createLazyPluginInputs(() => [cloudflareTest({
11
+ ...pluginOptions,
9
12
  wrangler: {
10
13
  configPath: DEFAULT_WRANGLER_CONFIG_PATH,
11
14
  ...wrangler
12
15
  }
13
- })]) }, include === void 0 ? {} : { test: { include: [...include] } }, { test });
14
- return createNodeConfig(mergeConfigFragments(cloudflareTestConfig, config));
16
+ })]) };
15
17
  }
16
18
  //#endregion
17
- export { createCloudflareWorkersConfig, createCloudflareWorkersConfig as createConfig };
19
+ export { createCloudflareTestConfig };
18
20
 
19
21
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/cloudflare-workers/index.ts"],"sourcesContent":["import type { UserConfig } from \"vite-plus\";\nimport { cloudflareTest } from \"@cloudflare/vitest-pool-workers\";\nimport type { ConfigInput } from \"../shared/config.ts\";\nimport { createNodeConfig } from \"../node/index.ts\";\nimport {\n createDefinedConfig,\n createLazyPluginInputs,\n mergeConfigFragments,\n} from \"../shared/config.ts\";\nimport { DEFAULT_WRANGLER_CONFIG_PATH } from \"../shared/constants.ts\";\n\ntype CloudflareWorkersPluginOptions = Exclude<\n NonNullable<Parameters<typeof cloudflareTest>[0]>,\n (...args: readonly never[]) => unknown\n>;\n\nexport interface CloudflareWorkersConfigOptions extends Omit<\n CloudflareWorkersPluginOptions,\n \"wrangler\"\n> {\n readonly config?: ConfigInput;\n readonly include?: readonly string[];\n readonly test?: UserConfig[\"test\"];\n readonly wrangler?: CloudflareWorkersPluginOptions[\"wrangler\"];\n}\n\nexport function createCloudflareWorkersConfig(\n options: CloudflareWorkersConfigOptions = {},\n): UserConfig {\n const { config = {}, include, test, wrangler, ...testPluginOptions } = options;\n const cloudflareTestConfig = createDefinedConfig(\n {\n plugins: createLazyPluginInputs(() => [\n cloudflareTest({\n ...testPluginOptions,\n wrangler: {\n configPath: DEFAULT_WRANGLER_CONFIG_PATH,\n ...wrangler,\n },\n }),\n ]),\n },\n include === undefined\n ? {}\n : {\n test: {\n include: [...include],\n },\n },\n {\n test,\n },\n );\n\n return createNodeConfig(mergeConfigFragments(cloudflareTestConfig, config));\n}\n\nexport { createCloudflareWorkersConfig as createConfig };\n"],"mappings":";;;;AA0BA,SAAgB,8BACd,UAA0C,CAAC,GAC/B;CACZ,MAAM,EAAE,SAAS,CAAC,GAAG,SAAS,MAAM,UAAU,GAAG,sBAAsB;CACvE,MAAM,uBAAuB,oBAC3B,EACE,SAAS,6BAA6B,CACpC,eAAe;EACb,GAAG;EACH,UAAU;GACR,YAAY;GACZ,GAAG;EACL;CACF,CAAC,CACH,CAAC,EACH,GACA,YAAY,KAAA,IACR,CAAC,IACD,EACE,MAAM,EACJ,SAAS,CAAC,GAAG,OAAO,EACtB,EACF,GACJ,EACE,KACF,CACF;CAEA,OAAO,iBAAiB,qBAAqB,sBAAsB,MAAM,CAAC;AAC5E"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/cloudflare-workers/index.ts"],"sourcesContent":["import { cloudflareTest } from \"@cloudflare/vitest-pool-workers\";\nimport { lazyPlugins } from \"vite-plus\";\nimport type { ConfigFragment } from \"../compose.ts\";\nimport { DEFAULT_WRANGLER_CONFIG_PATH } from \"../constants.ts\";\n\ntype LazyPluginInput = object | readonly object[] | false | null | undefined;\n\ntype CloudflareTestOptions = Exclude<\n NonNullable<Parameters<typeof cloudflareTest>[0]>,\n (...args: readonly never[]) => unknown\n>;\n\nexport interface CloudflareTestConfigOptions extends Omit<CloudflareTestOptions, \"wrangler\"> {\n readonly wrangler?: CloudflareTestOptions[\"wrangler\"];\n}\n\nfunction createLazyPluginInputs(\n factory: () => readonly LazyPluginInput[],\n): ConfigFragment[\"plugins\"] {\n // eslint-disable-next-line typescript/no-unsafe-type-assertion -- Vite 8 plugin types recurse beyond TypeScript's comparison limit; lazyPlugins returns the named Vite plugins represented by this shallow boundary.\n return lazyPlugins(factory as never) as ConfigFragment[\"plugins\"];\n}\n\nexport function createCloudflareTestConfig(\n options: CloudflareTestConfigOptions = {},\n): ConfigFragment {\n const { wrangler, ...pluginOptions } = options;\n\n return {\n plugins: createLazyPluginInputs(() => [\n cloudflareTest({\n ...pluginOptions,\n wrangler: {\n configPath: DEFAULT_WRANGLER_CONFIG_PATH,\n ...wrangler,\n },\n }),\n ]),\n };\n}\n"],"mappings":";;;;AAgBA,SAAS,uBACP,SAC2B;CAE3B,OAAO,YAAY,OAAgB;AACrC;AAEA,SAAgB,2BACd,UAAuC,CAAC,GACxB;CAChB,MAAM,EAAE,UAAU,GAAG,kBAAkB;CAEvC,OAAO,EACL,SAAS,6BAA6B,CACpC,eAAe;EACb,GAAG;EACH,UAAU;GACR,YAAY;GACZ,GAAG;EACL;CACF,CAAC,CACH,CAAC,EACH;AACF"}
@@ -0,0 +1,47 @@
1
+ import { n as PluginInput, r as composeConfig, t as ConfigFragment } from "../compose-Cichpffs.mjs";
2
+ import { UserConfig } from "vite-plus";
3
+ //#region src/constants.d.ts
4
+ declare const CODE_FILES: readonly ["**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts}"];
5
+ declare const COMMONJS_FILES: readonly ["**/*.{cjs,cts}"];
6
+ declare const CONFIG_FILES: readonly ["**/*.config.{js,jsx,ts,tsx,mjs,cjs,mts,cts}"];
7
+ declare const TEST_FILES: readonly ["**/test/**", "**/tests/**", "**/__tests__/**", "**/*.{test,spec}.{js,jsx,ts,tsx,mjs,cjs,mts,cts}"];
8
+ declare const RUNTIME_OVERRIDE_EXCLUDE_FILES: readonly string[];
9
+ //#endregion
10
+ //#region src/fragments.d.ts
11
+ type PackConfig = Exclude<UserConfig["pack"], readonly unknown[] | undefined>;
12
+ declare const baseToolingConfig: ConfigFragment;
13
+ declare const nodeRuntimeConfig: ConfigFragment;
14
+ declare const browserRuntimeConfig: ConfigFragment;
15
+ declare const reactCoreConfig: ConfigFragment;
16
+ declare const reactDomConfig: ConfigFragment;
17
+ declare const reactNativeRuntimeConfig: ConfigFragment;
18
+ declare const reactNativeGeneratedConfig: ConfigFragment;
19
+ declare const cloudflareWorkerRuntimeConfig: ConfigFragment;
20
+ declare const cloudflareWorkerGeneratedConfig: ConfigFragment;
21
+ declare const nodeTestLintConfig: ConfigFragment;
22
+ declare const browserTestLintConfig: ConfigFragment;
23
+ declare const cloudflareWorkerTestLintConfig: ConfigFragment;
24
+ declare const libraryPackDefaults: PackConfig;
25
+ declare const libraryPackConfig: ConfigFragment;
26
+ declare const workspaceRunConfig: ConfigFragment;
27
+ //#endregion
28
+ //#region src/lint/types.d.ts
29
+ type LintConfig = NonNullable<UserConfig["lint"]>;
30
+ type LintOverride = NonNullable<LintConfig["overrides"]>[number];
31
+ type LintProfile = Omit<LintOverride, "excludeFiles" | "files">;
32
+ //#endregion
33
+ //#region src/lint/profiles.d.ts
34
+ declare const nodeLint: LintProfile;
35
+ declare const browserLint: LintProfile;
36
+ declare const reactCoreLint: LintProfile;
37
+ declare const reactDomLint: LintProfile;
38
+ declare const reactNativeRuntimeLint: LintProfile;
39
+ declare const reactWebLint: LintProfile;
40
+ declare const reactNativeLint: LintProfile;
41
+ declare const cloudflareWorkerLint: LintProfile;
42
+ declare const nodeTestLint: LintProfile;
43
+ declare const browserTestLint: LintProfile;
44
+ declare const cloudflareWorkerTestLint: LintProfile;
45
+ //#endregion
46
+ export { CODE_FILES, COMMONJS_FILES, CONFIG_FILES, type ConfigFragment, type PluginInput, RUNTIME_OVERRIDE_EXCLUDE_FILES, TEST_FILES, baseToolingConfig, browserLint, browserRuntimeConfig, browserTestLint, browserTestLintConfig, cloudflareWorkerGeneratedConfig, cloudflareWorkerLint, cloudflareWorkerRuntimeConfig, cloudflareWorkerTestLint, cloudflareWorkerTestLintConfig, composeConfig, libraryPackConfig, libraryPackDefaults, nodeLint, nodeRuntimeConfig, nodeTestLint, nodeTestLintConfig, reactCoreConfig, reactCoreLint, reactDomConfig, reactDomLint, reactNativeGeneratedConfig, reactNativeLint, reactNativeRuntimeConfig, reactNativeRuntimeLint, reactWebLint, workspaceRunConfig };
47
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/constants.ts","../../src/fragments.ts","../../src/lint/types.ts","../../src/lint/profiles.ts"],"mappings":";;;cAAa;cACA;cACA;cACA;cAMA;;;KCeR,aAAa,QAAQ;cAEb,mBAAmB;cAQnB,mBAAmB;cAInB,sBAAsB;cAItB,iBAAiB;cAKjB,gBAAgB;cAIhB,0BAA0B;cAI1B,4BAA4B;cAK5B,+BAA+B;cAI/B,iCAAiC;cAKjC,oBAAoB;cAIpB,uBAAuB;cAIvB,gCAAgC;cAIhC,qBAAqB;cAOrB,mBAAmB;cAInB,oBAAoB;;;KC1FrB,aAAa,YAAY;KACzB,eAAe,YAAY;KAC3B,cAAc,KAAK;;;cCoElB,UAAU;cAOV,aAAa;cAOb,eAAe;cAKf,cAAc;cAiDd,wBAAwB;cAOxB,cAAc;cAWd,iBAAiB;cAUjB,sBAAsB;cAMtB,cAAc;cASd,iBAAiB;cASjB,0BAA0B"}