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

Export wrap as es2015 instead of commonjs #4158

Merged
merged 8 commits into from
Jan 2, 2019
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/apollo-boost/rollup-bundle.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const globals = {
'fast-json-stable-stringify': 'stringify',
'graphql-tag': 'gql',
'apollo-utilities': 'apolloUtilities',
optimism: 'optimism',
};

export default {
Expand Down
3 changes: 1 addition & 2 deletions packages/apollo-cache-inmemory/package-lock.json

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

2 changes: 2 additions & 0 deletions packages/apollo-cache-inmemory/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import build, { globals } from '../../config/rollup.config';
const globalsOverride = {
...globals,
'graphql/language/printer': 'print',
optimism: 'optimism',
'graphql/language/visitor': 'visitor',
};

export default build('apollo.cache.inmemory', {
Expand Down
6 changes: 6 additions & 0 deletions packages/apollo-cache-inmemory/src/declarations.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare module 'optimism' {
export function wrap<T>(
originalFunction: T,
options?: OptimisticWrapOptions,
): OptimisticWrapperFunction<T>;
}
13 changes: 1 addition & 12 deletions packages/apollo-cache-inmemory/src/optimism.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
declare function require(id: string): any;

export type OptimisticWrapperFunction<
T = (...args: any[]) => any
> = T & {
Expand All @@ -14,16 +12,7 @@ export type OptimisticWrapOptions = {
makeCacheKey?(...args: any[]): any;
};

const {
wrap,
}: {
wrap<T>(
originalFunction: T,
options?: OptimisticWrapOptions,
): OptimisticWrapperFunction<T>;
} = require('optimism'); // tslint:disable-line

export { wrap };
export { wrap } from 'optimism';

export class CacheKeyNode<KeyType = object> {
private children: Map<any, CacheKeyNode<KeyType>> | null = null;
Expand Down