Skip to content

Commit

Permalink
[BUGFIX beta] Implement cacheKeyForTree hook.
Browse files Browse the repository at this point in the history
This hook was added in [ember-cli/rfcs#90](https://github.com/ember-cli/rfcs/blob/master/complete/0090-addon-tree-caching.md),
and essentially guarantees that a given tree returned by an addon is
considered stable (or not).

In the case of Ember Data, we do not have different tree output
based on our parent (project or addon).

Specifically, this implementation allows both an app _and_ a lazy engine to
depend on `ember-data` without duplicating the `ember-data` assets in both
the `assets/vendor.js` and `engine-dist/<engine-name>/assets/engine-vendor.js`.
  • Loading branch information
rwjblue committed Aug 10, 2017
1 parent 171102c commit 59bf5cb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const merge = require('broccoli-merge-trees');
const semver = require('semver');
const version = require('./lib/version');
const BroccoliDebug = require('broccoli-debug');
const calculateCacheKeyForTree = require('calculate-cache-key-for-tree');

// allow toggling of heimdall instrumentation
let INSTRUMENT_HEIMDALL = false;
Expand Down Expand Up @@ -213,6 +214,9 @@ module.exports = {
production: app.bowerDirectory + '/ember-data/ember-data.prod.js'
});
}
},

cacheKeyForTree(treeType) {
return calculateCacheKeyForTree(treeType, this);
}
};

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"broccoli-funnel": "^1.2.0",
"broccoli-merge-trees": "^2.0.0",
"broccoli-rollup": "^1.2.0",
"calculate-cache-key-for-tree": "^1.1.0",
"chalk": "^1.1.1",
"ember-cli-babel": "^6.4.1",
"ember-cli-path-utils": "^1.0.0",
Expand Down
6 changes: 6 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,12 @@ calculate-cache-key-for-tree@^1.0.0:
dependencies:
json-stable-stringify "^1.0.1"

calculate-cache-key-for-tree@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/calculate-cache-key-for-tree/-/calculate-cache-key-for-tree-1.1.0.tgz#0c3e42c9c134f3c9de5358c0f16793627ea976d6"
dependencies:
json-stable-stringify "^1.0.1"

caller-path@^0.1.0:
version "0.1.0"
resolved "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz#94085ef63581ecd3daa92444a8fe94e82577751f"
Expand Down

0 comments on commit 59bf5cb

Please sign in to comment.