@dschz/bun-plugin-solid

中文文档
1.0.4发布于 2025/06/06MITTypeScriptES Module零依赖近 30 天下载 2080

A Bun plugin for transforming SolidJS TSX/JSX files at runtime or build time using Babel. Supports SSR and DOM output.

原始使用文档
文档目录6 节
  1. Features
  2. Installation
  3. Plugin Options
  4. Usage
  5. 🔧 Runtime (Development) via Preload Script
  6. 📦 Build-Time Compilation with Bun.build()

bun-plugin-solid

@dschz/bun-plugin-solid

License npm version Bundle Size JSR CI

🧩 A Bun plugin for transforming SolidJS JSX/TSX files at runtime or build time using Babel. Supports SSR and DOM output.

🟢 Works seamlessly with Bun and Elysia servers for both runtime and build-time JSX/TSX transformation.

⚠️ Note: This plugin is designed specifically for use with the Bun runtime. It will not work in Node.js, Deno, or other JavaScript environments.

Features

  • ✅ Works in both bun run (runtime) and bun build (build-time) contexts
  • 🎯 Supports SSR (generate: "ssr") and DOM (generate: "dom") output
  • 💧 Hydratable output toggle for SSR
  • 🧱 Designed to be invoked via preload or build plugins
  • 🪄 Minimal and explicit configuration surface

Installation

bun add -d @dschz/bun-plugin-solid @babel/core @babel/preset-typescript babel-preset-solid

These are peer dependencies, so they must be installed manually:

  • @babel/core
  • @babel/preset-typescript
  • babel-preset-solid

Plugin Options

Plugin options generate and hydratable are directly derived from babel-preset-solid and will be passed to it under the hood.

type SolidPluginOptions = {
  /**
   * Whether to generate DOM or SSR-compatible output.
   * Defaults to "dom".
   */
  generate?: "dom" | "ssr";

  /**
   * Enables hydration code generation for SSR.
   * Defaults to true.
   */
  hydratable?: boolean;

  /**
   * Controls source map generation:
   * - false: no source maps
   * - true: external .map file
   * - "inline": base64-encoded inline source maps
   *
   * Defaults to "inline".
   */
  sourceMaps?: boolean | "inline";

  /**
   * Enable verbose debug logs during transform.
   * Defaults to false.
   */
  debug?: boolean;
};

Usage

🔧 Runtime (Development) via Preload Script

Use this for runtime-based workflows like server-side rendering (SSR) with Elysia, Bun, or other Bun-native frameworks.

bunPreload.ts:

import { SolidPlugin } from "@dschz/bun-plugin-solid";

await Bun.plugin(
  SolidPlugin({
    generate: "ssr",
    hydratable: true,
    debug: true,
  }),
);

bunfig.toml:

jsx = "solid"
jsxFactory = "solid-js"
preload = ["./bunPreload.ts"]

Run:

bun run server.ts

📦 Build-Time Compilation with Bun.build()

Use this in production workflows to pre-compile .tsx or .jsx files to JavaScript.

build.ts:

import { SolidPlugin } from "@dschz/bun-plugin-solid";

await Bun.build({
  entrypoints: ["./src/index.ts"],
  outdir: "./dist",
  target: "bun",
  format: "esm",
  plugins: [
    SolidPlugin({
      generate: "ssr",
      hydratable: true,
      sourceMaps: false, // recommended for production
    }),
  ],
});

版本与发布记录

@dschz/bun-plugin-solid 共发布 5 个版本,首次发布于 2025/05/09;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.4latest2025/06/061.4 年前
1.0.32025/05/121.5 年前
1.0.22025/05/091.5 年前
1.0.12025/05/091.5 年前
1.0.02025/05/091.5 年前

关于 @dschz/bun-plugin-solid 的常见问题

@dschz/bun-plugin-solid 是什么?

A Bun plugin for transforming SolidJS TSX/JSX files at runtime or build time using Babel. Supports SSR and DOM output.

如何安装 @dschz/bun-plugin-solid?

在项目目录运行 npm install @dschz/bun-plugin-solid,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@babel/core(>=7.24.0)、@babel/preset-typescript(>=7.24.0)、babel-preset-solid(>=1.8.9)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@dschz/bun-plugin-solid 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dschz/bun-plugin-solid 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@dschz/bun-plugin-solid 可以商用吗?

@dschz/bun-plugin-solid 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dschz/bun-plugin-solid 的下载量有多少?

根据 npm 官方下载统计,@dschz/bun-plugin-solid 在 2026/10/13 – 2026/11/11 这 30 天内被下载 2,080 次,日均约 69 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dschz/bun-plugin-solid 还在维护吗?

最新版本 1.0.4 发布于 2025/06/06(1.4 年前);至今共发布 5 个版本,其中过去 12 个月发布了 0 个;首次发布于 2025/05/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。