Skip to content

Commit 1b9e019

Browse files
ef4mansona
authored andcommitted
manually apply babel in older ember-cli versions
1 parent 632658a commit 1b9e019

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

lib/ember-addon-main.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,36 @@ module.exports = {
9696
}
9797

9898
this._addon.logger.debug(`setup *.hbs compiler with ${htmlbarsOptions.pluginNames}`);
99-
return debugTree(
99+
let output = debugTree(
100100
this._addon.transpileTree(inputTree, {
101101
isProduction,
102102
...htmlbarsOptions,
103103
}),
104104
'03-output'
105105
);
106+
107+
let checker = new VersionChecker(this._addon.project).for('ember-cli', 'npm');
108+
let requiresBabelTree = checker.lt('3.13.0');
109+
let isAddon = this._addon.parent !== this._addon.project;
110+
111+
// as a result of https://github.com/ember-cli/ember-cli-htmlbars/pull/749 we are relying
112+
// on babel for all template comilation. This works fine since [email protected] but before
113+
// that there was a different path for **addon** templates and they would not be compiled
114+
// correctly. This change wraps the output of addons in a babel tree since ember-cli
115+
// isn't doing that properly.
116+
if (requiresBabelTree && isAddon) {
117+
let babelAddon = this._addon.parent.addons.find(
118+
(addon) => addon.name === 'ember-cli-babel'
119+
);
120+
output = babelAddon.transpileTree(output, {
121+
babel: this._addon.parent.options.babel,
122+
'ember-cli-babel': {
123+
compileModules: false,
124+
},
125+
});
126+
}
127+
128+
return output;
106129
},
107130

108131
precompile(string, _options) {

0 commit comments

Comments
 (0)