Does not unwrap default exports in CJS under default
property
#101
Labels
bug
Something isn't working
default
property
#101
Uh oh!
There was an error while loading. Please reload this page.
Problem
Various transpilers (like TypeScript) put default exports under the
default
property when transpiling ESM to CJS.Meaning:
becomes (roughly):
When consuming such modules, transpilers add "unwrap" helpers (like
tslib.__importDefault
in TypeScript) to detect the__esModule
property inexports
and use thedefault
property.In essence, importing
mylib
from above like this:will produce the following output (roughly) in TypeScript:
This is not the case with pkgroll, it'll consume
mylib
without any helpers or checks during bundling.Please consult the attached repro repository as well as the failing CI showcasing the issue.
Expected behavior
pkgroll uses helpers or detects such cases during bundling to create outputs that handle such cases.
Minimal reproduction URL
https://github.com/enisdenjo/pkgroll-cjs-default-exports-unwrap
Version
v2.5.1
Node.js version
v22.11.0
Package manager
npm
Operating system
macOS
Bugs are expected to be fixed by those affected by it
Compensating engineering work financially will speed up resolution
The text was updated successfully, but these errors were encountered: