SauravKanchan / svelte-chartjs

svelte wrapper for chart.js
https://saurav.tech/mdbsvelte/?path=/story/charts--examples
MIT License
298 stars 38 forks source link

[Bug]: Imports are broken after upgrade to 3.1.4 #143

Closed coolroman closed 7 months ago

coolroman commented 8 months ago

In 3.1.4 exports are broken:

 import { Bar } from "svelte-chartjs";

Error: Module '"svelte-chartjs"' has no exported member 'Bar'. (ts)

Reproduction

Create new SvelteKit project. Install svelte-chartjs version 3.1.4. Add import from svelte-chartjs (as shown above) to one of your .svelte files. Run npm run svelte-check.

chart.js version

4.4.1

svelte-chartjs version

3.1.4

Possible solution

This amend to "exports" section of package.json fixes the issue (but I`m not 100% sure it is the right way of fixing this):

  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
     ...
    }
}
dysfunc commented 8 months ago

Hey @rkulinsky! Could you provide an example of what you're seeing using CodePen, CodeSandbox, or REPL?

The library is working fine with the same config you specified:

https://codesandbox.io/p/devbox/dry-bush-xy24j5?embed=1

npeeples commented 8 months ago

image

@dysfunc Correct, the package still works, this is a typescript warning.

coolroman commented 8 months ago

@dysfunc I`m using Sveltekit. Sorry, I forgot to mention this issue is a result of "svelte-check" command.

Here is the link to the example: DevBox

(Look at the terminal output there or run yarn svelte-check in a new one).

avi12 commented 8 months ago

I'm using Svelte in Plasmo and I'm experiencing the same issue I discovered this issue when I tried to produce a Chrome extension build

dysfunc commented 8 months ago

This was an oversight on my part from the last release. I fixed the type def path, and a PR is up for review.

niemyjski commented 7 months ago

I've pushed out a new release for this issue.

coolroman commented 7 months ago

I've pushed out a new release for this issue.

Verified. The issue has gone away in my case.