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

Svelte 4 migration and accompanying fixes #266

Open
dmitrysmagin opened this issue Nov 29, 2023 · 0 comments
Open

Svelte 4 migration and accompanying fixes #266

dmitrysmagin opened this issue Nov 29, 2023 · 0 comments

Comments

@dmitrysmagin
Copy link

Hello.
It turns out that Elderjs could be easily migrated to Svelte 4.
It needs minor code fixes (that could be applied as well without migrating to Svelte 4).

Example patch:
dmitrysmagin@0b82c2a

I haven't created the pull request, because this patch is applied on top of v1.7.5 and still uses rollup. I haven't tried to use esbuild yet.

So, minor fixes that could be applied right away without breaking anything:
image
Both in Svelte 3 and 4 PreprocessorGroup could be imported from 'svelte/types/compiler/preprocess', but Svelte 4 removes types.d.ts in favor of index.d.ts

image
'Number' is not a Typescript type, but 'number' is. With Svelte 4 it gives a compile error, but Svelte 3 passes it.

image
Svelte 4 drops the field 'format' from CompileOptions, so the target is always 'esm'.

Also, CompileResult type doesn't have 'js.dependencies' field so assigning it has no sense. Dependencies tracking is needed here for hot recompile, so we can use the local var with this.addWatchFile());

Other than that, for successful migration to Svelte 4 some packages are needed to be upgraded:
svelte - to 4.2.7
rollup - minumum to v2.78.0, otherwise hooks like onMount won't work in hydration mode
@rollup/plugin-node-resolve - to 15.2.3
jest - to 29.7.0
typescript - to 5.3.2

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

No branches or pull requests

1 participant