Open socketopp opened 3 weeks ago
I haven't looked into the Svelte 5 generated server JS output, but I suspect it has breaking changes. So that would make this plugin incompatible with Svelte 5. I will look into making it compatible. I'm afraid there will be a lot that needs changing!
I haven't looked into the Svelte 5 generated server JS output, but I suspect it has breaking changes. So that would make this plugin incompatible with Svelte 5. I will look into making it compatible. I'm afraid there will be a lot that needs changing!
What parts in svelte-email-tailwind is related to the breaking changes in Svelte 5? I helped svelty-email with some breaking changes and it was only concerning Server API changes.
The error originates from:
function substituteHead(code, twClean) {
// 3. Handle responsive head styles
const headStyle = `<style>${getMediaQueryCss(twClean)}</style>`;
// const hasResponsiveStyles = /@media[^{]+\{(?<content>[\s\S]+?)\}\s*\}/gm.test(headStyle)
const startStringPre = '${validate_component(Head, "Head").$$render($$result,';
const iS = code.indexOf(startStringPre);
if (iS === -1) {
throw new Error('Missing <Head /> component!');
}
I am not sure why this error occurs or what the code is doing. The inline-tailwind.js
file is quite complex. I couldn't imagine adding tailwind to svelte-email would be this complicated?
What parts in svelte-email-tailwind is related to the breaking changes in Svelte 5?
This Vite plugin takes an email component's SSR code as a string, and manipulates the string. It looks for all 'class' properties, transforms those classes to styles, then put them back into the original stringified SSR code as a 'style' prop.
In Svelte 4, it would look something like this:
${validate_component(MyComponent, "MyComponent").$$render($$result, { classes: "text-sm" }, {}, {})}
This plugin then looks for the pattern $$result, {
, and subsequently looks for class properties. It's turned into:
${validate_component(MyComponent, "MyComponent").$$render($$result, { style: "font-size: 14px" }, {}, {})}
In Svelte 5, the SSR JS output is different:
MyComponent($$payload, { classes: "text-sm" });
If we're lucky, the only syntax change is that '$$result' becomes '$$payload'. But I doubt that's all - I have to look into it.
PS: You can find these outputs on the Svelte REPL: in the JS "Output tab", with "Compiler options - generate" set to "SSR".
Interesting approach! Hope your migration to Svelte 5 goes well.
Invite.svelte
I have been using it like this
However, I receive the following error in Svelte 5. Is there anything I can do to fix this?
Also the config require parameters