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

Reenable Rollup preserveModules option, and consolidate utils/utilities directories. #5437

Merged
merged 26 commits into from
Oct 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1273193
Re-enable rollup `preserveModules` to avoid ESM bundling
hwillson Oct 10, 2019
96a5266
Remove all module index.ts files
hwillson Oct 11, 2019
47da102
Stop exporting the cache functionality we don't want to expose
hwillson Oct 11, 2019
da2b56a
Move `subscribeAndCount` test only utility out of main package
hwillson Oct 11, 2019
ad25bbb
Move graphql specific utilities into `utilities/graphql`
hwillson Oct 11, 2019
9d4e731
Move common utilities into `utilities/common`
hwillson Oct 11, 2019
34c7f47
Stop exporting the `assign` utility (meant for internal use)
hwillson Oct 11, 2019
b297e37
Stop exporting the `canUseWeakMap` utility (meant for internal use)
hwillson Oct 11, 2019
96e9d25
Stop exporting the `cloneDeep` utility (meant for internal use)
hwillson Oct 11, 2019
5db7b40
Stop exporting `environment` utilities (meant for internal use)
hwillson Oct 11, 2019
41ef5dd
Stop exporting the `errorHandling` utilities (meant for internal use)
hwillson Oct 11, 2019
83e265c
Stop exporting the `isEqual` utility (meant for internal use)
hwillson Oct 11, 2019
836a38d
Stop exporting the `maybeDeepFreeze` utility (meant for internal use)
hwillson Oct 11, 2019
bf9161e
Stop exporting the `mergeDeep` utilities (meant for internal use)
hwillson Oct 11, 2019
0ce921b
Stop exporting the `stripSymbols` utility (meant for internal use)
hwillson Oct 11, 2019
db29456
Move test only `stripSymbols` utility out of the main bundle
hwillson Oct 11, 2019
0869922
Remove duplicate `stripSymbols` utility
hwillson Oct 11, 2019
133d16e
Move `arrays` utilities into `utilities/common`
hwillson Oct 11, 2019
e748a04
Move `capitalizeFirstLetter` into `utilities/common`
hwillson Oct 11, 2019
fa6bb8d
Move the `observableToPromise` utility out of the main bundle
hwillson Oct 11, 2019
96b5852
Move the test only `wrap` utilities out of the main bundle
hwillson Oct 11, 2019
fe8de17
Move observable utilities into `utilities/observables`
hwillson Oct 11, 2019
10ce705
Stop exporting all graphql utilities
hwillson Oct 11, 2019
6fb8fed
Changelog update
hwillson Oct 11, 2019
df162c4
Reduce bundlesize threshold
hwillson Oct 11, 2019
5ac4a65
Add `preserveModules` comment to `rollup.config.js`
hwillson Oct 11, 2019
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
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@
- `QueryManager#startQuery`
- `ObservableQuery#currentResult`

