nest-modules / mailer

📨 A mailer module for Nest framework (node.js)
https://nest-modules.github.io/mailer/
MIT License
837 stars 175 forks source link

Import error using MjmlAdapter #982

Closed jaqarrick closed 1 year ago

jaqarrick commented 1 year ago

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 commented 1 year ago

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

bebjakub commented 1 year ago

@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 commented 1 year ago

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

carlos3g commented 2 weeks ago

Did you solve it? @bebjakub

bebjakub commented 1 week ago

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