-
-
Notifications
You must be signed in to change notification settings - Fork 54
RFC for caching results of treeFor
hook
#90
Conversation
Ember CLI: Production code stripping
``` | ||
The default implementation for `Addon.prototype.cacheKeyForTree` will: | ||
|
||
- Utilize a shared NPM package (e.g. `calculate-cache-key-for-tree`) that will generate a cache key that incorporates at least the following pieces of information: |
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.
An additional or complementary heuristic may be that they are at the exact same place on disk?
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.
@stefanpenner - Ya, I'm happy to add that also.
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.
@rwjblue only if you think it adds value. Just wanted to share, in-case it was overlooked.
treeFor
hook results.treeFor
hook
Implement addon treeFor caching. In Ember CLI today, all addons at each level are built through the standard `treeFor` / `treeFor*` hooks. These hooks are responsible for preprocessing the JavaScript included by the tree returned from that specific hook (e.g., `treeForAddon` preprocesses the JS for the addon tree). [This RFC](ember-cli/rfcs#90) proposes a mechanism that would allow these returned trees to be cached by default (when no build time customization is done) and expose proper hooks for addon authors to control the degree to which we dedupe these trees. See [ember-cli/rfcs#90](ember-cli/rfcs#90) for more context. *Note:* This effort was derived from @stefanpenner's work in #6429. ### TODO: - [x] Unit test `cacheKeyForTree` implementation - [x] Confirm that `treeFor*` method overrides opt-out of caching - [x] Confirm that modifying `this.treeForMethods` opts out of caching. - [x] Confirm that repeated calls to `cacheKeyForTree` return the same value. - [x] Unit test `treeFor` caching mechanism - [x] Extract basic `cacheKeyForTree` implementation to stand alone utility function - [x] test ### Future TODO: - [ ] Ensure `mergeTrees` macro utility function is updated to properly dedupe when called like `mergeTrees([treeA, treeA])`. (#6574) - [ ] Updates to Broccoli to ensure that "reused / previously built trees" are represented properly in heimdall tree. This will included confirming that `buildSteps` properly handles the deduplicated results and shows an improvement. - [ ] Extract the default `cacheKeyForTree` implementation into a separate package. - [ ] Add API docs for `Addon.prototype.cacheKeyForTree` (in a separate PR after the corresponding RFC lands, so that ember-cli.com/api does not show the experimental API's until the RFC lands).
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.
LGTM
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.
Looks good to me. Only potential suggestion would be mentioning the cache API and maybe link to cache-key-for-tree.
This was promoted to Final Comment Period in our team meeting. |
As discussed in ember-cli/rfcs#90
Discussed at ember-cli core team meeting today. No new information was brought up during the final comment period, and all of the ember-cli core team is in favor. Merging... |
Promote cacheKeyForTree to public API As discussed in ember-cli/rfcs#90. Should be good to go once the RFC is merged. Pro tip: use `?w=1` when viewing the changes to tidy up the large amount of whitespace changes in the tests.
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`.
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`.
RFC for caching results of `treeFor` hook
Rendered
Implementation PR here.