Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
fix rollup imports and sourcemap support(jest + rollup) (#489)
Browse files Browse the repository at this point in the history
* fix rollup imports

* add mapCoverage to jest for ts sourcemaps

* add sourcemap support for tsc to rollup

* apollo-link: allowSyntheticDefaultImports is true and zen-observable a default import not * as

* add esModuleInterop config to tsc to ensure * as imports are illegal
  • Loading branch information
James Baxley authored Feb 20, 2018
1 parent 7fcfa9c commit 98f9d15
Show file tree
Hide file tree
Showing 29 changed files with 45 additions and 26 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"lint-staged": "6.1.1",
"pre-commit": "1.2.2",
"prettier": "1.10.2",
"rollup-plugin-sourcemaps": "^0.4.2",
"ts-jest": "21.2.4",
"typescript": "2.7.2"
}
Expand Down
3 changes: 2 additions & 1 deletion packages/apollo-link-batch-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": ["ts", "tsx", "js", "json"],
"testPathIgnorePatterns": ["/node_modules/", "sharedHttpTests.ts"]
"testPathIgnorePatterns": ["/node_modules/", "sharedHttpTests.ts"],
"mapCoverage": true
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApolloLink, execute, Observable, makePromise } from 'apollo-link';
import { print } from 'graphql';
import * as fetchMock from 'fetch-mock';
import fetchMock from 'fetch-mock';
import gql from 'graphql-tag';

import { sharedHttpTest } from './sharedHttpTests';
Expand Down
3 changes: 2 additions & 1 deletion packages/apollo-link-batch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": ["ts", "tsx", "js", "json"]
"moduleFileExtensions": ["ts", "tsx", "js", "json"],
"mapCoverage": true
}
}
3 changes: 2 additions & 1 deletion packages/apollo-link-context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": ["ts", "tsx", "js", "json"]
"moduleFileExtensions": ["ts", "tsx", "js", "json"],
"mapCoverage": true
}
}
3 changes: 2 additions & 1 deletion packages/apollo-link-dedup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": ["ts", "tsx", "js", "json"]
"moduleFileExtensions": ["ts", "tsx", "js", "json"],
"mapCoverage": true
}
}
3 changes: 2 additions & 1 deletion packages/apollo-link-error/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": ["ts", "tsx", "js", "json"]
"moduleFileExtensions": ["ts", "tsx", "js", "json"],
"mapCoverage": true
}
}
3 changes: 2 additions & 1 deletion packages/apollo-link-http-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": ["ts", "tsx", "js", "json"]
"moduleFileExtensions": ["ts", "tsx", "js", "json"],
"mapCoverage": true
}
}
2 changes: 1 addition & 1 deletion packages/apollo-link-http-common/src/__tests__/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createOperation, Observable, ApolloLink, execute } from 'apollo-link';
import gql from 'graphql-tag';
import * as fetchMock from 'fetch-mock';
import fetchMock from 'fetch-mock';

import {
parseAndCheckHttpResponse,
Expand Down
1 change: 1 addition & 0 deletions packages/apollo-link-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": ["ts", "tsx", "js", "json"],
"mapCoverage": true,
"testPathIgnorePatterns": ["/node_modules/", "sharedHttpTests.ts"]
}
}
2 changes: 1 addition & 1 deletion packages/apollo-link-http/src/__tests__/httpLink.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Observable, ApolloLink, execute } from 'apollo-link';
import gql from 'graphql-tag';
import * as fetchMock from 'fetch-mock';
import fetchMock from 'fetch-mock';
import objectToQuery from 'object-to-querystring';

import { sharedHttpTest } from './sharedHttpTests';
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-link-http/src/__tests__/sharedHttpTests.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Observable, ApolloLink, execute } from 'apollo-link';
import { print } from 'graphql';
import gql from 'graphql-tag';
import * as fetchMock from 'fetch-mock';
import fetchMock from 'fetch-mock';

