Back to Tsx

CJS default-import interop

notes/bun/cjs-esm-interop.md

4.23.11789 B
Original Source

CJS default-import interop

Bun intentionally differs from Node for marked CommonJS default exports.

Bun v1.3.14 unwraps exports.default when __esModule: true is present, except when the CommonJS target is inside a type: module package scope. Its released tests lock both outcomes (test matrix).

The runtime calls this a Babel-compatible interpretation and can suppress it with ignoreESModuleAnnotation (implementation). The selector is the importee's package scope, not the importing file's module format, so it is not equivalent to Node, TypeScript, or esbuild policy.