我有一个打字稿monorepo原型设置,并使用增量构建与cjs,yarn工作区和项目引用一起运行:
https://github.com/rosskevin/learn-a/tree/build-cjs-esm
由于tsc -b
在每个项目中都使用默认的tsconfig.json
,并且它们是为cjs设置的,因此我想简单地通过命令行传递覆盖:
yarn tsc -b --outDir lib/esm --module esnext --target esnext ✘ 127
yarn run v1.12.3
$ /Users/kross/projects/js/node_modules/.bin/tsc -b --outDir lib/esm --module esnext --target esnext
error TS5072: Unknown build option '--outDir'.
error TS5072: Unknown build option '--module'.
error TS5072: Unknown build option '--target'.
error Command failed with exit code 1.
为打字稿项目引用项目同时获取cjs和esm构建的最佳方法是什么?
答案 0 :(得分:0)
在https://www.typescriptlang.org/docs/handbook/compiler-options.html
-b --build
构建此项目及其由Project指定的所有依赖项 参考文献。请注意,此标志与此上的其他标志不兼容 页。在这里https://www.typescriptlang.org/docs/handbook/project-references.html
了解更多
答案 1 :(得分:0)
为两个目标构建的唯一方法(在可能的情况下使用增量)是对其他每个项目的cjs tsc -b
和非增量(似乎)执行增量。
当前正在工作:
"build": "tsc -b",
"build:esm": "lerna exec --stream --parallel -- ../../node_modules/.bin/tsc --outDir lib/esm --module esnext --target esnext",
这是原型仓库: