我有一个monorepo,其中我将一个子项目转换为TypeScript。在我的npm脚本中,我有:
"build-proj1":"tsc --build ./proj1/tsconfig.json"
它起作用了,但出于某种原因,我注意到它非常慢。
当我把它改为:
"build-proj1":"tsc --project ./proj1/tsconfig.json"
它执行得更快并且产生同样的结果..。
我的tsconfig.json
供参考:
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"module": "CommonJS",
"target": "es2018",
"lib": ["es2019"],
"noImplicitAny": false,
"declaration": false,
"allowJs": true,
"preserveConstEnums": true,
"outDir": "./dist",
"sourceMap": true,
"skipLibCheck": true,
"baseUrl": "./",
"types": ["node"],
"typeRoots": ["../node_modules/@types"],
"strict": true,
"esModuleInterop": true,
"disableReferencedProjectLoad": true,
"paths": {
"root-common/*": ["../common/*"],
"root-config/*": ["../config/*"],
"root/*": ["../*"]
}
},
"include": ["./**/*"],
"exclude": ["node_modules", "**/*.spec.ts", "**/*.test.*", "./dist/**/*", "../common/**/*test.*"]
}
我的问题是--build
和--project
之间有什么区别,以及为什么--build
的运行速度会比--project
慢得多
发布于 2022-07-26 16:10:03
根据tsc --help
--project, -p Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'.
--build, -b Build one or more projects and their dependencies, if out of date
--project
选项编译一个项目。
--build
选项可以看作是一个构建协调器,它查找引用的项目,检查它们是否是最新的,并按照正确的顺序构建过时的项目。有关细节,请参阅文档。
要回答第二个问题,--build
选项要慢一些,因为它也编译依赖项,但在第二次运行时应该更快,因为它只编译过时的项目。
https://stackoverflow.com/questions/67796765
复制相似问题