output.module
- Type:
boolean - Default:
false
Whether to output JavaScript files in ES modules format.
Tip
- This feature is currently experimental and only available when output.target is
'web'or'node'. - If you need to build JavaScript libraries in ESM format, we recommend using Rslib, which is an out-of-the-box library development tool built on top of Rsbuild.
Web applications
When building a web application, Rsbuild generates the output in the IIFE format by default.
If you want to output ES Modules instead, set output.module to true:
rsbuild.config.ts
Tip
When output.module is enabled, Rsbuild automatically adds type="module" to the generated <script> tags, meaning html.scriptLoading is set to module.
Node.js applications
When building Node.js applications, Rsbuild outputs CommonJS format by default. You can set output.module to true to output ES modules format:
rsbuild.config.ts
Running ESM bundles
To properly run ESM bundles in Node.js, you can choose either of the following approaches:
- Set the
typefield in package.json to'module':
package.json
- Change the output JavaScript file extension to
.mjs:
rsbuild.config.ts

