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

Option to specify outExtension for generated dts files? #939

Open
errmayank opened this issue Jun 28, 2023 · 4 comments · May be fixed by #1235
Open

Option to specify outExtension for generated dts files? #939

errmayank opened this issue Jun 28, 2023 · 4 comments · May be fixed by #1235

Comments

@errmayank
Copy link

errmayank commented Jun 28, 2023

Like we can modify output extension of JavaScript files is there also a way to do the same for type definition files?

I tried returning this because dts was showing up in the autocomplete return options but it doesn't work.

format: ['cjs', 'esm'],
outExtension({ format }) {
  switch (format) {
    case 'cjs': {
      return { js: '.cjs', dts: '.d.cts' };
    }
    case 'esm': {
      return { js: '.mjs', dts: '.d.mts' };
    }
    default: {
      return { js: '.js', dts: '.d.ts' };
    }
  }
}

Output type definition files generated after building have extensions .d.ts and .d.cts which is the default since my package is of type module. Is there a way to do this?

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@rodrigoehlers
Copy link

Facing the exact same problem.

@egorderg
Copy link

It looks like 'outExtension' is overridden to 'undefined' when it's passed to rollup. In the rollup dts handling is even a check if there is a custom 'outExtension'.

@Lonli-Lokli
Copy link

Lonli-Lokli commented Sep 6, 2024

is there any workaround? I would like to use 'file.d.mts' for esm typings.

There is no merged PR but seems like nobody want to merge it

@Lonli-Lokli
Copy link

Lonli-Lokli commented Sep 9, 2024

@zvictor Seems like dts factory has been disabled explicitly?
#668

Is there any way to specify it, eg use https://github.com/vkiryukhin/jsonfn?

Or merge https://github.com/egoist/tsup/pull/1053/files ?

@aryaemami59 aryaemami59 linked a pull request Oct 16, 2024 that will close this issue
2 tasks
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 a pull request may close this issue.

4 participants