mefechoel / svelte-navigator

Simple, accessible routing for Svelte
Other
508 stars 39 forks source link

Support Svelte 4 #111

Open Foorack opened 1 year ago

Foorack commented 1 year ago

Currently svelte-navigator has a dependency on Svelte 3.x, which causes issues for projects wanting to upgrade to Svelte 4.

$ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: svelte-navigator@3.2.2
npm ERR! Found: svelte@4.0.1
npm ERR! node_modules/svelte
npm ERR!   dev svelte@"^4.0.1" from the root project
npm ERR!   peer svelte@"^3.54.0 || ^4.0.0-next.0" from @sveltejs/kit@1.20.1
npm ERR!   node_modules/@sveltejs/kit
npm ERR!     peer @sveltejs/kit@"^1.0.0" from @sveltejs/adapter-auto@2.1.0
npm ERR!     node_modules/@sveltejs/adapter-auto
npm ERR!       dev @sveltejs/adapter-auto@"^2.1.0" from the root project
npm ERR!   9 more (@sveltejs/vite-plugin-svelte, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer svelte@"3.x" from svelte-navigator@3.2.2
npm ERR! node_modules/svelte-navigator
npm ERR!   dev svelte-navigator@"^3.2.2" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: svelte@3.59.2
npm ERR! node_modules/svelte
npm ERR!   peer svelte@"3.x" from svelte-navigator@3.2.2
npm ERR!   node_modules/svelte-navigator
npm ERR!     dev svelte-navigator@"^3.2.2" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
norricorp commented 1 year ago

Working with svelte 4 would be very useful. Last commit was 8 months ago. Is the project still active?

flpms commented 1 year ago

That's a good question, I already schedule a change to sveltekit after see this issue.

Be sides exists the roadmap https://github.com/mefechoel/svelte-navigator/issues/19

norricorp commented 1 year ago

I have forked the project (norricorp/svelte4-navigator), downloaded it and made changes. It compiles and I have used it in my project (which is also upgraded to svelte 4) and it all appears to work. I have no pushed the changes yet. So after the changes have been pushed, I open a PR to go from norricorp/svelte4-navigator to mefechoel/svelte-navigator? But that depends if mefechoel is still updating it. Is there a test suite I can run against my change?

norricorp commented 1 year ago

I have commited to the forked repo and created a pull request to the part repo. I guess it is up to mefechoel now?

mefechoel commented 1 year ago

Hello there ans thanks for the pr! Unfortunately i don't have a lot of time to work on the project, but i'll try to review your pr soon. There are quite extensive tests, you can run using the npm test command. I'll also run them in the github actions pipeline of you pr, so you'll see the results there too.

vdawg-git commented 1 year ago

Hey guys, which other libraries for routing can you recommend?

Foorack commented 1 year ago

I migrated my app to SvelteKit and used its routing instead. Pain-free transition but took some time. Did it all in one big go. -------- Original Message -------- On Aug 28, 2023, 12:19, Visual-Dawg wrote:

Hey guys, which other libraries for routing can you recommend?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

norricorp commented 1 year ago

I agree that svelte kit is the answer but I would like to get svelte navigator working with svelte 4 just because ....

kevin4dhd commented 1 year ago

any solution?

norricorp commented 1 year ago

Unfortunately not. I think override is the short term answer and sveltekit is the long term answer. With regard to testing, the test app definitely behaves differently in the svelte 3 and 4 versions, with chunks of code not called in history.js. It may possibly the test app that is the problem.

pndiogo commented 1 year ago

While SvelteKit seems to be the more future proof approach, svelte-navigator is just a nice library to implement on an existing Svelte project. Is there any perpective of updating it's Svelte dependency to version 4?

norricorp commented 1 year ago

Hi @pndiogo, basically I am stuck so any help would be great. I have run the svelte 4 migration (which updated svelteinternal.d.ts) and package.json. The changes pass unit tests and it works fine in my app. But the integration tests fail. I have added console.logging to both my changes and the original svelte3 code and can see where functions are not called in the former but no idea why this is happening. Could even be the test app.

I completely agree with your comment that svelte-navigator is just easier to use for an existing project. Certainly moving to sveltekit is a lot of work.

If you would like to discuss further than am more than happy to email you directly.

MrBns commented 1 year ago

I think this project is died. owner should archive this repo so that everyone can understand.

flpms commented 1 year ago

I already fork the project and try to learn more about it. anyone here already tried the project that's was forked?

https://github.com/EmilTholin/svelte-routing

This project seems continue be maintained

sushidub commented 1 year ago

UPDATE: Nevermind, I see in your commit you've just updated the dependencies list which I can do myself locally. Good luck on the testing.


@norricorp

I think override is the short term answer ...

I realize your fork and PR solves this issue and your now just waiting on help from the current maintainer to get the integration tests to pass. In theory tho, is it possible to go ahead and use your override for those of us that don't want to wait on the PR merge (assuming our own risk of course). If so, do you have a commit hash you would recommend using with just the override and not all the testing mumble jumble?

abrman commented 1 year ago

I used npm install svelte-navigator --force seems to work also, but you'll never feel clean again.

ignatij commented 9 months ago

Any progress here on this issue? We struggle with the same problem

dysfunc commented 9 months ago

This is what I'm using in our production app:

"overrides": {
  "svelte-navigator": {
    "svelte": ">=4.x"
  }
}

I've started working on a branch to migrate this package to Svelte 4+. It's partially done, but a decent amount to go.

marekdedic commented 9 months ago

Unfortunately, it seems that svelte-navigator may be abandoned. I am currently switching to SvelteKit (with adapter-static) due to this... :(

norricorp commented 9 months ago

That was the conclusion I came to as well. Just to add that restructuring for sveltekit is a lot of work and it did make me realise how convienient svelte-navigator is so a great shame that it is no more.

flpms commented 9 months ago

Did you consider use the original https://github.com/EmilTholin/svelte-routing? This project is a fork from svelte-routing, may it's more easy to migrate.

Sadly I didn't tried yet, but I'll pretty soon

Unfortunately, it seems that svelte-navigator may be abandoned. I am currently switching to SvelteKit (with adapter-static) due to this... :(

norricorp commented 3 months ago

I decided eventually to use Sveltekit but I do like the idea of navigator which does one thing. Anyway, I had another attempt and the problem was with the test app rather than the actual library and I now have the tests passing. And eventually got lint passing I have now hit problems with husky when it comes to commiting. But I think the underlying problem is with prettier where I get "No parser could be inferred for file ...." Using prettier 3.3.3 and prettier-plugin-svelte3.2.6