Use case
Framework
Owner
Sveltekit Vite Preprocess Migration
This codemod updates import paths and ensures compatibility with changes in library structures. In this example, it modifies the import statement for vitePreprocess to reflect updates in the library's API.
Sveltekit Import And Path Simplification
This codemod simplifies the import statements and path resolution in your SvelteKit project. It replaces the usage of
resolvePath
and concatenation withbase
by using theresolveRoute
function from$app/paths
. This results in cleaner and more readable code.Add Status To Error Handling
This codemod improves error handling in SvelteKit by updating the way errors are returned in the load function. In SvelteKit 1, errors were handled inconsistently, often missing the status property or failing to trigger the handleError hook. SvelteKit 2 standardizes error handling by automatically including the status and message properties in error responses.
Add Multipart Enctype To Forms With File Input
This codemod automatically adds the enctype="multipart/form-data" attribute to forms containing file input fields. It ensures that forms with file inputs properly handle file uploads during non-JS submissions, which is a requirement for SvelteKit v2.
Replace Throw With Error Call
This codemod simplifies error handling and redirects in your TypeScript project by replacing
throw error()
andthrow redirect()
statements with direct calls toerror()
andredirect()
. This change aligns with modern practices and results in cleaner, more readable code.Svelte/5/Migration Recipe
This recipe is a set of codemods that will help migrate to Svelte 5.
Svelte/5/Svelte Element Expression
This codemod updates Svelte component definitions by transforming the
this
attribute in<svelte:element>
tags:Svelte/5/Server Api Changes
This codemod updates Svelte component rendering:
Svelte/5/Is Where Scoping
This codemod updates CSS handling in your project:
Svelte/5/Components As Functions Onfunction
This codemod updates Svelte component instantiation and event handling for Svelte 5:
Svelte/5/Components As Functions Destroyfunction
This codemod updates Svelte component instantiation and event handling for Svelte 5:
Svelte/5/Components As Functions
In Svelte 3 and 4, components were classes, while in Svelte 5, components are functions. This codemod updates the instantiation of Svelte components to use
mount
orhydrate
(imported from svelte), ensuring compatibility with Svelte 5's new functional component model.