okrad / svelte-progressbar

A multiseries, SVG progressbar component made with Svelte
https://okrad.github.io/svelte-progressbar/
MIT License
129 stars 18 forks source link

Could not load index.mjs for typescript project #32

Open kneumei opened 1 year ago

kneumei commented 1 year ago

Getting this error when doing npm build:

Could not load C:\\node_modules\@okrad\svelte-progressbar\index.mjs (imported by src/App.svelte): ENOENT: no such file or directory, open 'C:\\node_modules\@okrad\svelte-progressbar\index.mjs'

To reproduce:

  1. npx degit sveltejs/template app
  2. node scripts/setupTypeScript.js
  3. npm i
  4. npm i @okrad/svelte-progressbar

    Modify main.ts

    
    import App from './App.svelte';

const app = new App({ target: document.body, props: { name: 'world', series: [{ perc: 20 }, { perc: 42 }] } });

export default app;


Modify App.svelte

Hello {name}!

Visit the Svelte tutorial to learn how to build Svelte apps.



Finally run `npm run build`
kneumei commented 1 year ago

I'm also seeing this, but I think this is just a typescript definition issue that I can ignore.

Argument of type 'typeof ProgressBar' is not assignable to parameter of type 'ConstructorOfATypedSvelteComponent'.
  Type 'ProgressBar' is missing the following properties from type 'ATypedSvelteComponent': $$events_def, $$slot_def, $on

Possible causes:
- You use the instance type of a component where you should use the constructor type
- Type definitions are missing for this Svelte Component. If you are using Svelte 3.31+, use SvelteComponentTyped to add a definition:
  import type { SvelteComponentTyped } from "svelte";
  class ComponentName extends SvelteComponentTyped<{propertyName: string;}> {}ts(2345)
kneumei commented 1 year ago

Downgrading to 1.11.3 looks like it fixes the issue. In this version I see index.js and index.mjs in the node_modules folder

image

In the 2.0.0 version, I don't see these files

image

okrad commented 1 year ago

Hi @kneumei, thank you for reporting! Can you try out the newest release (2.0.1)?

kneumei commented 1 year ago

Thanks @okrad

Looks like the build time errors and warnings are resolved, but now I'm getting a runtime error. I'm not really familiar enough with svelte to diagnose much...but I am running this as I described in my previous post: I just modified the hello world svelte project to include progress bar

image

okrad commented 1 year ago

@kneumei, it should be fixed now, with the added advantage that the library is now converted to Sveltekit!

The disadvantage is that the library doesn't get bundled by default, In case it is needed, the bundled version can get created by running the npm run bundle command.

Can you try it out?