@chialab/rna-bundler

中文文档
0.19.3发布于 2026/06/24MITTypeScriptES Module构建来源已验证近 30 天下载 5627

A JavaScript, CSS and HTML bundler based on esbuild.

原始使用文档
文档目录6 节
  1. Install
  2. Usage
  3. Via import
  4. Via cli
  5. Known limitations and workarounds
  6. License

RNA Bundler

A JavaScript, CSS and HTML bundler based on esbuild.

[!CAUTION] RNA cli development is deprecated and discontinued. It's recommended to use RNA plugins directly in your projects using vite, esbuild, or other supported tools.

NPM

Install

The bundler is part of the @chialab/rna cli, but you can use it as a module.

npm i @chialab/rna-bundler -D
yarn add @chialab/rna-bundler -D
pnpm add @chialab/rna-bundler -D

Usage

Compile JS and CSS modules and HTML apps using esbuild. It can output multiple module formats and it can be used to build a single module or to bundle all dependencies of an application.

Please note that HTML and CSS loaders are separated plugins that needs to be installed in order to work.

Via import

import { build } from '@chialab/rna';

await build({
    input: 'index.js',
    output: 'dist/esm/index.js',
    // code: '...',
    // rootDir: '.',
    platform: 'browser' // 'node',
    format: 'esm', // 'cjs' 'iife'
    // globalName: '', // global name for iife modules
    sourcemap: true,
    minify: true,
});

Via cli

rna build [options] [entry...]

Options:
  -C, --config <path>         the rna config file
  -O, --output <path>         output directory or file
  --format <type>             bundle format
  --platform <type>           platform destination
  --bundle                    bundle dependencies
  --minify                    minify the build
  --public <path>             public path
  --target <query>            output targets (es5, es2015, es2020)
  --entryNames <pattern>      output file names
  --chunkNames <pattern>      output chunk names
  --assetNames <pattern>      output asset names
  --clean                     cleanup output path
  --manifest <path>           generate manifest file
  --entrypoints <path>        generate entrypoints file
  --name <identifier>         the iife global name
  --external [modules]        comma separated external packages
  --no-map                    do not generate sourcemaps
  --jsx <mode>                jsx transformation mode (transform, preserve, automatic)
  --jsxFactory <identifier>   jsx pragma
  --jsxFragment <identifier>  jsx fragment
  --jsxImportSource <name>    jsx module name
  -h, --help                  display help for command

Samples

$ rna build src/index.js --output dist/esm/index.js --format esm
$ rna build src/index.js --output public/index.js --format iife --minify --bundle
$ rna build src/index.css --output public/index.css --minify --bundle

Known limitations and workarounds

Esbuild does not merge import statements from the same external source when bundling (see #3). Consumed esbuild bundles in webpack can be affected by a wrong optimization.

Workaround
Update webpack configuration with following rule:

module.exports = {
    optimization: {
        innerGraph: false,
    },
};

License

RNA Bundler is released under the MIT license.

版本与发布记录

@chialab/rna-bundler 共发布 189 个版本,首次发布于 2021/04/16;过去 12 个月发布了 3 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.19.3latest2026/06/244 个月前
0.19.22026/06/244 个月前
0.19.12026/02/258 个月前
0.19.02025/08/251.2 年前
0.19.0-beta.3beta2024/11/052 年前
0.19.0-beta.22024/07/092 年前

其他发布通道:alpha → 0.18.0-alpha.1,beta → 0.19.0-beta.3。

关于 @chialab/rna-bundler 的常见问题

@chialab/rna-bundler 是什么?

A JavaScript, CSS and HTML bundler based on esbuild.

如何安装 @chialab/rna-bundler?

在项目目录运行 npm install @chialab/rna-bundler,或使用 pnpm add / yarn add / bun add。

@chialab/rna-bundler 支持 TypeScript 吗?

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

@chialab/rna-bundler 支持 ESM 还是 CommonJS?

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

@chialab/rna-bundler 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@chialab/rna-bundler 可以商用吗?

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

@chialab/rna-bundler 的下载量有多少?

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

@chialab/rna-bundler 还在维护吗?

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