Skip to content

Commit f08e0fe

Browse files
committed
fix(react-email): No error with missing default function export (#2084)
1 parent 2cfe468 commit f08e0fe

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

.changeset/wet-planes-camp.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-email": patch
3+
---
4+
5+
Add error message for when an email template does not have a default export

packages/react-email/src/utils/get-email-component.ts

+15
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,21 @@ export const getEmailComponent = async (
106106
};
107107
}
108108

109+
if (typeof parseResult.data.default !== 'function') {
110+
return {
111+
error: improveErrorWithSourceMap(
112+
new Error(
113+
`The email component at ${emailPath} does not contain a default exported function`,
114+
{
115+
cause: parseResult.error,
116+
},
117+
),
118+
emailPath,
119+
sourceMapToEmail,
120+
),
121+
};
122+
}
123+
109124
const { data: componentModule } = parseResult;
110125

111126
return {

0 commit comments

Comments
 (0)