Skip to content

[feature] Generate esm-specific declaration files #760

Closed
@IanVS

Description

@IanVS

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions