@acusti/vite-plugin-react-compiler 0.5.0 → 0.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.
Files changed (2) hide show
  1. package/README.md +27 -26
  2. 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/Rolldown decided against shipping the Rust React Compiler integration
24
- in Vite core over the binary size it would add, so the official React
25
- Compiler path for Vite remains Babel: @vitejs/plugin-react’s
26
- `reactCompilerPreset` running babel-plugin-react-compiler via
27
- [@rolldown/plugin-babel][]. That works, but it drags a full Babel
28
- parse/transform/print pipeline through every source file of an otherwise
29
- all-native oxc/rolldown build.
30
-
31
- This plugin is the published native alternative: a `transform`-hook plugin
32
- that calls [oxc-transform-react][], the Rust React Compiler bindings the
33
- oxc project publishes. The compiler pass runs with `enforce: 'pre'` (the
34
- same position the Babel pass occupies today) and emits JSX untouched
35
- (`jsx: 'preserve'`), so Vite’s own oxc transform stays in charge of
36
- JSX/refresh/TypeScript handling downstream — the plugin only adds the
37
- compiler pass. (oxc-transform-react does strip TypeScript syntax, which
38
- matches how the Babel path uses @babel/preset-typescript.)
39
-
40
- [@rolldown/plugin-babel]:
41
- https://www.npmjs.com/package/@rolldown/plugin-babel
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, on
64
- purpose: its reason for existing is completing the all-native oxc/rolldown
65
- pipeline that Vite 8 introduced.
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 (and remove any Babel-based React
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: [react(), reactCompiler()],
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.5.0",
3
+ "version": "0.7.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.148.0"
44
+ "oxc-transform-react": "0.153.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/node": "^26.1.0",
48
48
  "typescript": "^7",
49
49
  "vite": "^8",
50
- "vitest": "^4"
50
+ "vitest": "^5"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "vite": ">=8.0.0"