smeijer / unimported

Find and fix dangling files and unused dependencies in your JavaScript projects.
MIT License
1.97k stars 71 forks source link

FIX: try to resolve file path from root alias - Help needed #197

Closed ngouy closed 9 months ago

ngouy commented 11 months ago

Disclaimer:

I have no idea on overall how this function is even working, nor why It happens to meAll I know is that sometimes the resolveImport method is called with this for example:

path: /src/core/schedules/dto/schedule-schema/schedule-composition-data.dto cdw: /Users/nathangouy/Work/backend/src/actions/account-managment/some-action

and it fails to resolve

I also have seen that in my aliases, I had an alias for the root that points to /Users/nathangouy/Work/backend/ So plugging the "root" alias with the path makes my trouble go away


TODO:


PS: my config is as simple as it can gets:

{
  "entry": [
    "src/app.module.ts",
    "src/main.ts"
  ],
  "extensions": [
    ".ts",
    ".js"
  ]
}
ngouy commented 11 months ago

cc @smeijer

Wondering if it would be possible to have your quick 2 cents on that one? 🙏

smeijer commented 11 months ago

My quick 2 cents are that I'm hesitant to merge, given that you, and thus I, don't know what problem this exactly solves.

I'd be happy to take a proper look if you can make a small reproduction. The tests in this project are quite straightforward, so if there is a bug in the resolver, it should be possible to make a failing test.

ngouy commented 11 months ago

Gotcha. I will try to take a deeper look. But other than putting a debugger in the code while this is failing on my project, and see "weird" things, I have no idea on why it happens basically.

Is there a TLDR; on what could influence this or that? I will take a few and post:

Is there a way to create and test this package in any js code-sandbox like?

ngouy commented 9 months ago

Seems like bump to node 20 fixed the thing 🤷