Fab*_*bis 5 npm typescript monorepo
我一直在网上寻找解决方案,但没有找到任何有价值的东西。基本上,我正在寻找一种工具或某种方法来同时在多个目录中启动 TypeScript 文件观看/编译。
我有一个包含范围 NPM 包(@test/one、@test/two、@test/ Three 等)的 monorepo,我想同时观看/编译所有这些包。
看起来 TS 并不支持这一点,而且也没有任何工具可以做到这一点。我发现的最接近的是nodemon,我可以让它同时监视多个目录,但它只支持在单个位置执行脚本/二进制文件,而我需要它在更改时在每个监视的目录中执行“tsc”。
我可以用 nodemon 做的最好的事情如下,但当然这不是一个很好的方法,因为它会编译所有包,即使只有一个更改:
npx nodemon --watch test-shared-api --watch test-shared-redux --watch test-shared-types -e js,ts,jsx,tsx --exec "npx tsc --build test-shared-api/tsconfig.json && npx tsc --build test-shared-types/tsconfig.json && npx tsc -build test-shared-redux/tsconfig.json"
Run Code Online (Sandbox Code Playgroud)
同时,我可以在 package.json 中执行以下操作,这更好,但仍然可以做得更好:
"scripts": {
"ts-watch-shared-types": "tsc -p packages/@test-shared/test-shared-types/tsconfig.json -w",
"ts-watch-shared-api": "tsc -p packages/@test-shared/test-shared-api/tsconfig.json -w",
"ts-watch-shared-redux": "tsc -p packages/@test-shared/test-shared-redux/tsconfig.json -w",
"ts-shared-watch": "concurrently -k -n w: npm:ts-watch-shared-*"
},
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
| 归档时间: |
|
| 查看次数: |
4112 次 |
| 最近记录: |