-
Notifications
You must be signed in to change notification settings - Fork 41
Breaking: Svelte 5 #295
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
Breaking: Svelte 5 #295
Conversation
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks so much @Antosik for taking of this big migration effort! 👍
i've been meaning to tackle this as well but haven't gotten to it yet so really appreciated 🙏
contributing.md
Outdated
@@ -12,6 +12,7 @@ To submit a pull request, clone the repo, install dependencies and start the dev | |||
git clone https://github.com/janosh/svelte-multiselect | |||
cd svelte-multiselect | |||
npm install | |||
npm run package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think contributors need to run npm run package
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running npm run dev
requires calling npm run package
first. Without it, SvelteKit can’t load the library from the dist
folder, resulting in an error like:
[plugin:vite:import-analysis] Failed to resolve entry for package "svelte-multiselect". The package may have incorrect main/module/exports specified in its package.json.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, good call! i think having the package import itself may be an antipattern. i mainly did it so that the mdsvexample
code fences show the package name as users would write it instead of $lib
- import MultiSelect from '$lib'
+ import MultiSelect from 'svelte-multiselect'
package.json
Outdated
"@testing-library/jest-dom": "^6.6.3", | ||
"@testing-library/svelte": "^5.2.6", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally, i would like to stick to pure vitest
unit testing. can we do without @testing-library
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I referenced @testing-library based
on the docs:
While the process is very straightforward, it is also low level and somewhat brittle, as the precise structure of your component may change frequently. Tools like @testing-library/svelte can help streamline your tests.
That said, I’m ready to revert to pure Vitest if you prefer it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes please. i've been using pure vitest on several different projects and so far it's been great. haven't felt the need for additional testing packages and like to keep things lean.
tests/unit/Test2WayBind.svelte
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can get rid of this file entirely now with runes? never liked this hacky workaround for testing 2-way binding...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not entirely sure about that. The docs mention:
When writing component tests that involve two-way bindings, context, or snippet props, it’s best to create a wrapper component for your specific test and interact with that. @testing-library/svelte contains some examples.
Looks like we still need to keep it for now…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah bummer! thanks for digging this up! 👍
tests/unit/utils.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file contains a lot of boilerplate. many of the functions are 1-liners so probably better to inline them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are purely utility functions to improve test readability and keep things consistent. But if you’d prefer, I can inline them instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, please inline. thank you!
great news! 🎉 |
…yntax - add bubble, stopPropagation, preventDefault event modifier functions in MultiSelect.svelte - skip readme tests (no longer work due to different code structure not matching Svelte 4 specific regexes) - fix lint and typescript errors
for more information, see https://pre-commit.ci
…g-library/user-event, reverting MultiSelect.svelte.test.ts to pure vitest
…ange needed in docs) - restore running end-to-end tests in GitHub Actions - MultiSelect forward ...rest props to the input element
did some more work. getting close to ready to merge. all unit tests now passing. some playwright tests still failing and some docs still need updating (like renaming slots to snippets) |
- MultiSelect.svelte CSS: replace `:where` with `:is` for less recessive button styles - single Toc component in +layout.svelte for /, /changelog, /contributing - remove redundant Toc imports and instances from +page.svelte, changelog, and contributing pages - fix async loading of changelog in +page.server.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was a big lift! thanks for all your hard work @Antosik 👍 and sorry for the long delay in getting this over the finish line
Work in progress
Breaking changes
svelte
dependency has been moved to peer dependencies.svelte@^5.8.0
is now required3.1. The
onchange
event now triggers only on the component itself, not on theinput
element (to avoid event overlap)3.2.
selected
slot was renamed toselectedItem
Events
Events are now divided into two categories: native events - MultiSelectNativeEvents (triggered on the
input
element) and generated events - MultiSelectComponentEvents (triggered on the component itself).Event naming conventions have been slightly adjusted (e.g.,
on:add
→onadd
), and custom event details are no longer required (e.g.,e.detail.type
→e.type
).Example
Before (svelte4):
After (svelte5):
SlotsSnippetsSlot names have been slightly adjusted (e.g.,
expand-icon
→expandIcon
, etc.).Example
Before (svelte4):
After (svelte5):
Minor changes
MultiSelectEvents
were removed in favor ofMultiSelectComponentEvents
&MultiSelectNativeEvents
Todos
@testing-library/svelte
(?))--legacy-peer-deps
flag)css-classes
example to use:where
Checklist
[ ] has tests (only needed if any new functionality was added or bugs fixed)
[ ] has examples/docs (only needed if any new functionality was added)
Useful links