Skip to content

Commit c82e203

Browse files
authored
feat!: support solidjs v2, drop support for v1 (#268)
1 parent af88ffb commit c82e203

21 files changed

Lines changed: 2985 additions & 1897 deletions

‎LICENSE‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
MIT License
22

33
Copyright (c) 2022 Ray <https://github.com/so1ve>
4+
Copyright (c) 2020-2026 Alexandre Mouton-Brady and Solid contributors
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
of this software and associated documentation files (the "Software"), to deal

‎README.md‎

Lines changed: 79 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,105 +2,147 @@
22

33
[![NPM version](https://img.shields.io/npm/v/unplugin-solid?color=a1b858&label=)](https://www.npmjs.com/package/unplugin-solid)
44

5+
Solid 2 compilation for Vite, Rollup, Rolldown, webpack, Rspack, esbuild, and Astro, powered by unplugin.
6+
57
## 📦 Installation
68

79
```bash
8-
$ npm install -D unplugin-solid
9-
$ yarn add -D unplugin-solid
10-
$ pnpm add -D unplugin-solid
10+
npm install -D unplugin-solid
11+
npm install solid-js@^2.0.0-rc.9 @solidjs/web@^2.0.0-rc.9
12+
```
13+
14+
For TypeScript projects, preserve JSX for the plugin and use the web runtime's JSX types:
15+
16+
```json
17+
{
18+
"compilerOptions": {
19+
"jsx": "preserve",
20+
"jsxImportSource": "@solidjs/web"
21+
}
22+
}
1123
```
1224

1325
## 🚀 Usage
1426

27+
Add the adapter for your build tool to its configuration. Vite and Astro require Vite 8 or 9.
28+
1529
<details>
16-
<summary>Vite</summary><br>
30+
<summary>Vite</summary>
1731

1832
```ts
1933
// vite.config.ts
2034
import Solid from "unplugin-solid/vite";
35+
import { defineConfig } from "vite";
2136

2237
export default defineConfig({
23-
plugins: [Solid({/* options */})],
38+
plugins: [Solid()],
2439
});
2540
```
2641

27-
<br></details>
42+
</details>
2843

2944
<details>
30-
<summary>Rollup</summary><br>
45+
<summary>Rollup</summary>
3146

32-
```ts
47+
```js
3348
// rollup.config.js
3449
import Solid from "unplugin-solid/rollup";
3550

3651
export default {
37-
plugins: [
38-
Solid({/* options */}),
39-
// other plugins
40-
],
52+
plugins: [Solid()],
4153
};
4254
```
4355

44-
<br></details>
56+
</details>
4557

4658
<details>
47-
<summary>Rolldown</summary><br>
59+
<summary>Rolldown</summary>
4860

49-
```ts
61+
```js
5062
// rolldown.config.js
5163
import Solid from "unplugin-solid/rolldown";
5264

5365
export default {
54-
plugins: [
55-
Solid({/* options */}),
56-
// other plugins
57-
],
66+
plugins: [Solid()],
5867
};
5968
```
6069

61-
<br></details>
70+
</details>
6271

6372
<details>
64-
<summary>Webpack</summary><br>
73+
<summary>webpack</summary>
74+
75+
```js
76+
// webpack.config.cjs
77+
const Solid = require("unplugin-solid/webpack");
6578

66-
```ts
67-
// webpack.config.js
6879
module.exports = {
69-
/* ... */
70-
plugins: [require("unplugin-solid/webpack")({/* options */})],
80+
plugins: [Solid()],
7181
};
7282
```
7383

74-
<br></details>
84+
</details>
7585

7686
<details>
77-
<summary>esbuild</summary><br>
87+
<summary>Rspack</summary>
7888

79-
```ts
80-
// esbuild.config.js
89+
```js
90+
// rspack.config.cjs
91+
const Solid = require("unplugin-solid/rspack");
92+
93+
module.exports = {
94+
plugins: [Solid()],
95+
};
96+
```
97+
98+
</details>
99+
100+
<details>
101+
<summary>esbuild</summary>
102+
103+
```js
104+
// build.mjs
81105
import { build } from "esbuild";
106+
import Solid from "unplugin-solid/esbuild";
82107

83-
build({
84-
/* ... */
85-
plugins: [require("unplugin-solid/esbuild")({/* options */})],
108+
await build({
109+
entryPoints: ["src/index.tsx"],
110+
bundle: true,
111+
outdir: "dist",
112+
plugins: [Solid()],
86113
});
87114
```
88115

89-
<br></details>
116+
</details>
90117

91118
<details>
92-
<summary>Astro</summary><br>
119+
<summary>Astro</summary>
93120

94-
```ts
121+
```js
95122
// astro.config.mjs
123+
import { defineConfig } from "astro/config";
96124
import Solid from "unplugin-solid/astro";
97125

98126
export default defineConfig({
99-
integrations: [Solid({/* options */})],
127+
integrations: [Solid({})],
100128
});
101129
```
102130

103-
<br></details>
131+
</details>
132+
133+
## ⚙️ Options
134+
135+
All adapters use the native Solid compiler by default. Pass `compiler: "babel"` to use the Babel compiler:
136+
137+
```ts
138+
Solid({ compiler: "babel" });
139+
```
140+
141+
Use `solid` to configure JSX compilation and `babel` to add Babel plugins or presets. With the native compiler, custom Babel transforms run before JSX compilation.
142+
143+
Vite and Astro support refresh, SSR compilation, and experimental TSRX. Compiling TSRX with the Babel backend also requires `@tsrx/[email protected]`. Use `refresh: { disabled: true }` to disable refresh, or `observe: true` to select Solid’s observable runtime builds.
144+
145+
The other adapters support JSX compilation options. Set `ssr: true` when compiling a server bundle and `dev: true` to enable compiler development output.
104146

105147
## 📝 License
106148

‎package.json‎

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "unplugin-solid",
33
"version": "2.0.0",
4-
"packageManager": "pnpm@11.13.0",
4+
"packageManager": "pnpm@12.5.1",
55
"author": "Ray <[email protected]> (@so1ve)",
66
"type": "module",
77
"description": "Transform Solid.js code in various bundlers powered by unplugin",
@@ -59,37 +59,40 @@
5959
"typecheck": "tsc --noEmit"
6060
},
6161
"dependencies": {
62+
"@ampproject/remapping": "^2.3.0",
6263
"@babel/core": "^7.29.7",
63-
"babel-preset-solid": "^1.9.12",
64+
"@solidjs/babel-plugin": "^2.0.0-rc.9",
65+
"@solidjs/compiler": "^2.0.0-rc.9",
6466
"merge-anything": "^6.0.6",
65-
"solid-refresh": "^0.7.8",
6667
"unplugin": "^3.3.0",
67-
"vitefu": "^1.1.3"
68+
"vitefu": "^1.0.4"
6869
},
6970
"devDependencies": {
70-
"@so1ve/eslint-config": "^4.6.2",
71-
"@so1ve/prettier-config": "^4.6.2",
71+
"@so1ve/eslint-config": "^4.7.0",
72+
"@so1ve/prettier-config": "^4.7.0",
73+
"@solidjs/vite-plugin": "^3.0.0-next.44",
74+
"@solidjs/web": "^2.0.0-rc.9",
7275
"@sxzz/test-utils": "^0.5.18",
7376
"@types/babel__core": "^7.20.5",
7477
"@types/node": "^26.1.1",
7578
"bumpp": "^11.1.0",
7679
"esbuild": "^0.28.1",
77-
"eslint": "^10.7.0",
78-
"prettier": "^3.9.5",
80+
"eslint": "^10.11.0",
81+
"prettier": "^3.9.9",
7982
"rollup": "^4.62.2",
80-
"solid-js": "^1.9.14",
83+
"solid-js": "^2.0.0-rc.9",
8184
"tsdown": "^0.22.7",
8285
"typescript": "^6.0.3",
8386
"unplugin-oxc": "^0.6.1",
8487
"vite": "^8.1.4",
85-
"vite-plugin-solid": "^2.11.12",
8688
"vitest": "^4.1.10",
8789
"webpack": "^5.108.4"
8890
},
8991
"peerDependencies": {
90-
"@testing-library/jest-dom": "^5.16.6 || ^5.17.0 || ^6.0.0",
91-
"solid-js": "^1.9.9",
92-
"vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
92+
"@solidjs/web": "^2.0.0-rc.9",
93+
"@testing-library/jest-dom": "^5.16.6 || ^5.17.0 || ^6.0.0 || ^7.0.0",
94+
"solid-js": "^2.0.0-rc.9",
95+
"vite": "^8.0.0 || ^9.0.0"
9396
},
9497
"peerDependenciesMeta": {
9598
"@testing-library/jest-dom": {

0 commit comments

Comments
 (0)