Closed ruudboon closed 6 years ago
Hello,
We no longer expose a class, so the export default is now mjml2html function, removing those brackets will fix it
On Sat, Jan 20, 2018 at 11:09 AM, Ruud Boon notifications@github.com wrote:
When trying out MJML4 with the node example provided
import { mjml2html } from 'mjml'
/ Compile an mjml string / const htmlOutput = mjml2html(`
Hello World! `)
/ Print the responsive HTML generated and MJML errors if any / console.log(htmlOutput)
I get the following message:
const htmlOutput = mjml_1.mjml2html(` TypeError: mjml_1.mjml2html is not a function
Is the naming changed?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mjmlio/mjml/issues/959, or mute the thread https://github.com/notifications/unsubscribe-auth/AAizzSBKASUZEim8fpf48UkmfODJZsZhks5tMbtCgaJpZM4RlYjA .
-- Cordialement, Maxime BRAZEILLES
const htmlOutput = mjml_1.default(`
TypeError: mjml_1.default is not a function
Gives undefined. I'll will check the code to see what's happening. btw I'm on 4.0.0-alpha.5.
Well it should work with the regular import of mjml package, we'll investigate
On 21 Jan 2018, at 08:45, Ruud Boon notifications@github.com wrote:
Ah, importing mjml-core instead of miml works way better..Want me to sent a pull for the documentation?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
@ruudboon can you try just replacing
import { mjml2html } from 'mjml'
by
import mjml2html from 'mjml'
I tried and it works fine
Well as @ngarnier said, it works for me too, might be an issue with your babel config, I'm closing the issue.
You can try it back with the latest beta to see if it fix it for you
Sorry my fault indeed. It was part of a typescript project so I had to do
import * as mjml2html from 'mjml'
how would this work with gulp-mjml ?
The current master branch of gulp-mjml
has a fix for this issue. I've installed it like so in package.json:
"gulp-mjml": "git+https://git@github.com/mjmlio/gulp-mjml.git#1cf5074c32621a2d6bc7",
It has been released on npm too so no need to use the git package 👌
Oh great, not sure why I didn't realise that!
I also had this issue, and I found this solution.
import mjml2html = require('mjml');
It works very well with typescript!
FWIW, I had to use
import mjml2html from "mjml";
with the allowSyntheticDefaultImports
property of my tsconfig.json
set to true
import * as mjml2html from 'mjml'
worked for my typescript project :) Thank you @ruudboon
import * as mjml2html from 'mjml'
worked for my typescript project :) Thank you @ruudboon
It worked but I didn't have any type support in Webstorm using this method
I resolved the issue by importing it like this: import mjml2html from 'mjml';
, and I added the esModuleInterop: true
property to the ts.config.json file.
Hi ! I'm having this error when i try to mock the function using Jest.
How could i mock the mjml2mjml
function importing: import * as mjml2html from 'mjml'
?
I am having great issues using it on Netlify functions (and I think it might be a Netlify related thing really)
TypeError: (0 , import_mjml_core.default) is not a function
I had to the following as the only thing that would work:
import * as mjml2html from "mjml";
mjml2html.default(`<mjml>....)
When trying out MJML4 with the node example provided
I get the following message:
Is the naming changed?