Skip to content

Commit

Permalink
Avoid errors when using older Ember versions. (#1102)
Browse files Browse the repository at this point in the history
With ember-cli-htmlbars 4.2, there is a check to disable co-location
support on old ember versions (which, even when compiled, would fail
at runtime due to missing `setComponentTemplate`). This is causing
build failures when running ember-try with old Ember versions. Since
we don't actually run the app or its tests in ember-try, we can work
around the problem by skipping template compilation for now.

Co-authored-by: Godfrey Chan <[email protected]>
  • Loading branch information
chancancode authored and RobbieTheWagner committed Dec 14, 2019
1 parent b932dbd commit 8861e83
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
22 changes: 21 additions & 1 deletion ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const options = {
sourceDirs: [
'public/assets/svg'
]
}
},
};

// Firefox requires non-minified assets for review :(
Expand All @@ -56,6 +56,26 @@ module.exports = function(defaults) {
options.vendorFiles = { 'jquery.js': null };
}

// When running ember-try on Ember < 3.13, colocation support is
// disabled in ember-cli-htmlbars and causes a build error. When
// running ember-try, we actually don't care about the "app" side
// at all – all we do is run the ember_debug tests (via a --filter
// option to ember test in the ember-try config). The only reason
// we are even building the app is to get the test harness (qunit
// and friends) to work. In the long run, we should split up the
// build and not run the app build in ember-try, but in the mean
// time, this drops all *.hbs files (but keeping everything else)
// to avoid the problem. The app will of course not work correctly
// at runtime, but it was never meant to work on old ember versions
// in the first place.
if (!emberChecker.gte('3.13.0')) {
options.trees = {
app: new Funnel('app', {
exclude: ['**/*.hbs'],
}),
};
}

let app = new EmberApp(defaults, options);

// Use `app.import` to add additional libraries to the generated
Expand Down
25 changes: 25 additions & 0 deletions lib/ui/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
'use strict';

const VersionChecker = require('ember-cli-version-checker');

module.exports = {
name: require('./package').name,

// When running ember-try on Ember < 3.13, colocation support is
// disabled in ember-cli-htmlbars and causes a build error. When
// running ember-try, we actually don't care about the "app" side
// at all – all we do is run the ember_debug tests (via a --filter
// option to ember test in the ember-try config). The only reason
// we are even building the app is to get the test harness (qunit
// and friends) to work. In the long run, we should split up the
// build and not run the app build in ember-try, but in the mean
// time, this drops all the addon files (since we don't need them)
// to avoid the problem. The app will of course not work correctly
// at runtime, but it was never meant to work on old ember versions
// in the first place.
treeForAddon() {
let checker = new VersionChecker(this.project);
let emberChecker = checker.forEmber();

if (emberChecker.gte('3.13.0') ) {
return this._super.treeForAddon.apply(this, arguments);
} else {
return null;
}
},

isDevelopingAddon() {
return true;
}
Expand Down
1 change: 1 addition & 0 deletions lib/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"ember-cli-babel": "*",
"ember-cli-htmlbars": "*",
"ember-cli-sass": "*",
"ember-cli-version-checker": "*",
"ember-svg-jar": "*"
}
}

0 comments on commit 8861e83

Please sign in to comment.