@geajs/vite-plugin

中文文档
1.5.0发布于 2026/09/30MITTypeScriptES Module近 30 天下载 3967

Vite plugin for Gea framework - JSX/TSX transform, reactivity, HMR

原始使用文档
文档目录13 节
  1. Installation
  2. Configuration
  3. What It Does
  4. JSX to HTML String Compilation
  5. Reactive Binding Generation
  6. Event Delegation Wiring
  7. Function-to-Class Conversion
  8. Conditional and List Rendering
  9. Hot Module Replacement
  10. TypeScript Setup
  11. Virtual Module
  12. Related Packages
  13. License

@geajs/vite-plugin

npm version License: MIT

Vite plugin that powers Gea's compile-time JSX transforms, reactive binding generation, event delegation wiring, and hot module replacement.

Installation

npm install -D @geajs/vite-plugin

Requires vite ^7.3.1 as a peer dependency.

Configuration

// vite.config.ts
import { defineConfig } from 'vite'
import { geaPlugin } from '@geajs/vite-plugin'

export default defineConfig({
  plugins: [geaPlugin()]
})

That's it. No configuration options are needed — the plugin handles everything automatically.

What It Does

JSX to HTML String Compilation

The plugin transforms JSX in your .jsx and .tsx files into HTML template strings at build time. This means there is no createElement call at runtime — templates compile down to plain strings that are inserted into the DOM.

  • className is automatically converted to class
  • React-style event names are converted to Gea's lowercase attributes (onClick becomes click)
  • Component tags are converted to kebab-case custom elements with data-prop-* attributes

Reactive Binding Generation

The plugin analyzes which state paths your template reads (e.g., counterStore.count) and generates observe() calls that surgically update only the DOM nodes that depend on changed state. No virtual DOM diffing required.

Event Delegation Wiring

Event handlers declared in JSX (click={fn}, input={fn}, etc.) are compiled into an events getter that uses event delegation — a single global listener per event type on document.body, rather than individual listeners on each element.

Function-to-Class Conversion

Function components are automatically converted to class components at build time. You write simple functions; the plugin handles the rest:

// What you write
export default function Greeting({ name }) {
  return <h1>Hello, {name}!</h1>
}

// What the plugin produces (conceptually)
class Greeting extends Component {
  template({ name }) {
    return `<h1>Hello, ${name}!</h1>`
  }
}

Conditional and List Rendering

  • Conditional expressions (cond && <X />) are compiled into <template> markers with efficient swap logic
  • .map() calls with key props are compiled into applyListChanges calls that handle adds, deletes, reorders, and swaps without touching unchanged items

Hot Module Replacement

The plugin injects HMR support that preserves component state across edits. When you save a file, only the changed components are updated — no full page reload.

TypeScript Setup

Gea provides JSX type-checking via TypeScript's jsxImportSource. When your tsconfig.json includes "jsx": "react-jsx" and "jsxImportSource": "@geajs/core", editors get full prop autocompletion, type errors on invalid attributes, and hover types — without any framework-specific plugin. The plugin also adds gea-env.d.ts to the compilerOptions.types array for additional type support.

Virtual Module

The plugin provides a virtual:gea-reconcile module used internally for keyed list reconciliation.

License

MIT — Copyright (c) 2017-present Armagan Amcalar

版本与发布记录

@geajs/vite-plugin 共发布 41 个版本,首次发布于 2026/03/18;过去 12 个月发布了 41 个版本。

版本发布日期距今
1.5.0latest2026/09/301 个月前
1.4.32026/09/241 个月前
1.4.22026/09/231 个月前
1.4.12026/06/294 个月前
1.4.02026/06/284 个月前
1.3.12026/04/276 个月前

关于 @geajs/vite-plugin 的常见问题

@geajs/vite-plugin 是什么?

Vite plugin for Gea framework - JSX/TSX transform, reactivity, HMR

如何安装 @geajs/vite-plugin?

在项目目录运行 npm install @geajs/vite-plugin,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:vite(^8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@geajs/vite-plugin 支持 TypeScript 吗?

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

@geajs/vite-plugin 支持 ESM 还是 CommonJS?

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

@geajs/vite-plugin 可以商用吗?

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

@geajs/vite-plugin 的下载量有多少?

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

@geajs/vite-plugin 还在维护吗?

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