Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

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

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
116 changes: 79 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,105 +2,147 @@

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

Solid 2 compilation for Vite, Rollup, Rolldown, webpack, Rspack, esbuild, and Astro, powered by unplugin.

## 📦 Installation

```bash
$ npm install -D unplugin-solid
$ yarn add -D unplugin-solid
$ pnpm add -D unplugin-solid
npm install -D unplugin-solid
npm install solid-js@^2.0.0-rc.9 @solidjs/web@^2.0.0-rc.9
```

For TypeScript projects, preserve JSX for the plugin and use the web runtime's JSX types:

```json
{
"compilerOptions": {
"jsx": "preserve",
"jsxImportSource": "@solidjs/web"
}
}
```

## 🚀 Usage

Add the adapter for your build tool to its configuration. Vite and Astro require Vite 8 or 9.

<details>
<summary>Vite</summary><br>
<summary>Vite</summary>

```ts
// vite.config.ts
import Solid from "unplugin-solid/vite";
import { defineConfig } from "vite";

export default defineConfig({
plugins: [Solid({/* options */})],
plugins: [Solid()],
});
```

<br></details>
</details>

<details>
<summary>Rollup</summary><br>
<summary>Rollup</summary>

```ts
```js
// rollup.config.js
import Solid from "unplugin-solid/rollup";

export default {
plugins: [
Solid({/* options */}),
// other plugins
],
plugins: [Solid()],
};
```

<br></details>
</details>

<details>
<summary>Rolldown</summary><br>
<summary>Rolldown</summary>

```ts
```js
// rolldown.config.js
import Solid from "unplugin-solid/rolldown";

export default {
plugins: [
Solid({/* options */}),
// other plugins
],
plugins: [Solid()],
};
```

<br></details>
</details>

<details>
<summary>Webpack</summary><br>
<summary>webpack</summary>

```js
// webpack.config.cjs
const Solid = require("unplugin-solid/webpack");

```ts
// webpack.config.js
module.exports = {
/* ... */
plugins: [require("unplugin-solid/webpack")({/* options */})],
plugins: [Solid()],
};
```

<br></details>
</details>

<details>
<summary>esbuild</summary><br>
<summary>Rspack</summary>

```ts
// esbuild.config.js
```js
// rspack.config.cjs
const Solid = require("unplugin-solid/rspack");

module.exports = {
plugins: [Solid()],
};
```

</details>

<details>
<summary>esbuild</summary>

```js
// build.mjs
import { build } from "esbuild";
import Solid from "unplugin-solid/esbuild";

build({
/* ... */
plugins: [require("unplugin-solid/esbuild")({/* options */})],
await build({
entryPoints: ["src/index.tsx"],
bundle: true,
outdir: "dist",
plugins: [Solid()],
});
```

<br></details>
</details>

<details>
<summary>Astro</summary><br>
<summary>Astro</summary>

```ts
```js
// astro.config.mjs
import { defineConfig } from "astro/config";
import Solid from "unplugin-solid/astro";

export default defineConfig({
integrations: [Solid({/* options */})],
integrations: [Solid({})],
});
```

<br></details>
</details>

## ⚙️ Options

All adapters use the native Solid compiler by default. Pass `compiler: "babel"` to use the Babel compiler:

```ts
Solid({ compiler: "babel" });
```

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.

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.

The other adapters support JSX compilation options. Set `ssr: true` when compiling a server bundle and `dev: true` to enable compiler development output.

## 📝 License

Expand Down
29 changes: 16 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "unplugin-solid",
"version": "2.0.0",
"packageManager": "pnpm@11.13.0",
"packageManager": "pnpm@12.5.1",
"author": "Ray <[email protected]> (@so1ve)",
"type": "module",
"description": "Transform Solid.js code in various bundlers powered by unplugin",
Expand Down Expand Up @@ -59,37 +59,40 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@ampproject/remapping": "^2.3.0",
"@babel/core": "^7.29.7",
"babel-preset-solid": "^1.9.12",
"@solidjs/babel-plugin": "^2.0.0-rc.9",
"@solidjs/compiler": "^2.0.0-rc.9",
"merge-anything": "^6.0.6",
"solid-refresh": "^0.7.8",
"unplugin": "^3.3.0",
"vitefu": "^1.1.3"
"vitefu": "^1.0.4"
},
"devDependencies": {
"@so1ve/eslint-config": "^4.6.2",
"@so1ve/prettier-config": "^4.6.2",
"@so1ve/eslint-config": "^4.7.0",
"@so1ve/prettier-config": "^4.7.0",
"@solidjs/vite-plugin": "^3.0.0-next.44",
"@solidjs/web": "^2.0.0-rc.9",
"@sxzz/test-utils": "^0.5.18",
"@types/babel__core": "^7.20.5",
"@types/node": "^26.1.1",
"bumpp": "^11.1.0",
"esbuild": "^0.28.1",
"eslint": "^10.7.0",
"prettier": "^3.9.5",
"eslint": "^10.11.0",
"prettier": "^3.9.9",
"rollup": "^4.62.2",
"solid-js": "^1.9.14",
"solid-js": "^2.0.0-rc.9",
"tsdown": "^0.22.7",
"typescript": "^6.0.3",
"unplugin-oxc": "^0.6.1",
"vite": "^8.1.4",
"vite-plugin-solid": "^2.11.12",
"vitest": "^4.1.10",
"webpack": "^5.108.4"
},
"peerDependencies": {
"@testing-library/jest-dom": "^5.16.6 || ^5.17.0 || ^6.0.0",
"solid-js": "^1.9.9",
"vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
"@solidjs/web": "^2.0.0-rc.9",
"@testing-library/jest-dom": "^5.16.6 || ^5.17.0 || ^6.0.0 || ^7.0.0",
"solid-js": "^2.0.0-rc.9",
"vite": "^8.0.0 || ^9.0.0"
},
"peerDependenciesMeta": {
"@testing-library/jest-dom": {
Expand Down
Loading
Loading