Skip to content

Commit

Permalink
Merge branch 'main' into release-3.5.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamn committed Aug 30, 2021
2 parents 91ae6ee + f54e125 commit 082894d
Show file tree
Hide file tree
Showing 59 changed files with 282 additions and 185 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,24 @@
- Update `zen-observable-ts` to eliminate transitive dependency on `@types/zen-observable`. <br/>
[@benjamn](https://github.com/benjamn) in [#8695](https://github.com/apollographql/apollo-client/pull/8695)

## Apollo Client 3.4.10 (not yet released)
## Apollo Client 3.4.10

### Improvements

- Warn when calling `refetch({ variables })` instead of `refetch(variables)`, except for queries that declare a variable named `$variables` (uncommon). <br/>
[@benjamn](https://github.com/benjamn) in [#8702](https://github.com/apollographql/apollo-client/pull/8702)

### Bug Fixes

- Fix `ObservableQuery.getCurrentResult()` returning cached `data` with certain fetch policies. <br/>
[@brainkim](https://github.com/brainkim) in [#8718](https://github.com/apollographql/apollo-client/pull/8718)

- Prevent `ssrMode`/`ssrForceFetchDelay` from causing queries to hang. <br/>
[@brainkim](https://github.com/brainkim) in [#8709](https://github.com/apollographql/apollo-client/pull/8709)

- Import `@apollo/client/utilities/globals` internally wherever `__DEV__` is used, not just in `@apollo/client/**/index.js` entry points. <br/>
[@benjamn](https://github.com/benjamn) in [#8720](https://github.com/apollographql/apollo-client/pull/8720)

## Apollo Client 3.4.9

### Bug Fixes
Expand Down
54 changes: 0 additions & 54 deletions config/checkDEV.ts

This file was deleted.

6 changes: 2 additions & 4 deletions config/entryPoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ const entryPoints = [
{ dirs: ['react', 'hooks'] },
{ dirs: ['react', 'parser'] },
{ dirs: ['react', 'ssr'] },
{ dirs: ['utilities'],
sideEffects: [
"./globals/**"
]},
{ dirs: ['utilities'] },
{ dirs: ['utilities', 'globals'], sideEffects: true },
{ dirs: ['testing'], extensions: [".js", ".jsx"] },
];

Expand Down
28 changes: 27 additions & 1 deletion config/resolveModuleIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,30 @@ eachFile(distDir, (file, relPath) => new Promise((resolve, reject) => {
fs.readFile(file, "utf8", (error, source) => {
if (error) return reject(error);

const output = new Transformer().transform(source, file);
const tr = new Transformer;
const output = tr.transform(source, file);

if (
/\b__DEV__\b/.test(source) &&
// Ignore modules that reside within @apollo/client/utilities/globals.
!relPath.startsWith("utilities/globals/")
) {
let importsUtilitiesGlobals = false;

tr.absolutePaths.forEach(absPath => {
const distRelativePath =
path.relative(distDir, absPath).split(path.sep).join("/");
if (distRelativePath === "utilities/globals/index.js") {
importsUtilitiesGlobals = true;
}
});

if (!importsUtilitiesGlobals) {
reject(new Error(`Module ${
relPath
} uses __DEV__ but does not import @apollo/client/utilities/globals`));
}
}

if (source === output) {
resolve(file);
Expand All @@ -24,6 +47,8 @@ const n = recast.types.namedTypes;
type Node = recast.types.namedTypes.Node;

class Transformer {
absolutePaths = new Set<string>();

transform(code: string, file: string) {
const ast = reparse(code);
const transformer = this;
Expand Down Expand Up @@ -103,6 +128,7 @@ class Transformer {
} : pkg;
},
});
this.absolutePaths.add(absPath);
const relPath = path.relative(basedir, absPath);
const relId = relPath.split(path.sep).join('/');
return this.isRelative(relId) ? relId : "./" + relId;
Expand Down
6 changes: 3 additions & 3 deletions docs/package-lock.json

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

2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
},
"devDependencies": {
"typedoc": "0.15.8",
"typescript": "4.3.5"
"typescript": "4.4.2"
}
}
42 changes: 21 additions & 21 deletions package-lock.json

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

9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@
"scripts": {
"prebuild": "npm run clean",
"build": "tsc",
"postbuild": "npm run update-version && npm run invariants && npm run sourcemaps && npm run rollup && npm run prepdist && npm run resolve && npm run check-DEV && npm run verify-version",
"postbuild": "npm run update-version && npm run invariants && npm run sourcemaps && npm run rollup && npm run prepdist && npm run resolve && npm run verify-version",
"update-version": "node config/version.js update",
"verify-version": "node config/version.js verify",
"invariants": "ts-node-script config/processInvariants.ts",
"sourcemaps": "ts-node-script config/rewriteSourceMaps.ts",
"rollup": "rollup -c ./config/rollup.config.js",
"prepdist": "node ./config/prepareDist.js",
"resolve": "ts-node-script config/resolveModuleIds.ts",
"check-DEV": "ts-node-script config/checkDEV.ts",
"clean": "rimraf -r dist coverage lib temp",
"test": "jest --config ./config/jest.config.js",
"test:debug": "BABEL_ENV=server node --inspect-brk node_modules/.bin/jest --config ./config/jest.config.js --runInBand --testTimeout 99999",
Expand Down Expand Up @@ -101,7 +100,7 @@
"@types/hoist-non-react-statics": "3.3.1",
"@types/jest": "26.0.24",
"@types/lodash": "4.14.172",
"@types/node": "16.7.1",
"@types/node": "16.7.6",
"@types/react": "17.0.19",
"@types/react-dom": "17.0.2",
"@types/recompose": "0.30.8",
Expand All @@ -125,10 +124,10 @@
"rollup-plugin-terser": "7.0.2",
"rxjs": "6.6.7",
"subscriptions-transport-ws": "0.9.19",
"terser": "5.7.1",
"terser": "5.7.2",
"ts-jest": "26.5.6",
"ts-node": "10.2.1",
"typescript": "4.3.5",
"typescript": "4.4.2",
"wait-for-observables": "1.0.3"
},
"publishConfig": {
Expand Down
12 changes: 11 additions & 1 deletion src/__tests__/__snapshots__/exports.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ Array [
"buildQueryFromSelectionSet",
"canUseWeakMap",
"canUseWeakSet",
"checkDEV",
"checkDocument",
"cloneDeep",
"compact",
Expand Down Expand Up @@ -373,3 +372,14 @@ Array [
"valueToObjectRepresentation",
]
`;

exports[`exports of public entry points @apollo/client/utilities/globals 1`] = `
Array [
"DEV",
"InvariantError",
"checkDEV",
"global",
"invariant",
"maybe",
]
`;
2 changes: 2 additions & 0 deletions src/__tests__/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import * as reactParser from "../react/parser";
import * as reactSSR from "../react/ssr";
import * as testing from "../testing";
import * as utilities from "../utilities";
import * as utilitiesGlobals from "../utilities/globals";

const entryPoints = require("../../config/entryPoints.js");

Expand Down Expand Up @@ -61,6 +62,7 @@ describe('exports of public entry points', () => {
check("@apollo/client/react/ssr", reactSSR);
check("@apollo/client/testing", testing);
check("@apollo/client/utilities", utilities);
check("@apollo/client/utilities/globals", utilitiesGlobals);

it("completeness", () => {
const { join } = require("path").posix;
Expand Down
3 changes: 1 addition & 2 deletions src/cache/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { checkDEV } from "../utilities";
checkDEV();
import '../utilities/globals';

export { Transaction, ApolloCache } from './core/cache';
export { Cache } from './core/types/Cache';
Expand Down
2 changes: 1 addition & 1 deletion src/cache/inmemory/entityStore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { invariant } from '../../utilities/globals';
import { dep, OptimisticDependencyFunction } from 'optimism';
import { invariant } from 'ts-invariant';
import { equal } from '@wry/equality';
import { Trie } from '@wry/trie';

Expand Down
3 changes: 2 additions & 1 deletion src/cache/inmemory/inMemoryCache.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { invariant } from '../../utilities/globals';

// Make builtins like Map and Set safe to use with non-extensible objects.
import './fixPolyfills';

import { DocumentNode } from 'graphql';
import { OptimisticWrapperFunction, wrap } from 'optimism';
import { equal } from '@wry/equality';
import { invariant } from 'ts-invariant';

import { ApolloCache } from '../core/cache';
import { Cache } from '../core/types/Cache';
Expand Down
2 changes: 2 additions & 0 deletions src/cache/inmemory/object-canon.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import "../../utilities/globals";

import { Trie } from "@wry/trie";
import {
canUseWeakMap,
Expand Down
3 changes: 2 additions & 1 deletion src/cache/inmemory/policies.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { invariant, InvariantError } from '../../utilities/globals';

import {
InlineFragmentNode,
FragmentDefinitionNode,
Expand All @@ -6,7 +8,6 @@ import {
} from 'graphql';

import { Trie } from '@wry/trie';
import { invariant, InvariantError } from 'ts-invariant';

import {
FragmentMap,
Expand Down

0 comments on commit 082894d

Please sign in to comment.