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

Build: Composite TypeScript setup #39786

Merged
merged 2 commits into from
Mar 9, 2020
Merged

Conversation

sirreal
Copy link
Member

@sirreal sirreal commented Feb 29, 2020

Changes proposed in this Pull Request

  • Fix client typechecking
  • Update gutenboarding typechecking to extend client
  • Setup "monorepo" composite packages

Testing instructions

  • Verify the typecheck jobs are working well on CI.

Closes #39659

@matticbot
Copy link
Contributor

@matticbot
Copy link
Contributor

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

@sirreal sirreal marked this pull request as ready for review March 1, 2020 15:07
@sirreal sirreal requested review from a team as code owners March 1, 2020 15:07
@sirreal sirreal requested a review from a team March 1, 2020 15:07
@sirreal sirreal added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Mar 1, 2020
@sirreal sirreal requested a review from a team March 1, 2020 15:08
package.json Outdated
@@ -130,7 +130,7 @@
"test-server:coverage": "npm run -s test-server -- --coverage",
"test-server:watch": "npm run -s test-server -- --watch",
"translate": "i18n-calypso --format pot --output-file ./calypso-strings.pot -k translate,__,_x,_n,_nx -e date '**/*.js' '**/*.jsx' '**/*.ts' '**/*.tsx' '!build/**' '!packages/**/dist/**' '!public/**' '!**/test/**' '!node_modules/**' '!apps/full-site-editing/**' '!**/node_modules/**'",
"typecheck": "tsc --noEmit",
"typecheck": "NODE_OPTIONS='--max-old-space-size=4096' tsc --project client",
Copy link
Contributor

@ockham ockham Mar 1, 2020

Choose a reason for hiding this comment

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

This is used in the typecheck-strict check:

command: npm run typecheck -- --project client/landing/gutenboarding

which thus now reads, expanded:

> NODE_OPTIONS='--max-old-space-size=4096' tsc --project client "--project" "client/landing/gutenboarding"

So we probably need to add a dedicated script to package.json and use it in the CCI config, or solve the problem there.

package.json Show resolved Hide resolved
@@ -18,7 +18,7 @@ import MediaListStore from './list-store';
import MediaValidationStore from './validation-store';

/**
* @typedef MediaActions
* @typedef IMediaActions
Copy link
Contributor

Choose a reason for hiding this comment

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

Noice! this fixes the tsc error that was crashing tsc locally

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this could land on its own to fix the client. The tsc error message was completely unhelpful and I'd speculated the problem was related to the client reorganization which I intended to address with these fixes, but along the way I found this was the issue 🙂

I believe this is a typings regression introduced in #39057 / #39048

Copy link
Member Author

Choose a reason for hiding this comment

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

Pulled this into #39868

@roo2
Copy link
Contributor

roo2 commented Mar 2, 2020

The circleCI Typecheck task raises errors and says it exits with status 1 but the CircleCi job still passes. https://circleci.com/gh/Automattic/wp-calypso/621319?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link

Edit: Ahh ok I see that's the intended behavior.

@@ -243,7 +243,7 @@ jobs:
- prepare
- run:
name: TypeScript strict typecheck of individual subprojects
command: npm run typecheck -- --project client/landing/gutenboarding
command: npm run tsc -- --project client/landing/gutenboarding
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm are there other projects/directories that we should add here under typecheck-strict? it's currently just doing gutenboarding

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that was discussed when I originally added this section. My reasoning was that this enables us to gradually add other strictly-typechecked parts of Calypso -- I'm doing that e.g. in #39373 (which, granted, is just an experiment).

Copy link
Contributor

@ockham ockham left a comment

Choose a reason for hiding this comment

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

Not sure I understand all the nuance on this one, but it looks sane overall, and it's great to see the TypeScript check working again.

client/tsconfig.json Outdated Show resolved Hide resolved
@sirreal sirreal added [Status] Ready to Merge Build and removed [Status] In Progress [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Mar 2, 2020
save-tsc-cache: &save-tsc-cache
name: Save TypeScript cache
key: v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v0-tsc-{{ .Branch }}-{{ .Revision }}
key: v{{ .Environment.GLOBAL_CACHE_PREFIX }}-v1-tsc-{{ .Branch }}-{{ .Revision }}
paths:
- ~/.tsc-cache
Copy link
Member Author

Choose a reason for hiding this comment

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

Interesting one here… for composite and incremental builds, I believe TypeScript skips outputting anything if the caches are up to date. We can add packages/*/dist to the cache to catch and tsc-build output.

Suggested change
- ~/.tsc-cache
- ~/.tsc-cache
- packages/*/dist

@sirreal
Copy link
Member Author

sirreal commented Mar 4, 2020

Rebased

@sirreal sirreal force-pushed the update/composite-typescript-setup branch 2 times, most recently from 4a1aa8f to 8da8761 Compare March 4, 2020 09:34
@sirreal sirreal added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels Mar 4, 2020
@sirreal
Copy link
Member Author

sirreal commented Mar 4, 2020

I've rebase and cleaned this up. I'd love another round of reviews!

@sirreal sirreal added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Mar 4, 2020
Copy link
Member

@p-jackson p-jackson left a comment

Choose a reason for hiding this comment

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

The CI job is succeeding and the config changes make sense.

A thought about the tsBuildInfoFile names: we're probably not going to have name collisions for gutenboarding and composite-checkout-wpcom, but components and client seem more common.

Should our pattern for choosing tsBuildInfoFile be more path based? e.g. packages-components, client-landing-gutenboarding, etc.?

I thought we could use package name from package.json since that should probably be unique, but not every tsconfig.json has a package.json e.g. gutenboarding

@sirreal
Copy link
Member Author

sirreal commented Mar 6, 2020

A thought about the tsBuildInfoFile names: we're probably not going to have name collisions for gutenboarding and composite-checkout-wpcom, but components and client seem more common.

It's important to keep in mind that only projects that we're building here using the TypeScript compiler (tsc) will produce these files. We'll never be generating .tsbuildinfo or see them for external projects like packages from Gutenberg.

Should our pattern for choosing tsBuildInfoFile be more path based? e.g. packages-components, client-landing-gutenboarding, etc.?

That's a find idea although I believe we're unlikely to run into issues with collisions unless we blatantly reuse a name. I'll add this change.

@sirreal sirreal force-pushed the update/composite-typescript-setup branch from 89ff4ce to 77704d9 Compare March 6, 2020 10:42
@sirreal
Copy link
Member Author

sirreal commented Mar 6, 2020

Rebased and applied suggestions. With several approvals, I'll plan to move ahead with this soon unless there's any opposition.

@sirreal sirreal added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Mar 6, 2020
@sirreal sirreal merged commit 45d38e6 into master Mar 9, 2020
@sirreal sirreal deleted the update/composite-typescript-setup branch March 9, 2020 10:32
@matticbot matticbot removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Status] Ready to Merge labels Mar 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants