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] Error loading external tsconfig files from extends in typescript 5.3.2 #976

Open
3 tasks done
batusai513 opened this issue Nov 23, 2023 · 27 comments
Open
3 tasks done
Labels
bug something not go good

Comments

@batusai513
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Have you read the CONTRIBUTING guide on posting bugs, and CODE_OF_CONDUCT?

  • yes I read the things

This issue exists in the latest tap version

  • I am using the latest tap

Description

After updating to typescript 5.3.2 when trying to run the test I get an error from ts-node saying that it could not find the external tsconfig file from the extends field, this works just ok in typescript 5.2.2.

I think the issue is related to ts-node because in some other project that uses ts-node to run in development I had the same issue, replacing ts-node with tsx solved it there.

/Users/user/code/seo-cms/seo-cms-bundler-lambda/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@10.9.5_@types+nod
e@20.9.4_typescript@5.2.2/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:743
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^
TSError: ⨯ Unable to compile TypeScript:
error TS6053: File '@tsconfig/node20/tsconfig.json' not found.

    at createTSError (/Users/user/code/seo-cms/seo-cms-bundler-lambda/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-
2009@10.9.5_@types+node@20.9.4_typescript@5.2.2/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:743:12)
    at reportTSError (/Users/user/code/seo-cms/seo-cms-bundler-lambda/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-
2009@10.9.5_@types+node@20.9.4_typescript@5.2.2/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:747:19)
    at createFromPreloadedConfig (/Users/user/code/seo-cms/seo-cms-bundler-lambda/node_modules/.pnpm/@isaacs+ts-node-temp-
fork-for-pr-2009@10.9.5_@types+node@20.9.4_typescript@5.2.2/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:758:36)
    at create (/Users/user/code/seo-cms/seo-cms-bundler-lambda/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@10
.9.5_@types+node@20.9.4_typescript@5.2.2/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:572:10)
    at Object.register (/Users/user/code/seo-cms/seo-cms-bundler-lambda/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-p
r-2009@10.9.5_@types+node@20.9.4_typescript@5.2.2/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:544:15)
    at file:///Users/user/code/seo-cms/seo-cms-bundler-lambda/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@10.
