@acusti/vite-plugin-react-compiler 0.4.0 → 0.6.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.
- package/README.md +27 -26
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -20,25 +20,27 @@ production.
|
|
|
20
20
|
|
|
21
21
|
## Why this exists
|
|
22
22
|
|
|
23
|
-
Vite
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
compiler pass
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
23
|
+
Vite ships a native React Compiler integration now: as of
|
|
24
|
+
`@vitejs/plugin-react` 6.1, passing `compiler: true` runs
|
|
25
|
+
[oxc-transform-react][] — the same Rust bindings this plugin uses — instead
|
|
26
|
+
of Babel. For a plain Vite + React app, that flag is the whole story; this
|
|
27
|
+
plugin has nothing to add.
|
|
28
|
+
|
|
29
|
+
The catch is that `compiler: true` is an option of `@vitejs/plugin-react`
|
|
30
|
+
itself, and plenty of setups don’t run that plugin. React Router in
|
|
31
|
+
framework mode is the common case: it runs `@react-router/dev/vite` in
|
|
32
|
+
place of `@vitejs/plugin-react`, which means no `compiler: true`, and no
|
|
33
|
+
`reactCompilerPreset` Babel fallback either, since that’s
|
|
34
|
+
`@vitejs/plugin-react`’s too. Swap in a different React/JSX plugin and
|
|
35
|
+
native React Compiler support goes with it.
|
|
36
|
+
|
|
37
|
+
This plugin is the compiler pass, decoupled from `@vitejs/plugin-react` so
|
|
38
|
+
it can run under any of them: a `transform`-hook plugin that calls
|
|
39
|
+
oxc-transform-react directly, with `enforce: 'pre'` (the position
|
|
40
|
+
`@vitejs/plugin-react`’s own native pass occupies) and emits JSX untouched
|
|
41
|
+
(`jsx: 'preserve'`), so whatever plugin is handling JSX/refresh downstream
|
|
42
|
+
stays in charge of that. (oxc-transform-react strips TypeScript syntax
|
|
43
|
+
itself, matching how the Babel path uses @babel/preset-typescript.)
|
|
42
44
|
|
|
43
45
|
## Usage
|
|
44
46
|
|
|
@@ -60,24 +62,23 @@ pins the newest version that passes this repo’s test suite and ships it in
|
|
|
60
62
|
regular plugin releases. If you need a different version, use your package
|
|
61
63
|
manager’s `overrides` (npm, pnpm, bun) or `resolutions` (yarn) to force it.
|
|
62
64
|
|
|
63
|
-
Like [@acusti/vite-plugin-svg-react][], this plugin requires Vite ≥ 8
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
Like [@acusti/vite-plugin-svg-react][], this plugin requires Vite ≥ 8: it
|
|
66
|
+
plugs into the native oxc/rolldown transform pipeline that Vite 8
|
|
67
|
+
introduced, and doesn’t work without it.
|
|
66
68
|
|
|
67
69
|
[@acusti/vite-plugin-svg-react]:
|
|
68
70
|
https://www.npmjs.com/package/@acusti/vite-plugin-svg-react
|
|
69
71
|
|
|
70
|
-
Add the plugin to your vite config
|
|
71
|
-
Compiler wiring, e.g. `reactCompilerPreset` + @rolldown/plugin-babel):
|
|
72
|
+
Add the plugin to your vite config alongside your other Vite plugins:
|
|
72
73
|
|
|
73
74
|
```ts
|
|
74
75
|
// vite.config.ts
|
|
76
|
+
import { reactRouter } from '@react-router/dev/vite';
|
|
75
77
|
import reactCompiler from '@acusti/vite-plugin-react-compiler';
|
|
76
|
-
import react from '@vitejs/plugin-react';
|
|
77
78
|
import { defineConfig } from 'vite';
|
|
78
79
|
|
|
79
80
|
export default defineConfig({
|
|
80
|
-
plugins: [
|
|
81
|
+
plugins: [reactRouter(), reactCompiler()],
|
|
81
82
|
});
|
|
82
83
|
```
|
|
83
84
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acusti/vite-plugin-react-compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Vite plugin that runs React Compiler via oxc-transform-react, the native Rust port’s Node bindings, instead of Babel",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"memoization",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"tsc": "tsc --noEmit"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"oxc-transform-react": "0.
|
|
44
|
+
"oxc-transform-react": "0.150.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/node": "^26.1.0",
|
|
48
48
|
"typescript": "^7",
|
|
49
49
|
"vite": "^8",
|
|
50
|
-
"vitest": "^
|
|
50
|
+
"vitest": "^5"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"vite": ">=8.0.0"
|