Lynx/Modules/Build Plugin/API reference
@sigx/lynx-plugin · Stable

API reference#

Every export of @sigx/lynx-plugin — the Rspack / Rspeedy plugin for SignalX Lynx dual-thread rendering.

The package is ESM-only with a single entry point. Everything below is reachable from @sigx/lynx-plugin:

TypeScript
import { pluginSigxLynx, LAYERS, applyEntry } from '@sigx/lynx-plugin';
import type { PluginSigxLynxOptions } from '@sigx/lynx-plugin';

pluginSigxLynx is the default API. LAYERS and applyEntry are low-level escapes for custom build setups.

Functions#

pluginSigxLynx#

Creates the Rspack / Rspeedy plugin that wires SignalX into Lynx's dual-thread (Background + Main Thread) build pipeline. This is the only export most projects use.

TypeScript
export function pluginSigxLynx(options?: PluginSigxLynxOptions): RsbuildPlugin

Parameters

  • options — optional. A PluginSigxLynxOptions object controlling CSS selector / inheritance behavior and debug-info placement. Omit it to use the defaults.

Returns

An RsbuildPlugin — the plugin object you place in your config's plugins array. The returned plugin is named lynx:sigx and declares pre: ['lynx:rsbuild:plugin-api', 'lynx:config', 'lynx:rsbuild:dev'], so it runs after Rspeedy's own config and dev plugins.

Platform: build-time, both iOS and Android. This is not a native module; it produces the dual-thread bundles that the native runtime consumes.

TypeScript
// lynx.config.ts
import { defineConfig } from '@lynx-js/rspeedy';
import { pluginSigxLynx } from '@sigx/lynx-plugin';

export default defineConfig({
  plugins: [pluginSigxLynx()],
});

applyEntry#

Low-level helper that performs the dual-thread entry splitting directly. For each user entry it creates a <name>__main-thread entry in the main-thread layer and a <name> entry in the background layer, then registers the template-webpack-plugin to stitch them into one .lynx template. pluginSigxLynx calls this for you; reach for it only when building a custom plugin or bypassing the standard pipeline.

TypeScript
export declare function applyEntry(
  api: RsbuildPluginAPI,
  opts?: ApplyEntryOptions,
): Promise<void>

Parameters

  • api — the RsbuildPluginAPI handed to a plugin's setup function.
  • opts — optional. An ApplyEntryOptions object with the same CSS / debug fields as PluginSigxLynxOptions. Note that the ApplyEntryOptions type itself is not re-exported from the package root (see Types below).

Returns

A Promise<void> that resolves once the entries and template plugin are registered.

Platform: build-time, both iOS and Android.

Constants#

LAYERS#

Webpack module-layer name constants used to separate the dual-thread bundles — background JS versus main-thread Lepus. Use these when writing custom rules that need to target one layer.

TypeScript
export const LAYERS = {
  BACKGROUND: 'sigx:background',
  MAIN_THREAD: 'sigx:main-thread',
} as const;

Members

  • LAYERS.BACKGROUND'sigx:background'. The layer for the background-thread JS bundle.
  • LAYERS.MAIN_THREAD'sigx:main-thread'. The layer for the main-thread (Lepus) bundle.

Platform: build-time, both iOS and Android.

Types#

PluginSigxLynxOptions#

Configuration options accepted by pluginSigxLynx. All fields are optional.

TypeScript
export interface PluginSigxLynxOptions {
  /** Whether to enable CSS selector support in the Lynx template. @defaultValue true */
  enableCSSSelector?: boolean;
  /** Whether to enable CSS inheritance in the Lynx engine. @defaultValue false */
  enableCSSInheritance?: boolean;
  /** A list of additional CSS properties to inherit beyond the engine defaults. Only effective when enableCSSInheritance is true. */
  customCSSInheritanceList?: string[];
  /** Whether themes and safe-area may ride inline CSS custom properties (requires Lynx ≥ 3.9). @defaultValue true */
  enableCSSInlineVariables?: boolean;
  /** Whether to place debug info outside the template bundle. @defaultValue true */
  debugInfoOutside?: boolean;
}

Fields

  • enableCSSSelector?: boolean — enable CSS selector support in the Lynx template. Default true.
  • enableCSSInheritance?: boolean — enable CSS inheritance in the Lynx engine. Default false.
  • customCSSInheritanceList?: string[] — additional CSS properties to inherit beyond the engine defaults. Only effective when enableCSSInheritance is true.
  • enableCSSInlineVariables?: boolean — let themes (@sigx/lynx-zero ThemeProvider) and safe-area publish inline CSS custom properties for first-frame-perfect runtime theming. Default true; requires Lynx ≥ 3.9 on native hosts. A kill switch for hosts that can't run 3.9.
  • debugInfoOutside?: boolean — place debug info outside the template bundle. Default true.

ApplyEntryOptions#

Parameter type of applyEntry. It carries the same fields as PluginSigxLynxOptions.

TypeScript
export interface ApplyEntryOptions {
  enableCSSSelector?: boolean;        // default true
  enableCSSInheritance?: boolean;     // default false
  customCSSInheritanceList?: string[];
  debugInfoOutside?: boolean;         // default true
}

Note: ApplyEntryOptions is declared in the plugin's internal entry module but is not re-exported through the package root — only the applyEntry function symbol is. Consumers importing from @sigx/lynx-plugin get applyEntry but cannot name ApplyEntryOptions via the public entry. Pass an inline object literal, or use PluginSigxLynxOptions, which has the same shape.

RsbuildPlugin#

Return type of pluginSigxLynx. Imported as a type from @rsbuild/core. The returned object has name: 'lynx:sigx' and pre: ['lynx:rsbuild:plugin-api', 'lynx:config', 'lynx:rsbuild:dev'].

See also#

  • Usage — practical setup and worklet authoring.
  • Overview — what the plugin does at build time.