From 59bf5cb06d229c4b6e83a28332102162e85140c9 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Tue, 1 Aug 2017 10:25:17 -0400 Subject: [PATCH] [BUGFIX beta] Implement `cacheKeyForTree` hook. 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//assets/engine-vendor.js`. --- index.js | 6 +++++- package.json | 1 + yarn.lock | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index de266d8599d..533c4c1c69b 100644 --- a/index.js +++ b/index.js @@ -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; @@ -213,6 +214,9 @@ module.exports = { production: app.bowerDirectory + '/ember-data/ember-data.prod.js' }); } + }, + + cacheKeyForTree(treeType) { + return calculateCacheKeyForTree(treeType, this); } }; - diff --git a/package.json b/package.json index 7150226bca7..5d40e736268 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index aebf82223c6..7a7783e870c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"