boolean
false
Whether to output JavaScript files in ES modules format.
'node'
.When building Node.js bundles, Rsbuild outputs CommonJS format by default. You can set output.module
to true
to output ES modules format:
export default {
output: {
target: 'node',
module: true,
},
};
To properly run ESM bundles in Node.js, you can choose either of the following approaches:
type
field in package.json to 'module'
:{
"type": "module"
}
.mjs
:export default {
output: {
filename: {
js: '[name].mjs',
},
},
};