Reputation: 1392
I have a TypeScript project, based on Node.js, with several modules (using workspaces). Everything executes correctly, but I’m still receiving warnings. In particular, when running this (as a package.json
‘script’ in Yarn)
ts-node --project path/tsconfig.json path/script.ts <args-to-script>
I’m seeing two classes of warnings:
makefont.ts
, because I (have to) specify .ts
file extensions;I think the two warnings are related. I’m using NodeJS 23.7.0, Yarn 1.22.22, ts-node 10.9.2, TypeScript 5.5.4
Without the .ts
, I get “Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/andrew/projects/retrofabulationzx/app/node_modules/fonts/font1' imported from /Users/andrew/projects/retrofabulationzx/app/rom/build/makefont.ts
”
Note that, additionally, I’ve had to split off a type import (Glyph
) into a separate import
statement. I suspect that both of these issues are related to the ‘Type Stripping’ mentioned below:
It seems that ts-node is using the (experimental) Node Type Stripping feature to run TypeScript… I am sure that it wasn’t doing this previously, before I implemented workspaces…
Does ts-node have problems running within a Yarn/NPM ‘workspace’?
fonts/
(workspace)
font1.ts
package.json
tsconfig.json
rom/
(workspace)
build/
makefont.ts
tsconfig.json
generated/
(output directory)package.json
package.json
tsconfig.json
{
"private": true,
"workspaces": [
"fonts",
"rom",
],
"devDependencies": {
"@jest/globals": "^29.1.2",
"@types/node": "^22.4.0",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5.5.4"
},
"packageManager": "[email protected]"
}
{
"compilerOptions": {
"target": "es6",
"module": "ES6",
"outDir": "dist",
"esModuleInterop": true,
"moduleResolution": "node"
},
"include": [],
"exclude": [ "**/node_modules" ],
}
{
"name": "fonts",
"version": "1.0.0",
"type": "module"
}
{
"extends": "../tsconfig.json",
"compilerOptions": {
"composite": true
},
"include": [ "./*.ts" ]
}
{
"name": "rom",
"version": "1.0.0",
"type": "module",
"devDependencies": {
"@types/node": "^22.4.0",
"fonts": "1.0.0",
"ts-node": "^10.9.2",
"typescript": "^5.5.4",
"zxsys": "1.0.0"
},
"scripts": {
"genfont": "ts-node --project build/tsconfig.json build/makefont.ts generated/font.z80",
// plus others
}
}
{
"extends": "../../tsconfig.json",
"ts-node": {
"esm": true
},
"compilerOptions": {
},
"references": [
{ "path": "../../fonts" },
// +others
],
"include": [ "./*.ts" ],
}
yarn workspace rom genfont
Upvotes: 0
Views: 317