From bf3f444e077fde83d0895be5bcdd3a32921b64d4 Mon Sep 17 00:00:00 2001 From: Ruslan Zavacky Date: Fri, 10 Dec 2021 11:30:18 +0000 Subject: [PATCH 1/2] chore: introduce cacheKeyForTree to avoid running treeForX multiple times --- index.js | 12 ++++++++++++ package.json | 1 + yarn.lock | 7 +++++++ 3 files changed, 20 insertions(+) diff --git a/index.js b/index.js index 88471a48..e89dc3d7 100644 --- a/index.js +++ b/index.js @@ -16,6 +16,7 @@ const path = require('path'); const getBabelOptions = require('./lib/get-babel-options'); const findApp = require('./lib/find-app'); const emberPlugins = require('./lib/ember-plugins'); +const cacheKeyForTree = require('calculate-cache-key-for-tree'); const APP_BABEL_RUNTIME_VERSION = new WeakMap(); const PROJECTS_WITH_VALID_EMBER_CLI = new WeakSet(); @@ -273,6 +274,17 @@ module.exports = { return polyfillTree; }, + cacheKeyForTree(treeType) { + if (treeType === 'addon') { + let isRootBabel = this.parent === this.project; + let shouldIncludeHelpers = isRootBabel && _shouldIncludeHelpers(this._getAppOptions(), this); + + return cacheKeyForTree('addon', this, [shouldIncludeHelpers]); + } + + return cacheKeyForTree(treeType, this); + }, + included: function(app) { this._super.included.apply(this, arguments); this.app = app; diff --git a/package.json b/package.json index dbd1f381..883d13a2 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,7 @@ "devDependencies": { "babel-eslint": "^10.1.0", "broccoli-test-helper": "^1.4.0", + "calculate-cache-key-for-tree": "^2.0.0", "chai": "^4.1.2", "co": "^4.6.0", "common-tags": "^1.8.0", diff --git a/yarn.lock b/yarn.lock index 25a3ae41..e01b567d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2860,6 +2860,13 @@ calculate-cache-key-for-tree@^1.0.0: dependencies: json-stable-stringify "^1.0.1" +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== + dependencies: + json-stable-stringify "^1.0.1" + call-bind@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" From 84b72c727b195456aaa482ba87fdde3cee95e64b Mon Sep 17 00:00:00 2001 From: Ruslan Zavacky Date: Mon, 13 Dec 2021 12:13:48 +0000 Subject: [PATCH 2/2] chore(GH-421): move `calculate-cache-key-for-tree` to deps --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 883d13a2..4d6eeeec 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "broccoli-debug": "^0.6.4", "broccoli-funnel": "^2.0.2", "broccoli-source": "^2.1.2", + "calculate-cache-key-for-tree": "^2.0.0", "clone": "^2.1.2", "ember-cli-babel-plugin-helpers": "^1.1.1", "ember-cli-version-checker": "^4.1.0", @@ -71,7 +72,6 @@ "devDependencies": { "babel-eslint": "^10.1.0", "broccoli-test-helper": "^1.4.0", - "calculate-cache-key-for-tree": "^2.0.0", "chai": "^4.1.2", "co": "^4.6.0", "common-tags": "^1.8.0",