carstenlebek / svelte-email

Write and send emails with Svelte ✉️🚀
https://svelte-email.vercel.app
MIT License
458 stars 36 forks source link

Broken with current Svelte versions #2

Closed mikroskeem closed 1 year ago

mikroskeem commented 1 year ago
Uncaught (in promise) TypeError: template.render is not a function
    at render (render.js:6:14)
    at instance (+page.svelte:8:23)
    at init (index.mjs:2016:11)
    at new Page (+page.svelte:34:39)
    at createProxiedComponent (svelte-hooks.js?v=77ff2d76:341:9)
    at new ProxyComponent (proxy.js?v=77ff2d76:242:7)
    at new Proxy<+page> (proxy.js?v=77ff2d76:349:11)
    at construct_svelte_component_dev (index.mjs:2232:26)
    at Array.create_default_slot (root.svelte? [sm]:42:82)
    at create_slot (index.mjs:71:28)

https://github.com/carstenlebek/svelte-email/blob/1e43a93941bc63b21ac0a390bfceb700c6205030/src/lib/render.ts#L17-L19

Excerpt of package.json ```json { "devDependencies": { "@sveltejs/adapter-auto": "^2.0.0", "@sveltejs/kit": "^1.5.0", "@typescript-eslint/eslint-plugin": "^5.45.0", "@typescript-eslint/parser": "^5.45.0", "eslint": "^8.28.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-svelte3": "^4.0.0", "prettier": "^2.8.0", "prettier-plugin-svelte": "^2.8.1", "svelte": "^3.54.0", "svelte-check": "^3.0.1", "tslib": "^2.4.1", "typescript": "^4.9.3", "vite": "^4.0.0", "svelte-email": "^0.0.4" } } ```
ErikSandquist commented 1 year ago

Please share some of your code. It works perfectly for me. Make sure you using it in an async function with await before rendering.

An example of it: async function renderEmail() { html = await render({ template: Receipt, props: { firstName: 'John' } }); }

jacobrsterling commented 1 year ago

In the README you have this as an example:

const emailHtml = render({
    component: Hello,
    props: {
        name: 'Svelte'
    }
});

But it should be this:

const emailHtml = render({
    template: Hello,
    props: {
        name: 'Svelte'
    }
});
Antonio-Bennett commented 1 year ago

@jakedickerson good catch. PR to update readme was merged. https://github.com/carstenlebek/svelte-email/pull/3

eltigerchino commented 1 year ago

@carstenlebek this issue can be closed

yashash-pugalia commented 1 year ago

@carstenlebek this issue can be closed

in some parts of the docs its still component like in https://svelte-email.vercel.app/docs/integrations/aws-ses

mikroskeem commented 1 year ago

I managed to get it working by going through new documentation - moved rendering to server side and now it works.