Skip to content

Commit

Permalink
Avoid repeatedly checking the ember-cli version
Browse files Browse the repository at this point in the history
Since `ember-cli` is the process controlling the addon instantiation, we
only need to ensure that we are using the correct version once (not once
per ember-cli-babel instance).

Since `ember-cli-babel` is the single most commonly used addon, this
non-trivially reduces the amount of overhead during the early part of a
build.

(cherry picked from commit ffc96b8)
  • Loading branch information
rwjblue committed Jan 19, 2021
1 parent d253e2f commit 39bc0b2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const defaultShouldIncludeHelpers = require('./lib/default-should-include-helper
const findApp = require('./lib/find-app');

const APP_BABEL_RUNTIME_VERSION = new WeakMap();
const PROJECTS_WITH_VALID_EMBER_CLI = new WeakSet();

let count = 0;

Expand All @@ -19,11 +20,14 @@ module.exports = {
init() {
this._super.init && this._super.init.apply(this, arguments);

let checker = new VersionChecker(this);
let dep = checker.for('ember-cli', 'npm');
if (!PROJECTS_WITH_VALID_EMBER_CLI.has(this.project)) {
let checker = new VersionChecker(this);
let dep = checker.for('ember-cli', 'npm');

if (dep.lt('2.13.0')) {
throw new Error(`ember-cli-babel@7 (used by ${this._parentName()} at ${this.parent.root}) cannot be used by ember-cli versions older than 2.13, you used ${dep.version}`);
if (dep.lt('2.13.0')) {
throw new Error(`ember-cli-babel@7 (used by ${this._parentName()} at ${this.parent.root}) cannot be used by ember-cli versions older than 2.13, you used ${dep.version}`);
}
PROJECTS_WITH_VALID_EMBER_CLI.add(this.project);
}
},

Expand Down

0 comments on commit 39bc0b2

Please sign in to comment.