- `ApolloClient` is now only available as a named export. The default
`ApolloClient` export has been removed.
- `ApolloClient` is now only available as a named export. The default `ApolloClient` export has been removed. <br/>
[@hwillson](https://github.com/hwillson) in [#5425](https://github.com/apollographql/apollo-client/pull/5425)

- Utilities that were previously externally available through the `apollo-utilities` package, are now internal only. <br/>
[@hwillson](https://github.com/hwillson) in [#TODO](https://github.com/apollographql/apollo-client/pull/TODO)

## Apollo Client (2.6.4)

Expand Down
3 changes: 2 additions & 1 deletion config/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ module.exports = {
testURL: 'http://localhost',
testPathIgnorePatterns: [
'/node_modules/',
'/dist/'
'/dist/',
'src/__tests__/utils'
],
modulePathIgnorePatterns: ['/dist/'],
setupFiles: ['<rootDir>/src/config/jest/setup.ts'],
Expand Down
6 changes: 6 additions & 0 deletions config/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ function prepareESM() {
format: 'esm',
sourcemap: true,
},
// The purpose of this job is to ensure each `./dist` ESM file is run
// through the `invariantPlugin`, with any resulting changes added
// directly back into each ESM file. By setting `preserveModules`
// to `true`, we're making sure Rollup doesn't attempt to create a single
// combined ESM bundle with the final result of running this job.
preserveModules: true,
hwillson marked this conversation as resolved.
Show resolved Hide resolved
plugins: [
nodeResolve(),
invariantPlugin({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
{
"name": "apollo-client",
"path": "./dist/apollo-client.cjs.min.js",
"maxSize": "24 kB"
"maxSize": "22.75 kB"
hwillson marked this conversation as resolved.
Show resolved Hide resolved
}
],
"peerDependencies": {
Expand Down
17 changes: 8 additions & 9 deletions src/ApolloClient.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { ExecutionResult, DocumentNode } from 'graphql';
import { invariant, InvariantError } from 'ts-invariant';

import {
ApolloLink,
FetchResult,
GraphQLRequest,
execute,
} from './link/core';
import { ApolloCache, DataProxy } from './cache/core';
import { ApolloLink } from './link/core/ApolloLink';
import { FetchResult, GraphQLRequest } from './link/core/types';
import { execute } from './link/core/execute';
import { ApolloCache } from './cache/core/cache';
import { DataProxy } from './cache/core/types/DataProxy';
import { QueryManager } from './core/QueryManager';
import {
ApolloQueryResult,
Expand All @@ -16,7 +14,7 @@ import {
} from './core/types';
import { ObservableQuery } from './core/ObservableQuery';
import { LocalState, FragmentMatcher } from './core/LocalState';
import { Observable } from './util/Observable';
import { Observable } from './utilities/observables/Observable';
import {
QueryOptions,
WatchQueryOptions,
Expand All @@ -26,7 +24,8 @@ import {
} from './core/watchQueryOptions';
import { DataStore } from './data/store';
import { version } from './version';
import { UriFunction, HttpLink } from './link/http';
import { HttpLink } from './link/http/HttpLink';
import { UriFunction } from './link/http/selectHttpOptionsAndBody';

export interface DefaultOptions {
watchQuery?: Partial<WatchQueryOptions>;
Expand Down
6 changes: 3 additions & 3 deletions src/__mocks__/mockLinks.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { print } from 'graphql/language/printer';

import { Observable } from '../util/Observable';
import { Observable } from '../utilities/observables/Observable';
import { ApolloLink } from '../link/core/ApolloLink';
import {
Operation,
ApolloLink,
FetchResult,
GraphQLRequest,
} from '../link/core';
} from '../link/core/types';

interface MockApolloLink extends ApolloLink {
operation?: Operation;
Expand Down
2 changes: 1 addition & 1 deletion src/__mocks__/mockQueryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { QueryManager } from '../core/QueryManager';
import { mockSingleLink, MockedResponse } from './mockLinks';

import { DataStore } from '../data/store';
import { InMemoryCache } from '../cache/inmemory';
import { InMemoryCache } from '../cache/inmemory/inMemoryCache';

// Helper method for the tests that construct a query manager out of a
// a list of mocked responses for a mocked network interface.
Expand Down
13 changes: 7 additions & 6 deletions src/__tests__/ApolloClient.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import gql from 'graphql-tag';

import { Observable } from '../util/Observable';
import { ApolloLink } from '../link/core';
import { HttpLink } from '../link/http';
import { InMemoryCache, makeReference } from '../cache/inmemory';
import { stripSymbols } from '../utilities';
import { withWarning } from '../util/wrap';
import { Observable } from '../utilities/observables/Observable';
import { ApolloLink } from '../link/core/ApolloLink';
import { HttpLink } from '../link/http/HttpLink';
import { InMemoryCache } from '../cache/inmemory/inMemoryCache';
import { makeReference } from '../cache/inmemory/helpers';
import { stripSymbols } from './utils/stripSymbols';
import { withWarning } from './utils/wrap';
import { ApolloClient } from '../';
import { DefaultOptions } from '../ApolloClient';
import { FetchPolicy, QueryOptions } from '../core/watchQueryOptions';
Expand Down
13 changes: 7 additions & 6 deletions src/__tests__/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ import { cloneDeep, assign } from 'lodash';
import { GraphQLError, ExecutionResult, DocumentNode } from 'graphql';
import gql from 'graphql-tag';

import { Observable } from '../util/Observable';
import { ApolloLink } from '../link/core';
import { InMemoryCache, PossibleTypesMap } from '../cache/inmemory';
import { stripSymbols } from '../utilities';
import { Observable } from '../utilities/observables/Observable';
import { ApolloLink } from '../link/core/ApolloLink';
import { InMemoryCache } from '../cache/inmemory/inMemoryCache';
import { PossibleTypesMap } from '../cache/inmemory/types';
import { stripSymbols } from './utils/stripSymbols';
import { WatchQueryOptions, FetchPolicy } from '../core/watchQueryOptions';
import { ApolloError } from '../errors/ApolloError';
import { ApolloClient } from '..';
import subscribeAndCount from '../util/subscribeAndCount';
import { withWarning } from '../util/wrap';
import subscribeAndCount from './utils/subscribeAndCount';
import { withWarning } from './utils/wrap';
import { mockSingleLink } from '../__mocks__/mockLinks';

describe('client', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/fetchMore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { assign, cloneDeep } from 'lodash';
import gql from 'graphql-tag';

import { mockSingleLink } from '../__mocks__/mockLinks';
import { InMemoryCache } from '../cache/inmemory';
import { InMemoryCache } from '../cache/inmemory/inMemoryCache';
import { ApolloClient, NetworkStatus, ObservableQuery } from '../';

describe('updateQuery on a simple query', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/graphqlSubscriptions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import gql from 'graphql-tag';

import { mockObservableLink, MockedSubscription } from '../__mocks__/mockLinks';
import { InMemoryCache } from '../cache/inmemory';
import { InMemoryCache } from '../cache/inmemory/inMemoryCache';
import { ApolloClient } from '../';
import { QueryManager } from '../core/QueryManager';
import { DataStore } from '../data/store';
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/local-state/export.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import gql from 'graphql-tag';
import { print } from 'graphql/language/printer';

import { Observable } from '../../util/Observable';
import { ApolloLink } from '../../link/core';
import { Observable } from '../../utilities/observables/Observable';
import { ApolloLink } from '../../link/core/ApolloLink';
import { ApolloClient } from '../..';
import { InMemoryCache } from '../../cache/inmemory';
import { InMemoryCache } from '../../cache/inmemory/inMemoryCache';

describe('@client @export tests', () => {
it(
Expand Down
11 changes: 6 additions & 5 deletions src/__tests__/local-state/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import gql from 'graphql-tag';
import { DocumentNode, GraphQLError } from 'graphql';
import { introspectionQuery } from 'graphql/utilities';

import { Observable } from '../../util/Observable';
import { ApolloLink, Operation } from '../../link/core';
import { Observable } from '../../utilities/observables/Observable';
import { ApolloLink } from '../../link/core/ApolloLink';
import { Operation } from '../../link/core/types';
import { ApolloClient } from '../..';
import { ApolloCache } from '../../cache/core';
import { InMemoryCache } from '../../cache/inmemory';
import { hasDirectives } from '../../utilities';
import { ApolloCache } from '../../cache/core/cache';
import { InMemoryCache } from '../../cache/inmemory/inMemoryCache';
import { hasDirectives } from '../../utilities/graphql/directives';

describe('General functionality', () => {
it('should not impact normal non-@client use', () => {
Expand Down
9 changes: 4 additions & 5 deletions src/__tests__/local-state/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ import gql from 'graphql-tag';
import { DocumentNode, ExecutionResult } from 'graphql';
import { assign } from 'lodash';

import { Observable } from '../../util/Observable';
import { ApolloLink } from '../../link/core';
import { Observable, Observer } from '../../utilities/observables/Observable';
import { ApolloLink } from '../../link/core/ApolloLink';
import { ApolloClient } from '../..';
import mockQueryManager from '../../__mocks__/mockQueryManager';
import { Observer } from '../../util/Observable';
import wrap from '../../util/wrap';
import wrap from '../../__tests__/utils/wrap';
import { ApolloQueryResult, Resolvers } from '../../core/types';
import { WatchQueryOptions } from '../../core/watchQueryOptions';
import { LocalState } from '../../core/LocalState';
import { InMemoryCache } from '../../cache/inmemory';
import { InMemoryCache } from '../../cache/inmemory/inMemoryCache';

// Helper method that sets up a mockQueryManager and then passes on the
// results to an observer.
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/local-state/subscriptions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import gql from 'graphql-tag';

import { Observable } from '../../util/Observable';
import { ApolloLink } from '../../link/core';
import { Observable } from '../../utilities/observables/Observable';
import { ApolloLink } from '../../link/core/ApolloLink';
import { ApolloClient } from '../..';
import { InMemoryCache } from '../../cache/inmemory';
import { InMemoryCache } from '../../cache/inmemory/inMemoryCache';

describe('Basic functionality', () => {
it('should not break subscriptions', done => {
Expand Down
9 changes: 4 additions & 5 deletions src/__tests__/mutationResults.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { cloneDeep } from 'lodash';
import gql from 'graphql-tag';

import { Observable } from '../util/Observable';
import { ApolloLink } from '../link/core';
import { Observable, Subscription } from '../utilities/observables/Observable';
import { ApolloLink } from '../link/core/ApolloLink';
import { mockSingleLink } from '../__mocks__/mockLinks';
import { ApolloClient } from '..';
import { InMemoryCache } from '../cache/inmemory';
import { Subscription } from '../util/Observable';
import { withWarning } from '../util/wrap';
import { InMemoryCache } from '../cache/inmemory/inMemoryCache';
import { withWarning } from './utils/wrap';

describe('mutation results', () => {
const query = gql`
Expand Down
8 changes: 5 additions & 3 deletions src/__tests__/optimistic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import gql from 'graphql-tag';

import { mockSingleLink } from '../__mocks__/mockLinks';
import { MutationQueryReducersMap } from '../core/types';
import { Subscription } from '../util/Observable';
import { Subscription } from '../utilities/observables/Observable';
import { ApolloClient } from '../';
import { addTypenameToDocument, stripSymbols } from '../utilities';
import { InMemoryCache, makeReference } from '../cache/inmemory';
import { addTypenameToDocument } from '../utilities/graphql/transform';
import { stripSymbols } from './utils/stripSymbols';
import { InMemoryCache } from '../cache/inmemory/inMemoryCache';
import { makeReference } from '../cache/inmemory/helpers';

describe('optimistic mutation results', () => {
const query = gql`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { stripSymbols } from '../stripSymbols';
import { stripSymbols } from './utils/stripSymbols';

interface SymbolConstructor {
(description?: string | number): symbol;
Expand Down
7 changes: 4 additions & 3 deletions src/__tests__/subscribeToMore.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import gql from 'graphql-tag';
import { DocumentNode, OperationDefinitionNode } from 'graphql';

import { ApolloLink, Operation } from '../link/core';
import { ApolloLink } from '../link/core/ApolloLink';
import { Operation } from '../link/core/types';
import { mockSingleLink, mockObservableLink } from '../__mocks__/mockLinks';
import { ApolloClient } from '../';
import { InMemoryCache } from '../cache/inmemory';
import { stripSymbols } from '../utilities';
import { InMemoryCache } from '../cache/inmemory/inMemoryCache';
import { stripSymbols } from './utils/stripSymbols';

const isSub = (operation: Operation) =>
(operation.query as DocumentNode).definitions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ObservableQuery } from '../core/ObservableQuery';
import { ApolloQueryResult } from '../core/types';
import { Subscription } from '../util/Observable';
import { ObservableQuery } from '../../core/ObservableQuery';
import { ApolloQueryResult } from '../../core/types';
import { Subscription } from '../../utilities/observables/Observable';

/**
*
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ObservableQuery } from '../core/ObservableQuery';
import { ApolloQueryResult } from '../core/types';
import { Subscription } from '../util/Observable';
import { asyncMap } from './observables';
import { ObservableQuery } from '../../core/ObservableQuery';
import { ApolloQueryResult } from '../../core/types';
import { Subscription } from '../../utilities/observables/Observable';
import { asyncMap } from '../../utilities/observables/observables';

export default function subscribeAndCount(
done: jest.DoneCallback,
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions src/cache/core/cache.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { DocumentNode } from 'graphql';

import { getFragmentQueryDocument } from '../../utilities';
import { DataProxy, Cache } from './types';
import { getFragmentQueryDocument } from '../../utilities/graphql/fragments';
import { DataProxy } from './types/DataProxy';
import { Cache } from './types/Cache';
import { justTypenameQuery, queryFromPojo, fragmentFromPojo } from './utils';

export type Transaction<T> = (c: ApolloCache<T>) => void;
Expand Down
2 changes: 0 additions & 2 deletions src/cache/core/index.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/cache/core/types/index.ts

This file was deleted.

5 changes: 3 additions & 2 deletions src/cache/inmemory/__tests__/cache.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import gql, { disableFragmentWarnings } from 'graphql-tag';

import { stripSymbols, cloneDeep } from '../../../utilities';
import { InMemoryCache, InMemoryCacheConfig } from '..';
import { stripSymbols } from '../../../__tests__/utils/stripSymbols';
import { cloneDeep } from '../../../utilities/common/cloneDeep';
import { InMemoryCache, InMemoryCacheConfig } from '../inMemoryCache';
import { makeReference } from '../helpers';

disableFragmentWarnings();
Expand Down
4 changes: 2 additions & 2 deletions src/cache/inmemory/__tests__/readFromStore.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { assign, omit } from 'lodash';
import gql from 'graphql-tag';

import { stripSymbols } from '../../../utilities';
import { StoreObject } from '../';
import { stripSymbols } from '../../../__tests__/utils/stripSymbols';
import { StoreObject } from '../types';
import { StoreReader } from '../readFromStore';
import { defaultNormalizedCacheFactory } from '../entityCache';
import { withError } from './diffAgainstStore';
Expand Down
3 changes: 2 additions & 1 deletion src/cache/inmemory/__tests__/roundtrip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import gql from 'graphql-tag';
import { withError } from './diffAgainstStore';
import { withWarning } from './writeToStore';
import { EntityCache } from '../entityCache';
import { StoreReader, StoreWriter } from '../';
import { StoreReader } from '../readFromStore';
import { StoreWriter } from '../writeToStore';

function assertDeeplyFrozen(value: any, stack: any[] = []) {
if (value !== null && typeof value === 'object' && stack.indexOf(value) < 0) {
Expand Down
8 changes: 3 additions & 5 deletions src/cache/inmemory/__tests__/writeToStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import {
} from 'graphql';
import gql from 'graphql-tag';

import {
storeKeyNameFromField,
addTypenameToDocument,
cloneDeep,
} from '../../../utilities';
import { storeKeyNameFromField } from '../../../utilities/graphql/storeUtils';
import { addTypenameToDocument } from '../../../utilities/graphql/transform';
import { cloneDeep } from '../../../utilities/common/cloneDeep';
import { StoreWriter } from '../writeToStore';
import { defaultNormalizedCacheFactory } from '../entityCache';
import { makeReference } from '../helpers';
Expand Down
6 changes: 4 additions & 2 deletions src/cache/inmemory/inMemoryCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { DocumentNode } from 'graphql';
import { wrap } from 'optimism';
import { KeyTrie } from 'optimism';

import { Cache, ApolloCache, Transaction } from '../core';
import { addTypenameToDocument, canUseWeakMap } from '../../utilities';
import { ApolloCache, Transaction } from '../core/cache';
import { Cache } from '../core/types/Cache';
import { addTypenameToDocument } from '../../utilities/graphql/transform';
import { canUseWeakMap } from '../../utilities/common/canUse';
import {
ApolloReducerConfig,
NormalizedCacheObject,
Expand Down
Loading