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

[Bug]: node16 moduleResolution no longer works since 29.2.4 #4552

Open
skrtheboss opened this issue Sep 13, 2024 · 4 comments
Open

[Bug]: node16 moduleResolution no longer works since 29.2.4 #4552

skrtheboss opened this issue Sep 13, 2024 · 4 comments
Labels
🐛 Bug Confirmed Bug is confirmed

Comments

@skrtheboss
Copy link

skrtheboss commented Sep 13, 2024

Version

29.2.5

Steps to reproduce

  1. Clone my repo at https://github.com/skrtheboss/ts-jest-node16-module-resolution
  2. Run pnpm install
  3. Run pnpm nx run eslint-rules:test --skip-nx-cache --no-cache
  4. The command should fail with:
> nx run eslint-rules:test --no-cache

> jest --no-cache

 FAIL   eslint-rules  rules/my-custom-rule.spec.ts
  ● Test suite failed to run

    rules/my-custom-rule.ts:18:31 - error TS2307: Cannot find module '@typescript-eslint/utils/ast-utils' or its corresponding type declarations.

    18 import { isTypeKeyword } from '@typescript-eslint/utils/ast-utils';
                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 PASS   eslint-rules  rules/a-my-custom-rule.spec.ts

Test Suites: 1 failed, 1 passed, 2 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        4.012 s
Ran all test suites.
Warning: command "jest --no-cache" exited with non-zero status code
—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Ran target test for project eslint-rules (6s)

      With additional flags:
        --cache=false

   ✖  1/1 failed
   ✔  0/1 succeeded [0 read from cache]

Expected behavior

  1. Clone my repo at https://github.com/skrtheboss/ts-jest-node16-module-resolution
  2. Checkout branch with older version git checkout fix/ts-jest-29-2-3 or git checkout fix/ts-jest-29-1-0
  3. Run pnpm install
  4. Run pnpm nx run eslint-rules:test --skip-nx-cache --no-cache
  5. The command will succed with:
> nx run eslint-rules:test --no-cache

> jest --no-cache

 PASS   eslint-rules  rules/my-custom-rule.spec.ts
  ● Console

    console.log
      false

      at create (rules/my-custom-rule.ts:36:13)
          at Array.forEach (<anonymous>)

 PASS   eslint-rules  rules/a-my-custom-rule.spec.ts

Test Suites: 2 passed, 2 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        4.097 s
Ran all test suites.

Actual behavior

Tests fail since exports field of @typescript-eslint/utils package is not taken into consideration while resolution is performed

Debug log

Content is too long.

Additional context

As far as I can tell, the commit that breaks this is 70b9530.

Environment

System:
    OS: Linux 6.10 Arch Linux
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  Binaries:
    Node: 20.17.0 - ~/.nvm/versions/node/v20.17.0/bin/node
    npm: 10.8.2 - ~/.nvm/versions/node/v20.17.0/bin/npm
    pnpm: 9.10.0 - ~/.nvm/versions/node/v20.17.0/bin/pnpm
  npmPackages:
    jest: ^29.7.0 => 29.7.0
@skrtheboss
Copy link
Author

ts-jest.log

@ahnpnl
Copy link
Collaborator

ahnpnl commented Sep 13, 2024

Hi, we reverted the change because it caused breaking change. We will introduce a temporarily flag to support this.

A suggested flag name is useModernResolution

Duplicated with #4198

@skrtheboss
Copy link
Author

Hi @ahnpnl,
Thank you for the feedback! I should have found this issue myself 🤦‍♂️.
I'm okay with whatever you think is best!

Clashsoft added a commit to Morphclue/apollusia that referenced this issue Oct 8, 2024
Clashsoft added a commit to Morphclue/apollusia that referenced this issue Oct 8, 2024
* feat: nx migrate and angular update

* feat: turn off no-unused-expressions

* fix: imports formatting in app.module.ts

* feat: update mongodb-memory-server, ical-generator and reflect-metadata

* fix: use NodeNext moduleResolution

* fix(ci): Node version 22

* revert: upgrade mean-stream/nestx

* feat: upgrade @mean-stream/nestx

* fix: module NodeNext in tsconfig

* feat: pnpm 9.12.0

* feat: NodeNext for tsconfig.spec.json

* test: Revert ts-jest to 29.2.3

See: kulshekhar/ts-jest#4198
See:  kulshekhar/ts-jest#4552

---------

Co-authored-by: Adrian Kunz <[email protected]>
@edisonmatoso
Copy link

edisonmatoso commented Dec 5, 2024

Hi @ahnpnl, Thank you for the feedback! I should have found this issue myself 🤦‍♂️. I'm okay with whatever you think is best!

@skrtheboss, how did you solve it? I'm facing the same problem, I've tried the solutions described on the issue mentioned above but nothing worked.

I'm at:
ts-jest v29.2.5
node v20.14.0
typescript v4.7.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Confirmed Bug is confirmed
Projects
None yet
Development

No branches or pull requests

3 participants