-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Error: Component.render(...) is no longer valid in Svelte 5 #34
Comments
Hi there, had same issue, instead of this code for example :
I use this one :
|
If anyone has a good function to convert nicely to plainText... EDIT: nevermind, just saw the import { convert } from 'html-to-text'; in the render.ts file :) |
My workaround based on @robthepaper's workaround, and the implementation in import type { Component, ComponentProps, SvelteComponent } from "svelte";
import { convert } from "html-to-text";
import { render } from "svelte/server";
const renderAsPlainText = (markup: string) => {
return convert(markup, {
selectors: [
{ selector: "img", format: "skip" },
{ selector: "#__svelte-email-preview", format: "skip" },
],
});
};
export const renderEmail = async <
Comp extends SvelteComponent<any> | Component<any>,
Props extends ComponentProps<Comp> = ComponentProps<Comp>,
>(
component: Comp,
props?: Props,
) => {
const rendered = render(component as any, {
props,
});
const doctype =
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
const html = `${doctype}${rendered.body}`;
const text = renderAsPlainText(rendered.body);
return {
html,
text,
};
}; Looking at the HTML output before and after looks quite similar. |
I can confirm with @valterkraemer's fix the package runs well on Svelte 5 @carstenlebek would it be possible to get an update on the package to allow users to use it on the new version? I've made a fork which details the fixes provided in the thread. |
Any idea why the fix hasn't been released |
@carstenlebek do you think you can review and merge these changes? |
@carstenlebek would it be possible to take a look at this fix? |
@lamungu would you consider forking this project and taking over as maintainer, since you already did the fix? It looks like this project has been abandoned; last commit is 2 years old and the maintenaer is unresponsive. |
Svelte Docs: https://svelte-5-preview.vercel.app/docs/breaking-changes#components-are-no-longer-classes-server-api-changes
Problem location: https://github.com/carstenlebek/svelte-email/blob/master/src/lib/render.ts#L19
The text was updated successfully, but these errors were encountered: