Skip to content

Commit

Permalink
apollo-server-express: Add direct dependency on express. (#3239)
Browse files Browse the repository at this point in the history
The [literal `import`-ing of `express` in `ApolloServer.ts`][1] isn't new
but, prior to #3047, it had only been a typing dependency — not an actual
runtime dependency — since the TypeScript compiler doesn't emit `require`s
when only types are utilized.

To see this first hand, see [the emitted `dist/ApolloServer.js` in
`[email protected]`][2] compared to [the same file in
`[email protected]`][3].  (Hard to decipher, but check
around like 15 and search for `"express"` in the second link.)

Now that we actually utilize `express.Router` to build the composition of
middleware in #3047 , it's true that `express` is no longer just a type
dependency, but does warrant being a regular dependency as well!

Since this has never been the case before during the entirety of the v2
line, I'm a bit concerned about introducing it now, but it seems other
integrations like `apollo-server-koa` already have similar requirements
going back to its introduction in [#1282][4]

https://github.com/apollographql/apollo-server/blob/92ea402a90bf9817c9b887707abbd77dcf5edcb4/packages/apollo-server-koa/package.json#L41

Furthermore, we already have similar direct dependencies on other packages
which we use directly, like [`cors`][5] and [`body-parser`][6]:

https://github.com/apollographql/apollo-server/blob/ff3af66a0f3c63bfb056feca82fc7e7b7592b4a5/packages/apollo-server-express/package.json

If this turns out to be problematic, we could consider declaring it only in
`peerDependencies`, but those come with their own [share of confusion][7].

[1]: https://github.com/apollographql/apollo-server/blob/6d9c3b8c97/packages/apollo-server-express/src/ApolloServer.ts#L1
[2]: https://unpkg.com/[email protected]/dist/ApolloServer.js
[3]: https://unpkg.com/[email protected]/dist/ApolloServer.js
[4]: #1282:
[5]: https://npm.im/cors
[6]: https://npm.im/body-parser
[7]: npm/rfcs#43
Fixes: #3238
  • Loading branch information
abernix authored Aug 31, 2019
1 parent 7950c42 commit 1084d17
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/apollo-server-express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"apollo-server-types": "file:../apollo-server-types",
"body-parser": "^1.18.3",
"cors": "^2.8.4",
"express": "^4.17.1",
"graphql-subscriptions": "^1.0.0",
"graphql-tools": "^4.0.0",
"parseurl": "^1.3.2",
Expand Down

0 comments on commit 1084d17

Please sign in to comment.