@@ -142,24 +142,26 @@ export const createDependencyGraph = async (directory: string) => {
142
142
}
143
143
}
144
144
145
- /*
146
- If the path to the dependency does not include a file extension, such that our check
147
- for it being a javascript module fails, then we can assume it has the same as the `filePath`
148
- */
149
- if ( ! isJavascriptModule ( pathToDependencyFromDirectory ) ) {
150
- const pathWithExtension =
151
- path . extname ( pathToDependencyFromDirectory ) . length > 0
152
- ? pathToDependencyFromDirectory
153
- : checkFileExtensionsUntilItExists ( pathToDependencyFromDirectory ) ;
154
-
155
- if ( pathWithExtension ) {
156
- pathToDependencyFromDirectory = pathWithExtension ;
157
- } else if ( isDev ) {
158
- // only warn about this on development as it is probably going to be irrelevant otherwise
159
- console . warn (
160
- `Could not determine the file extension for the file at ${ pathToDependencyFromDirectory } ` ,
161
- ) ;
145
+ const extension = path . extname ( pathToDependencyFromDirectory ) ;
146
+ const pathWithEnsuredExtension = ( ( ) => {
147
+ if (
148
+ extension . length > 0 &&
149
+ existsSync ( pathToDependencyFromDirectory )
150
+ ) {
151
+ return pathToDependencyFromDirectory ;
162
152
}
153
+ return checkFileExtensionsUntilItExists (
154
+ pathToDependencyFromDirectory . replace ( extension , '' ) ,
155
+ ) ;
156
+ } ) ( ) ;
157
+
158
+ if ( pathWithEnsuredExtension ) {
159
+ pathToDependencyFromDirectory = pathWithEnsuredExtension ;
160
+ } else if ( isDev ) {
161
+ // only warn about this on development as it is probably going to be irrelevant otherwise
162
+ console . warn (
163
+ `Could not find file at ${ pathToDependencyFromDirectory } ` ,
164
+ ) ;
163
165
}
164
166
165
167
return pathToDependencyFromDirectory ;
0 commit comments