File tree 2 files changed +8
-6
lines changed
2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 38
38
},
39
39
"homepage" : " https://github.com/webtretech/nestjs-mailer-react-adapter#readme" ,
40
40
"dependencies" : {
41
- "@react-email/render" : " ^0.0.7"
41
+ "@react-email/render" : " ^0.0.7" ,
42
+ "locter" : " ^1.2.2"
42
43
},
43
44
"peerDependencies" : {
44
45
"@nestjs-modules/mailer" : " ^1.8.1"
Original file line number Diff line number Diff line change 1
1
import { MailerOptions , TemplateAdapter } from "@nestjs-modules/mailer" ;
2
2
import { Options as RenderOptions , render } from "@react-email/render" ;
3
+ import { getModuleExport , load } from "locter" ;
3
4
import path from "node:path" ;
4
5
5
- interface AdapterConfig extends RenderOptions { }
6
+ type AdapterConfig = RenderOptions ;
6
7
7
8
export class ReactAdapter implements TemplateAdapter {
8
9
private config : AdapterConfig = {
@@ -23,11 +24,11 @@ export class ReactAdapter implements TemplateAdapter {
23
24
: path . join ( options . template . dir , path . dirname ( template ) ) ;
24
25
const templatePath = path . join ( templateDir , templateName + templateExt ) ;
25
26
26
- import ( templatePath )
27
+ load ( templatePath )
27
28
. then ( ( tmpl ) => {
28
- const Component = tmpl . default . default ;
29
- const html = render ( < Component { ... context } /> , this . config ) ;
30
- mail . data . html = html ;
29
+ const moduleDefault = getModuleExport ( tmpl ) ;
30
+ const Component = moduleDefault . value ;
31
+ mail . data . html = render ( < Component { ... context } /> , this . config ) ;
31
32
32
33
return callback ( ) ;
33
34
} )
You can’t perform that action at this time.
0 commit comments