nuxt-generation-emails 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/module.mjs +8 -1
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -605,10 +605,15 @@ export function registerMjmlComponents(): void {
|
|
|
605
605
|
write: true,
|
|
606
606
|
getContents: () => `import { computed, h, getCurrentInstance } from 'vue'
|
|
607
607
|
import type { ComputedRef } from 'vue'
|
|
608
|
-
import mjml2html from 'mjml-browser'
|
|
609
608
|
import Handlebars from 'handlebars'
|
|
610
609
|
import { registerMjmlComponents } from './register-components'
|
|
611
610
|
|
|
611
|
+
// Lazy-load mjml-browser only on the client to avoid "window is not defined" during SSR
|
|
612
|
+
let mjml2html: ((mjml: string) => { html: string; errors: unknown[] }) | null = null
|
|
613
|
+
if (import.meta.client) {
|
|
614
|
+
mjml2html = (await import('mjml-browser')).default
|
|
615
|
+
}
|
|
616
|
+
|
|
612
617
|
const mjmlTemplates: Record<string, string> = import.meta.glob(
|
|
613
618
|
['${templateGlobPath}/**/*.mjml', '!${templateGlobPath}/components/**'],
|
|
614
619
|
{ query: '?raw', import: 'default', eager: true }
|
|
@@ -654,6 +659,8 @@ export function useNgeTemplate(name: string, props: Record<string, unknown>): Co
|
|
|
654
659
|
const compiled = Handlebars.compile(source)
|
|
655
660
|
|
|
656
661
|
const renderedHtml = computed(() => {
|
|
662
|
+
// mjml-browser requires window \u2014 skip rendering during SSR
|
|
663
|
+
if (!mjml2html) return ''
|
|
657
664
|
try {
|
|
658
665
|
const mjmlString = compiled({ ...props })
|
|
659
666
|
const result = mjml2html(mjmlString)
|
package/package.json
CHANGED