twilio-labs / function-templates

Twilio Function templates for different Voice, SMS, Video, Chat, Sync, etc use cases
MIT License
339 stars 318 forks source link

Migration of 'forward-message-sendgrid' to @sendgrid/mail due to ES Module incompatibility with Twilio Functions #419

Open AkashM398 opened 1 year ago

AkashM398 commented 1 year ago

Issue:

The latest 'got' release (v12.6.0) is currently a native ES module and no longer provides a CommonJS export. Currently, the "forward-message-sendgrid" has the older 'got' release (v6.7.1) in its dependencies. While most users tend to upgrade the library in the dependencies to the latest version, they will face the following error.

Error [ERR_REQUIRE_ESM]: require() of ES Module /var/task/node_modules/got/dist/source/index.js from /var/task/handlers/ZNXXXXXXXXXXXXXXXXXXXXXXXXXXX.js not supported. Instead change the require of index.js in /var/task/handlers/ZNXXXXXXXXXXXXXXXXXXXXXXXXXXX.js to a dynamic import() which is available in all CommonJS modules

However, due to Twilio Functions currently does not support ES modules, using the dynamic import() will produce an error too.

Solution:

It is advisable to migrate this example to sendgrid-nodejs (@sendgrid/mail) as it is officially maintained by the Sendgrid team.

PR:

PR #420

welcome[bot] commented 1 year ago

Thank you so much for opening your first issue in this project! We'll try to get back to it as quickly as possible. While you are waiting...here's a random picture of a corgi (powered by dog.ceo)

picture of dog