For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt, and this page is available as Markdown at /next/zh/api/packages/external-bundle-rsbuild-plugin/interfaces/ReactLynxExternalsPresetOptions.md.
Lynx
  • 简体中文
  • Interface: ReactLynxExternalsPresetOptions

    内置 reactlynx externals 预设的选项。

    Properties

    async?

    optional async?: boolean | ((context: object) => boolean)

    选择是否异步加载 ReactLynx 运行时 bundle。

    web 运行时(@lynx-js/web-core)只能通过 fetchBundle().then 异步获取 external bundle,因此 ReactLynx 必须以 promise 形式挂载,使用它的模块需要先等待该 promise 再读取子路径,否则 React.memo 等会从尚未完成的 promise 上读取,得到 undefined。独立回调可根据 systemInfo 在运行时选择加载方式。回调会序列化到 bundle 中,不能引用构建配置里的变量或导入。回调模式始终使消费模块异步执行,即使选择了同步加载。

    该选项仅控制运行时的挂载方式;在 lynx / lynx-* 以外的 environment 中会选用 web bundle。

    Example

    { async: ({ systemInfo }) => ['Harmony', 'web'].includes(String(systemInfo['platform'])) }

    Default Value

    false


    bundlePath?

    optional bundlePath?: string

    将 ReactLynx 运行时 bundle 产出到当前构建产物中,并通过生成的运行时 public path 加载。

    对于普通的 Rspeedy 项目,优先使用它而不是 url。除了让 运行时从 publicPath 解析出最终 URL 之外,该插件还会 将对应的 @lynx-js/react-umd bundle 复制到产物中, 这样应用 bundle 就可以引用它,而无需在发布时额外手动复制。

    Default Value

    'react.lynx.bundle';在 lynx / lynx-* 以外的 environment 中为 'react.web.bundle'


    reactUmdPackageName?

    optional reactUmdPackageName?: string

    提供 ReactLynx 运行时 bundle 的包名。

    为其他发行版封装该插件时(例如 @byted-lynx/react-umd),可覆盖该选项。

    Default Value

    '@lynx-js/react-umd'


    url?

    optional url?: NonNullable<string | (() => string | Promise<string>) | undefined>

    直接覆盖运行时 bundle 的 URL。

    仅当 ReactLynx 运行时托管在当前构建产物之外(例如 CDN 上)时才使用该选项。与 bundlePath 不同,该选项不会向当前编译产出任何额外资源。

    Deprecated

    建议优先使用 bundlePath,它通过运行时 public path 解析,并支持自动产出资源。

    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。