For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /config/lib/index.md.
close
  • English
  • Overview

    The lib field is an optional array of objects used to describe the library outputs generated by Rslib. Each lib item corresponds to one output and can contain lib configurations and Rsbuild configurations, as detailed in Configure Rslib.

    • Type: LibConfig[] (see RslibConfig)
    • Default: [{}]
    • Required: false

    When the lib field is omitted, Rslib uses a default configuration equivalent to lib: [{}] to generate a single output. The output format is specified by the top-level format; if no top-level format is configured, the output format defaults to 'esm'.

    When the lib field is explicitly configured, its value must be a non-empty array.

    For example, the following configuration will generate ESM and CJS outputs:

    rslib.config.mjs
    export default {
      lib: [
        {
          format: 'esm',
        },
        {
          format: 'cjs',
        },
      ],
    };

    Top-level lib configurations

    The following lib configurations can be placed outside the lib field as top-level configuration shared across lib outputs, or inside a lib item to configure a specific output:

    Non-top-level lib configurations

    The following lib configurations do not support top-level configuration and can only be specified in a lib item to configure an individual output: