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

Node.js 20 support #46

Open
ai opened this issue Apr 19, 2023 · 7 comments
Open

Node.js 20 support #46

ai opened this issue Apr 19, 2023 · 7 comments

Comments

@ai
Copy link
Contributor

ai commented Apr 19, 2023

Reproduction:

echo "import { test } from 'uvu'; test('one', () => {}); test.run()" > index.test.ts
npm install uvu tsm
npx tsm ./node_modules/.bin/uvu

Node.js 19.9.0 output:

(node:140378) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:140378) DeprecationWarning: Obsolete loader hook(s) supplied and will be ignored: getFormat, transformSource
(node:140378) DeprecationWarning: Obsolete loader hook(s) supplied and will be ignored: getFormat, transformSource
index.test.ts
•   (1 / 1)

  Total:     1
  Passed:    1
  Skipped:   0
  Duration:  0.26ms

Node.js 20.0.0 output:

(node:140181) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:140181) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:140181) DeprecationWarning: Obsolete loader hook(s) supplied and will be ignored: getFormat, transformSource
@ai ai mentioned this issue Apr 20, 2023
@ai ai changed the title uvu + tsm regression on Node.js 20: can’t find tests Node.js 20 support Apr 23, 2023
@ai
Copy link
Contributor Author

ai commented Apr 23, 2023

@lukeed seems like the issue is between tsm and Node.js in general. Not only uvu. #47

Could be related with nodejs/node#44710

@vanyauhalin
Copy link

Until it's fixed, you can use tsm via node -r.

$ node -v
v20.0.0
$ cat package.json
{
  "scripts": {
    "test": "node -r tsm index.test.ts"
  },
  "devDependencies": {
    "tsm": "^2.3.0",
    "uvu": "^0.5.6"
  }
}
$ cat index.test.ts
import { test } from 'uvu'; test('one', () => {}); test.run()
$ npm run test

> test
> node -r tsm index.test.ts

•   (1 / 1)

  Total:     1
  Passed:    1
  Skipped:   0
  Duration:  0.36ms

@vanyauhalin
Copy link

My previous answer was incorrect. Perhaps, I didn't understand the problem right away. When I used tsm as a loader, I encountered the same error.

$ cat package.json 
{
  "type": "module",
  "scripts": {
    "test": "node --loader tsm index.test.ts"
  },
  "devDependencies": {
    "tsm": "^2.3.0",
    "uvu": "^0.5.6"
  }
}
$ npm run test

> test
> node --loader tsm index.test.ts

(node:19810) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:19810) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:19810) DeprecationWarning: Obsolete loader hook(s) supplied and will be ignored: getFormat, transformSource

@ai
Copy link
Contributor Author

ai commented May 5, 2023

Fixed in Node.js 20.1.0

@lukeed
Copy link
Owner

lukeed commented Jun 27, 2023

Closing as it appears to have been a Node thing

@lukeed lukeed closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2023
@lukeed
Copy link
Owner

lukeed commented Jun 27, 2023

Still a Node issue. 🙄 ESM loaders in 20.x lost access to process.argv ... good move /s
See nodejs/node#48577

Also reverting #47 for the time being

@lukeed lukeed reopened this Jun 27, 2023
lukeed added a commit that referenced this issue Jun 27, 2023
@davidwincent
Copy link

Still seeings problems with node v20.11.1

Component Version
OS Debian GNU/Linux 12 (bookworm)
Node.js v20.11.1
tsm 2.3.0

package.json

{
    "name": "x-x-x-x",
    "version": "0.1.0",
    "description": "",
    "main": "index.js",
    "type": "module",
    "scripts": {
        "dev": "node --require dotenv/config --loader tsm src/index.ts",
        "test": "node --test .",
        "lint": "eslint . --max-warnings 0"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "devDependencies": {
        "@kaching-hq/typescript-config": "workspace:^",
        "dotenv": "^16.4.5",
        "tsm": "^2.3.0",
        "typescript": "^5.4.2"
    },
    "dependencies": {
        "firebase-admin": "^12.0.0",
        "googleapis": "^134.0.0"
    }
}

pnpm dev output

> node --require dotenv/config --loader tsm src/index.ts

(node:3856956) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("tsm", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)

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

No branches or pull requests

4 participants