Skip to content

Commit 5848bcd

Browse files
authored
fix(react-email): dev:preview command failing (#2246)
1 parent f723344 commit 5848bcd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@ import { parse } from '@babel/parser';
22

33
import traverseModule from '@babel/traverse';
44

5-
// @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.
6-
const traverse = traverseModule.default;
5+
const traverse =
6+
// we keep this check here so that this still works with the dev:preview
7+
// script's use of tsx
8+
typeof traverseModule === 'function'
9+
? traverseModule
10+
: // @ts-expect-error This is fine since the default export is wrapped in a
11+
// default function. The problem is that babel/traverse is not ESM.
12+
traverseModule.default;
713

814
export const getImportedModules = (contents: string) => {
915
const importedPaths: string[] = [];

0 commit comments

Comments
 (0)