svelte-dts icon indicating copy to clipboard operation
svelte-dts copied to clipboard

[!] (plugin svelte-dts) TypeError: Cannot read properties of undefined (reading 'output')

Open colantuomo opened this issue 2 years ago • 1 comments

Hi guys! I've added this library to a project but Im receiving this error, I dont know what I did wrong.

[!] (plugin svelte-dts) TypeError: Cannot read properties of undefined (reading 'output')

My rollup config looks like this:

import svelte from 'rollup-plugin-svelte';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import autoPreprocess from 'svelte-preprocess';
import svelteDts from 'svelte-dts';

import pkg from './package.json';

const name = pkg.name
  .replace(/^(@\S+\/)?(svelte-)?(\S+)/, '$3')
  .replace(/^\w/, (m) => m.toUpperCase())
  .replace(/-\w/g, (m) => m[1].toUpperCase());

export default {
  input: 'src/index.svelte',
  output: [
    { file: pkg.module, format: 'es' },
    { file: pkg.main, format: 'umd', name },
  ],
  plugins: [
    svelteDts(),
    resolve(),
    commonjs(),
    svelte({ preprocess: autoPreprocess() }),
    typescript(),
  ],
};

colantuomo avatar Jan 03 '23 14:01 colantuomo

if it's gonna help you somehow you gotta pass an options object and define name property which would be your d.ts file. But beat it, it's not working anyway. This plugin and documentation just sucks

But you can try to do something like that

svelteDts({ name: "dist/types.d.ts" })

or just define it in "types" prop in your package.json, cuz it uses it by default. Idk, i've been trying to make it work for like 2 hours and no success. Just find another package which works

fox-foxivich avatar Feb 02 '23 05:02 fox-foxivich