Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import error using MjmlAdapter #982

Closed
jaqarrick opened this issue Apr 26, 2023 · 5 comments · Fixed by #984
Closed

Import error using MjmlAdapter #982

jaqarrick opened this issue Apr 26, 2023 · 5 comments · Fixed by #984

Comments

@jaqarrick
Copy link
Contributor

Description

When using the MjmlAdapter from the mailer module I get the following error when the compile function is invoked:

TypeError: (0 , mjml_1.default) is not a function

To Reproduce
In my email module imports I have the following

    MailerModule.forRootAsync({
      useFactory: () => ({
         ...
          adapter: new MjmlAdapter('ejs', {
            inlineCssEnabled: false,
          }),
         ...
    }),

When I call the mailerService.sendMail function the error is thrown.

Expected behavior
The function should successfully compile mjml to html

Suggested Solution
I would suggest updating the import statement here to

import * as mjml2html from 'mjml'

I've recreated the adapter locally outside of the package and this solution works.

Let me know if I'm missing something!

@bebjakub
Copy link

bebjakub commented Jun 21, 2023

@juandav Hello, I'm also experiencing the same issue.
MRE https://github.com/bebjakub/nest-mailer-mjml-test

@bebjakub
Copy link

bebjakub commented Jun 22, 2023

@juandav Thank you a lot!
When do you plan the release, pls? The last release was 3 years ago,... https://www.npmjs.com/package/@nest-modules/mailer
Thank you!

@bebjakub
Copy link

Hi @jaqarrick , I tested your PR, but for me works only import mjml2html = require('mjml') as a solution from this issue mjmlio/mjml#2430 or mjmlio/mjml#1387 (comment)
How did you achieve working it with import * as mjml2html from 'mjml'?
Thank you!

@carlos3g
Copy link

Did you solve it? @bebjakub

@bebjakub
Copy link

@carlos3g I duplicated MjmlAdapter and imported mjml with import mjml2html = require('mjml');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants