@rexezuge/tooling 1.6.0 → 1.7.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.
@@ -66,6 +66,23 @@ export const DEFAULT_CLOUDFLARE_MOCKS: readonly string[] = ['workers', 'sockets'
66
66
  */
67
67
  export const KIT_NO_EXTERNAL: readonly RegExp[] = [/(^|[/\\])@rexezuge\//];
68
68
 
69
+ /**
70
+ * Bare specifiers the kit and its consumer must resolve to **one** copy.
71
+ *
72
+ * Every entry is a peer of a kit package rather than a dependency, which is
73
+ * exactly why it is needed: a peer is not installed twice under a registry
74
+ * install, so the two sides already agree. A `link:` install breaks that
75
+ * agreement — the symlinked package directory carries its own `node_modules`, and
76
+ * with `@rexezuge/*` inlined into Vite's pipeline (see {@link KIT_NO_EXTERNAL})
77
+ * the kit's copy wins for its own imports while the consumer's wins for the app's.
78
+ *
79
+ * Two Reacts is not a warning: `useState` is read off a module-level hook
80
+ * dispatcher that only one of them initialises, so every hook inside a kit
81
+ * component throws `Cannot read properties of null (reading 'useState')`. The
82
+ * failure names the kit, and the cause is the install layout.
83
+ */
84
+ export const KIT_DEDUPE: readonly string[] = ['react', 'react-dom', 'react/jsx-runtime', 'lucide-react'];
85
+
69
86
  /**
70
87
  * What `workspaceAliases` accepts.
71
88
  */
package/src/vitest.ts CHANGED
@@ -34,7 +34,7 @@
34
34
  */
35
35
 
36
36
  import { defineConfig, type Plugin } from 'vitest/config';
37
- import { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';
37
+ import { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_DEDUPE, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';
38
38
  import type { VitestAlias } from './vitest-aliases.ts';
39
39
 
40
40
  export type { VitestAlias } from './vitest-aliases.ts';
@@ -198,7 +198,19 @@ export function defineUnitVitestConfig(options: UnitVitestConfigOptions = {}): R
198
198
 
199
199
  return defineConfig({
200
200
  ...(options.plugins !== undefined && { plugins: [...options.plugins] }),
201
- resolve: { alias: aliases, noExternal: [...KIT_NO_EXTERNAL, ...(options.noExternal ?? [])] },
201
+ resolve: {
202
+ alias: aliases,
203
+ noExternal: [...KIT_NO_EXTERNAL, ...(options.noExternal ?? [])],
204
+ // The peer runtime a consumer and the kit must agree on. `@rexezuge/web`
205
+ // declares `react`, `react-dom` and `lucide-react` as peers, which under a
206
+ // registry install means neither package carries its own copy. Under the
207
+ // `link:` workflow this repo's own README recommends, the symlinked
208
+ // directory **does** have one — so the kit resolves its own React and the
209
+ // consumer resolves theirs, and every hook in a kit component throws
210
+ // `Cannot read properties of null (reading 'useState')`. Dedupe points the
211
+ // bare specifier at one copy for both.
212
+ dedupe: [...KIT_DEDUPE],
213
+ },
202
214
  test: {
203
215
  globals: true,
204
216
  environment: 'node',