JavaScript API
Rslib provides a comprehensive JavaScript API for developers to directly use Rslib's capabilities in JavaScript or TypeScript code.
Rslib's JavaScript API can be used in Node.js, Deno, or Bun.
v0.19.0 and above.
Getting started
This basic example demonstrates how to use the Rslib JavaScript API.
1. Install Rslib
Install the @rslib/core package:
2. Create an Rslib instance
Call the createRslib method to create an Rslib instance:
The createRslib method accepts various options. Learn more in the API - createRslib documentation.
3. Call Rslib instance methods
The Rslib instance provides several methods for different scenarios.
For example, when building the output, use the rslib.build method which will build production outputs:
For more information about Rslib instance methods, see the Rslib instance documentation.
These three steps cover the basic usage of Rslib. Next, you can customize the build process with Rslib configurations and Rsbuild plugins.
Export formats
Rslib only supports ES Modules formats:
