Skip to content

BUG: Incompatibility with grape js headless mode #392

@pboneure

Description

@pboneure

GrapesJS version

  • I confirm to use the latest version of GrapesJS

GrapesJS MJML version

  • I confirm to use the latest version of GrapesJS MJML

What browser are you using?

Not applicable (it's running on a server)

Reproducible demo link

https://codesandbox.io/p/sandbox/m86rgn

Describe the bug

How to reproduce the bug?

  1. Init GrapeJS in headless mode
  2. Try to run command mjml-code-to-html

What is the expected behavior?
The html is created (and does not rely on window since we run it in headless mode).

What is the current behavior?
We have this error :

window is not defined
ReferenceError: window is not defined
    at Object.moduleId [as 480] ...

If is necessary to execute some code in order to reproduce the bug, paste it here below:

  const editor = grapesjs.init({
    telemetry: false,
    headless: true,
    plugins: [usePlugin(grapesJSMJML, { useCustomTheme: false })],
    projectData: {"test": "test"} as ObjectAny,
  });
  console.log(emailEditor.runCommand('mjml-code-to-html').html.toString());

Workaround:

We found a solution by importing global-jsdom/register, that gives a mock of window.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions