-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Refactor to avoid import cycle between inMemoryCache.ts
and readFromStore.ts
#8850
Refactor to avoid import cycle between inMemoryCache.ts
and readFromStore.ts
#8850
Conversation
export { | ||
InMemoryCache, | ||
InMemoryCacheConfig, | ||
} from './inmemory/inMemoryCache'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InMemoryCacheConfig
is now exported by the
export * from './inmemory/types';
line below.
} from '../../utilities'; | ||
|
||
export const { | ||
hasOwnProperty: hasOwn, | ||
} = Object.prototype; | ||
|
||
export function defaultDataIdFromObject( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved defaultDataIdFromObject
here to prevent another dependency cycle between helpers.ts
and policies.ts
.
return compact(defaultConfig, config); | ||
} | ||
|
||
export function shouldCanonizeResults( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The shouldCanonizeResults
helper now lives in helpers.ts
, whence it can be non-circularly imported by both inMemoryCache.ts
and readFromStore.ts
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circular dependencies. Not even once!
The
shouldCanonizeResults
helper function introduced in #8822 was defined ininMemoryCache.ts
but also used inreadFromStore.ts
. Since these two modules already mutually import TypeScript types from each other, the addition of a concrete/value export caused Rollup to begin displaying a warning about the new dependency cycle:Dependency cycles in JavaScript are generally harmless and often unavoidable, but we can simplify the work of bundlers like Rollup by eliminating the cycles that are avoidable (as this one is).