`scanImportsFromDir` fails to detect `subdir/index.{tsx|jsx}` files
Environment
- Unimport:
v3.7.1 - Node:
v18.16.1
Reproduction
https://github.com/aklinker1/unimport-tsx-bug
pnpm i
node index.mjs
Describe the bug
When components/index.ts exports a subdirectory with a index.tsx file in it, an error is throw (see logs below).
https://github.com/aklinker1/unimport-tsx-bug/blob/56985dab7724fae0c3e28f3801d6b3297bb2eed3/components/index.ts#L1
Same error is thrown if the file is components/Iframe/index.jsx.
There is a work-around, change the export in components/index.ts:
-export * from "./Iframe";
+export * from "./Iframe/index.tsx";
Additional context
This issue originates from: https://github.com/wxt-dev/wxt/issues/440
I did some research into this and it appears we just need to add "tsx" and "jsx" to the file extensions array?
https://github.com/unjs/unimport/blob/8a622c9c38d28ee9a80e7c0b8cb82bea05a69766/src/scan-dirs.ts#L41-L48
#229 fixed this for non-JSX files.
Logs
$ node index.mjs
node:internal/process/esm_loader:97
internalBinding('errors').triggerUncaughtException(
^
[Error: EISDIR: illegal operation on a directory, read] {
errno: -21,
code: 'EISDIR',
syscall: 'read'
}
Node.js v18.16.1