mirror of
https://github.com/oven-sh/bun
synced 2026-02-19 15:21:54 +00:00
The bundler was passing `isNodeMode=1` to `__toESM` for all files with ESM syntax, but it should only do so for files in a true Node.js ESM context (.mjs/.mts extension or "type": "module" in package.json). This caused CJS modules using the `__esModule` + `exports.default` pattern (common in TypeScript-compiled packages) to have their default export double-wrapped when imported from a regular .js file using ESM syntax. The fix preserves the resolver-determined module type (based on file extension and package.json "type" field) through the parse phase into the linker, using it instead of the syntax-based `exports_kind` for the `input_module_type` printer option. Closes #26901 Co-Authored-By: Claude <noreply@anthropic.com>