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

Use TypeScript project references #1772

Merged
merged 7 commits into from
Oct 8, 2018
Merged

Conversation

martijnwalraven
Copy link
Contributor

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 needs allowJs: true and declaration: false. So we compile it on installation as part of prepare, 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.

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-io
Copy link

codecov-io commented Oct 5, 2018

Codecov Report

Merging #1772 into master will decrease coverage by 0.38%.
The diff coverage is 0%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
packages/apollo-server-core/src/runHttpQuery.ts 30.2% <0%> (ø) ⬆️
packages/apollo-server/src/exports.ts 100% <0%> (ø) ⬆️
packages/apollo-datasource-rest/src/HTTPCache.ts 97.87% <0%> (ø) ⬆️
packages/apollo-server-koa/src/index.ts 100% <0%> (ø) ⬆️
packages/apollo-server-express/src/index.ts 100% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0ebf890...6654c0d. Read the comment docs.

Copy link
Member

@abernix abernix left a 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": {
Copy link
Member

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

@abernix abernix merged commit 65088d0 into master Oct 8, 2018
@abernix abernix deleted the typescript-project-references branch October 8, 2018 09:36
skevy pushed a commit to skevy/apollo-server that referenced this pull request Oct 24, 2018
abernix added a commit that referenced this pull request Nov 12, 2018
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.
abernix added a commit that referenced this pull request Nov 12, 2018
…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.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 22, 2023
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.

3 participants