RNA Bundler 软件
基于 JavaScript、 CSS 和 HTML 捆绑器 兴建。 。 。 .
[叹息] RNA cli开发被贬值并停止. 建议在您的项目中直接使用 RNA 插件, 使用 vite, esbuilt, 或其他支持的工具 .
安装
捆绑是其中的一部分 @chialab/rna cli,但可以用作模块.
npm i @chialab/rna-bundler -D
yarn add @chialab/rna-bundler -D
pnpm add @chialab/rna-bundler -D
使用量
使用 JS 和 CSS 模块和 HTML 应用程序编译 esbuild。它可以输出多个模块格式,并可用于构建单个模块或捆绑应用程序的所有依赖性.
请注意,HTML和CSS加载器是分离的插件,需要安装才能工作.
通过导入
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,
});
通过 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
样本
$ 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
已知的限制和变通办法
Esbuild 在捆绑时不会合并同一外部来源的导入语句( 见 3号) (中文(简体) ). 网包中被消耗的自建捆绑可能会受到错误优化的影响.
工作周边
以下列规则更新网页包配置 :
module.exports = {
optimization: {
innerGraph: false,
},
};
许可证
RNA Bundler 软件 将在 麻省理工学院 执照.