From f33b729678f0fdecc7442c820d70f986577e9849 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Thu, 22 Mar 2018 14:46:19 +0100 Subject: [PATCH] Add support for importing from `ember-cli-htmlbars-inline-precompile` --- lib/ast-plugins.js | 3 ++- package.json | 2 +- tests/unit/components/inline-precompilation-test.js | 7 +++++++ yarn.lock | 6 +++--- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/ast-plugins.js b/lib/ast-plugins.js index e5827465..127b9ca1 100644 --- a/lib/ast-plugins.js +++ b/lib/ast-plugins.js @@ -49,7 +49,8 @@ module.exports = { precompile.baseDir = () => path.resolve(__dirname, '..'); precompile.cacheKey = () => cacheKey; - precompileInlineHTMLBarsPlugin = [HTMLBarsInlinePrecompilePlugin, { precompile }]; + let modulePaths = ['ember-cli-htmlbars-inline-precompile', 'htmlbars-inline-precompile']; + precompileInlineHTMLBarsPlugin = [HTMLBarsInlinePrecompilePlugin, { precompile, modulePaths }]; pluginCache[cacheKey] = precompileInlineHTMLBarsPlugin; } diff --git a/package.json b/package.json index 90eac792..af1e2f50 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "ember-cli" ], "dependencies": { - "babel-plugin-htmlbars-inline-precompile": "^0.2.3", + "babel-plugin-htmlbars-inline-precompile": "^0.2.4", "ember-cli-version-checker": "^2.0.0", "hash-for-dep": "^1.0.2", "heimdalljs-logger": "^0.1.7", diff --git a/tests/unit/components/inline-precompilation-test.js b/tests/unit/components/inline-precompilation-test.js index 2d9ec496..5fac064e 100644 --- a/tests/unit/components/inline-precompilation-test.js +++ b/tests/unit/components/inline-precompilation-test.js @@ -1,4 +1,5 @@ import hbs from 'htmlbars-inline-precompile'; +import hbs2 from 'ember-cli-htmlbars-inline-precompile'; import { moduleForComponent, test } from 'ember-qunit'; moduleForComponent('inline-precompilation', { @@ -10,3 +11,9 @@ test('using `hbs` tagged string places the precompiled template', function(asser assert.equal(this.$().text().trim(), "greeting: hello from view", "inline precompile of the HTMLBars template works"); }); + +test('using `hbs` tagged string from `ember-cli-htmlbars-inline-precompile` replaces the precompiled template', function(assert) { + this.render(hbs2`{{inline-precompilation}}`); + + assert.equal(this.$().text().trim(), "greeting: hello from view", "inline precompile of the HTMLBars template works"); +}); diff --git a/yarn.lock b/yarn.lock index d223e99c..8173c7c9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -486,9 +486,9 @@ babel-plugin-eval@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/babel-plugin-eval/-/babel-plugin-eval-1.0.1.tgz#a2faed25ce6be69ade4bfec263f70169195950da" -babel-plugin-htmlbars-inline-precompile@^0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/babel-plugin-htmlbars-inline-precompile/-/babel-plugin-htmlbars-inline-precompile-0.2.3.tgz#cd365e278af409bfa6be7704c4354beee742446b" +babel-plugin-htmlbars-inline-precompile@^0.2.4: + version "0.2.4" + resolved "https://registry.yarnpkg.com/babel-plugin-htmlbars-inline-precompile/-/babel-plugin-htmlbars-inline-precompile-0.2.4.tgz#54b48168432bbc03f1f26f2e9090cb222bc78c75" babel-plugin-inline-environment-variables@^1.0.1: version "1.0.1"