Skip to content
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

Merged
merged 1 commit into from
Jun 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ packages/tsdocs/fixtures/monorepo/docs
/docs/site/readmes
/docs/apidocs/reports-temp
/docs/apidocs/models
*.tsbuildinfo
bajtos marked this conversation as resolved.
Show resolved Hide resolved

# TBD: Exclude api reports from git for now
/docs/apidocs/reports
Expand Down
2 changes: 2 additions & 0 deletions packages/build/config/tsconfig.common.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
// FIXME(bajtos) LB4 is not compatible with this setting yet
"strictPropertyInitialization": false,

"incremental": true,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add "tsBuildInfoFile": ".tsbuildinfo",.

Copy link
Member Author

@bajtos bajtos May 21, 2019

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.

Copy link
Contributor

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.

Copy link
Member Author

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 as true and its error to specify incremental as false 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 or outFile option, the outFileWithoutExtension.tsbuildinfo file is written next to output js file.
  • If project specified outDir, config files base file name with extension as .tsbuildinfo is written in outDir
  • 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.)

Copy link
Member Author

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 in outDir

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" :(

"lib": ["es2018", "esnext.asynciterable"],
"module": "commonjs",
"moduleResolution": "node",
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/generators/project/templates/_.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@ api-docs/

# Transpiled JavaScript files from Typescript
/dist

# Cache used by TypeScript's incremental build
*.tsbuildinfo
2 changes: 2 additions & 0 deletions packages/cli/generators/project/templates/tsconfig.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"resolveJsonModule": true,
"skipLibCheck": true,

"incremental": true,

"lib": ["es2018", "esnext.asynciterable"],
"module": "commonjs",
"moduleResolution": "node",
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/test/integration/generators/app.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ describe('app-generator specific files', () => {
const pkg = JSON.parse(await readFile('package.json'));
expect(pkg.scripts).to.have.property('migrate', 'node ./dist/migrate');
});

it('creates .gitignore', () => {
assert.fileContent('.gitignore', /^\*\.tsbuildinfo$/m);
});
});

describe('app-generator with docker disabled', () => {
Expand Down