Skip to content

Commit

Permalink
chore: introduce cacheKeyForTree to avoid running treeForX multiple t…
Browse files Browse the repository at this point in the history
…imes
  • Loading branch information
Ruslan Zavacky authored and chriskrycho committed Dec 16, 2021
1 parent 0d47e8b commit 5b660a2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3662,6 +3662,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"
Expand Down

0 comments on commit 5b660a2

Please sign in to comment.