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

Upgrade to Svelte 5 #490

Merged
merged 43 commits into from
Oct 28, 2024
Merged

Upgrade to Svelte 5 #490

merged 43 commits into from
Oct 28, 2024

Conversation

josdejong
Copy link
Owner

@josdejong josdejong commented Oct 15, 2024

Issues:

  • [IMPEDIMENT] Incompatible dependencies: svelte-awesome and rollup-plugin-svelte. Solution: the dependencies must update their peer requirements to include Svelte 5. See [Feature] - Svelte 5 support RobBrazier/svelte-awesome#1186 (comment).
  • [IMPEDIMENT] Circular dependencies reported by Rollup, when running npm run build. Not a show stopper. Is a known issue, see Svelte 5: Several circular dependencies in client runtime modules sveltejs/svelte#10140. Since this is not critical but just annoying, will mark this as solved for now.
  • New compiler warnings: "Invalid tr inside table". Solved in the main branch
  • New compiler warnings: "Self-closing HTML tags for non-void elements are ambiguous". Solved in the main branch
  • Compiler warnings "Unused CSS selector". A few valid cases are resolved in the main branch. The main cause is the recursive JSONNode component. It looks like in Svelte 5, the styles are not recursively applied to child instances of JSONNode. Solved by defining the recursive styling needed for nested child components using :global. It would be good to look into an alternative solution that does not require using :global.
  • Compiler warnings "Properties of objects and arrays are not reactive unless in runes mode". They mostly fire wrongly on TypeScript enum objects. Solved via a workaround by adding a temporary warningFilter in the svelte config. I think this is a bug in the svelte 5 compiler. UPDATE: this workaround is not suitable: when used as a svelte library, this requires the consumer to configure these warningFilters too, but that is not workable.
  • Some unit tests are broken. Fixed by mounting via mount, adding some config in vitest.config.js, and adapting the expected output and snapshots.
  • Scrolling by pressing the middle mouse button throws an error “Uncaught TypeError: handler is undefined”. Solved in the main branch by removing on:focus={undefined} and on:blur={undefined}, and instead ignore the svelte warning a11y-mouse-events-have-key-events.
  • Styling of the vanilla output is broken. Solved by configuring postcss in the Rollup config.
  • Update peerDependencies to support svelte 5 and its release candidates
  • Double clicking a value in tree or table mode doesn’t open edit mode for the value. Double clicking a key works fine. Looks like changing the selection in the mousedown handler in JSONNode breaks handling of the double click event.
  • Method updateProps of the vanilla library not working: this.$set(props) is removed in Svelte 5.
  • Method destroy of the vanilla library doesn't work: this.$destroy() is deprecated in Svelte 5.
  • Update all dependencies to the latest version, change sass version again to use ^ and resolve all deprecation warnings.
  • The class JsonEditor is no longer exported by Svelte 5. Find an alternative solution

TODO:

  • Fix all open issues
  • Do a through functional test round.
  • Test performance. It looks like the editor is about twice as slow on Firefox, and four times as fast on Chrome 🤔
  • Test using the library in a Svelte 4, Svelte 5, vanilla, and React (TS) project
  • Test whether it is possible to keep the library compatible with both Svelte 4 and 5
  • Await the release of Svelte 5 and support for Svelte 5 by the dependencies
  • Merge and publish

@josdejong josdejong mentioned this pull request Oct 15, 2024
17 tasks
# Conflicts:
#	package-lock.json
#	package.json
# Conflicts:
#	src/lib/components/modals/SortModal.svelte
#	src/lib/components/modals/TransformModal.svelte
#	src/lib/components/modes/JSONEditorRoot.svelte
#	src/lib/components/modes/tablemode/ColumnHeader.svelte
#	src/lib/components/modes/tablemode/TableMode.svelte
#	src/lib/components/modes/treemode/TreeMode.svelte
# Conflicts:
#	package-lock.json
#	package.json
#	src/lib/components/modals/SortModal.svelte
#	src/lib/components/modals/TransformModal.svelte
#	src/lib/components/modes/JSONEditorRoot.svelte
#	src/lib/components/modes/tablemode/ColumnHeader.svelte
#	src/lib/components/modes/tablemode/TableMode.svelte
#	src/lib/components/modes/treemode/TreeMode.svelte
@josdejong
Copy link
Owner Author

Ok all is ready 🎉 .

Everything still works in Svelte 4 (and 3), which is amazing, and there should be no breaking changes at all. I'll still publish this as a major breaking change since there may be subtle edge cases (just like it this PR itself involved fixing some subtle breaking changes).

@josdejong josdejong merged commit 588caa5 into main Oct 28, 2024
3 checks passed
@josdejong josdejong deleted the chore/svelte5 branch October 28, 2024 11:03
@josdejong josdejong mentioned this pull request Oct 28, 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

Successfully merging this pull request may close these issues.

1 participant