diff --git a/packages/ember/package.json b/packages/ember/package.json index 23244ba..ab1cc05 100644 --- a/packages/ember/package.json +++ b/packages/ember/package.json @@ -38,6 +38,7 @@ "broccoli-node-api": "^1.7.0", "broccoli-plugin": "^4.0.3", "broccoli-source": "^3.0.0", + "calculate-cache-key-for-tree": "2.0.0", "debug": "^4.3.1", "ember-cli-babel": "^7.23.1", "ember-cli-htmlbars": "^5.3.1", diff --git a/packages/ember/src/index.ts b/packages/ember/src/index.ts index 54c8a7f..129f63e 100644 --- a/packages/ember/src/index.ts +++ b/packages/ember/src/index.ts @@ -13,6 +13,7 @@ import { DemoComponentChunk } from './plugins/types'; import docfyOutputTemplate from './docfy-output-template'; import getDocfyConfig from './get-config'; import { isDemoComponents } from './plugins/utils'; +import cacheKeyForTree from 'calculate-cache-key-for-tree'; import debugFactory from 'debug'; const debug = debugFactory('@docfy/ember'); @@ -134,6 +135,21 @@ module.exports = { this._super.included.apply(this, args); }, + // Re-enables caching of this addon, due to opting out + // of the caching implicitly by specifying treeFor* methods + cacheKeyForTree(treeType: string): string { + switch (treeType) { + case 'app': { + const sources = (this.docfyConfig as DocfyConfig).sources + .map((item) => item.root) + .join(','); + return cacheKeyForTree(treeType, this, [sources]); + } + default: + return cacheKeyForTree(treeType, this); + } + }, + treeForApp(tree: Node): Node { const trees: Node[] = [this._super.treeForApp.call(this, tree)]; if (isDeepAddonInstance(this)) { diff --git a/yarn.lock b/yarn.lock index 339adad..24eab3c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5678,7 +5678,7 @@ cacheable-request@^2.1.1: normalize-url "2.0.1" responselike "1.0.2" -calculate-cache-key-for-tree@^2.0.0: +calculate-cache-key-for-tree@2.0.0, calculate-cache-key-for-tree@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/calculate-cache-key-for-tree/-/calculate-cache-key-for-tree-2.0.0.tgz#7ac57f149a4188eacb0a45b210689215d3fef8d6" integrity sha512-Quw8a6y8CPmRd6eU+mwypktYCwUcf8yVFIRbNZ6tPQEckX9yd+EBVEPC/GSZZrMWH9e7Vz4pT7XhpmyApRByLQ==