Skip to content

Commit

Permalink
Merge pull request #4234 from apollographql/wip-reduce-bundle-size
Browse files Browse the repository at this point in the history
Trim low-hanging fruit to reduce bundle sizes (part 1 of issue #4324).
  • Loading branch information
benjamn committed Jan 17, 2019
2 parents 449788f + 2815cac commit 3510493
Show file tree
Hide file tree
Showing 24 changed files with 359 additions and 732 deletions.
28 changes: 26 additions & 2 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,32 @@

## Apollo Client (vNext)

### Apollo Client (vNext)

- The `apollo-client` package no longer exports a `printAST` function from
`graphql/language/printer`. If you need this functionality, import it
directly: `import { print } from "graphql/language/printer"`

### Apollo Cache In-Memory (vNext)

- The `flattenSelections` helper function is no longer exported from
`apollo-utilities`, since `getDirectiveNames` has been reimplemented
without using `flattenSelections`, and `flattenSelections` has no clear
purpose now. If you need the old functionality, use a visitor:
```ts
import { visit } from "graphql/language/visitor";

function flattenSelections(selection: SelectionNode) {
const selections: SelectionNode[] = [];
visit(selection, {
SelectionSet(ss) {
selections.push(...ss.selections);
}
});
return selections;
}
```

## Apollo Client (2.4.9)

### Apollo Client (2.4.9)
Expand Down Expand Up @@ -71,8 +97,6 @@
[@PowerKiKi](https://github.com/PowerKiKi) in [#3693](https://github.com/apollographql/apollo-client/pull/3693) <br/>
[@nandito](https://github.com/nandito) in [#3865](https://github.com/apollographql/apollo-client/pull/3865)

### Apollo Utilities (1.0.27)

- Schema/AST tranformation utilities have been updated to work properly with
`@client` directives. <br/>
[@justinmakaila](https://github.com/justinmakaila) in [#3482](https://github.com/apollographql/apollo-client/pull/3482)
Expand Down
12 changes: 11 additions & 1 deletion config/rollup.config.js
@@ -1,3 +1,4 @@
import node from 'rollup-plugin-node-resolve';
import sourcemaps from 'rollup-plugin-sourcemaps';

export const globals = {
Expand Down Expand Up @@ -36,7 +37,16 @@ export default (name, override = {}) => {
);

config.plugins = config.plugins || [];
config.plugins.push(sourcemaps());
config.plugins.push(
sourcemaps(),
node({
// Inline anything imported from the tslib package, e.g. __extends
// and __assign. This depends on the "importHelpers":true option in
// tsconfig.base.json.
module: true,
only: ['tslib'],
}),
);
return config;
};

Expand Down
1 change: 1 addition & 0 deletions config/tsconfig.base.json
Expand Up @@ -5,6 +5,7 @@
"noUnusedLocals": true,
"skipLibCheck": true,
"moduleResolution": "node",
"importHelpers": true,
"removeComments": true,
"sourceMap": true,
"declaration": true,
Expand Down
9 changes: 5 additions & 4 deletions package.json
Expand Up @@ -24,22 +24,22 @@
{
"name": "apollo-cache",
"path": "./packages/apollo-cache/lib/bundle.min.js",
"maxSize": "1 kB"
"maxSize": "900 B"
},
{
"name": "apollo-cache-inmemory",
"path": "./packages/apollo-cache-inmemory/lib/bundle.min.js",
"maxSize": "7 kB"
"maxSize": "6.2 kB"
},
{
"name": "apollo-client",
"path": "./packages/apollo-client/lib/bundle.min.js",
"maxSize": "10.25 kB"
"maxSize": "9.15 kB"
},
{
"name": "apollo-utilities",
"path": "./packages/apollo-utilities/lib/bundle.min.js",
"maxSize": "5 kB"
"maxSize": "4.3 kB"
}
],
"jest": {
Expand Down Expand Up @@ -111,6 +111,7 @@
"rollup-plugin-sourcemaps": "0.4.2",
"rxjs": "6.3.3",
"ts-jest": "23.1.4",
"tslib": "^1.9.3",
"tslint": "5.12.1",
"typescript": "3.2.2",
"uglify-js": "3.4.9",
Expand Down
Expand Up @@ -246,14 +246,7 @@ Object {

exports[`MapCache writing to the store throws when trying to write an object without id that was previously queried with id 1`] = `
"Error writing result to store for query:
query Failure {
item {
stringField
}
}
{\\"kind\\":\\"Document\\",\\"definitions\\":[{\\"kind\\":\\"OperationDefinition\\",\\"operation\\":\\"query\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"Failure\\"},\\"variableDefinitions\\":[],\\"directives\\":[],\\"selectionSet\\":{\\"kind\\":\\"SelectionSet\\",\\"selections\\":[{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"item\\"},\\"arguments\\":[],\\"directives\\":[],\\"selectionSet\\":{\\"kind\\":\\"SelectionSet\\",\\"selections\\":[{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"stringField\\"},\\"arguments\\":[],\\"directives\\":[]}]}}]}}],\\"loc\\":{\\"start\\":0,\\"end\\":106}}
Store error: the application attempted to write an object with no provided id but the store already contains an id of abcd for this object. The selectionSet that was trying to be written is:
item {
stringField
}"
{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"item\\"},\\"arguments\\":[],\\"directives\\":[],\\"selectionSet\\":{\\"kind\\":\\"SelectionSet\\",\\"selections\\":[{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"stringField\\"},\\"arguments\\":[],\\"directives\\":[]}]}}"
`;
Expand Up @@ -4,14 +4,7 @@ exports[
`writing to the store throws when trying to write an object without id that was previously queried with id 1`
] = `
"Error writing result to store for query:
query Failure {
item {
stringField
}
}
{\\"kind\\":\\"Document\\",\\"definitions\\":[{\\"kind\\":\\"OperationDefinition\\",\\"operation\\":\\"query\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"Failure\\"},\\"variableDefinitions\\":[],\\"directives\\":[],\\"selectionSet\\":{\\"kind\\":\\"SelectionSet\\",\\"selections\\":[{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"item\\"},\\"arguments\\":[],\\"directives\\":[],\\"selectionSet\\":{\\"kind\\":\\"SelectionSet\\",\\"selections\\":[{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"stringField\\"},\\"arguments\\":[],\\"directives\\":[]}]}}]}}],\\"loc\\":{\\"start\\":0,\\"end\\":106}}
Store error: the application attempted to write an object with no provided id but the store already contains an id of abcd for this object. The selectionSet that was trying to be written is:
item {
stringField
}"
{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"item\\"},\\"arguments\\":[],\\"directives\\":[],\\"selectionSet\\":{\\"kind\\":\\"SelectionSet\\",\\"selections\\":[{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"stringField\\"},\\"arguments\\":[],\\"directives\\":[]}]}}"
`;
Expand Up @@ -4,14 +4,7 @@ exports[
`writing to the store throws when trying to write an object without id that was previously queried with id 1`
] = `
"Error writing result to store for query:
query Failure {
item {
stringField
}
}
{\\"kind\\":\\"Document\\",\\"definitions\\":[{\\"kind\\":\\"OperationDefinition\\",\\"operation\\":\\"query\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"Failure\\"},\\"variableDefinitions\\":[],\\"directives\\":[],\\"selectionSet\\":{\\"kind\\":\\"SelectionSet\\",\\"selections\\":[{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"item\\"},\\"arguments\\":[],\\"directives\\":[],\\"selectionSet\\":{\\"kind\\":\\"SelectionSet\\",\\"selections\\":[{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"stringField\\"},\\"arguments\\":[],\\"directives\\":[]}]}}]}}],\\"loc\\":{\\"start\\":0,\\"end\\":106}}
Store error: the application attempted to write an object with no provided id but the store already contains an id of abcd for this object. The selectionSet that was trying to be written is:
item {
stringField
}"
{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"item\\"},\\"arguments\\":[],\\"directives\\":[],\\"selectionSet\\":{\\"kind\\":\\"SelectionSet\\",\\"selections\\":[{\\"kind\\":\\"Field\\",\\"name\\":{\\"kind\\":\\"Name\\",\\"value\\":\\"stringField\\"},\\"arguments\\":[],\\"directives\\":[]}]}}"
`;
51 changes: 0 additions & 51 deletions packages/apollo-cache-inmemory/src/__tests__/queryKeyMaker.ts

This file was deleted.

158 changes: 0 additions & 158 deletions packages/apollo-cache-inmemory/src/queryKeyMaker.ts

This file was deleted.

0 comments on commit 3510493

Please sign in to comment.