Skip to content

Commit

Permalink
Re-enable Typescript esModuleInterop
Browse files Browse the repository at this point in the history
`esModuleInterop` was enabled in
e4164c8
to help with importing from packages that use default exports.
Those changes were reverted in
#1210
to work around a few reported issues. Those issues are no longer
relevant, so this commit re-enables `esModuleInterop`, and
updates all default imports to use the more common (standard)
import syntax.
  • Loading branch information
hwillson committed Sep 20, 2018
1 parent 3b21ade commit d7f2962
Show file tree
Hide file tree
Showing 31 changed files with 104 additions and 59 deletions.
6 changes: 3 additions & 3 deletions docs/source/essentials/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ import express from 'express'
import { ApolloServer } from 'apollo-server-express'
import typeDefs from './graphql/schema'
import resolvers from './graphql/resolvers'
import * as fs from 'fs'
import * as https from 'https'
import * as http from 'http'
import fs from 'fs'
import https from 'https'
import http from 'http'

const configurations = {
// Note: You may need sudo to run on port 443
Expand Down
43 changes: 43 additions & 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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"jest": "23.6.0",
"jest-matcher-utils": "23.6.0",
"js-sha256": "0.9.0",
"koa": "^2.5.3",
"koa-multer": "1.0.2",
"lerna": "3.4.0",
"lint-staged": "7.2.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo-engine-reporting/src/agent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as os from 'os';
import os from 'os';
import { gzip } from 'zlib';
import { DocumentNode } from 'graphql';
import {
Expand All @@ -9,7 +9,7 @@ import {
} from 'apollo-engine-reporting-protobuf';

import { fetch, Response } from 'apollo-server-env';
import * as retry from 'async-retry';
import retry from 'async-retry';

import { EngineReportingExtension } from './extension';

Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-cache-memcached/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { KeyValueCache } from 'apollo-server-caching';
import * as Memcached from 'memcached';
import Memcached from 'memcached';
import { promisify } from 'util';

export class MemcachedCache implements KeyValueCache {
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo-server-cache-redis/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { KeyValueCache } from 'apollo-server-caching';
import * as Redis from 'redis';
import Redis from 'redis';
import { promisify } from 'util';
import * as DataLoader from 'dataloader';
import DataLoader from 'dataloader';

export class RedisCache implements KeyValueCache {
// FIXME: Replace any with proper promisified type
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-caching/src/InMemoryLRUCache.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as LRU from 'lru-cache';
import LRU from 'lru-cache';
import { KeyValueCache } from './KeyValueCache';

export class InMemoryLRUCache implements KeyValueCache {
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-core/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GraphQLSchema, DocumentNode } from 'graphql';
import { SchemaDirectiveVisitor, IResolvers, IMocks } from 'graphql-tools';
import { ConnectionContext } from 'subscriptions-transport-ws';
import * as WebSocket from 'ws';
import WebSocket from 'ws';
import { GraphQLExtension } from 'graphql-extensions';
export { GraphQLExtension } from 'graphql-extensions';

Expand Down
8 changes: 4 additions & 4 deletions packages/apollo-server-express/src/ApolloServer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as express from 'express';
import * as corsMiddleware from 'cors';
import express from 'express';
import corsMiddleware from 'cors';
import { json, OptionsJson } from 'body-parser';
import {
renderPlaygroundPage,
Expand All @@ -11,8 +11,8 @@ import {
ApolloServerBase,
formatApolloErrors,
} from 'apollo-server-core';
import * as accepts from 'accepts';
import * as typeis from 'type-is';
import accepts from 'accepts';
import typeis from 'type-is';

import { graphqlExpress } from './expressApollo';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as express from 'express';
import express from 'express';

import * as http from 'http';
import http from 'http';

import * as request from 'request';
import * as FormData from 'form-data';
import * as fs from 'fs';
import request from 'request';
import FormData from 'form-data';
import fs from 'fs';
import { createApolloFetch } from 'apollo-fetch';

import { gql, AuthenticationError, Config } from 'apollo-server-core';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as connect from 'connect';
import * as query from 'qs-middleware';
import connect from 'connect';
import query from 'qs-middleware';
import { ApolloServer } from '../ApolloServer';
import { Config } from 'apollo-server-core';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as express from 'express';
import express from 'express';

import * as http from 'http';
import http from 'http';

import { RESTDataSource } from 'apollo-datasource-rest';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as express from 'express';
import express from 'express';
import { ApolloServer } from '../ApolloServer';
import testSuite, {
schema as Schema,
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-express/src/expressApollo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as express from 'express';
import express from 'express';
import {
GraphQLOptions,
HttpQueryError,
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-hapi/src/ApolloServer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as hapi from 'hapi';
import hapi from 'hapi';
import { parseAll } from 'accept';
import {
renderPlaygroundPage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if (NODE_MAJOR_VERSION < 8) {
return;
}

import * as hapi from 'hapi';
import hapi from 'hapi';
import { ApolloServer } from '../ApolloServer';
import { Config } from 'apollo-server-core';

Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-hapi/src/hapiApollo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as Boom from 'boom';
import Boom from 'boom';
import { Server, Request, RouteOptions } from 'hapi';
import {
GraphQLOptions,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* tslint:disable:no-unused-expression */
import * as http from 'http';
import * as net from 'net';
import http from 'http';
import net from 'net';
import { sha256 } from 'js-sha256';
import express = require('express');
import bodyParser = require('body-parser');
Expand All @@ -19,7 +19,7 @@ import {

import { PubSub } from 'graphql-subscriptions';
import { SubscriptionClient } from 'subscriptions-transport-ws';
import * as WebSocket from 'ws';
import WebSocket from 'ws';

import { execute } from 'apollo-link';
import { createHttpLink } from 'apollo-link-http';
Expand Down
12 changes: 6 additions & 6 deletions packages/apollo-server-koa/src/ApolloServer.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as Koa from 'koa';
import * as corsMiddleware from '@koa/cors';
import * as bodyParser from 'koa-bodyparser';
import * as compose from 'koa-compose';
import Koa from 'koa';
import corsMiddleware from '@koa/cors';
import bodyParser from 'koa-bodyparser';
import compose from 'koa-compose';
import {
renderPlaygroundPage,
RenderPageOptions as PlaygroundRenderPageOptions,
} from '@apollographql/graphql-playground-html';
import { ApolloServerBase, formatApolloErrors } from 'apollo-server-core';
import * as accepts from 'accepts';
import * as typeis from 'type-is';
import accepts from 'accepts';
import typeis from 'type-is';

import { graphqlKoa } from './koaApollo';

Expand Down
10 changes: 5 additions & 5 deletions packages/apollo-server-koa/src/__tests__/ApolloServer.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as Koa from 'koa';
import Koa from 'koa';

import * as http from 'http';
import http from 'http';

import * as request from 'request';
import * as FormData from 'form-data';
import * as fs from 'fs';
import request from 'request';
import FormData from 'form-data';
import fs from 'fs';
import { createApolloFetch } from 'apollo-fetch';

import { gql, AuthenticationError, Config } from 'apollo-server-core';
Expand Down
6 changes: 3 additions & 3 deletions packages/apollo-server-koa/src/__tests__/datasource.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Koa from 'koa';
import * as KoaRouter from 'koa-router';
import Koa from 'koa';
import KoaRouter from 'koa-router';

import * as http from 'http';
import http from 'http';

import { RESTDataSource } from 'apollo-datasource-rest';

Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-koa/src/__tests__/koaApollo.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as Koa from 'koa';
import Koa from 'koa';
import { ApolloServer } from '../ApolloServer';
import testSuite, {
schema as Schema,
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-koa/src/koaApollo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as Koa from 'koa';
import Koa from 'koa';
import {
GraphQLOptions,
HttpQueryError,
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-lambda/src/ApolloServer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as lambda from 'aws-lambda';
import lambda from 'aws-lambda';
import { ApolloServerBase } from 'apollo-server-core';
import { GraphQLOptions, Config } from 'apollo-server-core';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import testSuite, {
CreateAppOptions,
} from 'apollo-server-integration-testsuite';
import { Config } from 'apollo-server-core';
import * as url from 'url';
import url from 'url';
import { IncomingMessage, ServerResponse } from 'http';

const createLambda = (options: CreateAppOptions = {}) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-lambda/src/lambdaApollo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as lambda from 'aws-lambda';
import lambda from 'aws-lambda';
import {
GraphQLOptions,
HttpQueryError,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import micro from 'micro';
import * as listen from 'test-listen';
import listen from 'test-listen';
import { createApolloFetch } from 'apollo-fetch';
import { gql } from 'apollo-server-core';
import * as FormData from 'form-data';
import * as fs from 'fs';
import * as rp from 'request-promise';
import FormData from 'form-data';
import fs from 'fs';
import rp from 'request-promise';

import { ApolloServer } from '../ApolloServer';

Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-micro/src/microApollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
convertNodeHttpToRequest,
} from 'apollo-server-core';
import { send, json, RequestHandler } from 'micro';
import * as url from 'url';
import url from 'url';
import { IncomingMessage, ServerResponse } from 'http';

import { MicroRequest } from './types';
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as request from 'request';
import request from 'request';
import { createApolloFetch } from 'apollo-fetch';

import { gql, ApolloServer } from '../index';
Expand Down
6 changes: 3 additions & 3 deletions packages/apollo-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// an express app for you instead of applyMiddleware (which you might not even
// use with express). The dependency is unused otherwise, so don't worry if
// you're not using express or your version doesn't quite match up.
import * as express from 'express';
import * as http from 'http';
import * as net from 'net';
import express from 'express';
import http from 'http';
import net from 'net';
import {
ApolloServer as ApolloServerBase,
CorsOptions,
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"target": "es2016",
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"sourceMap": true,
"declaration": true,
"declarationMap": true,
Expand Down

0 comments on commit d7f2962

Please sign in to comment.