Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not load index.mjs for typescript project #32

Open
kneumei opened this issue Mar 16, 2023 · 5 comments
Open

Could not load index.mjs for typescript project #32

kneumei opened this issue Mar 16, 2023 · 5 comments

Comments

@kneumei
Copy link

kneumei commented Mar 16, 2023

Getting this error when doing npm build:

Could not load C:<Path-To-My-App>\node_modules@okrad\svelte-progressbar\index.mjs (imported by src/App.svelte): ENOENT: no such file or directory, open 'C:<Path-To-My-App>\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

<script lang="ts">
  import type { Series } from "@okrad/svelte-progressbar";
  import ProgressBar from "@okrad/svelte-progressbar";
  export let name: string;
  export let series: Series[] = [];
</script>

<main>
  <h1>Hello {name}!</h1>
  <p>
    Visit the <a href="https://svelte.dev/tutorial">Svelte tutorial</a> to learn
    how to build Svelte apps.
  </p>
  <ProgressBar {series} />
</main>

Finally run npm run build

@kneumei
Copy link
Author

kneumei commented Mar 16, 2023

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
Copy link
Author

kneumei commented Mar 16, 2023

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
Copy link
Owner

okrad commented Mar 21, 2023

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

@kneumei
Copy link
Author

kneumei commented Mar 21, 2023

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
Copy link
Owner

okrad commented Mar 22, 2023

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants