@@ -94,7 +94,9 @@ export const createDependencyGraph = async (directory: string) => {
94
94
const getDependencyPaths = async ( filePath : string ) => {
95
95
const contents = await fs . readFile ( filePath , 'utf8' ) ;
96
96
97
- const importedPaths = getImportedModules ( contents ) ;
97
+ const importedPaths = isJavascriptModule ( filePath )
98
+ ? getImportedModules ( contents )
99
+ : [ ] ;
98
100
const importedPathsRelativeToDirectory = importedPaths . map (
99
101
( dependencyPath ) => {
100
102
const isModulePath = ! dependencyPath . startsWith ( '.' ) ;
@@ -112,7 +114,7 @@ export const createDependencyGraph = async (directory: string) => {
112
114
/*
113
115
path.resolve resolves paths differently from what imports on javascript do.
114
116
115
- So if we wouldn't do this, for an email at "/path/to/email.tsx" with a dependecy path of "./other-email"
117
+ So if we wouldn't do this, for an email at "/path/to/email.tsx" with a dependency path of "./other-email"
116
118
would end up going into /path/to/email.tsx/other-email instead of /path/to/other-email which is the
117
119
one the import is meant to go to
118
120
*/
@@ -122,7 +124,7 @@ export const createDependencyGraph = async (directory: string) => {
122
124
123
125
let isDirectory = false ;
124
126
try {
125
- // will throw if the the file is not existant
127
+ // will throw if the the file is not existent
126
128
isDirectory = statSync ( pathToDependencyFromDirectory ) . isDirectory ( ) ;
127
129
} catch ( _ ) { }
128
130
if ( isDirectory ) {
@@ -145,9 +147,10 @@ export const createDependencyGraph = async (directory: string) => {
145
147
for it being a javascript module fails, then we can assume it has the same as the `filePath`
146
148
*/
147
149
if ( ! isJavascriptModule ( pathToDependencyFromDirectory ) ) {
148
- const pathWithExtension = checkFileExtensionsUntilItExists (
149
- pathToDependencyFromDirectory ,
150
- ) ;
150
+ const pathWithExtension =
151
+ path . extname ( pathToDependencyFromDirectory ) . length > 0
152
+ ? pathToDependencyFromDirectory
153
+ : checkFileExtensionsUntilItExists ( pathToDependencyFromDirectory ) ;
151
154
152
155
if ( pathWithExtension ) {
153
156
pathToDependencyFromDirectory = pathWithExtension ;
0 commit comments