From ce6d82e125bc65610b93733052d16859bb59329f Mon Sep 17 00:00:00 2001 From: honbin Date: Thu, 29 Oct 2026 21:50:44 +0900 Subject: [PATCH] fix(init): match the React starter's oxc-transform-react to @vitejs/plugin-react The React starter enables `react({ compiler: true })` and adds oxc-transform-react ^0.149.0, but @vitejs/plugin-react 6.1.2, which @void/react depends on, declares an optional peer of ^0.152.0. On 0.x that range is 0.152.x only, so new projects start with an invalid peer (`npm ls` reports it, and strict peer installs can fail). The range had drifted unnoticed since it was added, so a unit test now compares it with the installed plugin's peer and fails when a catalog bump moves it. --- packages/void/src/cli/template.ts | 2 +- packages/void/test/unit/init.test.ts | 2 +- packages/void/test/unit/template.test.ts | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 packages/void/test/unit/template.test.ts diff --git a/packages/void/src/cli/template.ts b/packages/void/src/cli/template.ts index 0a8e5546a..7bed5d191 100644 --- a/packages/void/src/cli/template.ts +++ b/packages/void/src/cli/template.ts @@ -48,7 +48,7 @@ export const SCAFFOLD_TOOLCHAIN_OPTIONS = [ ] as const; const REACT_SCAFFOLD_COMPILER_DEV_DEPENDENCIES = { - 'oxc-transform-react': '^0.149.0', + 'oxc-transform-react': '^0.152.0', } as const; export const SCAFFOLD_FRAMEWORK_OPTIONS = [ diff --git a/packages/void/test/unit/init.test.ts b/packages/void/test/unit/init.test.ts index c7ab8394d..fdf51b484 100644 --- a/packages/void/test/unit/init.test.ts +++ b/packages/void/test/unit/init.test.ts @@ -2821,7 +2821,7 @@ export default config; expect(pkg.devDependencies.vite).toBe('npm:@voidzero-dev/vite-plus-core@^1.3.0'); expect(pkg.devDependencies.void).toBe('^0.2.3'); expect(pkg.devDependencies['@void/react']).toBe('^0.2.3'); - expect(pkg.devDependencies['oxc-transform-react']).toBe('^0.149.0'); + expect(pkg.devDependencies['oxc-transform-react']).toBe('^0.152.0'); expectPnpmAllowBuilds(root); const reactViteConfig = readFileSync(join(root, 'vite.config.ts'), 'utf-8'); diff --git a/packages/void/test/unit/template.test.ts b/packages/void/test/unit/template.test.ts new file mode 100644 index 000000000..0e5de128c --- /dev/null +++ b/packages/void/test/unit/template.test.ts @@ -0,0 +1,21 @@ +import { readFileSync } from 'node:fs'; +import { findPackageJSON } from 'node:module'; +import { describe, expect, it } from 'vite-plus/test'; +import { SCAFFOLD_FRAMEWORKS } from '../../src/cli/template.ts'; + +describe('React starter', () => { + // The starter copies this range from the optional peer of the @vitejs/plugin-react that + // @void/react installs, so a catalog bump that moves the peer must update the starter too. + it("pins oxc-transform-react to @vitejs/plugin-react's peer range", () => { + const pluginReactManifest = findPackageJSON( + '@vitejs/plugin-react', + new URL('../../../react/package.json', import.meta.url), + ); + expect(pluginReactManifest).toBeDefined(); + const pluginReact = JSON.parse(readFileSync(pluginReactManifest!, 'utf-8')); + + expect(SCAFFOLD_FRAMEWORKS.react.devDependencies?.['oxc-transform-react']).toBe( + pluginReact.peerDependencies['oxc-transform-react'], + ); + }); +});