Open ai opened 1 year ago
@lukeed seems like the issue is between tsm
and Node.js in general. Not only uvu
. https://github.com/lukeed/tsm/pull/47
Could be related with https://github.com/nodejs/node/pull/44710
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
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
Fixed in Node.js 20.1.0
Closing as it appears to have been a Node thing
Still a Node issue. 🙄 ESM loaders in 20.x lost access to process.argv
... good move /s
See https://github.com/nodejs/node/issues/48577
Also reverting #47 for the time being
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)
Reproduction:
Node.js 19.9.0 output:
Node.js 20.0.0 output: