Skip to content

Commit

Permalink
fix: Try to identify unbuilt installed modules
Browse files Browse the repository at this point in the history
  • Loading branch information
atdrago committed Feb 7, 2022
1 parent 0b29ec2 commit 196fb5e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,14 @@ export default function (styleApi: IStyleAPI): IStyleItem[] {
moduleName: `${imported.moduleName}.tsx`,
};

// In some cases, the module may not be built, and might only exist as a
// file with a `.ts` extension (not `.js`). Try to handle these cases by
// searching for a `.ts` file with the same name.
const __filenameWithTs = __filename.replace(/\.js$/, '.ts');

return (
isInstalledModule(__filename)(imported) ||
isInstalledModule(__filenameWithTs)(imported) ||
isInstalledModule(__filename)(importedWithTs) ||
isInstalledModule(__filename)(importedWithTsx)
);
Expand Down

0 comments on commit 196fb5e

Please sign in to comment.