When importing mjml as a node module the method mjml2html is no longer available as default export. This problem occurs since the 4.2 release.
Steps to reproduce the behavior:
require('mjml')mjml(templateString, cfg)mjml is not a functionExpected behavior
The given mjml templateString is converted to html.
MJML environment (please complete the following information):
The new export for handleMjmlConfig seems to be causing this problem: https://github.com/mjmlio/mjml/blob/master/packages/mjml/src/index.js#L49-L51
A workaround to fix this issue on the user's side is explicitly importing the default property: require('mjml').default
Yep I think we no longer want export anything else than the mjml2html function into mjml package. Removing this export should be fine, mjml-app might need some update due to this change cc @kmcb777
Should I still make a pull request? I removed the export for handleMjmlConfig in my local fork and it seems to be working as expected.
We've discussed a bit and it was used in mjml-app, so we might need to check that it works fine with the app first
@Michael-wm kudos to you for creating this issue.
The babel-plugin-add-module-exports export the default when only have one default export. The mjml package is breaked (in a minor version) since that the handleMjmlConfig is exposed in the same file.
EDIT: It's fixed, I did not see.
I'm not sure how this is fixed. At least in TypeScript, I cannot do either of these:
import mjml2html from "mjml";
import * as mjml2html from "mjml";
The only way to make this work is:
const mjml2html = require("mjml"); // tslint:disable-line no-var-requires
Which is.. undesirable. What is the plan for this?
I'm not a TS user so I don't really know why import mjml2html from "mjml";, but it should work fine 🤔
So the default is no longer needed, I'm closing the issue.
About the typescript issue, feel free to investigate a bit (maybe it comes from our babel config) and open a new issue please.
I'm still having this problem =/
You need to add some details, node version, mjml packages version, etc...
we can't really guess what's the issue for you ?
On Wed, Dec 26, 2018 at 6:34 PM Luan Muniz notifications@github.com wrote:
I'm still having this problem =/
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/mjmlio/mjml/issues/1387#issuecomment-449998487, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAizzVV8TvmUgR4JPL-OPfCS4PJjz6J-ks5u87MOgaJpZM4Xd2RD
.
--
Cordialement,
Maxime BRAZEILLES
It's not the same problem. I will create another issue for it. Sorry
Hi, this is likely not related to mjml directly, it's probably related to how you're building your code
If you import any other node module at this same place, you should have the same error
Most helpful comment
I'm not sure how this is fixed. At least in TypeScript, I cannot do either of these:
The only way to make this work is:
Which is.. undesirable. What is the plan for this?