-
-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] Generate esm-specific declaration files #760
Comments
My current workaround is to use the following in the config file (I have the inverse issue): async onSuccess() {
await cp(
resolve(__dirname, "dist/index.d.ts"),
resolve(__dirname, "dist/index.d.cts"),
);
}, (Needs more work for more complex libs, of course). |
For some extra context: pmndrs/zustand#1381 TL;DR: TypeScript treats the below as CJS even when technically MJS is used under the covers when
Or vice verse if the module is So the missing part of |
The |
Ooh, I must be copying the old |
any solution for this? It's breaking the type import in pnpm workspace with |
Should be fixed by #934? |
We are using tsup in storybook to bundle our files and create
.d.ts
files. A user, @weswigham, explained to us that we need to actually create separate type definition files for esm and cjs. Is this something that others have encountered? If so, maybe it makes sense for tsup to generate both.d.ts
and.d.mts
files.It looks like this is a typescript 4.7+ feature, and is explained in https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#package-json-exports-imports-and-self-referencing, which shows separate declaration files for the esm and cjs exports.
The
.d.mts
and.d.cts
extensions themselves are supported from 4.5+ (https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta/#new-file-extensions)The text was updated successfully, but these errors were encountered: