output.module
- Type:
boolean - Default:
truewhenoutput.targetisnode, otherwisefalse
Whether to output JavaScript files in ES modules format.
- 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:
When output.module is enabled, Rsbuild automatically adds type="module" to the generated <script> tags, meaning html.scriptLoading is set to module.
Web Workers
When output.target is 'web-worker', set output.module to true to output an ES module worker bundle, for example for runtimes that load workers with type: 'module':
Node.js applications
When building Node.js applications, Rsbuild outputs ES modules format by default. You can set output.module to false to output CommonJS format instead:
Running ESM bundles
Choose either of the following approaches to run ESM bundles in Node.js:
- Set the
typefield in package.json to'module':
- Change the output JavaScript file extension to
.mjs:

