Skip to content

Commit 4c7f597

Browse files
authored
fix(react-email): Fix use of @babel/traverse use in ESM (#2201)
1 parent 5ef9fe8 commit 4c7f597

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

.changeset/long-words-attack.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-email": patch
3+
---
4+
5+
fix `email dev` not working with `traversal` error

packages/react-email/src/cli/utils/preview/hot-reloading/get-imported-modules.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { parse } from '@babel/parser';
2-
import traverse from '@babel/traverse';
2+
3+
import traverseModule from '@babel/traverse';
4+
// @ts-expect-error This is fine since the default export is wrapped in a default function. The problem is that babel/traverse is not ESM.
5+
const traverse = traverseModule.default;
36

47
export const getImportedModules = (contents: string) => {
58
const importedPaths: string[] = [];
@@ -10,7 +13,7 @@ export const getImportedModules = (contents: string) => {
1013
plugins: ['jsx', 'typescript', 'decorators'],
1114
});
1215

13-
traverse(parsedContents, {
16+
traverse.default(parsedContents, {
1417
ImportDeclaration({ node }) {
1518
importedPaths.push(node.source.value);
1619
},

0 commit comments

Comments
 (0)