From 30aff5e3ee6423e90387a59a50a5dd86b21ff0e0 Mon Sep 17 00:00:00 2001 From: Dirk-Jan Rutten Date: Sat, 10 Mar 2018 11:12:19 +0100 Subject: [PATCH 1/5] Improved the types of apollo-client --- .../apollo-client/src/core/ObservableQuery.ts | 94 +++++++++---------- packages/apollo-client/src/core/types.ts | 2 + .../src/core/watchQueryOptions.ts | 9 +- 3 files changed, 53 insertions(+), 52 deletions(-) diff --git a/packages/apollo-client/src/core/ObservableQuery.ts b/packages/apollo-client/src/core/ObservableQuery.ts index 0e2fe15dc6e..1dde9daae85 100644 --- a/packages/apollo-client/src/core/ObservableQuery.ts +++ b/packages/apollo-client/src/core/ObservableQuery.ts @@ -12,7 +12,7 @@ import { QueryScheduler } from '../scheduler/scheduler'; import { ApolloError } from '../errors/ApolloError'; import { QueryManager } from './QueryManager'; -import { ApolloQueryResult, FetchType } from './types'; +import { ApolloQueryResult, FetchType, OperationVariables } from './types'; import { ModifiableWatchQueryOptions, WatchQueryOptions, @@ -57,26 +57,29 @@ export const hasError = ( policy === 'none') || storeValue.networkError); -export class ObservableQuery extends Observable> { - public options: WatchQueryOptions; +export class ObservableQuery< + TData = any, + TVariables = OperationVariables +> extends Observable> { + public options: WatchQueryOptions; public queryId: string; /** * * The current value of the variables for this query. Can change. */ - public variables: { [key: string]: any }; + public variables: TVariables; private isCurrentlyPolling: boolean; private shouldSubscribe: boolean; private isTornDown: boolean; private scheduler: QueryScheduler; private queryManager: QueryManager; - private observers: Observer>[]; + private observers: Observer>[]; private subscriptionHandles: Subscription[]; - private lastResult: ApolloQueryResult; + private lastResult: ApolloQueryResult; private lastError: ApolloError; - private lastVariables: { [key: string]: any }; + private lastVariables: TVariables; constructor({ scheduler, @@ -84,10 +87,10 @@ export class ObservableQuery extends Observable> { shouldSubscribe = true, }: { scheduler: QueryScheduler; - options: WatchQueryOptions; + options: WatchQueryOptions; shouldSubscribe?: boolean; }) { - super((observer: Observer>) => + super((observer: Observer>) => this.onSubscribe(observer), ); @@ -97,7 +100,7 @@ export class ObservableQuery extends Observable> { // query information this.options = options; - this.variables = options.variables || {}; + this.variables = options.variables || ({} as TVariables); this.queryId = scheduler.queryManager.generateQueryId(); this.shouldSubscribe = shouldSubscribe; @@ -110,11 +113,11 @@ export class ObservableQuery extends Observable> { this.subscriptionHandles = []; } - public result(): Promise> { + public result(): Promise> { const that = this; return new Promise((resolve, reject) => { let subscription: Subscription; - const observer: Observer> = { + const observer: Observer> = { next(result) { resolve(result); @@ -150,7 +153,7 @@ export class ObservableQuery extends Observable> { * `partial` lets you know if the result from the local cache is complete or partial * @return {result: Object, loading: boolean, networkStatus: number, partial: boolean} */ - public currentResult(): ApolloCurrentResult { + public currentResult(): ApolloCurrentResult { if (this.isTornDown) { return { data: this.lastError ? {} : this.lastResult ? this.lastResult.data : {}, @@ -203,7 +206,7 @@ export class ObservableQuery extends Observable> { data, loading: isNetworkRequestInFlight(networkStatus), networkStatus, - } as ApolloQueryResult; + } as ApolloQueryResult; if ( queryStoreValue && @@ -218,12 +221,12 @@ export class ObservableQuery extends Observable> { this.lastResult = { ...result, stale }; } - return { ...result, partial } as ApolloCurrentResult; + return { ...result, partial } as ApolloCurrentResult; } // Returns the last result that observer.next was called with. This is not the same as // currentResult! If you're not sure which you need, then you probably need currentResult. - public getLastResult(): ApolloQueryResult { + public getLastResult(): ApolloQueryResult { return this.lastResult; } @@ -237,7 +240,7 @@ export class ObservableQuery extends Observable> { this.isTornDown = false; } - public refetch(variables?: any): Promise> { + public refetch(variables?: TVariables): Promise> { // early return if trying to read from cache during refetch if (this.options.fetchPolicy === 'cache-only') { return Promise.reject( @@ -249,18 +252,16 @@ export class ObservableQuery extends Observable> { if (!isEqual(this.variables, variables)) { // update observable variables - this.variables = { - ...this.variables, - ...variables, - }; + this.variables = Object.assign({}, this.variables, variables); } if (!isEqual(this.options.variables, this.variables)) { // Update the existing options with new variables - this.options.variables = { - ...this.options.variables, - ...this.variables, - }; + this.options.variables = Object.assign( + {}, + this.options.variables, + this.variables, + ); } // Override fetchPolicy for this call only @@ -276,7 +277,7 @@ export class ObservableQuery extends Observable> { public fetchMore( fetchMoreOptions: FetchMoreQueryOptions & FetchMoreOptions, - ): Promise> { + ): Promise> { // early return if no update Query if (!fetchMoreOptions.updateQuery) { throw new Error( @@ -297,10 +298,11 @@ export class ObservableQuery extends Observable> { combinedOptions = { ...this.options, ...fetchMoreOptions, - variables: { - ...this.variables, - ...fetchMoreOptions.variables, - }, + variables: Object.assign( + {}, + this.variables, + fetchMoreOptions.variables, + ), }; } @@ -322,7 +324,7 @@ export class ObservableQuery extends Observable> { }), ); - return fetchMoreResult as ApolloQueryResult; + return fetchMoreResult as ApolloQueryResult; }); } @@ -370,12 +372,11 @@ export class ObservableQuery extends Observable> { // will return null immediately. public setOptions( opts: ModifiableWatchQueryOptions, - ): Promise> { + ): Promise> { const oldOptions = this.options; - this.options = { - ...this.options, - ...opts, - } as WatchQueryOptions; + this.options = Object.assign({}, this.options, opts) as WatchQueryOptions< + TVariables + >; if (opts.pollInterval) { this.startPolling(opts.pollInterval); @@ -421,17 +422,14 @@ export class ObservableQuery extends Observable> { * */ public setVariables( - variables: any, + variables?: TVariables, tryFetch: boolean = false, fetchResults = true, - ): Promise> { + ): Promise> { // since setVariables restarts the subscription, we reset the tornDown status this.isTornDown = false; - const newVariables = { - ...this.variables, - ...variables, - }; + const newVariables = Object.assign({}, this.variables, variables); if (isEqual(newVariables, this.variables) && !tryFetch) { // If we have no observers, then we don't actually want to make a network @@ -511,7 +509,7 @@ export class ObservableQuery extends Observable> { this.scheduler.startPollingQuery(this.options, this.queryId); } - private onSubscribe(observer: Observer>) { + private onSubscribe(observer: Observer>) { // Zen Observable has its own error function, in order to log correctly // we need to declare a custom error if nothing is passed if ( @@ -546,7 +544,7 @@ export class ObservableQuery extends Observable> { private setUpQuery() { if (this.shouldSubscribe) { - this.queryManager.addObservableQuery(this.queryId, this); + this.queryManager.addObservableQuery(this.queryId, this); } if (!!this.options.pollInterval) { @@ -560,11 +558,11 @@ export class ObservableQuery extends Observable> { } this.isCurrentlyPolling = true; - this.scheduler.startPollingQuery(this.options, this.queryId); + this.scheduler.startPollingQuery(this.options, this.queryId); } - const observer: Observer> = { - next: (result: ApolloQueryResult) => { + const observer: Observer> = { + next: (result: ApolloQueryResult) => { this.lastResult = result; this.observers.forEach(obs => obs.next && obs.next(result)); }, @@ -574,7 +572,7 @@ export class ObservableQuery extends Observable> { }, }; - this.queryManager.startQuery( + this.queryManager.startQuery( this.queryId, this.options, this.queryManager.queryListenerForObserver( diff --git a/packages/apollo-client/src/core/types.ts b/packages/apollo-client/src/core/types.ts index 596708bd4c1..2d44d8b5a5f 100644 --- a/packages/apollo-client/src/core/types.ts +++ b/packages/apollo-client/src/core/types.ts @@ -8,6 +8,8 @@ export type QueryListener = ( newData?: any, ) => void; +export type OperationVariables = { [key: string]: any }; + export type PureQueryOptions = { query: DocumentNode; variables?: { [key: string]: any }; diff --git a/packages/apollo-client/src/core/watchQueryOptions.ts b/packages/apollo-client/src/core/watchQueryOptions.ts index 7600b75083e..7678fb0f356 100644 --- a/packages/apollo-client/src/core/watchQueryOptions.ts +++ b/packages/apollo-client/src/core/watchQueryOptions.ts @@ -4,7 +4,7 @@ import { DataProxy } from 'apollo-cache'; import { MutationQueryReducersMap } from './types'; -import { PureQueryOptions } from './types'; +import { PureQueryOptions, OperationVariables } from './types'; /** * fetchPolicy determines where the client may return a result from. The options are: @@ -36,12 +36,12 @@ export type ErrorPolicy = 'none' | 'ignore' | 'all'; /** * We can change these options to an ObservableQuery */ -export interface ModifiableWatchQueryOptions { +export interface ModifiableWatchQueryOptions { /** * A map going from variable name to variable value, where the variables are used * within the GraphQL query. */ - variables?: { [key: string]: any }; + variables?: TVariables; /** * The time interval (in milliseconds) on which this query should be @@ -73,7 +73,8 @@ export interface ModifiableWatchQueryOptions { /** * The argument to a query */ -export interface WatchQueryOptions extends ModifiableWatchQueryOptions { +export interface WatchQueryOptions + extends ModifiableWatchQueryOptions { /** * A GraphQL document that consists of a single query to be sent down to the * server. From c4121407ff0fb125e4e7b8f5d47f6a195eabe8ae Mon Sep 17 00:00:00 2001 From: Dirk-Jan Rutten Date: Sat, 10 Mar 2018 19:23:02 +0100 Subject: [PATCH 2/5] Improved the type definitions of the public functions. --- .../apollo-client/src/core/ObservableQuery.ts | 57 +++++++++++-------- .../src/core/watchQueryOptions.ts | 23 ++++---- 2 files changed, 47 insertions(+), 33 deletions(-) diff --git a/packages/apollo-client/src/core/ObservableQuery.ts b/packages/apollo-client/src/core/ObservableQuery.ts index 1dde9daae85..4c801f84634 100644 --- a/packages/apollo-client/src/core/ObservableQuery.ts +++ b/packages/apollo-client/src/core/ObservableQuery.ts @@ -33,18 +33,21 @@ export type ApolloCurrentResult = { partial?: boolean; }; -export interface FetchMoreOptions { +export interface FetchMoreOptions< + TData = any, + TVariables = OperationVariables +> { updateQuery: ( - previousQueryResult: { [key: string]: any }, + previousQueryResult: TData, options: { - fetchMoreResult?: { [key: string]: any }; - variables: { [key: string]: any }; + fetchMoreResult?: TData; + variables?: TVariables; }, - ) => Object; + ) => TData; } -export interface UpdateQueryOptions { - variables?: Object; +export interface UpdateQueryOptions { + variables?: TVariables; } export const hasError = ( @@ -275,8 +278,9 @@ export class ObservableQuery< .then(result => maybeDeepFreeze(result)); } - public fetchMore( - fetchMoreOptions: FetchMoreQueryOptions & FetchMoreOptions, + public fetchMore( + fetchMoreOptions: FetchMoreQueryOptions & + FetchMoreOptions, ): Promise> { // early return if no update Query if (!fetchMoreOptions.updateQuery) { @@ -316,12 +320,11 @@ export class ObservableQuery< ); }) .then(fetchMoreResult => { - this.updateQuery( - (previousResult: any, { variables }: { [key: string]: any }) => - fetchMoreOptions.updateQuery(previousResult, { - fetchMoreResult: fetchMoreResult.data, - variables, - }), + this.updateQuery((previousResult, { variables }) => + fetchMoreOptions.updateQuery(previousResult, { + fetchMoreResult: fetchMoreResult.data as TData, + variables, + }), ); return fetchMoreResult as ApolloQueryResult; @@ -331,7 +334,9 @@ export class ObservableQuery< // XXX the subscription variables are separate from the query variables. // if you want to update subscription variables, right now you have to do that separately, // and you can only do it by stopping the subscription and then subscribing again with new variables. - public subscribeToMore(options: SubscribeToMoreOptions): () => void { + public subscribeToMore( + options: SubscribeToMoreOptions, + ): () => void { const subscription = this.queryManager .startGraphQLSubscription({ query: options.document, @@ -340,11 +345,14 @@ export class ObservableQuery< .subscribe({ next: data => { if (options.updateQuery) { - this.updateQuery((previous: Object, { variables }) => - (options.updateQuery as UpdateQueryFn)(previous, { - subscriptionData: data, - variables, - }), + this.updateQuery((previous, { variables }) => + (options.updateQuery as UpdateQueryFn)( + previous, + { + subscriptionData: data as { data: TData }, + variables, + }, + ), ); } }, @@ -460,7 +468,10 @@ export class ObservableQuery< } public updateQuery( - mapFn: (previousQueryResult: any, options: UpdateQueryOptions) => any, + mapFn: ( + previousQueryResult: TData, + options: UpdateQueryOptions, + ) => TData, ): void { const { previousResult, @@ -469,7 +480,7 @@ export class ObservableQuery< } = this.queryManager.getQueryWithPreviousResult(this.queryId); const newResult = tryFunctionOrLogError(() => - mapFn(previousResult, { variables }), + mapFn(previousResult, { variables: variables as TVariables }), ); if (newResult) { diff --git a/packages/apollo-client/src/core/watchQueryOptions.ts b/packages/apollo-client/src/core/watchQueryOptions.ts index 7678fb0f356..44db098db0e 100644 --- a/packages/apollo-client/src/core/watchQueryOptions.ts +++ b/packages/apollo-client/src/core/watchQueryOptions.ts @@ -94,23 +94,26 @@ export interface WatchQueryOptions context?: any; } -export interface FetchMoreQueryOptions { +export interface FetchMoreQueryOptions { query?: DocumentNode; - variables?: { [key: string]: any }; + variables?: Pick; } -export type UpdateQueryFn = ( - previousQueryResult: Object, +export type UpdateQueryFn = ( + previousQueryResult: TData, options: { - subscriptionData: { data: any }; - variables?: { [key: string]: any }; + subscriptionData: { data: TData }; + variables?: TVariables; }, -) => Object; +) => TData; -export type SubscribeToMoreOptions = { +export type SubscribeToMoreOptions< + TData = any, + TVariables = OperationVariables +> = { document: DocumentNode; - variables?: { [key: string]: any }; - updateQuery?: UpdateQueryFn; + variables?: TVariables; + updateQuery?: UpdateQueryFn; onError?: (error: Error) => void; }; From e58e13a27e0f6ffdf490f07f72551544c7f2a0d0 Mon Sep 17 00:00:00 2001 From: Dirk-Jan Rutten Date: Mon, 2 Apr 2018 08:36:05 +0200 Subject: [PATCH 3/5] Fixed type issue. --- packages/apollo-client/CHANGELOG.md | 1 + packages/apollo-client/src/core/ObservableQuery.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/apollo-client/CHANGELOG.md b/packages/apollo-client/CHANGELOG.md index 2470edb603d..cc249d1a274 100644 --- a/packages/apollo-client/CHANGELOG.md +++ b/packages/apollo-client/CHANGELOG.md @@ -10,6 +10,7 @@ - onResetStore callbacks occur before refetching Observable Queries[PR#3010](https://github.com/apollographql/apollo-client/pull/3010) - Error message for in flight queries during `resetStore` includes link completion note[PR#3010](https://github.com/apollographql/apollo-client/pull/3010) - Fix navigator being undefined on React Native [PR##3164](https://github.com/apollographql/apollo-client/pull/3164) +- Typescript improvements. Made observable query parameterized on data and variables: `ObservableQuery` [PR#3140](https://github.com/apollographql/apollo-client/pull/3140) ### 2.2.3 - dependency updates diff --git a/packages/apollo-client/src/core/ObservableQuery.ts b/packages/apollo-client/src/core/ObservableQuery.ts index 4c801f84634..c79d40b0116 100644 --- a/packages/apollo-client/src/core/ObservableQuery.ts +++ b/packages/apollo-client/src/core/ObservableQuery.ts @@ -403,7 +403,7 @@ export class ObservableQuery< false; return this.setVariables( - this.options.variables, + this.options.variables as TVariables, tryFetch, opts.fetchResults, ); @@ -430,7 +430,7 @@ export class ObservableQuery< * */ public setVariables( - variables?: TVariables, + variables: TVariables, tryFetch: boolean = false, fetchResults = true, ): Promise> { From 6bc05e88f689fa716881fd5f9cda2ecb9d898046 Mon Sep 17 00:00:00 2001 From: Dirk-Jan Rutten Date: Mon, 2 Apr 2018 08:48:56 +0200 Subject: [PATCH 4/5] Moved the changelog --- packages/apollo-client/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/apollo-client/CHANGELOG.md b/packages/apollo-client/CHANGELOG.md index 1dfcb3a9e4e..e0ad42a4671 100644 --- a/packages/apollo-client/CHANGELOG.md +++ b/packages/apollo-client/CHANGELOG.md @@ -4,6 +4,7 @@ ### vNEXT - fixed edge case bug of changing fetchPolicies right after resetStore with no variables present +- Typescript improvements. Made observable query parameterized on data and variables: `ObservableQuery` [PR#3140](https://github.com/apollographql/apollo-client/pull/3140) ### 2.2.8 - Added the graphQLResultHasError in QueryManager.ts to check not only if result.errors is null, but also empty. @@ -21,7 +22,6 @@ - `ApolloError` can now be checked with `instanceof` operator - Fix navigator being undefined on React Native [PR##3164](https://github.com/apollographql/apollo-client/pull/3164) - Remove spread of variables preventing issues with removing keys [#3081](https://github.com/apollographql/apollo-client/pull/3081) -- Typescript improvements. Made observable query parameterized on data and variables: `ObservableQuery` [PR#3140](https://github.com/apollographql/apollo-client/pull/3140) ### 2.2.3 - dependency updates From a72eefd5538be76200765a54eafd771a18fb8390 Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Fri, 1 Jun 2018 08:01:24 -0400 Subject: [PATCH 5/5] Fixed `prettier` formatting issues --- packages/apollo-boost/package.json | 13 +++++++----- packages/apollo-cache-inmemory/package.json | 13 +++++++----- packages/apollo-cache/package.json | 16 +++++++------- packages/apollo-client/package.json | 23 ++++++++++++--------- packages/apollo-utilities/package.json | 13 +++++++----- 5 files changed, 46 insertions(+), 32 deletions(-) diff --git a/packages/apollo-boost/package.json b/packages/apollo-boost/package.json index 3829e23a478..0210ea135dd 100644 --- a/packages/apollo-boost/package.json +++ b/packages/apollo-boost/package.json @@ -29,10 +29,8 @@ "watch": "tsc -w -p .", "clean": "rimraf coverage/* && rimraf lib/*", "prepublishOnly": "npm run build", - "build:browser": - "browserify ./lib/index.js --i apollo-utilities -o=./lib/bundle.js && npm run minify:browser", - "minify:browser": - "uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.js", + "build:browser": "browserify ./lib/index.js --i apollo-utilities -o=./lib/bundle.js && npm run minify:browser", + "minify:browser": "uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.js", "filesize": "npm run build && npm run build:browser" }, "dependencies": { @@ -64,6 +62,11 @@ ".(ts|tsx)": "/node_modules/ts-jest/preprocessor.js" }, "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", - "moduleFileExtensions": ["ts", "tsx", "js", "json"] + "moduleFileExtensions": [ + "ts", + "tsx", + "js", + "json" + ] } } diff --git a/packages/apollo-cache-inmemory/package.json b/packages/apollo-cache-inmemory/package.json index e1ffa5aabd7..20317d93197 100644 --- a/packages/apollo-cache-inmemory/package.json +++ b/packages/apollo-cache-inmemory/package.json @@ -35,10 +35,8 @@ "watch": "tsc -w -p .", "clean": "rimraf coverage/* && rimraf lib/*", "prepublishOnly": "npm run build", - "build:browser": - "browserify ./lib/bundle.umd.js --i apollo-cache --i apollo-utilities --i graphql -o=./lib/bundle.js && npm run minify:browser", - "minify:browser": - "uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.js", + "build:browser": "browserify ./lib/bundle.umd.js --i apollo-cache --i apollo-utilities --i graphql -o=./lib/bundle.js && npm run minify:browser", + "minify:browser": "uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.js", "filesize": "npm run build:browser" }, "dependencies": { @@ -70,6 +68,11 @@ ".(ts|tsx)": "/node_modules/ts-jest/preprocessor.js" }, "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", - "moduleFileExtensions": ["ts", "tsx", "js", "json"] + "moduleFileExtensions": [ + "ts", + "tsx", + "js", + "json" + ] } } diff --git a/packages/apollo-cache/package.json b/packages/apollo-cache/package.json index 335116cbade..039e15f6f99 100644 --- a/packages/apollo-cache/package.json +++ b/packages/apollo-cache/package.json @@ -26,8 +26,7 @@ "scripts": { "coverage": "jest --coverage", "test": "jest", - "lint": - "tslint --type-check -p tsconfig.json src/*.ts && tslint --type-check -p tsconfig.json tests/*.ts", + "lint": "tslint --type-check -p tsconfig.json src/*.ts && tslint --type-check -p tsconfig.json tests/*.ts", "prebuild": "npm run clean", "build": "tsc -p .", "postbuild": "npm run bundle", @@ -35,10 +34,8 @@ "watch": "tsc -w -p .", "clean": "rimraf coverage/* && rimraf lib/*", "prepublishOnly": "npm run clean && npm run build", - "build:browser": - "browserify ./lib/bundle.umd.js --i apollo-utilities -o=./lib/bundle.js && npm run minify:browser", - "minify:browser": - "uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.js", + "build:browser": "browserify ./lib/bundle.umd.js --i apollo-utilities -o=./lib/bundle.js && npm run minify:browser", + "minify:browser": "uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.js", "filesize": "npm run build && npm run build:browser" }, "dependencies": { @@ -64,6 +61,11 @@ ".(ts|tsx)": "/node_modules/ts-jest/preprocessor.js" }, "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", - "moduleFileExtensions": ["ts", "tsx", "js", "json"] + "moduleFileExtensions": [ + "ts", + "tsx", + "js", + "json" + ] } } diff --git a/packages/apollo-client/package.json b/packages/apollo-client/package.json index d4c5a234e96..02465957f82 100644 --- a/packages/apollo-client/package.json +++ b/packages/apollo-client/package.json @@ -13,18 +13,14 @@ "dev": "./scripts/dev.sh", "deploy": "./scripts/deploy.sh", "test": "jest", - "benchmark": - "npm run build:benchmark && node benchmark_lib/benchmark/index.js", - "benchmark:inspect": - "npm run build:benchmark && node --inspect --debug-brk benchmark_lib/benchmark/index.js", + "benchmark": "npm run build:benchmark && node benchmark_lib/benchmark/index.js", + "benchmark:inspect": "npm run build:benchmark && node --inspect --debug-brk benchmark_lib/benchmark/index.js", "filesize": "npm run build && npm run build:browser", "type-check": "flow check", "build": "tsc", "build:benchmark": "tsc -p tsconfig.benchmark.json", - "build:browser": - "browserify ./lib/bundle.umd.js -o=./lib/bundle.js --i apollo-utilities --i apollo-cache --i apollo-link --i apollo-link-dedup && npm run minify:browser", - "minify:browser": - "uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.js", + "build:browser": "browserify ./lib/bundle.umd.js -o=./lib/bundle.js --i apollo-utilities --i apollo-cache --i apollo-link --i apollo-link-dedup && npm run minify:browser", + "minify:browser": "uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.js", "watch": "tsc -w", "bundle": "rollup -c rollup.config.js", "postbuild": "npm run bundle", @@ -98,7 +94,14 @@ ".(ts|tsx)": "/node_modules/ts-jest/preprocessor.js" }, "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", - "moduleFileExtensions": ["ts", "tsx", "js", "json"], - "setupFiles": ["/scripts/tests.js"] + "moduleFileExtensions": [ + "ts", + "tsx", + "js", + "json" + ], + "setupFiles": [ + "/scripts/tests.js" + ] } } diff --git a/packages/apollo-utilities/package.json b/packages/apollo-utilities/package.json index ad6fe345a51..a7b1e8b2aae 100644 --- a/packages/apollo-utilities/package.json +++ b/packages/apollo-utilities/package.json @@ -34,10 +34,8 @@ "watch": "tsc -w -p .", "clean": "rimraf lib/* && rimraf coverage/*", "prepublishOnly": "npm run clean && npm run build", - "build:browser": - "browserify ./lib/bundle.umd.js -o=./lib/bundle.js && npm run minify:browser", - "minify:browser": - "uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.js", + "build:browser": "browserify ./lib/bundle.umd.js -o=./lib/bundle.js && npm run minify:browser", + "minify:browser": "uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.js", "filesize": "npm run build && npm run build:browser" }, "devDependencies": { @@ -63,6 +61,11 @@ ".(ts|tsx)": "/node_modules/ts-jest/preprocessor.js" }, "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", - "moduleFileExtensions": ["ts", "tsx", "js", "json"] + "moduleFileExtensions": [ + "ts", + "tsx", + "js", + "json" + ] } }