-
Notifications
You must be signed in to change notification settings - Fork 111
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 #476
Upgrade to Svelte 5 #476
Conversation
…ctures (#450) BREAKING CHANGE: Though the editor functions exactly the same, this refactor changes the internal core data structures, so be careful.
BREAKING CHANGE: Changed the API to consistently use `undefined` instead of `null`. This involves properties `selection`, `onChange` (properties `contentErrors and `patchResult`), `onRenderContextMenu` (property `selection`), `onSelect`, and methods `validate`, and `select`.
…ilst editing a value
BREAKING CHANGE: Old deprecation messages are removed.
BREAKING CHANGE: The API of the `expand` function is changed from `expand(callback)` to `expand(path, callback)`, and can't be used anymore for collapsing nodes. Instead, use the `collapse(path)` method for that.
# Conflicts: # package-lock.json # package.json
fyi svelte-hmr isn't used with svelte5, its builtin now (compilerOptions.hmr). |
Ah, you're right, thanks. I've removed my local |
rollup-plugin-svelte should work with svelte5 too, it has >=3 in peer and the implementation checks for .svelte.js files too and compiles them with compileModule |
if you encounter errors with rollup-plugin-svelte and svelte5, a report with a minimal reproduction to it's repo would help us. |
Yes I will try that. |
Ok @dominikg here you go: I created a new, empty Svelte project using https://github.com/josdejong/test-svelte5-rollup I hope this helps pinpointing the issue. |
i'm not sure i follow why you want to build with rollup like that. If you are publishing a svelte library, i suggest you take a look at svelte-package. For your reproduction, please note that in svelte5, components are not classes anymore by default: you'd also have to bundle the svelte runtime, for it to work, but this is something i would not recommend doing. |
I publish two versions of this library:
Ahhh I get it, thanks for the pointer. I had seen these docs but for some reason it didn't land before 😅. The bundle works after using @dominikg do you think Svelte can fix the circular dependency issues reported by Rollup?
|
instead of exposing mount/unmount or even the svelte component to consumers i'd recommend exporting a |
Thanks for the suggestion. I cannot find this I was thinking about this approach right now: // factory function
export function createJSONEditor({ target, props }: Parameters<typeof mount>[1]) {
return mount(JSONEditor, { target, props })
}
// and in the JSONEditor.svelte component:
export async function destroy() {
unmount(this)
await tick() // await destroying
} Not the most beautiful but it works 😅 |
that destroy function is creative/clever. I was suggesting you make the factory function yourself, so what you posted is pretty much what i meant 👍 |
😂 OK 👍 Thanks for the help! I'm really happy that I the library is mostly working now, I expect I can figure out the issues related to styling and event handling myself. |
great, happy svelting thumb up and subscribe here for the circular dependencies sveltejs/svelte#10140 |
I would suggest breaking this PR up into smaller parts. Quite a lot of these changes like removing
I was using
I generally prefer rollup to Vite's library mode. Svelte package might be worth checking out. But probably best to avoid trying to bite off even more as part of this PR |
Thanks for your feedback Ben (and good luck with finishing svelte 5.0, I see it's close!). I may indeed use this PR just as experiment to explore what fixes/changes have to be done if there are a lot of merge conflicts. |
Closing this PR in favor of #490, where as many as issues as possible are solved directly in the |
Issues when upgrading to Svelte 5
Solve the Rollup bundle being broken. The build succeeds but when actually loading the
standalone.js
editor in a browser we get an error: "TypeError: props is undefined"Which is erroring at the first loaded component at the first line where a property is created:
Update documentation and examples on the API to create an editor:
createJSONEditor(...)
instead ofnew JSONEditor(...)
Refactor
updateProps(...)
so it doesn't use the deprecatedthis.$set(...)
Get rid of the need to configure
compatibility: { componentApi: 4 }
Solve the circular dependency issues reported when bundling using Rollup (an issue in Svelte?)
All dependencies must support Svelte 5. Current dependencies with issues:
[email protected]
[email protected]
[email protected]
Fix the UI unit tests not working (try
npm test
): "Svelte error: lifecycle_function_unavailablemount(...)
is not available on the server"Fix issues with event handlers: cannot edit a value by double-clicking it. Double clicking a key works. (tree and table mode)
Fix styling issues: styling of selection and hovering background does not work when hovering an expanded array or object, or when selecting a number of properties in an object (tree mode). Solve all the
Unused CSS selector
compiler warnings.Fix all compiler warnings
Remove deprecated Svelte option
<svelte:options immutable={true} />
Replace occurrences of
<div />
with<div></div>
To do's: