You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@rollup/plugin-typescript can be used to generate dual CJS + ESM builds, and it correctly generates *.cjs files using entryFilenames. However, for .cjs files, TypeScript requires a .d.cts matching extension. But this plugin will always output at *.d.ts, no matter the settings.
This means when you have a dual CJS + ESM build, you should be getting 2 copies of declarations, but one will always overwrite the other. Yes, the contents are identical. Yes, TypeScript should just figure it out. But TypeScript has chosen to require 1 definition to 1 file, always, which means .cjs files are untyped unless explicit .d.cts definitions exist.
Same for .mjs—if requested, those need .d.mts files as well, if using that extension.
@rollup/plugin-typescript
Feature Use Case
@rollup/plugin-typescript can be used to generate dual CJS + ESM builds, and it correctly generates
*.cjs
files usingentryFilenames
. However, for.cjs
files, TypeScript requires a.d.cts
matching extension. But this plugin will always output at*.d.ts
, no matter the settings.This means when you have a dual CJS + ESM build, you should be getting 2 copies of declarations, but one will always overwrite the other. Yes, the contents are identical. Yes, TypeScript should just figure it out. But TypeScript has chosen to require 1 definition to 1 file, always, which means
.cjs
files are untyped unless explicit.d.cts
definitions exist.Same for
.mjs
—if requested, those need.d.mts
files as well, if using that extension.Feature Proposal
Given this Rollup config, this should produce
*.d.cts
declarations. This may be a breaking change for some folks, but would satisfy TypeScriptThe text was updated successfully, but these errors were encountered: