mirror of
https://github.com/cloudflare/vinext.git
synced 2026-09-14 19:04:59 +08:00
52c81f3c5f
* feat: support the React Compiler via react: { compiler: true }
@vitejs/plugin-react 6.1.0 added an experimental `compiler` option backed by
oxc-transform-react. vinext already forwards its `react` option to that plugin,
but enabling the compiler broke the build for apps with JSX in plain `.js`
files: `vite:react-compiler` and `vinext:jsx-in-js` both run at `enforce: "pre"`
and the React plugin was registered first, so the compiler parsed those files as
plain JS and failed with `Unexpected JSX expression`.
Register `vinext:jsx-in-js` before `@vitejs/plugin-react`, bump the plugin-react
catalog entry to ^6.1.0, add oxc-transform-react as a dev dependency for the
tests, and document the option.
* fix: fail fast when react.compiler is set on plugin-react 6.0
Addresses review feedback.
@vitejs/plugin-react 6.0 accepts an unknown `compiler` key and drops it, and it
still satisfies vinext's published peer range, so a project that upgrades vinext
without upgrading the plugin would silently get no React Compiler. Probe the
plugin list the factory returns and throw an actionable error when the compiler
plugin is missing.
Also drops the hand-authored changeset: AGENTS.md says changesets are generated
from Conventional Commits in CI.
* fix: keep the compiler version error out of the import failure wrapper
Addresses review feedback.
The trailing `.catch()` wrapped every rejection from the plugin-react promise
chain, including the compiler version check, so the actionable message and its
install command were demoted to a nested `cause` behind
`vinext: Failed to load @vitejs/plugin-react.`. Attach the wrapper to the
dynamic import itself so only genuine import failures are relabeled.
* fix: move only the compiler plugin instead of the whole React group
Addresses review feedback.
Reordering the entire @vitejs/plugin-react group put `vinext:jsx-in-js` ahead of
`vite:react-babel`, so on plugin-react 5.x, which is still in the supported peer
range and does expose a `babel` option, a user-configured Babel transform would
stop seeing JSX in plain `.js` files. Split `vite:react-compiler` out of the
group and register just that plugin after `vinext:jsx-in-js`. Every other plugin
keeps the position it had before this PR.
Also documents that components using `<style jsx>` are not memoized, since
`vinext:styled-jsx` lowers their JSX through the Next.js SWC transform first.
Running the compiler ahead of it is not an option: the styled-jsx plugin selects
modules by matching `<style` in the source, and lowered JSX no longer matches,
which would silently disable styled-jsx entirely.
* fix(ci): account for React Compiler test dependency
---------
Co-authored-by: James <james@eli.cx>
56 lines
2.2 KiB
JSON
56 lines
2.2 KiB
JSON
{
|
|
"name": "vinext-monorepo",
|
|
"private": true,
|
|
"scripts": {
|
|
"build": "vp run @vinext/cloudflare#build && vp run vinext#build && vp run create-vinext-app#build",
|
|
"check": "vp check && node scripts/sync-next-types.mjs --check && node scripts/check-shim-types.mjs",
|
|
"test": "vp test run",
|
|
"test:unit": "vp test run --project unit",
|
|
"test:integration": "vp test run --project integration",
|
|
"test:watch": "vp test",
|
|
"vite-ecosystem-ci:before-install": "pnpm config set frozen-lockfile false --location project",
|
|
"vite-ecosystem-ci:build": "vp run vinext#build",
|
|
"vite-ecosystem-ci:test": "vp test run --project unit tests/build-optimization.test.ts tests/client-assets-build.test.ts && vp test run --project integration tests/app-router-rsc-plugin.test.ts tests/app-router-production-build.test.ts tests/vite-hmr-websocket.test.ts",
|
|
"sync:next-types": "node scripts/sync-next-types.mjs",
|
|
"check:next-types": "node scripts/sync-next-types.mjs --check && node scripts/check-shim-types.mjs",
|
|
"check:shim-types": "node scripts/check-shim-types.mjs",
|
|
"fmt": "vp fmt",
|
|
"fmt:check": "vp fmt --check",
|
|
"lint": "vp lint",
|
|
"test:e2e": "playwright test",
|
|
"knip": "knip",
|
|
"changeset": "changeset",
|
|
"prepare": "vp config",
|
|
"postinstall": "vp run @vinext/cloudflare#build && vp run vinext#build && vp run create-vinext-app#build && node scripts/typegen-workspaces.mjs"
|
|
},
|
|
"dependencies": {
|
|
"@mdx-js/react": "catalog:",
|
|
"@mdx-js/rollup": "catalog:"
|
|
},
|
|
"devDependencies": {
|
|
"@changesets/cli": "2.31.0",
|
|
"@mswjs/interceptors": "catalog:",
|
|
"@playwright/test": "catalog:",
|
|
"@sentry/nextjs": "catalog:",
|
|
"@types/node": "catalog:",
|
|
"@types/react": "catalog:",
|
|
"@types/react-dom": "catalog:",
|
|
"@vitejs/plugin-rsc": "catalog:",
|
|
"@vitest/coverage-istanbul": "catalog:",
|
|
"knip": "catalog:",
|
|
"msw": "catalog:",
|
|
"next": "catalog:",
|
|
"oxc-transform-react": "catalog:",
|
|
"pathslash": "catalog:",
|
|
"playwright": "catalog:",
|
|
"react": "catalog:",
|
|
"react-dom": "catalog:",
|
|
"sass": "catalog:",
|
|
"typescript": "catalog:",
|
|
"vite": "catalog:",
|
|
"vite-plus": "catalog:",
|
|
"vitest": "catalog:"
|
|
},
|
|
"packageManager": "pnpm@11.1.1"
|
|
}
|