MCPcopy Index your code
hub / github.com/ember-cli/ember-cli / validateCacheKey

Function validateCacheKey

lib/models/per-bundle-addon-cache/addon-proxy.js:21–40  ·  view source on GitHub ↗

* Validates that a new cache key for a given tree type matches the previous * cache key for the same tree type. To opt-in to bundle addon caching for * a given addon it's assumed that it returns stable cache keys; specifically * this is because the interplay between bundle addon caching and `embe

(realAddonInstance, treeType, newCacheKey)

Source from the content-addressed store, hash-verified

19 * @throws {Error} If the new cache key doesn't match the previous cache key
20 */
21function validateCacheKey(realAddonInstance, treeType, newCacheKey) {
22 let cacheKeyTracker = realAddonInstance[CACHE_KEY_FOR_TREE_TRACKER];
23
24 if (!cacheKeyTracker) {
25 cacheKeyTracker = {};
26 realAddonInstance[CACHE_KEY_FOR_TREE_TRACKER] = cacheKeyTracker;
27 }
28
29 cacheKeyTracker[treeType] = treeType in cacheKeyTracker ? cacheKeyTracker[treeType] : newCacheKey;
30
31 if (cacheKeyTracker[treeType] !== newCacheKey) {
32 throw new Error(
33 `[ember-cli] addon bundle caching can only be used on addons that have stable cache keys (previously \`${
34 cacheKeyTracker[treeType]
35 }\`, now \`${newCacheKey}\`; for addon \`${realAddonInstance.name}\` located at \`${
36 realAddonInstance.packageRoot || realAddonInstance.root
37 }\`)`
38 );
39 }
40}
41
42/**
43 * Returns a proxy to a target with specific handling for the

Callers 1

getFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…