Skip to content

Commit 87c8886

Browse files
author
Robert Jackson
committed
Remove Bower support.
Retrieving `ember-template-compiler` from `bower_components` is only required when using Ember versions older than 2.12. Bower itself is essentially deprecated, this removes the fallback code to use `bower_components/ember/ember-template-compiler.js` and improves the error message when we can't actually find `ember-source`. You can still provide a custom path to the template compiler (and therefore use Bower if you wish) by: ```js // ember-cli-build.js module.exports = function(defaults) { let app = new EmberApp(defaults, { 'ember-cli-htmlbars': { templateCompilerPath: `some_path/to/ember-template-compiler.js`, } }); }; ```
1 parent 7026bb0 commit 87c8886

File tree

4 files changed

+36
-14
lines changed

4 files changed

+36
-14
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,23 @@ await render(hbs`
125125

126126
There is a [codemod](https://github.com/ember-codemods/ember-cli-htmlbars-inline-precompile-codemod) available to automate this change.
127127

128+
### Custom Template Compiler
129+
130+
You can still provide a custom path to the template compiler (e.g. to test
131+
custom template compiler tweaks in an application) by:
132+
133+
```js
134+
// ember-cli-build.js
135+
136+
module.exports = function(defaults) {
137+
let app = new EmberApp(defaults, {
138+
'ember-cli-htmlbars': {
139+
templateCompilerPath: `some_path/to/ember-template-compiler.js`,
140+
}
141+
});
142+
};
143+
```
144+
128145
### Handlebars 2.0 Support (Ember < 1.10)
129146

130147
Handlebars 2.0 support has been removed. If you are using ember-cli-htmlbars with a 1.9.x project please continue

lib/ember-addon-main.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const path = require('path');
3+
const SilentError = require('silent-error');
44
const utils = require('./utils');
55

66
let registryInvocationCounter = 0;
@@ -191,20 +191,18 @@ module.exports = {
191191
let templateCompilerPath =
192192
config['ember-cli-htmlbars'] && config['ember-cli-htmlbars'].templateCompilerPath;
193193

194-
let ember = this.project.findAddonByName('ember-source');
195-
if (ember) {
196-
return ember.absolutePaths.templateCompiler;
197-
} else if (!templateCompilerPath) {
198-
templateCompilerPath = this.project.bowerDirectory + '/ember/ember-template-compiler';
194+
if (templateCompilerPath) {
195+
return templateCompilerPath;
199196
}
200197

201-
let absolutePath = path.resolve(this.project.root, templateCompilerPath);
202-
203-
if (path.extname(absolutePath) === '') {
204-
absolutePath += '.js';
198+
let ember = this.project.findAddonByName('ember-source');
199+
if (!ember) {
200+
throw new SilentError(
201+
`ember-cli-htmlbars: Cannot find the ember-source addon as part of the project, please ensure that 'ember-source' is in your projects dependencies or devDependencies`
202+
);
205203
}
206204

207-
return absolutePath;
205+
return ember.absolutePaths.templateCompiler;
208206
},
209207

210208
htmlbarsOptions() {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"heimdalljs-logger": "^0.1.10",
4545
"json-stable-stringify": "^1.0.1",
4646
"semver": "^6.3.0",
47+
"silent-error": "^1.1.1",
4748
"strip-bom": "^4.0.0",
4849
"walk-sync": "^2.0.2"
4950
},

yarn.lock

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7072,9 +7072,8 @@ mocha@^7.1.1:
70727072
yargs-unparser "1.6.0"
70737073

70747074
"module-name-inliner@link:./tests/dummy/lib/module-name-inliner":
7075-
version "0.1.0"
7076-
dependencies:
7077-
ember-cli-version-checker "*"
7075+
version "0.0.0"
7076+
uid ""
70787077

70797078
morgan@^1.9.1:
70807079
version "1.9.1"
@@ -8402,6 +8401,13 @@ resolve@^1.1.3, resolve@^1.1.6, resolve@^1.10.0, resolve@^1.10.1, resolve@^1.11.
84028401
dependencies:
84038402
path-parse "^1.0.6"
84048403

8404+
resolve@^1.13.1:
8405+
version "1.15.1"
8406+
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.15.1.tgz#27bdcdeffeaf2d6244b95bb0f9f4b4653451f3e8"
8407+
integrity sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w==
8408+
dependencies:
8409+
path-parse "^1.0.6"
8410+
84058411
responselike@1.0.2, responselike@^1.0.2:
84068412
version "1.0.2"
84078413
resolved "https://registry.yarnpkg.com/responselike/-/responselike-1.0.2.tgz#918720ef3b631c5642be068f15ade5a46f4ba1e7"

0 commit comments

Comments
 (0)