sendgridvercelhydrogen

Using Sendgrid with Hydrogen on Vercel


I am developing a Hydrogen (1.6.1) site. I have the @sendgrid/mail (7.7.0) package and I am able to successfully send messages on my local dev environment. However, when I deploy to Vercel, I'm getting the message...

[FAILED] Cannot bundle Node.js built-in "fs" imported from "node_modules/@sendgrid/helpers/classes/attachment.js". Consider disabling ssr.noExternal or remove the built-in dependency.
╭─ error ──────────────────────────────────────────────────────────────────────╮
│                                                                              │
│  Cannot bundle Node.js built-in "fs" imported from                           │
│  "node_modules/@sendgrid/helpers/classes/attachment.js". Consider disabling  │
│   ssr.noExternal or remove the built-in dependency.                          │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

I have tried disabling ssr.noExternal as suggested, but the app won't build in this configuration. Has anyone been able to deploy under this infrastructure?


Solution

  • We solved it by moving it into a netlify function.