oxc-project / oxc-resolver

Rust version of webpack/enhanced-resolve
https://oxc.rs/docs/guide/usage/resolver.html
MIT License
122 stars 18 forks source link

resolve '.' get an error path #201

Closed 9romise closed 3 months ago

9romise commented 3 months ago

I made a eslint-import-resolver based on oxc-resolver. Beside the rule import-x/no-self-import, it perfectly replaced eslint-import-resolver-node in my projects. I found the problem is for importing from '.'

For example, there is a folder includes index.ts and test.ts, when I write this, I got a correctly from index.ts in test.ts. But resolve.sync got the result like { path: '**/**/test.ts' }

// test.ts
import { a } from '.'
// index.ts
export  const a = 1

I'm not sure if it's really an issue and if I've made the issue clear, if not, feel free to close it or mention me.

Boshen commented 3 months ago

Is there an exports / imports field in its package.json? Otherwise I need a repro because I can't reproduce the problem after trying your setup here https://github.com/9romise/eslint-import-resolver-oxc/blob/main/src/nomalizeOptions.ts

9romise commented 3 months ago

I create a new branch to repro this. cc https://github.com/9romise/eslint-import-resolver-oxc/tree/repo/%23201

Just download the source and run pnpm i and pnpm run repo.

image

Boshen commented 3 months ago

It says it's found? Where's the failing case?

Boshen commented 3 months ago

Oh you meant it should resolve to index.ts.

9romise commented 3 months ago

In actual runtime, index.ts is imported instead of repo.ts, but the resolver finds repo.ts.

If this is by design, feel free to close this issue.

Boshen commented 3 months ago
  const result = resolver.sync(file, source)
                               ^^^^ this must be the directory, not the file.

Let me make this clearer in the docs.