Swatinem / rollup-plugin-dts

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

docs: add clarity to the .default import pattern #275

Closed spiltbeans closed 1 year ago

spiltbeans commented 1 year ago

Describing the problem

If you import the plugin as directed in the docs you may encounter a console error like:

import dts from "rollup-plugin-dts";

const config = [
  // …
  {
    input: "./my-input/index.d.ts",
    output: [{ file: "dist/my-library.d.ts", format: "es" }],
    plugins: [dts()],
  },
];

export default config;
[!] TypeError: dts is not a function

And you will be returned this if you log dts to the console:

{ default: [Function: plugin] }

This is a recorded issue in #247.

Describing the solution

This PR modifies the usage portion of the README.md file to include documentation on how to handle this error by using the package with dts.default(). This PR also includes sources to the issue within the README.md.

Describing changes to the package

This PR only changes the documentation in the README.md and does not affect implementation.

spiltbeans commented 1 year ago

I've created an alternate PR in #274 to solve the same issue. They are different solutions and only one should be accepted.

Swatinem commented 1 year ago

closing in favor of #274