9.5_@types+node@20.9.4_typescript@5.2.2/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/import.mjs:3:25
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24) {

Reproduction

I've prepared two playgrounds that will display the issue:

  • Run pnpm install
  • Run pnpm test

project with typescript 5.3.2
https://stackblitz.com/edit/stackblitz-starters-xyczc3?file=package.json

project with typescript 5.2.2
https://stackblitz.com/edit/stackblitz-starters-t9xr3w?file=package.json

Environment

which tap
/home/projects/stackblitz-starters-t9xr3w/node_modules/.bin/tap

npm ls tap

tap versions
    "@tapjs/core": "^1.4.6",
    "@tapjs/test": "^1.3.17",
    "@types/tap": "^15.0.11",
    "tap": "^18.6.1",

tap config list
# vim: set filetype=yaml :
# from package.json
allow-empty-coverage: true
disable-coverage: true
node-arg:
  - --require=dotenv/config

# env, cli, and defaults
color: true
coverage-report:
  - text
exclude:
  - "**/@(fixture*(s)|dist)/**"
include:
  - "**/@(test?(s)|__test?(s)__)/**/*.@(js|cjs|mjs|tap|cts|jsx|mts|ts|tsx)"
  - "**/*.@(test?(s)|spec).@(js|cjs|mjs|tap|cts|jsx|mts|ts|tsx)"
  - "**/test?(s).@(js|cjs|mjs|tap|cts|jsx|mts|ts|tsx)"
jobs: 6
reporter: base
snapshot-clean-cwd: true
timeout: 30

tap plugin list
@tapjs/after
@tapjs/after-each
@tapjs/asserts
@tapjs/before
@tapjs/before-each
@tapjs/filter
@tapjs/fixture
@tapjs/intercept
@tapjs/mock
@tapjs/node-serialize
@tapjs/snapshot
@tapjs/spawn
@tapjs/stdin
@tapjs/typescript
@tapjs/worker
# if using typescript:

npm ls @isaacs/ts-node-temp-fork-for-pr-2009

npm ls typescript

# posix:
uname -a

@batusai513 batusai513 added the bug something not go good label Nov 23, 2023
@isaacs
Copy link
Member

isaacs commented Nov 23, 2023

Yes, this is a ts-node shortcoming. It will be fixed by switching to tsimp, which uses tsc to load configs instead of doing the loading itself (and thus, supports whatever semantics tsc supports). Just ironing out some kinks with the thundering-herd problem in sock-daemon (which currently works, but getting such things passing tests in CI with full coverage is proving a bit challenging, slowed down by holidays and other personal stuff; it's close tho).

In the meantime, I recommend using the @tapjs/tsx plugin as an alternative to run typescript tests.

tap plugin add @tapjs/tsx
tap plugin rm @tapjs/typescript

@batusai513
Copy link
Author

I didn't know about that plugin, thanks for the tip and the hard work on tap, enjoy the holidays 👍

@piotr-cz
Copy link

This particular bug should be fixed in ts-node v11.0.0-beta.1
However I'm not sure how tap is using this package

@dannyb
Copy link

dannyb commented Nov 30, 2023

I updated my ts-node to v11.0.0-beta.1 and I am still getting the error. Reverting back to 5.2.x fixes the issue.

@piotr-cz
Copy link

piotr-cz commented Dec 4, 2023

@dannyb
tapjs maintains it's own ts-node fork.
You'd have to replace ts-node in tapjs dependencies - given that fork patches are not required anymore

@piotr-cz
Copy link

Apparently this problem has been fixed in ts-node 10.9.2
and now it can be backported into @isaacs\ts-node-temp-fork-for-pr-2009

pawel-id added a commit to pawel-id/bir1 that referenced this issue Dec 29, 2023
see hint related to other issue:
tapjs/tapjs#976 (comment)

```
npx tap plugin add @tapjs/tsx
npx tap plugin rm @tapjs/typescript
```
twistedstream added a commit to twistedstream/skattlada that referenced this issue Jan 27, 2024
- per: tapjs/tapjs#976 (comment)
  install @tapjs/tsx plugin to resolve issue with node v20
@dani-mp
Copy link

dani-mp commented Mar 7, 2024

Hi, @isaacs.

I'm facing a similar problem and I'm stuck. I remember having a hard time in the past as well to migrate to the new tap version with TypeScript. Since then, my tests have been passing both locally and in CI. Today I got a dependabot PR bumping TypeScript from 5.2.2 to 5.4.2, and my tests don't run anymore either locally or in CI.

Doing some research, I arrived here (I actually remember this issue from last time), try your suggestion below:

tap plugin add @tapjs/tsx
tap plugin rm @tapjs/typescript

This makes the tests pass locally but they still fail in CI, with the following error message:

yarn run v1.22.21
$ tap

> @tapjs/test-built@0.0.0 prepare
> tshy

TAP version 14
1..2

/home/runner/work/scan/scan/node_modules/@tapjs/test/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:743
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^

TSError: ⨯ Unable to compile TypeScript:
error TS6053: File '@tsconfig/strictest/tsconfig.json' not found.

    at createTSError (/home/runner/work/scan/scan/node_modules/@tapjs/test/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:743:12)
    at reportTSError (/home/runner/work/scan/scan/node_modules/@tapjs/test/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:747:19)
    at createFromPreloadedConfig (/home/runner/work/scan/scan/node_modules/@tapjs/test/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:758:36)
    at create (/home/runner/work/scan/scan/node_modules/@tapjs/test/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:572:10)
    at Object.register (/home/runner/work/scan/scan/node_modules/@tapjs/test/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:544:15)
    at file:///home/runner/work/scan/scan/node_modules/@tapjs/test/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/import.mjs:3:25
    at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:336:24) {
  diagnosticCodes: [ 6053 ]
}

Do you have any pointers?

This is my tap configuration in package.json after I run the commands you suggested above:

"tap": {
    "allow-empty-coverage": true,
    "disable-coverage": true,
    "plugin": [
      "@tapjs/tsx",
      "!@tapjs/typescript"
    ]
  }

Thanks.

@piotr-cz
Copy link

piotr-cz commented Mar 8, 2024

@dani-mp
Did you try installing @tsconfig/strictest ?
It might be required by one of the tap's dependencies, but not being included in it's package.json dependencies

Or problem may be that even you switched to @tapjs/tsx, tap is still trying to use @isaacs/ts-node-temp-fork-for-pr-2009

As for me, I'm waiting for the tsimp integration

@dani-mp
Copy link

dani-mp commented Mar 8, 2024

hey, @piotr-cz. @tsconfig/strictest is there, I'm actually using it myself as a base configuration. And it was working just fine before the TypeScript version bump.

@AxelDavidEspinosaMeneses

Yes, this is a ts-node shortcoming. It will be fixed by switching to tsimp, which uses tsc to load configs instead of doing the loading itself (and thus, supports whatever semantics tsc supports). Just ironing out some kinks with the thundering-herd problem in sock-daemon (which currently works, but getting such things passing tests in CI with full coverage is proving a bit challenging, slowed down by holidays and other personal stuff; it's close tho).

In the meantime, I recommend using the @tapjs/tsx plugin as an alternative to run typescript tests.

tap plugin add @tapjs/tsx
tap plugin rm @tapjs/typescript

I was facing the problem where when I was running TAP was not identifying my modules. This fixed the error. Thanks

@bcomnes
Copy link

bcomnes commented Apr 5, 2024

I was running into a similar problem, but slightly different inputs:

  • Working in a ts-in-js codebase (so all code is typed .js via jsdoc/docbloc ts)
  • My tsconfig.json uses an extended config file.
  • The extended config updates to a new peer version of typescript and then triggers the error TS6053: File '@tsconfig/node20/tsconfig.json' not found. error.
  • Switching to @tapjs/tsx results in a different error, but really what I want (in this case) is for tap to just not even try and deal with typescript.
  • Tap still tries to load the offending config even when setting "typecheck": false.
  • Creating an empty tsconfig.tap.json is enough to get tap to ignore my offending tsconfig.json and since I don't need to compile my tests, everything still works. (type checking gets run out of band with tap using tsc as normal)

So thats another workaround that may or may not help folks who just want to get tap to ignore tsconfig.json files it doesn't like.

@paambaati
Copy link

paambaati commented Apr 25, 2024

@isaacs I have the same issue (cannot load external tsconfig files via extends), and when I try to add the suggested plugin, I get this error –

$ tap plugin add @tapjs/tsx
adding plugins: [ '@tapjs/tsx' ]
installing: [ '@tapjs/tsx@1.1.21' ]
npm ERR! code 1
npm ERR! path /Users/me/my-project/node_modules/.pnpm/@tapjs+core@1.5.2_@types+node@20.12.7_react-dom@18.2.0_react@18.2.0/node_modules/@tapjs/core
npm ERR! command failed
npm ERR! command sh -c tshy
npm ERR! node:fs:1508
npm ERR!   const result = binding.readdir(
npm ERR!                          ^
npm ERR!
npm ERR! Error: ENOENT: no such file or directory, scandir 'src'
npm ERR!     at readdirSync (node:fs:1508:26)
npm ERR!     at getSources (file:///Users/me/my-project/node_modules/.pnpm/tshy@1.14.0/node_modules/tshy/dist/esm/sources.js:6:21)
npm ERR!     at file:///Users/me/my-project/node_modules/.pnpm/tshy@1.14.0/node_modules/tshy/dist/esm/sources.js:17:25
npm ERR!     at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
npm ERR!     at async ModuleLoader.import (node:internal/modules/esm/loader:323:24)
npm ERR!     at async loadESM (node:internal/process/esm_loader:28:7)
npm ERR!     at async handleMainPromise (node:internal/modules/run_main:120:12) {
npm ERR!   errno: -2,
npm ERR!   code: 'ENOENT',
npm ERR!   syscall: 'scandir',
npm ERR!   path: 'src'
npm ERR! }
npm ERR!
npm ERR! Node.js v21.7.3

@paambaati
Copy link

@isaacs FWIW, this issue persists with the latest release as well.

- @tapjs/core 1.5.2
+ @tapjs/core 1.5.3
- @tapjs/test 1.4.2
+ @tapjs/test 1.4.3
- @types/node 20.12.7
+ @types/node 20.12.10
- tap 18.7.2
+ tap 18.7.3

@brenc
Copy link

brenc commented May 16, 2024

@paambaati getting the same thing. Using pnpm and volta might have something to do with it. Had to manually install @tapjs/core and was finally able to run plugin commands, but then got the above error. Haven't been able to get any of my projects upgraded to tap@18 yet.

@paambaati
Copy link

Had to manually install @tapjs/core and was finally able to run plugin commands

@brenc How did you do this exactly? Would you mind walking me through those steps?

@brenc
Copy link

brenc commented May 16, 2024

@paambaati pnpm add -D @tapjs/core if you made it this far you already have this installed. I couldn't even run plugin commands at all until I installed @tapjs/core. Now I'm getting the same error as you when I run pnpm tap plugin add @tapjs/tsx.

@zetaraku
Copy link

Same problem here. I downgrade to typescript@5.2.2 and wait for the fix.

@brenc
Copy link

brenc commented May 21, 2024

I shifted over to testing the compiled Javascript. Had to remove @tapjs/typescript which causes the error when using extends, even if you're testing JS directly. It's not perfect, but it got me moving forward finally.

@paambaati
Copy link

paambaati commented May 23, 2024

With the latest release, I'm (EDIT: not) able to get past the error installing the tsx plugin with tap plugin add @tapjs/tsx.

devDependencies:
- @tapjs/core 1.5.4
+ @tapjs/core 2.0.0
- @tapjs/test 1.4.4
+ @tapjs/test 2.0.0
- tap 18.8.0
+ tap 19.0.0

But after that, the tests fail with the original error reporting earlier in this issue –

pnpm run test                                           3s 07:27:04 PM

> my-project@6.0.0 test /my-project
> cross-env NODE_OPTIONS="--no-warnings" tap run --disable-coverage


2> test/integration.test.ts

/my-project/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@10.9.5_@types+node@20.12.
12_typescript@5.4.5/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:743
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^

2> test/utils.test.ts

/my-project/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@10.9.5_@types+node@20.12.
12_typescript@5.4.5/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:743
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^

TSError: ⨯ Unable to compile TypeScript:
error TS6053: File '@tsconfig/node20/tsconfig.json' not found.

    at createTSError (/my-project/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@10.
9.5_@types+node@20.12.12_typescript@5.4.5/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:743:12)
    at reportTSError (/my-project/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@10.
9.5_@types+node@20.12.12_typescript@5.4.5/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:747:19)
    at createFromPreloadedConfig
(/my-project/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@10.9.5_@types+node@20.12
.12_typescript@5.4.5/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:758:36)
    at create (/my-project/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@10.9.5_@ty
pes+node@20.12.12_typescript@5.4.5/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:572:10)
    at Object.register (/my-project/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@1
0.9.5_@types+node@20.12.12_typescript@5.4.5/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:544:15)
    at file:///my-project/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@10.9.5_@typ
es+node@20.12.12_typescript@5.4.5/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/import.mjs:3:25
    at ModuleJob.run (node:internal/modules/esm/module_job:235:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:461:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:114:9) {
  diagnosticCodes: [ 6053 ]
}

Node.js v22.0.0

2> test/integration.test.ts
TSError: ⨯ Unable to compile TypeScript:
error TS6053: File '@tsconfig/node20/tsconfig.json' not found.

    at createTSError (/my-project/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@10.
9.5_@types+node@20.12.12_typescript@5.4.5/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:743:12)
    at reportTSError (/my-project/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@10.
9.5_@types+node@20.12.12_typescript@5.4.5/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:747:19)
    at createFromPreloadedConfig
(/my-project/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@10.9.5_@types+node@20.12
.12_typescript@5.4.5/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:758:36)
    at create (/my-project/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@10.9.5_@ty
pes+node@20.12.12_typescript@5.4.5/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:572:10)
    at Object.register (/my-project/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@1
0.9.5_@types+node@20.12.12_typescript@5.4.5/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:544:15)
    at file:///my-project/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@10.9.5_@typ
es+node@20.12.12_typescript@5.4.5/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/import.mjs:3:25
    at ModuleJob.run (node:internal/modules/esm/module_job:235:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:461:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:114:9) {
  diagnosticCodes: [ 6053 ]
}

Node.js v22.0.0

2> test/main.test.ts

/my-project/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@10.9.5_@types+node@20.12.
12_typescript@5.4.5/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:743
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^

TSError: ⨯ Unable to compile TypeScript:
error TS6053: File '@tsconfig/node20/tsconfig.json' not found.

    at createTSError (/my-project/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@10.
9.5_@types+node@20.12.12_typescript@5.4.5/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:743:12)
    at reportTSError (/my-project/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@10.
9.5_@types+node@20.12.12_typescript@5.4.5/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:747:19)
    at createFromPreloadedConfig
(/my-project/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@10.9.5_@types+node@20.12
.12_typescript@5.4.5/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:758:36)
    at create (/my-project/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@10.9.5_@ty
pes+node@20.12.12_typescript@5.4.5/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:572:10)
    at Object.register (/my-project/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@1
0.9.5_@types+node@20.12.12_typescript@5.4.5/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/src/index.ts:544:15)
    at file:///my-project/node_modules/.pnpm/@isaacs+ts-node-temp-fork-for-pr-2009@10.9.5_@typ
es+node@20.12.12_typescript@5.4.5/node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/import.mjs:3:25
    at ModuleJob.run (node:internal/modules/esm/module_job:235:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:461:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:114:9) {
  diagnosticCodes: [ 6053 ]
}

Node.js v22.0.0

 SKIP  test/integration.test.ts 0 OK 220ms
 ~ no tests found
 SKIP  test/main.test.ts 0 OK 219ms
 ~ no tests found
 SKIP  test/utils.test.ts 0 OK 217ms
 ~ no tests found


  🌈 TEST COMPLETE 🌈


 FAIL  test/utils.test.ts 0 217ms

 FAIL  test/main.test.ts 0 219ms

 FAIL  test/integration.test.ts 0 220ms

Asserts:  0 pass  3 fail  3 of 3 complete
Suites:   0 pass  3 fail  3 of 3 complete

# No coverage generated
# { total: 3, pass: 0, fail: 3 }
# time=269.149ms

 ELIFECYCLE  Test failed. See above for more details.

@paambaati
Copy link

Correction, the plugin installation no longer seems to be possible –

$ pnpm tap plugin add @tapjs/tsx

installing: [ '@tapjs/tsx@1.1.24' ]

added 130 packages in 18s

33 packages are looking for funding
  run `npm fund` for details
'@tapjs/tsx' does not appear to be a tap plugin. Could not load module with require(). Cannot find module '@tapjs/tsx'
Require stack:
- /my-project/node_modules/.pnpm/@tapjs+test@2.0.0_@tapjs+core@2.0.0_@types+node@20.12.12_react-dom@18.2.0_react@18.2.0__react_qsu6dfizunsmf7u66ytzxni6zq/node_modules/@tapjs/test/test-built
build failed
build failed
attempting to clean up added packages

removed 130 packages in 362ms

@paambaati
Copy link

paambaati commented May 24, 2024

I've got this working with these steps –

  1. Remove the @tapjs/typescript plugin

    tap plugin remove @tapjs/typescript
    
  2. Install the @tapjs/tsx plugin – manually, without the tap plugin add command

     npm i -D @tapjs/tsx
    
  3. Manually configure tap to run Node with the @tapjs/tsx import loader and include *.ts files (I suppose this is what the tap plugin install would've done had it worked) – CC: @isaacs.

    - "test": "tap run",
    + "test": "NODE_OPTIONS=\"--import=@tapjs/tsx/loader\" tap run --include=\"**/*.test.ts\"",

    Please adjust the --include filter to whatever fits your test setup.

After making these 3 changes, your code output should look very similar to this – paambaati/codeclimate-action@295386a (#747)

@paambaati
Copy link

Note that the above changes work locally, but not in a CI environment (https://github.com/paambaati/codeclimate-action/actions/runs/9222795319/job/25374681232?pr=747) – tap still seems to be trying to use its own forked version of ts-node. That needs further investigation.

isaacs added a commit that referenced this issue May 24, 2024
@isaacs
Copy link
Member

isaacs commented May 24, 2024

The forked ts-node is required to play nice with node's --import logic, at least until either ts-node supports what we need out of the box or I eventually get around to finishing tsimp.

I just pulled in the tsconfig/node20 fixes, if you update to tap 19.0.1, it should load this fine.

I also changed the plugin installation strategy in tap 19 (the main breaking change) so that plugins that get auto-installed go to ./.tap/plugins/node_modules instead of trying to install in the project node_modules as a devDep, which could really not be made to function properly on pnpm and yarn berry, without a lot of really annoying platform-detection work.

@isaacs
Copy link
Member

isaacs commented May 24, 2024

I think once ts-node 11 ships, it might actually address the issues that tap had with it, or at least it'd be worth investigating. I really don't like the experimental warnings when using --loader ts-node/esm, and a bunch of things got weird when it moved to a separate thread. --import is much cleaner and officially supported by node.

@piotr-cz
Copy link

W would not bet on ts-node 11: https://github.com/TypeStrong/ts-node/graphs/commit-activity

paambaati added a commit to paambaati/codeclimate-action that referenced this issue May 27, 2024
@paambaati
Copy link

I just pulled in the tsconfig/node20 fixes, if you update to tap 19.0.1, it should load this fine.

@isaacs Can confirm the latest version fixes the extends tsconfig issue as well as the plugin installation issue.

@dani-mp
Copy link

dani-mp commented May 27, 2024

I just pulled in the tsconfig/node20 fixes, if you update to tap 19.0.1, it should load this fine.

@isaacs Can confirm the latest version fixes the extends tsconfig issue as well as the plugin installation issue.

Indeed. My CI is ✅ again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something not go good
Projects
None yet
Development

No branches or pull requests

11 participants