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

feat!: add SvelteKit 2 support #76

Merged
merged 7 commits into from
Dec 17, 2023
Merged

Conversation

userquin
Copy link
Member

No description provided.

package.json Outdated
@@ -50,8 +50,8 @@
"test": "pnpm run -C examples/sveltekit-ts test"
},
"peerDependencies": {
"@sveltejs/kit": "^1.3.1",
"vite-plugin-pwa": ">=0.16.7 <1"
"@sveltejs/kit": "^1.3.1 || ^2.0.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sveltekit 2 requires vite5, sveltekit 1 requires vite4

Copy link
Member Author

@userquin userquin Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a dev dependency, Vite 4 and Vite 5 don't change plugin types, it should be compatible with Rollup 3 and 4.

I've tested this PR also with kit 1 and tests green:

  • extract example from main branch to a new folder
  • remove @vite-pwa/sveltekit from dev dependencies (using workspace protocol)
  • add vite 4.5.1, vite-plugin-pwa, workbox-window, workbox-precaching and workbox-routing as dev dependencies
  • pnpm build && pnpm pack in this PR, copy tgz to the new project folder
  • install the plugin using file protocol: pnpm add -D ./vite-pwa-sveltekit-0.2.10.tgz
  • tests green: pnpm test

https://github.com/userquin/sveltekit1-with-kit2pwa-plugin

@userquin
Copy link
Member Author

userquin commented Dec 15, 2023

Navigation seems to be broken when changing the url, for example (even with export const trailingSlash = 'never'; in layout):

  • navigate to /about/ using the link header (the link is to /about)
  • remove the trailing slash and press enter, kit should redirect to /about/

Previous test with disable: true in PWA configuration.

Maybe we need a breaking change and update the logic, we should include trailing and no trailing variant per route (html page).

I'll try to run the migration...

@userquin
Copy link
Member Author

userquin commented Dec 17, 2023

SvelteKit 2.0.1 fixes trailing slash: added Playwright offline + trailing slash test

@userquin userquin merged commit b24970e into main Dec 17, 2023
@userquin userquin deleted the userquin/feat-add-sveltekit-2-support branch December 17, 2023 14:14
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

Successfully merging this pull request may close these issues.

3 participants