@blotch/rsbuild-plugin-angular-lynx

中文文档
22.2.18发布于 2026/11/08MITTypeScriptES Module构建来源已验证近 30 天下载 3713

Rsbuild plugin for building AngularLynx applications

原始使用文档
文档目录6 节
  1. Installation
  2. Usage
  3. What It Does
  4. Budgets
  5. Intl
  6. Documentation

@blotch/rsbuild-plugin-angular-lynx

Rsbuild plugin that compiles Angular apps for the Lynx native runtime. Produces dual-thread bundles (main + background) for iOS, Android, and Web.

Installation

Using the Angular CLI? You don't need this package directly. ng add @blotch/angular-lynx installs @blotch/angular-lynx-build, whose ng build and ng serve builders depend on this plugin and add it to rspeedy's config. To pass it options, import it from there: import { pluginAngularLynx } from '@blotch/angular-lynx-build'.

To run rspeedy directly:

npm install @blotch/rsbuild-plugin-angular-lynx

Usage

Add the plugin to your lynx.config.ts:

import { pluginAngularLynx } from '@blotch/rsbuild-plugin-angular-lynx';
import { defineConfig } from '@lynx-js/rspeedy';

export default defineConfig({
  source: {
    entry: './src/main.ts',
  },
  plugins: [pluginAngularLynx()],
});

What It Does

  • Runs Angular's AOT compiler within Rsbuild/webpack
  • Splits each entry into main-thread and background-thread bundles for Lynx's dual-thread model
  • Bundles component stylesheets and processes CSS
  • Runs Tailwind CSS 3 from a tailwind.config.*, and rewrites the CSS Tailwind CSS 4 writes (layers, @property, nesting, oklch() and color-mix(), logical properties, translate/rotate/scale) into CSS Lynx reads, for the device and the web preview alike. See Tailwind CSS
  • Registers CUSTOM_ELEMENTS_SCHEMA so Angular accepts Lynx elements (<view>, <text>, etc.)
  • Enforces the build target's budgets with ng build's units and messages: a warning is printed, an error fails the build
  • Applies the build target's fileReplacements, as Angular's builders do: both threads' bundles are built from each with file instead of its replace file, and a watch build rebuilds when it changes
  • Adds the Intl APIs the intl option lists, which Lynx lacks, to the Lynx bundle (see Intl)

Budgets

Budgets in angular.json are checked against the lynx environment, the bundles devices load. The web preview isn't checked. A Lynx app ships .bundle files rather than separate scripts and stylesheets, so each budget type measures:

TypeMeasures
initialEach entry's bundle on its own, since a Lynx page loads one bundle
bundleThe bundle of the entry named by name
all / allScriptAll bundles and scripts together (scripts ship inside the bundles)
any / anyScriptEach bundle and script
anyComponentStyleEach component stylesheet, compiled

Media and fonts aren't counted. Under plain rspeedy dev budgets are skipped: the plugin then reads angular.json's default configuration, usually production, whose budgets don't fit a development build. ng serve checks them when the configuration it serves has them, as Angular's dev server does.

Intl

Lynx has no Intl on the main thread, where Angular runs, nor on the background thread except where it runs on JavaScriptCore. The intl build option in angular.json, or pluginAngularLynx({ intl }) when the build target isn't AngularLynx's, adds the APIs it lists to the Lynx bundle, on both threads, before the app's code:

"intl": ["DisplayNames", "NumberFormat", "Collator"]
  • DateTimeFormat, DisplayNames, ListFormat, NumberFormat, PluralRules and RelativeTimeFormat are FormatJS's polyfills, which the app installs (@formatjs/intl-*, with @formatjs/intl-getcanonicallocales and @formatjs/intl-locale; the build names the missing ones). They're optional peer dependencies here, because each package holds every locale's data.
  • The build adds the data of angular.json's i18n.sourceLocale and i18n.locales, and the APIs each one calls (NumberFormat needs PluralRules; DateTimeFormat and RelativeTimeFormat need NumberFormat).
  • Collator is the plugin's own, with localeCompare(): FormatJS has none. The build takes each locale's order of letters from Node's ICU (src/intl/collation-data.ts).
  • With no locale, they use the phone's language (appLocale) when the app has its data, and dates are in the phone's time zone, named by appTimeZone.
  • The web bundle gets none of it: the browser has Intl.

See Internationalization for what's approximate and what it adds to the bundle.

Documentation

Full docs at angularlynx.js.org.

版本与发布记录

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

版本发布日期距今
22.2.18latest2026/11/08今天
22.2.172026/11/08今天
22.2.162026/11/07今天
22.2.152026/11/071 天前
22.2.142026/11/071 天前
22.2.132026/11/062 天前

关于 @blotch/rsbuild-plugin-angular-lynx 的常见问题

@blotch/rsbuild-plugin-angular-lynx 是什么?

Rsbuild plugin for building AngularLynx applications

如何安装 @blotch/rsbuild-plugin-angular-lynx?

在项目目录运行 npm install @blotch/rsbuild-plugin-angular-lynx,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@angular/build(^22.2.0)、@lynx-js/rspeedy(^0.18.0)、@angular-devkit/core(^22.2.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@blotch/rsbuild-plugin-angular-lynx 支持 TypeScript 吗?

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

@blotch/rsbuild-plugin-angular-lynx 支持 ESM 还是 CommonJS?

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

@blotch/rsbuild-plugin-angular-lynx 可以商用吗?

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

@blotch/rsbuild-plugin-angular-lynx 的下载量有多少?

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

@blotch/rsbuild-plugin-angular-lynx 还在维护吗?

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