const sampleQuery = gql`
query SampleQuery {
Expand Down
3 changes: 2 additions & 1 deletion packages/apollo-link-polling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": ["ts", "tsx", "js", "json"]
"moduleFileExtensions": ["ts", "tsx", "js", "json"],
"mapCoverage": true
}
}
3 changes: 2 additions & 1 deletion packages/apollo-link-retry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": ["ts", "tsx", "js", "json"]
"moduleFileExtensions": ["ts", "tsx", "js", "json"],
"mapCoverage": true
}
}
3 changes: 2 additions & 1 deletion packages/apollo-link-schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": ["ts", "tsx", "js", "json"]
"moduleFileExtensions": ["ts", "tsx", "js", "json"],
"mapCoverage": true
}
}
3 changes: 2 additions & 1 deletion packages/apollo-link-ws/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": ["ts", "tsx", "js", "json"]
"moduleFileExtensions": ["ts", "tsx", "js", "json"],
"mapCoverage": true
}
}
1 change: 1 addition & 0 deletions packages/apollo-link/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### vNEXT
- Add `fromError` Observable helper
- change import method of zen-observable for rollup compat

### 1.1.0
- Expose `#execute` on ApolloLink as static
Expand Down
4 changes: 3 additions & 1 deletion packages/apollo-link/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"watch": "tsc -w -p . & rollup -c -w"
},
"dependencies": {
"@types/node": "^9.4.6",
"@types/zen-observable": "0.5.3",
"apollo-utilities": "^1.0.0",
"zen-observable": "^0.8.0"
Expand All @@ -67,6 +68,7 @@
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": ["ts", "tsx", "js", "json"]
"moduleFileExtensions": ["ts", "tsx", "js", "json"],
"mapCoverage": true
}
}
2 changes: 1 addition & 1 deletion packages/apollo-link/src/__tests__/link.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as Observable from 'zen-observable';
import Observable from 'zen-observable';
import gql from 'graphql-tag';
import { print } from 'graphql/language/printer';

Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-link/src/__tests__/linkUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
makePromise,
fromError,
} from '../linkUtils';
import * as Observable from 'zen-observable';
import Observable from 'zen-observable';

describe('Link utilities:', () => {
describe('validateOperation', () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/apollo-link/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ export {
} from './linkUtils';
export * from './types';

import * as Observable from 'zen-observable';

import Observable from 'zen-observable';
export { Observable };
2 changes: 1 addition & 1 deletion packages/apollo-link/src/link.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as Observable from 'zen-observable';
import Observable from 'zen-observable';

import {
GraphQLRequest,
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-link/src/linkUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getOperationName } from 'apollo-utilities';
import * as Observable from 'zen-observable';
import Observable from 'zen-observable';
import { print } from 'graphql/language/printer';

import { GraphQLRequest, Operation } from './types';
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-link/src/test-utils/mockLink.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Operation, RequestHandler, NextLink, FetchResult } from '../types';

import * as Observable from 'zen-observable';
import Observable from 'zen-observable';

import { ApolloLink } from '../link';

Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-link/src/test-utils/setContext.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Operation, NextLink, FetchResult } from '../types';

import * as Observable from 'zen-observable';
import Observable from 'zen-observable';

import { ApolloLink } from '../link';

Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-link/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as Observable from 'zen-observable';
import Observable from 'zen-observable';
import { ExecutionResult, DocumentNode } from 'graphql';

export interface GraphQLRequest {
Expand Down
3 changes: 2 additions & 1 deletion packages/apollo-link/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../../tsconfig",
"compilerOptions": {
"rootDir": "./src",
"outDir": "lib"
"outDir": "lib",
"allowSyntheticDefaultImports": true
},
"include": ["src/**/*.ts"],
"exclude": ["src/**/__tests__/*.ts"]
Expand Down
3 changes: 3 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sourcemaps from 'rollup-plugin-sourcemaps';

export const globals = {
// Apollo
'apollo-client': 'apollo.core',
Expand All @@ -24,6 +26,7 @@ export default name => ({
},
external: Object.keys(globals),
onwarn,
plugins: [sourcemaps()],
});

export function onwarn(message) {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"noImplicitAny": false,
"noUnusedParameters": false,
"noUnusedLocals": true,
"skipLibCheck": true
"skipLibCheck": true,
"esModuleInterop": true
}
}

0 comments on commit 98f9d15

Please sign in to comment.