Skip to content

Commit 05123db

Browse files
committed
feat: set up bun plugin
1 parent 5e8cf6e commit 05123db

18 files changed

+360
-887
lines changed

.nvmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 68 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,90 @@
11
<p>
2-
<img width="100%" src="https://assets.solidjs.com/banner?type=Ecosystem&background=tiles&project=library-name" alt="solid-create-script">
2+
<img width="100%" src="https://assets.solidjs.com/banner?type=Ecosystem&background=tiles&project=bun-plugin-solid-jsx" alt="bun-plugin-solid-jsx">
33
</p>
44

5-
# Template: SolidJS Library
5+
# bun-plugin-solid-jsx
66

7-
Template for [SolidJS](https://www.solidjs.com/) library package. Bundling of the library is managed by [tsup](https://tsup.egoist.dev/).
7+
> 🧩 A Bun plugin for transforming SolidJS JSX/TSX files at runtime or build time using Babel. Supports SSR and DOM output.
88
9-
Other things configured include:
9+
> ⚠️ **Note**: This plugin is designed specifically for use with the [Bun runtime](https://bun.sh). It will not work in Node.js, Deno, or other JavaScript environments.
1010
11-
- Bun (for dependency management and running scripts)
12-
- TypeScript
13-
- ESLint / Prettier
14-
- Solid Testing Library + Vitest (for testing)
15-
- Playground app using library
16-
- GitHub Actions (for all CI/CD)
11+
## Features
1712

18-
## Getting Started
13+
- ✅ Works in both `bun run` and `bun build` contexts
14+
- 🎯 Supports SSR (`generate: "ssr"`) and DOM (`generate: "dom"`) output
15+
- 💧 Hydratable output toggle for SSR
16+
- 🪄 Minimal and explicit configuration surface
17+
- 🧱 Designed to be invoked via `preload` or setup scripts
1918

20-
Some pre-requisites before install dependencies:
19+
## Installation
2120

22-
- Install Node Version Manager (NVM)
23-
```bash
24-
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
25-
```
26-
- Install Bun
27-
```bash
28-
curl -fsSL https://bun.sh/install | bash
29-
```
21+
```bash
22+
bun add -d bun-plugin-solid-jsx @babel/core @babel/preset-typescript babel-preset-solid
23+
```
3024

31-
### Installing Dependencies
25+
> Note: `@babel/core`, `@babel/preset-typescript` and `babel-preset-solid` are **peer dependencies** and must be installed separately.
3226
33-
```bash
34-
nvm use
35-
bun install
27+
---
28+
29+
## Usage
30+
31+
### Runtime via Bun Preload Script
32+
33+
This use-case applies to development workflows. Create a preload file:
34+
35+
```ts
36+
// solid-preload.ts
37+
import solidJSXPlugin from "bun-plugin-solid-jsx";
38+
39+
await solidJSXPlugin({
40+
generate: "ssr",
41+
hydratable: true,
42+
});
3643
```
3744

38-
### Local Development Build
45+
Update your `bunfig.toml`:
3946

40-
```bash
41-
bun start
47+
```toml
48+
jsx = "solid"
49+
jsxFactory = "solid-js"
50+
preload = ["./solid-preload.ts"]
4251
```
4352

44-
### Linting & Formatting
53+
---
4554

46-
```bash
47-
bun run lint # checks source for lint violations
48-
bun run format # checks source for format violations
55+
### With `Bun.build`
56+
57+
```ts
58+
// build.ts
59+
import solidJSXPlugin from "bun-plugin-solid-jsx";
60+
61+
await solidJSXPlugin({
62+
generate: "ssr",
63+
hydratable: true,
64+
});
65+
66+
await Bun.build({
67+
entrypoints: ["./src/index.ts"],
68+
outdir: "./dist",
69+
target: "bun",
70+
format: "esm",
71+
});
72+
```
73+
74+
---
75+
76+
## Plugin Options
4977

50-
bun run lint:fix # fixes lint violations
51-
bun run format:fix # fixes format violations
78+
```ts
79+
type SolidJSXPluginOptions = {
80+
generate?: "dom" | "ssr"; // default: "ssr"
81+
hydratable?: boolean; // default: true
82+
sourceMaps?: boolean | "inline"; // default: "inline"
83+
};
5284
```
5385

54-
### Contributing
86+
---
5587

56-
The only requirements when contributing are:
88+
## License
5789

58-
- You keep a clean git history in your branch
59-
- rebasing `main` instead of making merge commits.
60-
- Using proper commit message formats that adhere to [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/)
61-
- Additionally, squashing (via rebase) commits that are not [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/)
62-
- CI checks pass before merging into `main`
90+
MIT

build.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const result = await Bun.build({
2+
entrypoints: ["src/index.ts"],
3+
outdir: "dist",
4+
target: "bun",
5+
format: "esm",
6+
minify: true,
7+
external: ["@babel/core", "@babel/preset-typescript", "babel-preset-solid"],
8+
});
9+
10+
if (!result.success) {
11+
console.error("❌ Build failed");
12+
for (const log of result.logs) {
13+
console.error(log);
14+
}
15+
process.exit(1);
16+
}
17+
18+
console.log("✅ Build succeeded");
19+
20+
// Export empty object to treat this file as a module
21+
export {};

bun.lock

Lines changed: 113 additions & 627 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eslint.config.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import js from "@eslint/js";
22
import simpleImportSort from "eslint-plugin-simple-import-sort";
3-
import solid from "eslint-plugin-solid/configs/typescript";
43
import globals from "globals";
54
import tseslint from "typescript-eslint";
65

@@ -20,43 +19,11 @@ export default tseslint.config(
2019
"simple-import-sort/exports": "error",
2120
},
2221
},
23-
{
24-
files: ["**/*.ts", "**/*.tsx"],
25-
languageOptions: {
26-
parser: tseslint.parser,
27-
parserOptions: {
28-
sourceType: "module",
29-
project: "./tsconfig.json",
30-
ecmaFeatures: {
31-
jsx: true,
32-
},
33-
},
34-
globals: {
35-
...globals.browser,
36-
...globals.es2022,
37-
},
38-
},
39-
plugins: solid.plugins,
40-
rules: {
41-
...solid.rules,
42-
"@typescript-eslint/no-non-null-assertion": "off",
43-
"no-unused-vars": "off",
44-
"@typescript-eslint/no-unused-vars": [
45-
"error",
46-
{
47-
varsIgnorePattern: "^_",
48-
argsIgnorePattern: "^_",
49-
destructuredArrayIgnorePattern: "^_",
50-
},
51-
],
52-
},
53-
},
5422
{
5523
files: ["__tests__/**/*.ts", "__tests__/**/*.tsx"],
5624
languageOptions: {
5725
globals: {
5826
...globals.node,
59-
...globals.vitest,
6027
},
6128
},
6229
},

index.html

Lines changed: 0 additions & 16 deletions
This file was deleted.

package.json

Lines changed: 40 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,52 @@
11
{
2-
"name": "template-solidjs-library",
3-
"version": "0.0.0",
4-
"description": "Template for SolidJS library using tsup for bundling. Configured with Bun, NVM, TypeScript, ESLint, Prettier, Vitest, and GHA",
5-
"type": "module",
6-
"author": "Daniel Sanchez <dsanc89@icloud.com>",
2+
"name": "@danchez/bun-plugin-solid-jsx",
3+
"description": "A Bun plugin for transforming SolidJS JSX files at runtime or build time using Babel. Supports SSR and DOM output.",
4+
"version": "1.0.0",
5+
"author": "Daniel Sanchez",
76
"license": "MIT",
8-
"homepage": "https://github.com/thedanchez/template-solidjs-library#readme",
9-
"bugs": {
10-
"url": "https://github.com/thedanchez/template-solidjs-library/issues"
11-
},
12-
"files": [
13-
"dist"
14-
],
7+
"type": "module",
158
"main": "./dist/index.js",
169
"module": "./dist/index.js",
1710
"types": "./dist/index.d.ts",
18-
"browser": {},
19-
"exports": {
20-
"solid": "./dist/index.jsx",
21-
"import": {
22-
"types": "./dist/index.d.ts",
23-
"default": "./dist/index.js"
24-
}
25-
},
26-
"typesVersions": {},
11+
"keywords": [
12+
"bun",
13+
"plugin",
14+
"solid",
15+
"solidjs",
16+
"jsx",
17+
"ssr",
18+
"babel",
19+
"tsx"
20+
],
21+
"files": [
22+
"dist"
23+
],
2724
"scripts": {
28-
"build": "tsup",
29-
"build:watch": "tsup --watch",
30-
"dev": "vite",
31-
"format": "prettier . --check",
32-
"format:fix": "prettier . --write",
33-
"lint": "eslint .",
34-
"lint:fix": "eslint . --fix",
35-
"serve": "vite preview",
36-
"start": "vite",
37-
"test": "vitest run",
38-
"test:cov": "vitest run --coverage",
39-
"typecheck": "tsc --noEmit"
25+
"build": "bun build.ts && tsc --emitDeclarationOnly --declaration --outDir dist",
26+
"lint:fix": "eslint --fix .",
27+
"format:fix": "prettier --write ."
28+
},
29+
"peerDependencies": {
30+
"@babel/core": "^7.24.0",
31+
"@babel/preset-typescript": "^7.24.0",
32+
"babel-preset-solid": "^1.8.10"
4033
},
4134
"devDependencies": {
42-
"@solidjs/testing-library": "^0.8.10",
43-
"@testing-library/jest-dom": "^6.6.3",
44-
"@types/bun": "^1.2.3",
45-
"@typescript-eslint/eslint-plugin": "^8.25.0",
46-
"@typescript-eslint/parser": "^8.25.0",
47-
"@vitest/coverage-istanbul": "^3.0.7",
48-
"eslint": "^9.21.0",
35+
"@babel/core": "^7.24.0",
36+
"@babel/preset-typescript": "^7.24.0",
37+
"babel-preset-solid": "^1.8.10",
38+
"eslint": "^9.25.1",
4939
"eslint-plugin-simple-import-sort": "^12.1.1",
50-
"eslint-plugin-solid": "^0.14.5",
5140
"globals": "^16.0.0",
52-
"jiti": "^2.4.2",
53-
"jsdom": "^26.0.0",
54-
"prettier": "^3.5.2",
55-
"tsup": "^8.3.6",
56-
"tsup-preset-solid": "^2.2.0",
57-
"typescript": "^5.7.3",
58-
"typescript-eslint": "^8.25.0",
59-
"vite": "^6.2.0",
60-
"vite-plugin-solid": "^2.11.2",
61-
"vitest": "^3.0.7"
41+
"prettier": "^3.5.3",
42+
"typescript": "^5.8.3"
6243
},
63-
"peerDependencies": {
64-
"solid-js": "^1.9.4"
65-
}
44+
"exports": {
45+
"import": {
46+
"types": "./dist/index.d.ts",
47+
"default": "./dist/index.js"
48+
}
49+
},
50+
"browser": {},
51+
"typesVersions": {}
6652
}

playground/App.tsx

Lines changed: 0 additions & 19 deletions
This file was deleted.

playground/index.css

Whitespace-only changes.

playground/index.tsx

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)