Skip to content

import/no-unresolved on NX monorepos on 4.x #393

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

Open
keeban-io opened this issue Mar 18, 2025 · 10 comments
Open

import/no-unresolved on NX monorepos on 4.x #393

keeban-io opened this issue Mar 18, 2025 · 10 comments
Assignees

Comments

@keeban-io
Copy link

Hi,

Looks like #376 is resolved by #377 and deployed in 3.x codebase, but it's not patched on main 4.x, as whole config resolving logic is rewritten.

I'd appreciate any help. Thanks!

@JounQin
Copy link
Collaborator

JounQin commented Mar 18, 2025

Please provide reproduction.

v4 is confirmed resolves #376.

@prenaissance
Copy link

prenaissance commented Mar 23, 2025

I confirm that this happens for pnpm workspaces using import-x as well. The same configuration produces import-x/no-unresolved and import-x/order errors on version 4 and no errors on version 3.

Here's my eslint configuration.

To reproduce, clone this repo and checkout to the commit from the hyperlink, run pnpm add -Dw eslint-import-resolver-typescript@latest and then pnpm -w lint and observe the newly appeared eslint errors.

Logs: Version `@4` logs:
/home/prenaissance/Repos/omni-index/apps/backend/src/atproto/types/com/omni-index/comment.ts
  4:28  warning  'BlobRef' is defined but never used. Allowed unused vars must match /^_/u  @typescript-eslint/no-unused-vars
  5:10  warning  'CID' is defined but never used. Allowed unused vars must match /^_/u      @typescript-eslint/no-unused-vars

/home/prenaissance/Repos/omni-index/apps/backend/src/atproto/types/com/omni-index/comment/like.ts
  4:28  warning  'BlobRef' is defined but never used. Allowed unused vars must match /^_/u  @typescript-eslint/no-unused-vars
  5:10  warning  'CID' is defined but never used. Allowed unused vars must match /^_/u      @typescript-eslint/no-unused-vars

/home/prenaissance/Repos/omni-index/apps/frontends/omni-book/app/components/ui/button.tsx
  5:20  error  Unable to resolve path to module '~/lib/utils'  import-x/no-unresolved

/home/prenaissance/Repos/omni-index/apps/frontends/omni-book/app/components/ui/input.tsx
  3:20  error  Unable to resolve path to module '~/lib/utils'  import-x/no-unresolved

/home/prenaissance/Repos/omni-index/apps/frontends/omni-book/app/components/ui/label.tsx
  5:20  error  Unable to resolve path to module '~/lib/utils'  import-x/no-unresolved

/home/prenaissance/Repos/omni-index/apps/frontends/omni-book/app/routes/book.tsx
  3:21  error  Unable to resolve path to module '~/lib/env'              import-x/no-unresolved
  4:19  error  Unable to resolve path to module '~/components/ui/popup'  import-x/no-unresolved
  5:29  error  Unable to resolve path to module '~/lib/formats'          import-x/no-unresolved

/home/prenaissance/Repos/omni-index/apps/frontends/omni-book/app/routes/home.tsx
  2:22  error  Unable to resolve path to module '~/components/trending'  import-x/no-unresolved
  3:18  error  Unable to resolve path to module '~/components/hero'      import-x/no-unresolved
  4:21  error  Unable to resolve path to module '~/lib/env'              import-x/no-unresolved

/home/prenaissance/Repos/omni-index/apps/frontends/omni-book/app/routes/login.tsx
  2:24  error  Unable to resolve path to module '~/components/ui/button'  import-x/no-unresolved
  3:23  error  Unable to resolve path to module '~/components/ui/input'   import-x/no-unresolved
  4:23  error  Unable to resolve path to module '~/components/ui/label'   import-x/no-unresolved

/home/prenaissance/Repos/omni-index/apps/frontends/omni-book/app/server/routes/oauth/callback.ts
  1:10  warning  'redirect' is defined but never used. Allowed unused vars must match /^_/u       @typescript-eslint/no-unused-vars
  3:21  error    Unable to resolve path to module '~/server/env'                                  import-x/no-unresolved
  6:25  warning  'host' is assigned a value but never used. Allowed unused vars must match /^_/u  @typescript-eslint/no-unused-vars

