Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Use TypeScript project references #962

Merged
merged 11 commits into from
Nov 15, 2019
Merged

Use TypeScript project references #962

merged 11 commits into from
Nov 15, 2019

Conversation

ismail-syed
Copy link
Contributor

@ismail-syed ismail-syed commented Sep 5, 2019

Description

Closes #857

This PR adds Typescript Project References to quilt. In doing so we aim to see faster CI builds and faster local rebuilds.

Faster CI builds

  • Previously ~19mins CI runs
  • Currently in this branch I'm getting ~14mins

Faster local rebuilds

Screen Shot 2019-11-13 at 1 05 37 PM

@ismail-syed ismail-syed force-pushed the ts-project-references branch 5 times, most recently from f906ee4 to 8429568 Compare September 11, 2019 05:34
@ismail-syed ismail-syed force-pushed the ts-project-references branch 13 times, most recently from 05fa209 to 8437ba2 Compare September 16, 2019 02:44
@ismail-syed ismail-syed changed the title [WIP] Migrate codebase to use TS project references & incremental builds Migrate codebase to use TS project references & incremental builds Sep 16, 2019
@ismail-syed ismail-syed changed the title Migrate codebase to use TS project references & incremental builds Use TypeScript project references with incremental builds Sep 16, 2019
@ismail-syed ismail-syed marked this pull request as ready for review September 16, 2019 14:17
Copy link
Contributor

@marutypes marutypes left a comment

Choose a reason for hiding this comment

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

A few questions and comments, mostly I want the extraneous files burned and the ts-ignores gone, but we should also at the least create tasks for making sure the new boilerplate doesn't get out of synch in the future.

{"path": "./semaphore"},
{"path": "./sewing-kit-koa"},
{"path": "./useful-types"},
{"path": "./with-env"}
Copy link
Contributor

Choose a reason for hiding this comment

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

It sucks that we have to manually maintain a list like this. It doesn't have to be part of this PR but at the least we should add a task to include adding an entry here in the new package generator, or at least have a separate script that gets run after like we do with adding to the main readme.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a test to cover for now.

"./src/**/*.tsx"
],
"exclude": ["**/*.test.ts", "**/*.test.tsx"],
"references": [{"path": "../react-html"}]
Copy link
Contributor

@marutypes marutypes Sep 16, 2019

Choose a reason for hiding this comment

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

We already have issues with remembering to add dependencies to package.json when they are local packages. We are going to want to have some way of statically enforcing that dependencies are tracked in the tsconfig properly, whether through a linter, a custom script, a repo-level test, or whatever.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The compiler does an ok-ish good job at checking this. If a project is missing an explicit reference here then the build fails. That said, I've seen cases of it passing without an explicit reference. I'll open up an issue.

script.js Outdated Show resolved Hide resolved
packages/react-async/src/Prefetcher.tsx Outdated Show resolved Hide resolved
packages/react-self-serializers/src/I18n.tsx Outdated Show resolved Hide resolved
@@ -7,7 +7,7 @@ export class MockLink extends ApolloLink {
super();
}

request(operation: Operation) {
request(operation: Operation): Observable<any> {
Copy link
Contributor

Choose a reason for hiding this comment

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

is any right here?

Copy link
Contributor Author

@ismail-syed ismail-syed Nov 14, 2019

Choose a reason for hiding this comment

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

I spent a bit of time trying to address these. The changes were significant in some cases. I'd prefer having those changes in a subsequent PR if that's ok with you. I can open up an issue for now

packages/react-import-remote/src/hooks.ts Outdated Show resolved Hide resolved
package.json Outdated
"test": "NODE_ICU_DATA=node_modules/full-icu jest --maxWorkers=3 --coverage=false",
"check": "lerna run check",
"release": "lerna publish",
"clean": "rimraf './packages/*/dist/**/*.{js,d.ts}'",
"clean": "rimraf './packages/*/dist/**/*.{js,d.ts}' './packages/*/*.tsbuildinfo' './packages/*.tsbuildinfo'",
Copy link
Member

Choose a reason for hiding this comment

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

I know dist/src is annoying, but it's unavoidable for most projects. So I'd prefer standardising on that, even for projects that currently use dist.

Copy link
Member

Choose a reason for hiding this comment

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

More importantly, how are you planning to have tsbuildinfo files cached in CI? I'm still at the top of the PR, so I may be missing the magic that makes it happen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I'd prefer standardising on that, even for projects that currently use dist

I've updated all the monorepo tsconfigs to reflect this as sewing-kit does. ('.' as the baseUrl and rootDir). Also changed the number of imports from ./dist/foo to ./dist/src/foo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how are you planning to have tsbuildinfo files cached in CI?

I tried getting Travis to only cache the tsbuildinfo files, but I couldn't find any docs or working examples of caching files. Only directories. How does sewing-kit cache tsbuildinfo files?

In Travis, what if we move all the tsbuildinfos to a tmp_build_cache directory of some sort after a build and dump them back into their respective packages/* paths before a subsequent build starts.

@@ -0,0 +1,15 @@
{
"extends": "../tsconfig_base.json",
"compileOnSave": false,
Copy link
Member

Choose a reason for hiding this comment

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

compileOnSave should be in the base config, and deleted from all others.

"rootDir": "./src"
},
"include": [
"../../config/typescript/**/*",
Copy link
Member

Choose a reason for hiding this comment

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

What is this pulling in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't seem like anything. I wrote a script that converted all tsconfig.build.json => tsconfig.json and updated the extended field. Looking at the history of this file this must have been included from the generators.

"include": [
"../../config/typescript/**/*",
"./src/**/*.ts",
"./src/**/*.tsx"
Copy link
Member

Choose a reason for hiding this comment

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

Why does this need to process tsx files?

"./src/**/*.ts",
"./src/**/*.tsx"
],
"exclude": ["**/*.test.ts", "**/*.test.tsx"]
Copy link
Member

Choose a reason for hiding this comment

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

There are no test files, so 🔥

"rootDir": "./src"
},
"include": [
"../../config/typescript/**/*",
Copy link
Member

Choose a reason for hiding this comment

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

Same question about pulling in config and tsx files as above.

},
"include": ["./**/*.ts", "./**/*.tsx"],
"exclude": ["./node_modules"]
"include": ["../config/typescript/**/*.d.ts"]
Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense to have an include here? I thought all projects should specify their own includes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should be removed

@ismail-syed
Copy link
Contributor Author

Thanks for all the feedback folks. I'll get back around to addressing these comments sometime this week. Metrics tracking works is higher on my list of but I'll be been pushing this in-between cycles.

@ismail-syed ismail-syed force-pushed the ts-project-references branch from d1c8ac9 to 5ec4a47 Compare November 15, 2019 18:46
@ismail-syed ismail-syed changed the title Use TypeScript project references with incremental builds Use TypeScript project references Nov 15, 2019
@ismail-syed ismail-syed merged commit d3720fd into master Nov 15, 2019
@ismail-syed ismail-syed requested a deployment to production November 15, 2019 20:46 Abandoned
@michenly michenly requested a deployment to michenly-beta November 15, 2019 20:53 Abandoned
@michenly michenly requested a deployment to michenly-beta November 15, 2019 21:19 Abandoned
@michenly michenly requested a deployment to michenly-beta November 15, 2019 21:31 Abandoned
@michenly michenly requested a deployment to michenly-beta November 15, 2019 21:47 Abandoned
@michenly michenly requested a deployment to michenly-beta November 15, 2019 22:24 Abandoned
@ismail-syed ismail-syed requested a deployment to backfill November 15, 2019 22:35 Abandoned
@michenly michenly temporarily deployed to production November 21, 2019 17:49 Inactive
@michenly michenly temporarily deployed to michenly-beta November 21, 2019 17:54 Inactive
@theodoretan theodoretan temporarily deployed to gem December 10, 2019 21:19 Inactive
@BPScott BPScott deleted the ts-project-references branch May 22, 2021 00:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use --incremental flag and tsBuildInfo to speed up Quilt CI
5 participants