Skip to content

Commit

Permalink
manually apply babel in older ember-cli versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ef4 authored and mansona committed Sep 8, 2022
1 parent 632658a commit 1b9e019
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion lib/ember-addon-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,36 @@ module.exports = {
}

this._addon.logger.debug(`setup *.hbs compiler with ${htmlbarsOptions.pluginNames}`);
return debugTree(
let output = debugTree(
this._addon.transpileTree(inputTree, {
isProduction,
...htmlbarsOptions,
}),
'03-output'
);

let checker = new VersionChecker(this._addon.project).for('ember-cli', 'npm');
let requiresBabelTree = checker.lt('3.13.0');
let isAddon = this._addon.parent !== this._addon.project;

// as a result of https://github.com/ember-cli/ember-cli-htmlbars/pull/749 we are relying
// on babel for all template comilation. This works fine since ember-cli@3.13 but before
// that there was a different path for **addon** templates and they would not be compiled
// correctly. This change wraps the output of addons in a babel tree since ember-cli
// isn't doing that properly.
if (requiresBabelTree && isAddon) {
let babelAddon = this._addon.parent.addons.find(
(addon) => addon.name === 'ember-cli-babel'
);
output = babelAddon.transpileTree(output, {
babel: this._addon.parent.options.babel,
'ember-cli-babel': {
compileModules: false,
},
});
}

return output;
},

precompile(string, _options) {
Expand Down

0 comments on commit 1b9e019

Please sign in to comment.