-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Use TypeScript project references #1772
Conversation
We can't use `apollo-server-env` as a project reference because that requires `composite: true`, and that implies `declaration: true`, which doesn't work for `apollo-server-env` because we need to write our own declaration files for re-exported imports. This commit also removes `apollo-engine-reporting-protobuf` as a reference, which errored out because it doesn't actually contain any TypeScript code.
Codecov Report
@@ Coverage Diff @@
## master #1772 +/- ##
==========================================
- Coverage 74.2% 73.82% -0.39%
==========================================
Files 29 29
Lines 1167 1150 -17
Branches 288 296 +8
==========================================
- Hits 866 849 -17
+ Misses 291 290 -1
- Partials 10 11 +1
Continue to review full report at Codecov.
|
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.
This looks great to me. Particularly since the previous development process within this Apollo Server mono-repo had been increasingly painful — for example, when iterating on multiple packages at once and ensuring (or trying to ensure) the dependencies between overlapping changes had been re-built in the proper order.
This solves that pain and also gets rid of the overhead involved with running multiple TypeScript compilation instances! 🎉
@@ -0,0 +1,21 @@ | |||
{ | |||
"compilerOptions": { |
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.
I just want to point out that noEmitOnError
will be automatically enabled when project references are enabled. I was curious what would happen in a world of project references since, previously, files with typing errors would still be emitted to the dist
directory. These would often work until a more thorough compilation ultimately yielded a failing build. This was sometimes convenient but usually resulted in eventual disappointment right when you thought everything was work.
For this reason, I'd been tempted to turn on noEmitOnError
previously, but it seems that TypeScript has gone ahead and made that the default — understandably.
https://www.typescriptlang.org/docs/handbook/project-references.html#caveats
Similar spirit to: apollographql#1772 cc @martijnwalraven
The `apollo-server-cloud-functions` has been been mis-referenced (or referenced inconsistently) since its original inception in #1446 when its package directory was `apollo-server-cloud-function` (singular!) and the `package.json` referenced the plural form (`apollo-server-cloud-functions`): 724d9ff0#diff-e1d725fd66f7e9ef5251abf0437a09ca These references have been mostly fixed in the READMEs and supporting documentation, but the underlying monorepo directory structure has still not been fixed, which I'm sure contributed to this module being overlooked and unreferenced in the move to TypeScript project references in #1772. Additionally, the lack of referencing in the monorepo's TS config has resulted in it being broken in the most recent 2.2.0 release, as reported by @pyros2097 and @thetre97 in: #1896 (comment) This should fix that by properly adding the TypeScript project references.
…1948) * Add correct project references for `apollo-server-cloud-functions`. The `apollo-server-cloud-functions` has been been mis-referenced (or referenced inconsistently) since its original inception in #1446 when its package directory was `apollo-server-cloud-function` (singular!) and the `package.json` referenced the plural form (`apollo-server-cloud-functions`): 724d9ff0#diff-e1d725fd66f7e9ef5251abf0437a09ca These references have been mostly fixed in the READMEs and supporting documentation, but the underlying monorepo directory structure has still not been fixed, which I'm sure contributed to this module being overlooked and unreferenced in the move to TypeScript project references in #1772. Additionally, the lack of referencing in the monorepo's TS config has resulted in it being broken in the most recent 2.2.0 release, as reported by @pyros2097 and @thetre97 in: #1896 (comment) This should fix that by properly adding the TypeScript project references. * Sorting.
This PR updates this repo to use TypeScript project references, which enable incremental compilation and repo-wide file watching.
(The only exception is
apollo-server-env
, which isn't compatible with project references because it needsallowJs: true
anddeclaration: false
. So we compile it on installation as part ofprepare
, and it can be compiled manually when needed.)We'll have to figure out the best workflow here, but both initial compilation and watching seem to work. Tests are also passing (after an upgrade of
ts-jest
and some configuration changes). There seem to be some ordering issues however, so tests may run before compilation completes.