antoine-coulon / skott

All-in-one devtool to automatically analyze, search and visualize project modules and dependencies from JavaScript, TypeScript (JSX/TSX) and Node.js (ES6, CommonJS)
MIT License
645 stars 25 forks source link

Failed to Resolve with index.tsx files #120

Closed robertoyoc closed 11 months ago

robertoyoc commented 11 months ago

With the following structure:

  src/common/components/SafeContainer
├── constants.ts
├── elements.tsx
├── index.test.tsx
└── index.tsx

Then in another file I have:

import { SafeContainer } from "@/common/components/SafeContainer";

This is my tsconfig for the aliasing:

{
  "compilerOptions": {
    "baseUrl": ".",
    "jsx": "react",
    "esModuleInterop": true,
    "paths": {
      "@/*": ["./src/*"],
      "@assets/*": ["./assets/*"]
    },
    "strict": true
  },
  "exclude": ["node_modules", "dist"]
}

After running skott index.js --verbose I see

Start resolution for src/common/components/SafeContainer 
 ✖ Failed to resolve src/common/components/SafeContainer/index.js 

 ✖ Failed to resolve src/common/components/SafeContainer.ts 

 ✖ Failed to resolve src/common/components/SafeContainer/index.ts 

 ✖ Failed to resolve s.ts 

 ✖ Failed to resolve src/common/components/SafeContainer.js 

 ✖ Failed to resolve src/common/components/SafeContainer.tsx 

 ✖ Failed to resolve src/common/components/SafeContainer.jsx 

 ✖ Failed to resolve src/common/components/SafeContainer/index.js 

Looks like library is not checking index.tsx/index.jsx paths? Thanks for your help.

antoine-coulon commented 11 months ago

@robertoyoc thanks for opening that issue! It's indeed correct, skott is not checking index.jsx/index.tsx modules yet when they are being imported via ./ or . module declarations (they still can be resolved when being imported as ./index).

TSX/JSX support was added incrementally, and this is something I forgot to add.

antoine-coulon commented 11 months ago

Fixed in #121 by @robertoyoc, will be released in 0.31.3 🎉

@all-contributors please add @robertoyoc for code

allcontributors[bot] commented 11 months ago

@antoine-coulon

I've put up a pull request to add @robertoyoc! :tada: