Skip to content
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

feat: add declarationExt option #219

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

XiNiHa
Copy link

@XiNiHa XiNiHa commented May 28, 2024

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Adds declarationExt option that allows customizing extensions of .d.ts files.

The option behaves like this:

  • declarationExt: undefined
    • keeps the previous behavior (follows the sources' module format prefix (c|m) if available, otherwise .d.ts)
  • declarationExt: "d.ts" | "d.mts" | "d.cts"
    • forces every declaration file emitted to have the configured extension.
  • declarationExt: "infer"
    • infers the desired extension of declaration files based on other options like ext and format.
    • if ext is set, follows its module format prefix (c | m) if available, otherwise .d.ts
    • if format is set to "cjs", .d.ts
    • if format is not set or set to "esm", .d.mts

By introducing this option, it enables users to get declaration files with the correct extensions they should be. It was previously impossible to achieve when emitting multiple format of modules from a single source, since it would always emit .d.ts in that case. Now users can explicitly set declarationExt to have desired extensions, or use "infer" to let mkdist decide the best one.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@BasixKOR

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants