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

lazy load unused lambda packages in core #2324

Merged
merged 4 commits into from
May 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
- core: Expose SHA-256 hex hash digest of the Engine API key to plugins, when available, as `engine.apiKeyHash`. [PR# 2685](https://github.com/apollographql/apollo-server/pull/2685)
- `apollo-datasource-rest`: If another `Content-type` is already set on the response, don't overwrite it with `application/json`, allowing the user's initial `Content-type` to prevail. [PR #2520](https://github.com/apollographql/apollo-server/issues/2035)
- `apollo-cache-control`: Do not respond with `Cache-control` headers if the HTTP response contains `errors`. [PR #2715](https://github.com/apollographql/apollo-server/pull/2715)
- `apollo-server-core`: Skip loading `util.promifisy` polyfill in Node.js engines >= 8.0 [PR #2278](https://github.com/apollographql/apollo-server/pull/2278)
- `apollo-server-core`: Lazy load `subscriptions-transport-ws` in core [PR #2278](https://github.com/apollographql/apollo-server/pull/2278)
- `apollo-server-cache-redis`: **BREAKING FOR USERS OF `apollo-server-cache-redis`** (This is a package that must be updated separately but shares the same `CHANGELOG.md` with Apollo Server itself.) A new **major** version of this package has been published and updated to support Redis Standalone, Cluster and Sentinel modes. This is a breaking change since it is now based on [`ioredis`](https://github.com/luin/ioredis) instead of [`node_redis`](https://github.com/NodeRedis/node_redis). Although this update is compatible with the most common uses of `apollo-server-cache-redis`, please check the [options supported by `ioredis`](https://github.com/luin/ioredis/blob/master/API.md#new-redisport-host-options) while updating to this version. The constructor options are passed directly from `RedisCache` to the new Redis adapter. The pre-1.0 versions should continue to work with Apollo Server without modification. [PR #1770](https://github.com/apollographql/apollo-server/pull/1770)

### v2.5.0
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-core/src/ApolloServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ export class ApolloServerBase {
);
}
}

const { SubscriptionServer } = require('subscriptions-transport-ws');
const {
onDisconnect,
onConnect,
Expand Down
6 changes: 5 additions & 1 deletion packages/apollo-server-env/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import './polyfills/Object.values';
import './polyfills/Object.entries';

require('util.promisify').shim();
import runtimeSupportsPromisify from './utils/runtimeSupportsPromisify';

if (!runtimeSupportsPromisify) {
require('util.promisify').shim();
}

export * from './polyfills/fetch';
export * from './polyfills/url';
24 changes: 24 additions & 0 deletions packages/apollo-server-env/src/utils/runtimeSupportsPromisify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const runtimeSupportsPromisify = (() => {
if (
process &&
process.release &&
process.release.name === 'node' &&
process.versions &&
typeof process.versions.node === 'string'
) {
const [nodeMajor] = process.versions.node
.split('.', 1)
.map(segment => parseInt(segment, 10));

if (nodeMajor >= 8) {
return true;
}
return false;
}

// If we haven't matched any of the above criteria, we'll remain unsupported
// for this mysterious environment until a pull-request proves us otherwise.
return false;
})();

export default runtimeSupportsPromisify;