I´m implementing an Serverless stack on AWS with a Lambda function that submits an email formatted with MJML library in HTML format.
When trying to isolate the issue, I´ve created a simple function with the next code that runs on AWS lambda and it on itself doesn´t run (the rest does):
import mjml2html from 'mjml';
export async function sendEmail(){
console.log("sendEmail reached");
return mjml2html(`
<mjml>
<mj-body>
<mj-section>
<mj-column>
<mj-image width="100px" src="/assets/img/logo-small.png"></mj-image>
<mj-divider border-color="#F45E43"></mj-divider>
<mj-text font-size="20px" color="#F45E43" font-family="helvetica">Hello World</mj-text>
</mj-column>
</mj-section>
</mj-body>
</mjml>
`);
Even with this simple function, when calling the AWS lambda, I always get the following error and the console.log() isn´t executing, so I assume the error happens already at the import time:
"errorType": "TypeError",
"errorMessage": "Cannot read property '1' of undefined",
"stack": [
"TypeError: Cannot read property '1' of undefined",
" at isFileType (fs.js:178:19)",
" at Object.readFileSync (fs.js:367:16)",
" at /var/task/src/handlers/webpack:/uglify-js/tools/node.js:20:19",
" at Array.map (<anonymous>)",
" at /var/task/src/handlers/webpack:/uglify-js/tools/node.js:19:30",
" at Object.7199 (/var/task/src/handlers/webpack:/uglify-js/tools/node.js:24:1)",
" at ni (/var/task/src/handlers/webpack:/webpack/bootstrap:19:32)",
" at Object.56069 (/var/task/src/handlers/webpack:/html-minifier/src/htmlminifier.js:8:16)",
" at ni (/var/task/src/handlers/webpack:/webpack/bootstrap:19:32)",
" at Object.1510 (/var/task/src/handlers/webpack:/mjml-core/lib/index.js:100:21)"
]
}
I´ve looked for info on the same issue in mjml repo, mjml documentation, this forum... but no luck.
Could anybody help me identify the issue?
Thanks a lot.