From 29d80a3e26dba70c993306e79ed625dbea9be1f3 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli Date: Tue, 14 Dec 2021 15:39:34 -0500 Subject: [PATCH 1/3] Add treeFor cache --- packages/ember/package.json | 1 + packages/ember/src/index.ts | 7 +++++++ yarn.lock | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) 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..0411d03 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,12 @@ 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) { + 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== From ae93647777d26c870a968ab6f2b79d62bf6390ea Mon Sep 17 00:00:00 2001 From: NullVoxPopuli Date: Thu, 16 Dec 2021 19:14:41 -0500 Subject: [PATCH 2/3] Use more explicit cacheKeyForTree --- packages/ember/src/index.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/ember/src/index.ts b/packages/ember/src/index.ts index 0411d03..7539322 100644 --- a/packages/ember/src/index.ts +++ b/packages/ember/src/index.ts @@ -138,7 +138,16 @@ module.exports = { // Re-enables caching of this addon, due to opting out // of the caching implicitly by specifying treeFor* methods cacheKeyForTree(treeType) { - return cacheKeyForTree(treeType, this); + 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 { From 6084bc13bde229b05a94cf4fff3a4ad93fcacec4 Mon Sep 17 00:00:00 2001 From: Josemar Luedke Date: Thu, 16 Dec 2021 16:38:28 -0800 Subject: [PATCH 3/3] Add basic types for cacheKeyForTree --- packages/ember/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ember/src/index.ts b/packages/ember/src/index.ts index 7539322..129f63e 100644 --- a/packages/ember/src/index.ts +++ b/packages/ember/src/index.ts @@ -137,7 +137,7 @@ module.exports = { // Re-enables caching of this addon, due to opting out // of the caching implicitly by specifying treeFor* methods - cacheKeyForTree(treeType) { + cacheKeyForTree(treeType: string): string { switch (treeType) { case 'app': { const sources = (this.docfyConfig as DocfyConfig).sources