Swatinem / rollup-plugin-dts

A rollup plugin to generate .d.ts rollup files for your typescript project
GNU Lesser General Public License v3.0
815 stars 71 forks source link

error d.ts #286

Open liuseen-l opened 1 year ago

liuseen-l commented 1 year ago
rollup.config.ts
{
  input: ['./packages/nova/index.ts'],
  output: [
    {
      dir: 'dist/es',
      format: 'esm',
      preserveModules:true,
    },
  ],
  external:['lodash'],
  plugins: [ dts() ]
}

the compoents/index.d.ts is lost image

the nova/index.ts

export * from '../components'
export * from '../c'

the components/index.ts

export * from './button'
export * from './menu'

and the nova/index.d.ts is not right? image

aimee-gm commented 1 year ago

@liuseen-l Following the README.md:

While this plugin is fairly complete, it does not support all imaginable use-cases. In particular, the plugin works best with already existing .d.ts files generated by the typescript compiler from idiomatic code.

Working with .ts(x) or even .js(x) (when setting allowJs: true) does work, but is not recommended.

I've got it working by adding this as an additional step in rollup:

export default [
  {
    input: "./src/index.ts",
    plugins: [
      typescript(...), // tsconfig outputs type declarations to `/types`
      ...
    ],
    output: [...],
  },
  {
    input: "./dist/types/index.d.ts",
    output: [{ file: "dist/index.d.ts", format: "es" }],
    plugins: [dts()],
  },
];