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

# Function: pluginExternalBundle()

> **pluginExternalBundle**(`options`: [`PluginExternalBundleOptions`](/next/zh/api/packages/external-bundle-rsbuild-plugin/interfaces/PluginExternalBundleOptions.md)): `RsbuildPlugin`

创建一个用于加载 external bundle 的 Rsbuild 插件。

该插件封装了 externals-loading-webpack-plugin，并通过 api.useExposed 自动从 react-rsbuild-plugin 获取 layer 名称。

## Parameters

| Parameter | Type                                                                                                                            |
| --------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `options` | [`PluginExternalBundleOptions`](/next/zh/api/packages/external-bundle-rsbuild-plugin/interfaces/PluginExternalBundleOptions.md) |

## Returns

`RsbuildPlugin`

## Example

```ts
// rsbuild.config.ts
import { pluginExternalBundle } from '@lynx-js/external-bundle-rsbuild-plugin'
import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin'

export default {
  plugins: [
    pluginReactLynx(),
    pluginExternalBundle({
      externals: {
        lodash: {
          bundlePath: 'lodash.lynx.bundle',
          background: { sectionPath: 'background' },
          mainThread: { sectionPath: 'mainThread' },
        },
      },
    }),
  ],
}
```
