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 CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=4.0.0"
6
6
  },
7
- "version": "1.0.3",
7
+ "version": "1.0.4",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-generation-emails",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "A Nuxt module for authoring, previewing, and sending transactional email templates with MJML and Handlebars.",
5
5
  "author": "nullcarry@icloud.com",
6
6
  "repository": {