@animus-ui/unplugin

中文文档
0.1.87发布于 2026/10/24MITTypeScriptCommonJS构建来源已验证近 30 天下载 6531

Animus transform host for non-plugin bundlers — unplugin-based rollup/esbuild/rspack/webpack entry points over the one extraction session

原始使用文档
文档目录6 节
  1. Install
  2. Setup (rollup)
  3. Plugin ordering
  4. What it does
  5. Options
  6. License

@animus-ui/unplugin

Animus transform host for non-plugin bundlers — rollup, esbuild, rspack, and webpack entry points over the one extraction session. Transforms @animus-ui/system builder chains into static CSS at build time, delivers the stylesheet as a real emitted asset (animus.css), and supplies the __ANIMUS_DEV__ define.

Vite users: use @animus-ui/vite-plugin. Next.js users: use @animus-ui/next-plugin. The root export's reachable .vite adapter is unsupported — the supported surface is exactly the four subpath entries below.

Install

npm install --save-dev @animus-ui/unplugin
npm install @animus-ui/system

Requires Node >=22.12.0. Native engine binaries ship for darwin-arm64, linux-x64-gnu, and linux-arm64-gnu.

Setup (rollup)

// rollup.config.mjs — ESM configs use the NAMED export.
import { animusRollup as animus } from '@animus-ui/unplugin/rollup';
import esbuild from 'rollup-plugin-esbuild';

export default {
  input: 'src/entry.tsx',
  plugins: [
    // The host FIRST: its transform must see raw TSX (rollup has no
    // enforce ordering — config order is the law).
    animus({ system: './src/ds.ts', strict: true }),
    esbuild({ jsx: 'automatic', target: 'es2022' }),
  ],
  output: { dir: 'dist', format: 'esm' },
};

The other bundlers follow the same shape from their own subpaths: animusEsbuild from @animus-ui/unplugin/esbuild, animusRspack from @animus-ui/unplugin/rspack, animusWebpack from @animus-ui/unplugin/webpack. In CJS config files use the default export:

// CJS config files:
const animus = require('@animus-ui/unplugin/rollup').default;

A Node-ESM default import of the CJS build binds the exports object, not the plugin function — in ESM configs, always use the named export.

Plugin ordering

The extraction engine parses raw TSX — this host's transform must run before any TS/JSX transpilation. enforce: 'pre' orders webpack and rspack loader chains automatically; rollup consumers must list this plugin before their transpiler in the config. Mis-ordered builds emit a source-drift warning (transform-time source … differs from analyze-time source) followed by a bundler parse error on TSX syntax — move the Animus plugin first to fix it.

What it does

  • Runs the one ExtractionSession at buildStart inside your bundler's process; per-file transforms come from retained engine state. Analysis failure is build failure — never a silent passthrough.
  • Resolves the stylesheet id (.animus/styles.css), the system-props id, and one redirect per admitted design-system kit specifier to the exact entry extraction analyzed. tsconfig paths are the alias source.
  • Emits the extracted stylesheet as a real animus.css asset (for esbuild: written into outdir, or beside outfile).
  • With stylesheets: 'split', also emits the stylesheet as consecutive slices beside animus.css, animus.<slice>.<hash>.css (foundation, components, utilities), and animus-stylesheets.json, their names in link order. Their bytes in order are animus.css's; a slice an edit leaves alone keeps its name. A later build into the same directory removes the slices it no longer publishes, and the index when it publishes none.
  • Supplies the __ANIMUS_DEV__ dev-signal define through each bundler's own mechanism.
  • When a font face declares preload: true, emits animus-font-preloads.json beside animus.css: the preloads, as { href, type, fetchpriority }, with hrefs relative to the stylesheet. renderFontPreloads(preloads, { base, exclude }) returns the <link> tags for your HTML, where base is the URL animus.css's directory is served at, and exclude lists hrefs the document already preloads. The fontPreloads option (family names, or { family, weight?, style?, unicodeRange?, fetchpriority? }) selects the faces that preload in place of their preload flags; an entry's fetchpriority reaches their tags.

Options

Options are the shared driver core (system, exclude, strict, mode, targets, minify, …); unknown keys fail loud. mode ('development' | 'production') selects emission only — the minify default, the dev-signal define, engine dev diagnostics — never process lifecycle. When absent, the bundler's own command oracle applies (webpack/ rspack compiler.options.mode, rollup watch mode), else production (esbuild exposes no signal). exclude patterns are glob-aware; a list REPLACES the dist, .test. and .spec. defaults, while node_modules, .next and .animus always apply. Wherever the bundler writes is always excluded too: its output directories (every Vite environment's, each output's dir, webpack's output.path up to its first […] placeholder) and its output files by exact name (outfile, output.file). webpack, rspack, esbuild and Vite name them before analysis. Rollup and Rolldown name them only after analysis, so a watch excludes them from its second build on, and a build that has already analysed one reports it (an output file as earlier output; a file inside an output directory as earlier output or a source beside the output), naming what to add to exclude; under strict that build fails.

The full consumer contract — module-id families, the define contract, artifact set, platform matrix — lives in the standalone extraction contract.

License

MIT

版本与发布记录

@animus-ui/unplugin 共发布 68 个版本,首次发布于 2026/08/20;过去 12 个月发布了 68 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.87latest2026/10/2414 天前
0.1.862026/10/2315 天前
0.1.852026/10/2315 天前
0.1.842026/10/2216 天前
0.1.832026/10/2217 天前
0.1.822026/10/2217 天前

关于 @animus-ui/unplugin 的常见问题

@animus-ui/unplugin 是什么?

Animus transform host for non-plugin bundlers — unplugin-based rollup/esbuild/rspack/webpack entry points over the one extraction session

如何安装 @animus-ui/unplugin?

在项目目录运行 npm install @animus-ui/unplugin,或使用 pnpm add / yarn add / bun add。

@animus-ui/unplugin 支持 TypeScript 吗?

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

@animus-ui/unplugin 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@animus-ui/unplugin 需要什么版本的 Node.js?

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

@animus-ui/unplugin 可以商用吗?

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

@animus-ui/unplugin 的下载量有多少?

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

@animus-ui/unplugin 还在维护吗?

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