rollup-plugin-ts icon indicating copy to clipboard operation
rollup-plugin-ts copied to clipboard

Type-only files are being removed & declarations are created with a hash

Open overflowz opened this issue 3 years ago • 0 comments

  • Version: 2.0.5
  • Rollup Version: 2.63.0
  • Operating System and version (if applicable):
  • Node Version (if applicable):
  • Does it work with tsc (if applicable): Yes.

Reproduction

Create two files, one for types, another one to use it, for example:

// types.ts
export interface Foo {
  foo: number;
}
// index.ts
import { Foo } from './types';
export const foo: Foo = {
  foo: 123,
};

Now run the build (rollup with rollup-plugin-ts enabled). The output will be the only index.js and types-[hash].d.ts.

Expected Behavior

Files with only declarations inside should be generated as empty js files (or at least have an option to do so) and d.ts files should be generated with the same file name + d.ts

Actual Behavior

Files with only declarations inside get removed and d.ts file is generated with a random hash (i.e., types-1fb4813.d.ts).

Notes

This is actually critical for me when bundling project with preserveModules set to true, because for example in my case, things generated like this: some/path/to/declarations.ts does not generate any js file (which is fine, but at least I need .d.ts to be generated in that place with the original name + .d.ts) and in the root of build folder, it generates declarations-951a8ca8.d.ts.

overflowz avatar Jan 09 '22 19:01 overflowz