Hi,
I've noticed that format: ["cjs", "esm", "iife"],
and format: ["cjs", "esm"]
leads to different extensions being used. In the first scenario, .js
is the ES Module. In the second scenario, .js
is the CommonJS file.
This behaviour can be confusing, all the more that if you add type: "module"
to a package.json, it changes the way .js
files are interpreted. If you enable it, they are considered ES Modules (so a CommonJS export with extension .js
will fail at import), if you disable it that's the contrary.
I lost a few hours trying to grasp all those concept, and would have avoided the issue altogether with more explicit extensions.
It would probably be better to be always explicit, with .cjs
for the CommonJS export and .mjs
export. Or if it's a breaking change, make this an option.
I don't know if this behaviour comes from Tsup or Esbuild, so I can open an issue at Esbuild if necessary.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too