-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(build): enable incremental compilation #2928
Conversation
6a905ab
to
f53619d
Compare
Is it extracted from #1636 (I enabled incremental build there too)? |
.gitignore
Outdated
@@ -13,6 +13,7 @@ benchmark/dist | |||
.sandbox | |||
packages/cli/generators/datasource/connectors.json | |||
docs/site/readmes | |||
**/tsconfig.build.tsbuildinfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use dist/.tsbuildinfo
by configuring tsconfig compilerOptions with:
{
"tsBuildInfoFile": ".tsbuildinfo"
}
This way, no changes is needed in clean
script.
@@ -10,6 +10,8 @@ | |||
// FIXME(bajtos) LB4 is not compatible with this setting yet | |||
"strictPropertyInitialization": false, | |||
|
|||
"incremental": true, | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add "tsBuildInfoFile": ".tsbuildinfo",
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, "tsBuildInfoFile": ".tsbuildinfo"
setting in packages/build/config/tsconfig.common.json
will be resolved as packages/build/config/.tsbuildinfo
, which isn't what we want.
I think we will have to add tsBuildInfoFile
setting to every per-package package.json
file.
I'll take a look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, it's resolved against the outDir
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quoting from https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#configuration-inheritance-with-extends:
All relative paths found in the configuration file will be resolved relative to the configuration file they originated in.
See also microsoft/TypeScript#29172
Quoting also from microsoft/TypeScript#29813
- When tsconfig specifies compiler options
incremental
file with.tsbuildinfo
extension is emitted.- Composite projects indirectly specify
incremental
astrue
and its error to specifyincremental
asfalse
in the composite project- If project specifies
tsBuildInfoFile
options, it uses the path specified by that to write the build information.- If project specifies
out
oroutFile
option, theoutFileWithoutExtension.tsbuildinfo
file is written next to output js file.- If project specified
outDir
, config files base file name with extension as.tsbuildinfo
is written inoutDir
- Otherswise config files base file name with extension as
.tsbuildinfo
is written next to the config file
AFAICT, we are not setting outDir
in our tsconfig
files and configure it via a CLI option instead. This is a legacy from the days where we used to have multiple dist directories (dist8
for Node.js 8, dist10
for Node.js 10, etc.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If project specified
outDir
, config files base file name with extension as.tsbuildinfo
is written inoutDir
This rule does not seem to be triggered in our current build setup, even when I change all tsconfig.build.json
files to include "outDir": "dist"
:(
Not at all, I was not aware of that effort. In this pull request, I am unconditionally enabling incremental build for all mono-repo packages and all newly created projects. Existing projects created before my changes are not affected. |
Actually, that's not correct. Because the changes are made in shared |
f53619d
to
468af09
Compare
@raymondfeng I have updated the pull request, PTAL again.
The tests are failing because of a bug in |
468af09
to
adfb0a6
Compare
I think we should also modify list of files used by |
Maybe we should keep it simple - leave the defaults as is - |
adfb0a6
to
91b5aaa
Compare
Done. @raymondfeng LGTY now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed-off-by: Miroslav Bajtoš <[email protected]>
91b5aaa
to
5ee16ad
Compare
@raymondfeng should we modify |
Enable incremental compilation to speed up our builds. Note: this improvement will apply to projects consuming LoopBack too, once they upgrade to the latest version of
@loopback/build
.BEFORE
AFTER
The first build to populate tsbuildinfo file:
Subsequent builds (in my case, there were no code changes from the last build):
I am expecting the build times to improve even more when TypeScript 3.5 is released, see https://devblogs.microsoft.com/typescript/announcing-typescript-3-5-rc/
Checklist
👉 Read and sign the CLA (Contributor License Agreement) 👈
npm test
passes on your machinepackages/cli
were updatedexamples/*
were updated👉 Check out how to submit a PR 👈