Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scanImportsFromDir fails to detect subdir/index.{tsx|jsx} files #326

Open
aklinker1 opened this issue Feb 14, 2024 · 0 comments
Open

scanImportsFromDir fails to detect subdir/index.{tsx|jsx} files #326

aklinker1 opened this issue Feb 14, 2024 · 0 comments

Comments

@aklinker1
Copy link

aklinker1 commented Feb 14, 2024

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: wxt-dev/wxt#440

I did some research into this and it appears we just need to add "tsx" and "jsx" to the file extensions array?

const FileExtensionLookup = [
'.mts',
'.cts',
'.ts',
'.mjs',
'.cjs',
'.js'
]

#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant