Allow CJS to expose the default export with `require(...)` instead of `require(...).default`
- Dominant language
- Rust
- Stars
- 1.3k
- Forks
- 49
- PR merge metrics
- No merged PRs in 30d
Description
Hi, I've been trying to migrate the [TinyColor](https://github.com/bgrins/TinyColor) library to use Deno and cross compile to Node (CJS and ESM). It's all working fine (https://github.com/bgrins/TinyColor/pull/241), except for one problem:
The generated CJS exports the object on `default` when requiring (https://github.com/bgrins/TinyColor/blob/bcfcd1d49181a45fab2dd1858ef22890adba1809/npm/script/mod.js#L50) such that to access it I need to do `var tinycolor = require("tinycolor2").default` whereas the current behavior and external API works like `var tinycolor = require("tinycolor2");`. I don't want to change the existing API as the library is used by a lot of people - is there a way to change the output from dnt to match the current behavior?
My best guess was that it's the `esModuleInterop` option at https://github.com/denoland/dnt/blob/main/mod.ts#L348 which is causing this behavior, but the generated test output also expects to pull the object out of `.default` so maybe there would need to be more changes as well.
Contributor guide
Assessment
This issue has not been assessed yet.