> 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.

# @lynx-js/lynxtron-dev-plugins

`@lynx-js/lynxtron-dev-plugins` 提供构建插件，用于协调 RSpeedy、Rspack 和 Lynxtron 进程启动。

## RSpeedy Dev Ready 插件

从 `@lynx-js/lynxtron-dev-plugins/rspeedy` 引入 `pluginRspeedyDevReady()`：

```ts
import { pluginRspeedyDevReady } from '@lynx-js/lynxtron-dev-plugins/rspeedy';

export default {
  plugins: [pluginRspeedyDevReady()],
};
```

该插件在 RSpeedy dev server 启动和首次编译完成时输出可被其他开发脚本识别的状态：

| 输出 / 文件                       | 说明                                          |
| ----------------------------- | ------------------------------------------- |
| `RSPEEDY_DEV_SERVER:<port>`   | dev server 启动后输出端口。                         |
| `RSPEEDY_READY`               | 首次 dev 编译完成后输出。                             |
| `.tmp/dev-ready.rspeedy.json` | 首次 dev 编译完成后写入 `{ "ready": true }`，供等待脚本读取。 |

## dev-ready-rspeedy CLI

`dev-ready-rspeedy` 会等待 `.tmp/dev-ready.rspeedy.json` 出现并确认 `ready: true`，成功后删除该文件并输出 `dev-ready-speedy`。默认等待超时时间为 300 秒。

```bash
npx dev-ready-rspeedy
```

## Rspack Lynxtron 插件

从 `@lynx-js/lynxtron-dev-plugins/rspack` 引入 `pluginLynxtron()`：

```ts
import { pluginLynxtron } from '@lynx-js/lynxtron-dev-plugins/rspack';

export default {
  plugins: [
    pluginLynxtron({
      entry: './dist/main/main.js',
      isDev: true,
      args: ['--inspect=9222'],
    }),
  ],
};
```

仅当 `isDev` 为 `true` 且提供 `entry` 时，插件才会在编译完成后启动或重启 Lynxtron 进程。AutoLink 默认开启，在开发和生产构建中均生效；仅使用 AutoLink 时无需设置 `entry`。

| 选项         | 类型                       | 说明                                                                            |
| ---------- | ------------------------ | ----------------------------------------------------------------------------- |
| `entry`    | `string`                 | 可选，传给 Lynxtron CLI 的应用入口；开发期自动启动时需要设置。                                        |
| `isDev`    | `boolean`                | 开发模式标记；为 `true` 时关闭 minimize。插件会将 Rspack 的 `optimization.nodeEnv` 设为 `false`。 |
| `args`     | `string[]`               | 传给 Lynxtron CLI 的额外参数。                                                        |
| `autolink` | `boolean`                | 是否启用原生库 AutoLink，默认 `true`。                                                   |
| `env`      | `Record<string, string>` | 传给 Lynxtron 子进程的额外环境变量。                                                       |
| `command`  | `string`                 | Lynxtron 启动命令，默认是 `lynxtron`。                                                 |