/home/prenaissance/Repos/omni-index/apps/frontends/omni-book/app/server/routes/oauth/login.ts
  3:21  error  Unable to resolve path to module '~/server/env'  import-x/no-unresolved

/home/prenaissance/Repos/omni-index/apps/scrapers/common/gutenberg.ts
  1:36  error  Unable to resolve path to module '~/backend/media/payloads/entry/create-entry-request'                    import-x/no-unresolved
  2:1   error  `./utilities` import should occur before import of `~/backend/media/payloads/entry/create-entry-request`  import-x/order

/home/prenaissance/Repos/omni-index/apps/scrapers/scripts/import-gutenberg-batch.ts
  2:36  error  Unable to resolve path to module '~/backend/media/payloads/entry/create-entry-request'  import-x/no-unresolved
  3:48  error  Unable to resolve path to module '~/common/gutenberg'                                   import-x/no-unresolved

/home/prenaissance/Repos/omni-index/apps/scrapers/scripts/import-gutenberg.ts
  3:48  error  Unable to resolve path to module '~/common/gutenberg'  import-x/no-unresolved

✖ 25 problems (19 errors, 6 warnings)
  1 error and 0 warnings potentially fixable with the `--fix` option.

Version @3 logs:

/home/prenaissance/Repos/omni-index/apps/backend/src/atproto/types/com/omni-index/comment.ts
  4:28  warning  'BlobRef' is defined but never used. Allowed unused vars must match /^_/u  @typescript-eslint/no-unused-vars
  5:10  warning  'CID' is defined but never used. Allowed unused vars must match /^_/u      @typescript-eslint/no-unused-vars

/home/prenaissance/Repos/omni-index/apps/backend/src/atproto/types/com/omni-index/comment/like.ts
  4:28  warning  'BlobRef' is defined but never used. Allowed unused vars must match /^_/u  @typescript-eslint/no-unused-vars
  5:10  warning  'CID' is defined but never used. Allowed unused vars must match /^_/u      @typescript-eslint/no-unused-vars

/home/prenaissance/Repos/omni-index/apps/frontends/omni-book/app/server/routes/oauth/callback.ts
  1:10  warning  'redirect' is defined but never used. Allowed unused vars must match /^_/u       @typescript-eslint/no-unused-vars
  6:25  warning  'host' is assigned a value but never used. Allowed unused vars must match /^_/u  @typescript-eslint/no-unused-vars

✖ 6 problems (0 errors, 6 warnings)

@JounQin
Copy link
Collaborator

JounQin commented Mar 24, 2025

Thanks for reproduction, I'll take a look soon.

@JounQin
Copy link
Collaborator

JounQin commented May 7, 2025

@prenaissance It's indeed an regression of #376 with #345 and #377, maybe @carlocorradini want to rework on this with the latest version? Before that lands, prenaissance/omni-index#37 is a better solution which would have better performance than #345.

By the way, @carlocorradini if you agree, I'd like to invite you into this project, WDYT?

@carlocorradini
Copy link
Collaborator

@JounQin Sure, invite me 🫡🥳

@carlocorradini
Copy link
Collaborator

The overall logic and structure have undergone significant changes. Do you have any idea why this is happening? Is this confirmed exclusively for the NX and PNPM repositories?

@JounQin
Copy link
Collaborator

JounQin commented May 9, 2025

@JounQin Sure, invite me 🫡🥳

Just sent the invitation, welcome!

@JounQin
Copy link
Collaborator

JounQin commented May 9, 2025

The overall logic and structure have undergone significant changes. Do you have any idea why this is happening? Is this confirmed exclusively for the NX and PNPM repositories?

@carlocorradini We encourage users to use single tsconfig with references for better performance in v4, but users are still using multiple tsconfig projects, and then we get back the same situation before #345. The regression is that multiple projects use same ~/* prefix.

@carlocorradini
Copy link
Collaborator

@JounQin
I checked the new code and (sad to say) I'm not sure where to begin because we're using different resolution logic and data structures.
Can you help/point me in the right direction? 😥
Thanks

@JounQin
Copy link
Collaborator

JounQin commented May 13, 2025

@carlocorradini

I think it could be

for (const p of sortProjectsByAffinity(project, file)) {
const resolved = resolve(
source,
file,
{ ...options, project: p },
resolver,
)
if (resolved.found) {
return resolved
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants