---
url: /reference/OutputOptions.esModule.md
---
# esModule

* **Type**: `boolean` | `"if-default-prop"`
* **Optional**

Whether to add a `__esModule: true` property when generating exports for non-ES [formats](./OutputOptions.format).

This property signifies that the exported value is the namespace of an ES module and that the default export of this module corresponds to the `.default` property of the exported object.

* `true`: Always add the property when using [named exports mode](./OutputOptions.exports), which is similar to what other tools do.
* `"if-default-prop"`: Only add the property when using [named exports mode](./OutputOptions.exports) and there also is a default export. The subtle difference is that if there is no default export, consumers of the CommonJS version of your library will get all named exports as default export instead of an error or `undefined`.
* `false`: Never add the property even if the default export would become a property `.default`.

## Default

'if-default-prop'

## Interaction with Consuming Tools

Different tools handle the `__esModule` marker differently when importing your bundle:

* **Rolldown**: Use heuristics based on Node.js's behavior. See the [Bundling CJS](/in-depth/bundling-cjs#ambiguous-default-import-from-cjs-modules) guide for more details.
* **esbuild**: Use heuristics based on Node.js's behavior.
* **Node.js**: Does not respect `__esModule`. The default export is the `module.exports` value.
* **Babel**: Respects `__esModule`.
