官术网_书友最值得收藏!

Build mode

The TypeScript 3 compiler includes the ability to perform smart incremental builds using the --build flag. Let's give this a try in our example multiple project solution:

  1. First, let's go to the root of the solution, open the terminal, and enter the following:
tsc --build ProjectA --verbose

The --verbose flag tells the compiler to tell us the details of what it's doing. The messages confirm to us that it has picked up the Shared project as well as ProjectA

Projects in this build: 
* Shared/tsconfig.json
* ProjectA/tsconfig.json

The compiler then checks each project to see if it's up to date. If the project is up to date, we get something like the following:

Project 'Shared/tsconfig.json' is up to date because newest input 'Shared/src/utils.ts' is older than oldest output 'Shared/dist/utils.js'
  1. Let's make a change in the utils.ts file in the Shared project by adding a space somewhere, removing it, and then saving the file.
  2. Let's build ProjectA again:
tsc --build ProjectA --verbose

As expected, we get a message to indicate that the Shared project is out of date and will be rebuilt:

Project 'Shared/tsconfig.json' is out of date because oldest
output 'Shared/dist/utils.js' is older than newest input 'Shared/src/utils.ts

Building project '.../Shared/tsconfig.json'
  1. If we want to force a rebuild, even if projects are up to date, we can use the --force flag. Let's give this a try:
tsc --build ProjectA --force --verbose

When we do this, the compiler will still check whether projects are up to date (and tell us), but then it goes on to build each project.

So, in addition to great multiple-project support, we can speed up solution builds using the --build flag. As the solution grows over time, this becomes increasingly valuable. If ever we want to force a rebuild of a project, we can use the --force flag along with --build.

主站蜘蛛池模板: 宜阳县| 即墨市| 城固县| 关岭| 津南区| 鄂托克前旗| 郁南县| 内江市| 乐都县| 应用必备| 阿克苏市| 西林县| 新巴尔虎左旗| 兰溪市| 阿尔山市| 游戏| 大邑县| 方城县| 涟水县| 香格里拉县| 古丈县| 哈巴河县| 谷城县| 和静县| 铁岭市| 铜鼓县| 楚雄市| 房山区| 美姑县| 保定市| 来凤县| 湄潭县| 当雄县| 阿瓦提县| 东阳市| 郧西县| 常熟市| 漳浦县| 花莲县| 杭锦旗| 奉节县|