Skip to content

Commit

Permalink
Build: Speed up tsc builds (#38903)
Browse files Browse the repository at this point in the history
* Use incremental tsc builds (cache)

* Save and restore tsc cache on circleci

* Fix up main `tsconfig`
  • Loading branch information
sirreal authored Feb 13, 2020
1 parent 5b61638 commit 666c470
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 17 deletions.
19 changes: 19 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ references:
"$CIRCLE_TEST_REPORTS/server" \
"$CIRCLE_TEST_REPORTS/e2ereports" \
"$HOME/jest-cache" \
"$HOME/.tsc-cache" \
"$HOME/terser-cache"
# Jest cache caching
Expand Down Expand Up @@ -59,6 +60,22 @@ references:
paths:
- ~/jest-cache

#
# TypeScript compiler (tsc) cache caching
#
restore-tsc-cache: &restore-tsc-cache
name: Restore TypeScript cache
keys:
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v0-tsc-{{ .Branch }}-{{ .Revision }}
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v0-tsc-{{ .Branch }}
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v0-tsc-master
- v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v0-tsc
save-tsc-cache: &save-tsc-cache
name: Save TypeScript cache
key: v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v0-tsc-{{ .Branch }}-{{ .Revision }}
paths:
- ~/.tsc-cache

#
# Terser cache caching
#
Expand Down Expand Up @@ -197,10 +214,12 @@ jobs:
- run: *update-git-master
- save_cache: *save-git-cache
# npm dependencies
- restore_cache: *restore-tsc-cache
- restore_cache: *restore-npm-cache
- run: *npm-install
- run: *npm-e2e-install
- save_cache: *save-npm-cache
- save_cache: *save-tsc-cache
- run: npm run build-packages
- persist_to_workspace:
root: '~'
Expand Down
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Dockerfile
/.tsc-cache
.dockerignore
.git
.npm-debug.log*
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*.code-workspace
*.iml
*.iws
/.tsc-cache/
/tags
node_modules
/npm-debug.log*
Expand Down
6 changes: 5 additions & 1 deletion client/landing/gutenboarding/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"baseUrl": ".",
"paths": {
"*": [ "*", "../../*" ]
}
},

"noEmit": true,
"incremental": true,
"tsBuildInfoFile": "../../../.tsc-cache/gutenboarding"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"clean:build": "npx rimraf build client/server/bundler/*.json client/server/devdocs/search-index.js",
"clean:packages": "npx lerna run clean --stream",
"clean:public": "npx rimraf public",
"distclean": "npm run clean && npx rimraf node_modules client/node_modules apps/*/node_modules packages/*/node_modules test/e2e/node_modules",
"distclean": "npm run clean && npx rimraf node_modules client/node_modules apps/*/node_modules packages/*/node_modules test/e2e/node_modules .tsc-cache",
"docker": "docker run -it --name wp-calypso --rm -p 80:3000 wp-calypso",
"docker-jetpack-cloud": "docker run -it --env CALYPSO_ENV=jetpack-cloud-production --name wp-calypso --rm -p 80:3000 wp-calypso",
"eslint-branch": "node bin/eslint-branch.js",
Expand Down
5 changes: 4 additions & 1 deletion packages/components/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
"forceConsistentCasingInFileNames": true,

"typeRoots": [ "../../node_modules/@types" ],
"types": []
"types": [],

"incremental": true,
"tsBuildInfoFile": "../../.tsc-cache/components"
},
"include": [ "src" ],
"exclude": [ "**/docs/*", "**/test/*" ]
Expand Down
4 changes: 3 additions & 1 deletion packages/composite-checkout-wpcom/tsconfig-cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"module": "commonjs",
"declaration": false,
"declarationDir": null,
"outDir": "./dist/cjs"
"outDir": "./dist/cjs",

"tsBuildInfoFile": "../../.tsc-cache/composite-checkout-wpcom-cjs"
}
}
5 changes: 4 additions & 1 deletion packages/composite-checkout-wpcom/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
"esModuleInterop": true,

"typeRoots": [ "../../node_modules/@types" ],
"types": []
"types": [],

"incremental": true,
"tsBuildInfoFile": "../../.tsc-cache/composite-checkout-wpcom"
},
"include": [ "src/**/*" ],
"exclude": [ "**/test/**/*", "**/docs/**/*" ]
Expand Down
4 changes: 3 additions & 1 deletion packages/data-stores/tsconfig-cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"module": "commonjs",
"declaration": false,
"declarationDir": null,
"outDir": "dist/cjs"
"outDir": "dist/cjs",

"tsBuildInfoFile": "../../.tsc-cache/data-stores-cjs"
}
}
5 changes: 4 additions & 1 deletion packages/data-stores/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
"types": [],

"noEmitHelpers": true,
"importHelpers": true
"importHelpers": true,

"incremental": true,
"tsBuildInfoFile": "../../.tsc-cache/data-stores"
},
"files": [ "./src/index.ts", "./global.d.ts" ],
"exclude": [ "**/docs/*", "**/test/*" ]
Expand Down
22 changes: 12 additions & 10 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,26 @@
"isolatedModules": true,

"paths": {
"*": [ "*", "client/*", "server/*" ]
"*": [ "*", "client/*" ]
},
"baseUrl": "."
"baseUrl": ".",
"incremental": true,
"tsBuildInfoFile": ".tsc-cache/client"
},
"include": [ "client", "server" ],
"include": [ "client" ],
"exclude": [
"**/build-module/*",
"**/build-style/*",
"**/build/*",
"**/dist/*",
"**/node_modules/*",
"**/build",
"**/build-module",
"**/build-style",
"**/dist",
"**/node_modules",
"apps",
"build",
"cached-results.json",
"client/server/bundler/assets*.json",
"client/server/devdocs/search-index.js",
"packages",
"public",
"server/bundler/assets*.json",
"server/devdocs/search-index.js",
"stats.json"
]
}

0 comments on commit 666c470

Please sign in to comment.