Faire / mjml-react

React component library to generate the HTML emails on the fly
https://www.npmjs.com/package/@faire/mjml-react
MIT License
375 stars 16 forks source link

feat(utils/render): Accept mjml or mjml-browser in render() utility #120

Closed AaronMoat closed 1 month ago

AaronMoat commented 1 month ago

BREAKING CHANGE: utils/render now requires an additional argument, the import of either mjml or mjml-browser.

If you are not using the render utility, this has no effect. However, the mjml peer dependency has been removed, and so can be removed if not using for any other purpose. mjml-core has been added as an optional peer dependency for typings.

This change both allows greater flexibility, and removes dependencies pulled in via mjml -> mjml-cli unless necessary (using this utility).

Before:

render(email, options)

After:

import mjml2html from "mjml";
render(mjml2html, email, options);

Note: the render utility is undocumented.

emmclaughlin commented 1 month ago

I am not sure I fully understand the issue here with the render. We document and encourage writing your own render function and only keep the render function here for backwards compatibility with V2. Is there an issue with the newest version of mjml? It seems to still work for me when I upgrade and test.

In general there is much that could be made variable with the render (e.g. optimization parameters) but we want this package to have no opinion on how the render should be defined, as it is heavily a case by case basis.

AaronMoat commented 1 month ago

:+1: I was largely trying to loosen the peer dependencies requirement, but looking at this again after a break, this makes less sense because mjml-browser doesn't depend on core. Ignore this!

emmclaughlin commented 1 month ago

👍 I was largely trying to loosen the peer dependencies requirement, but looking at this again after a break, this makes less sense because mjml-browser doesn't depend on core. Ignore this!

That sounds good, glad it is cleared up. We appreciate the desire to contribute 😃