rollup-plugin-svelte-types

raw JSON →
1.0.6 verified Mon Apr 27 auth: no javascript

A Rollup plugin that generates TypeScript declaration (.d.ts) files for Svelte components, extracting props and events types. Version 1.0.6 is current; no frequent releases. Key differentiator: automates type generation for Svelte components in Rollup builds, reducing manual type work.

error Error: Could not find module 'svelte/compiler'
cause Missing svelte package in node_modules.
fix
npm install svelte --save-dev
error Error: Cannot find module 'rollup-plugin-svelte-types'
cause Package not installed or incorrect import path.
fix
npm install rollup-plugin-svelte-types --save-dev
gotcha Plugin requires svelte and svelte/compiler as implicit dependencies; does not install them automatically.
fix Ensure svelte is installed in your project.
breaking In version 1.0.0, the default declaration directory changed from './types' to './dist/types' only if libRoot is not set.
fix Set declarationDir explicitly to control output location.
deprecated Options `tsconfig` and `compilerOptions` were deprecated in v1.0.0; use TypeScript project configuration instead.
fix Ensure tsconfig.json is present; remove `tsconfig` and `compilerOptions` from plugin config.
gotcha Plugin may generate type errors if Svelte components have TypeScript syntax but no tsconfig covers the src directory.
fix Place a tsconfig.json in your project root or set `libRoot` to a directory with a tsconfig.
npm install rollup-plugin-svelte-types
yarn add rollup-plugin-svelte-types
pnpm add rollup-plugin-svelte-types

Minimal Rollup config using svelteDts plugin with custom libRoot and declarationDir, alongside svelte and resolve plugins.

import svelteDts from 'rollup-plugin-svelte-types';
import svelte from 'rollup-plugin-svelte';
import resolve from '@rollup/plugin-node-resolve';

export default {
  input: 'src/main.js',
  output: {
    dir: 'public',
    format: 'esm'
  },
  plugins: [
    svelteDts({
      libRoot: './src',
      declarationDir: './dist/types'
    }),
    svelte(),
    resolve()
  ]
};