When deploying/building for production, Blitzjs fails to find the dynamic import for preview-email when checking the validity of types. This is the code that comes out of the box with a new Blitzjs project in the ./mailers/forgotPasswordMailer.ts file. I suspect the production build tree shakes, removes the preview email dependency and even though the dynamic importing of the preview-email library should only occur in dev, it still thinks it is missing and fails to build.
Paste all your error logs here:
info - Generating route manifest...
info - Checking validity of types...
Failed to compile.
Apr 28 03:55:08 PM
./mailers/forgotPasswordMailer.ts:44:44
Type error: Cannot find module 'preview-email' or its corresponding type declarations.
Apr 28 03:55:08 PM
42 | } else {
43 | // Preview email in the browser
> 44 | const previewEmail = (await import("preview-email")).default
| ^
45 | await previewEmail(msg)
46 | }
47 | },
==> Build failed 😞
Paste all relevant code snippets here:
The block of code from forgotPasswordMailer.ts
return {
async send() {
if (process.env.NODE_ENV === "production") {
// TODO - send the production email, like this:
await SendGrid.sendEmail(msg)
throw new Error("No production email implementation in mailers/forgotPasswordMailer")
} else {
// Preview email in the browser
const previewEmail = (await import("preview-email")).default
await previewEmail(msg)
}
},
}
What is the problem?
When deploying/building for production, Blitzjs fails to find the dynamic import for
preview-email
when checking the validity of types. This is the code that comes out of the box with a new Blitzjs project in the./mailers/forgotPasswordMailer.ts
file. I suspect the production build tree shakes, removes the preview email dependency and even though the dynamic importing of the preview-email library should only occur in dev, it still thinks it is missing and fails to build.Paste all your error logs here:
Paste all relevant code snippets here:
The block of code from
forgotPasswordMailer.ts
What are detailed steps to reproduce this?
NODE_ENV=production yarn install --frozen-lockfile && blitz prisma generate && blitz build && blitz prisma migrate deploy && yarn start
Run
blitz -v
and paste the output here:Please include below any other applicable logs and screenshots that show your problem:
No response