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

Broken example imports? (bug/question) #246

Open
lucasl84 opened this issue Oct 16, 2024 · 0 comments
Open

Broken example imports? (bug/question) #246

lucasl84 opened this issue Oct 16, 2024 · 0 comments

Comments

@lucasl84
Copy link

Hi there,

Just opening this issue as I already had a basic SvelteKit app running. Cloned the repo and tried to directly integrate the examples by simply copying the relevant code to each appropriate place. Thing is I got this error:

2:52:04 PM [vite] Internal server error: Failed to resolve import "$dist" from "src/routes/dependencies/+page.svelte". Does the file exist?

which I resolved simply by replacing all $dist imports to:

import { SvelteGantt, SvelteGanttDependencies, SvelteGanttTable, MomentSvelteGanttDateAdapter } from 'svelte-gantt/svelte';

Is the $dist import correct? Moreover, simply checking out the repo, installing the dependencies, running npm run dev and then navigating to any of the relevant pages I get a 500 (here's the trace from Vite):

  VITE v4.0.1  ready in 865 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h to show help
Failed to load url /tmp/svelte-gantt/examples/dist (resolved id: /tmp/svelte-gantt/examples/dist). Does the file exist?
Failed to load url /tmp/svelte-gantt/examples/dist (resolved id: /tmp/svelte-gantt/examples/dist). Does the file exist?
Error: Failed to load url /tmp/svelte-gantt/examples/dist (resolved id: /tmp/svelte-gantt/examples/dist). Does the file exist?
    at loadAndTransform (file:///tmp/svelte-gantt/examples/example-sveltekit/node_modules/vite/dist/node/chunks/dep-2285ba4f.js:40373:21)
Failed to load url /tmp/svelte-gantt/examples/dist (resolved id: /tmp/svelte-gantt/examples/dist). Does the file exist?
Error: Failed to load url /tmp/svelte-gantt/examples/dist (resolved id: /tmp/svelte-gantt/examples/dist). Does the file exist?
    at loadAndTransform (file:///tmp/svelte-gantt/examples/example-sveltekit/node_modules/vite/dist/node/chunks/dep-2285ba4f.js:40373:21)
Failed to load url /tmp/svelte-gantt/examples/dist (resolved id: /tmp/svelte-gantt/examples/dist). Does the file exist?
Error: Failed to load url /tmp/svelte-gantt/examples/dist (resolved id: /tmp/svelte-gantt/examples/dist). Does the file exist?
    at loadAndTransform (file:///tmp/svelte-gantt/examples/example-sveltekit/node_modules/vite/dist/node/chunks/dep-2285ba4f.js:40373:21)
3:09:23 PM [vite-plugin-svelte] ssr compile in progress ...
Failed to load url /tmp/svelte-gantt/examples/dist (resolved id: /tmp/svelte-gantt/examples/dist). Does the file exist? (x2)
Failed to load url /tmp/svelte-gantt/examples/dist (resolved id: /tmp/svelte-gantt/examples/dist). Does the file exist?
Error: Failed to load url /tmp/svelte-gantt/examples/dist (resolved id: /tmp/svelte-gantt/examples/dist). Does the file exist?
    at loadAndTransform (file:///tmp/svelte-gantt/examples/example-sveltekit/node_modules/vite/dist/node/chunks/dep-2285ba4f.js:40373:21)
3:09:24 PM [vite-plugin-svelte] ssr compile done.
package       	files	 time	   avg
demo-sveltekit	    7	0.16s	23.0ms

Then after doing the import replacement as mentioned above re-running the examples I get:

> [email protected] dev
> vite dev


svelte-gantt doesn't appear to be written in CJS, but also doesn't appear to be a valid ES module (i.e. it doesn't have "type": "module" or an .mjs extension for the entry point). Please contact the package author to fix.

  VITE v4.0.1  ready in 834 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h to show help
Failed to load url svelte-gantt/svelte (resolved id: svelte-gantt/svelte). Does the file exist?
Cannot find module 'svelte-gantt/svelte' imported from '/tmp/svelte-gantt/examples/example-sveltekit/src/routes/+page.svelte'

Then I updated the svelte-gantt dependency to 4.4.2 and once again I got:

npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: [email protected]
npm error Found: [email protected]
npm error node_modules/svelte
npm error   dev svelte@"^3.54.0" from the root project
npm error
npm error Could not resolve dependency:
npm error peer svelte@"^4.0.0" from [email protected]
npm error node_modules/svelte-gantt
npm error   svelte-gantt@"4.4.2" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.

At this point I decided to give up with the examples from the cloned repo. As previously mentioned using an existing (and relatively up to date) SvelteKit app, copying relevant files and updating the imports made the trick. I think the examples should be tested and bring up to date, as of upmost importance for anyone trying to integrate your plugin with an existing app.

Thanks,
Lucas.

@lucasl84 lucasl84 changed the title Broken imports? (bug/question) Broken example imports? (bug/question) Oct 17, 2024
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

1 participant