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

Disable cts/mts extensions? #209

Open
michaelfaith opened this issue Mar 29, 2023 · 1 comment
Open

Disable cts/mts extensions? #209

michaelfaith opened this issue Mar 29, 2023 · 1 comment

Comments

@michaelfaith
Copy link

michaelfaith commented Mar 29, 2023

Question

Is it possible to disable the automatic extension naming? In our package, we're generating both cjs and mjs, but the type declarations are the same, and it would be redundant to include both. We'd like to just have .d.ts files in the root, and the cjs/mjs files nested in a cjs and esm folder. I can't seem to find a way to do this without having two sets of type declarations. This is my only real gripe. Otherwise, I've enjoyed the shift to this library.

RE:

if you're using TypeScript v4.7 or newer, the extension of your declaration files will depend on the extensions of your output files as controlled by your Rollup config:

  • .js output files will produce .d.ts and optionally .d.ts.map files
  • .mjs output files will produce .d.mts and optionally .d.mts.map files
  • .cjs output files will produce .d.cts and optionally .d.cts.map files
@liamcmitchell
Copy link

I have used the outputPath hook to rename output files to .d.ts:

  plugins: [
    ts({
      // ...
      hook: {
        outputPath: (path) => path.replace(/\.d\..ts/, '.d.ts'),
      },
    }),

Docs: https://github.com/wessberg/rollup-plugin-ts?tab=readme-ov-file#the-outputpath-hook

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

No branches or pull requests

2 participants