npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vite-plugin-airx

v0.7.1

Published

Vite 插件,用于将 Airx JSX 转换接入 Vite 项目。 默认使用 automatic JSX runtime(`airx/jsx-runtime`)。

Readme

vite-plugin-airx

Vite 插件,用于将 Airx JSX 转换接入 Vite 项目。 默认使用 automatic JSX runtime(airx/jsx-runtime)。

安装

npm install vite-plugin-airx

快速开始

1. 安装依赖

npm install airx vite-plugin-airx

2. 配置 vite.config.ts

import { defineConfig } from 'vite'
import airx from 'vite-plugin-airx'

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

3. 编写组件

import * as airx from 'airx'

function App() {
  return () => airx.createElement('div', null, 'Hello Airx!')
}

airx.createApp(airx.createElement(App)).mount(
  document.getElementById('root')!
)

工作原理

默认模式(automatic)通过 Vite config 钩子注入以下 esbuild 配置:

| 配置项 | 值 | 说明 | |--------|-----|------| | jsx | 'automatic' | 启用自动 JSX 运行时 | | jsxImportSource | 'airx' | 指向 airx/jsx-runtime |

如果你需要兼容旧项目,也可以切回 classic 模式:

import { defineConfig } from 'vite'
import airx from 'vite-plugin-airx'

export default defineConfig({
  plugins: [
    airx({
      runtime: 'classic'
    })
  ]
})

Vite 版本支持

| 版本 | 支持状态 | 说明 | |------|---------|------| | Vite 5.x | ✅ 官方支持 | peerDependency 明确声明 | | Vite 6.x | ✅ 官方支持 | peerDependency 明确声明 | | Vite 7.x | ✅ 官方支持 | peerDependency 明确声明 | | Vite 8.x | ✅ 官方支持 | 兼容 Rolldown 构建链路,JSX 配置仍通过 esbuild 生效 |

说明:Vite 8 使用 Rolldown 作为内部构建工具,但 JSX 转换配置仍通过 Vite 的 esbuild 选项统一接入。

示例

examples/minimal/ 目录,包含完整的最小可运行示例。

配置参考

可选配置

| 配置项 | 类型 | 默认值 | 说明 | |--------|------|--------|------| | runtime | 'automatic' \| 'classic' | 'automatic' | 选择 JSX 运行时模式 | | importSource | string | 'airx' | automatic 模式下的导入源 |

classic 模式使用固定注入:

  • jsxFactory: __airx__.createElement
  • jsxFragment: __airx__.Fragment
  • jsxInject: import * as __airx__ from 'airx'

演进路线

v0.2.x(当前)

  • 零配置插件
  • 支持 Vite 5.x
  • 最小 JSX 注入

v0.3.x(计划中)

  • 支持 Vite 6.x
  • 配置选项扩展
  • 完整的 CI 验证

v1.0.0(计划中)

  • 移除 Vite 5.x 支持
  • 稳定 API
  • 完整的文档和示例

系统限制

  • 插件依赖 airx 包导出 FragmentcreateElement
  • 暂不支持 SSR 场景
  • 不与其他 JSX 插件(如 @vitejs/plugin-react)同时使用

升级指南

从 v0.1.x 升级到 v0.2.x

v0.2.x 保持向后兼容,升级步骤:

npm install vite-plugin-airx@latest

相关文档