Closed tscpp closed 1 year ago
I accidentally posted the issue when it was incomplete. I edited the issue after posting it. If you are reading from email, it might not be up to date. Sorry for any incontinence.
I have created two pull requests which both addresses this issue. Feel free to close or merge either or both of them.
As I mentioned in #21, I went down the wrong rabbit hole. I realized how stupid my issue was. I am closing this issue but leaving #22 open if it is wanted.
Describe the bug A clear and concise description of what the bug is.
I am using
"module": "Node16"
in mytsconfig.json
which also implies"moduleResolution": "Node16"
. The "Node16" module resolution needs to identify this package as an ESM compatible module to be able to handle the exports type correctly.However, because this package doesn't have a"module": "..."
field the "Node16" module resolution recognizes this package as a CommonJS module, which causes all exports to be named, including the default exports.It seems to be caused by having the"types": "..."
field in the "exports" field. I tried to remove the "types" field from "exports", and it suddenly worked. I have no idea why.So in my case, this happens:
To Reproduce Steps to reproduce the behavior:
tsconfig.json
with"module": "Node16"
.Expected behavior A clear and concise description of what you expected to happen.
The package should include a"module": "..."
field in order for TypeScript to recognize the package as an ESM module.I think this may deserve an issue in TypeScript.
But for now, removing "exports.types" would fix this issue.One solution I found working was to set"type": "module"
.Alternatively, or additionally, export
EntryShakingPlugin
as a named export in addition to the default export. This also improves other aspects too. See https://basarat.gitbook.io/typescript/main-1/defaultisbad.