babel-plugin-htmlbars-inline-precompile
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -51,2 +51,76 @@ 'use strict'; | ||
it('passes through isProduction option when used as a call expression', function () { | ||
let source = 'hello'; | ||
plugins = [ | ||
[ | ||
HTMLBarsInlinePrecompile, | ||
{ | ||
precompile() { | ||
return precompile.apply(this, arguments); | ||
}, | ||
isProduction: true, | ||
}, | ||
], | ||
]; | ||
transform(`import hbs from 'htmlbars-inline-precompile';\nvar compiled = hbs('${source}');`); | ||
expect(optionsReceived).toEqual({ | ||
contents: source, | ||
isProduction: true, | ||
}); | ||
}); | ||
it('uses the user provided isProduction option if present', function () { | ||
let source = 'hello'; | ||
plugins = [ | ||
[ | ||
HTMLBarsInlinePrecompile, | ||
{ | ||
precompile() { | ||
return precompile.apply(this, arguments); | ||
}, | ||
isProduction: false, | ||
}, | ||
], | ||
]; | ||
transform( | ||
`import hbs from 'htmlbars-inline-precompile';\nvar compiled = hbs('${source}', { isProduction: true });` | ||
); | ||
expect(optionsReceived).toEqual({ | ||
contents: source, | ||
isProduction: true, | ||
}); | ||
}); | ||
it('passes through isProduction option when used as a TaggedTemplateExpression', function () { | ||
let source = 'hello'; | ||
plugins = [ | ||
[ | ||
HTMLBarsInlinePrecompile, | ||
{ | ||
precompile() { | ||
return precompile.apply(this, arguments); | ||
}, | ||
isProduction: true, | ||
}, | ||
], | ||
]; | ||
transform(`import hbs from 'htmlbars-inline-precompile';\nvar compiled = hbs\`${source}\`;`); | ||
expect(optionsReceived).toEqual({ | ||
contents: source, | ||
isProduction: true, | ||
}); | ||
}); | ||
it('allows static userland options when used as a call expression', function() { | ||
@@ -53,0 +127,0 @@ let source = 'hello'; |
@@ -0,1 +1,3 @@ | ||
* Adds `isProduction` option and pass through to `ember-template-compiler` (4619772) | ||
## v3.1.0 (2020-05-06) | ||
@@ -2,0 +4,0 @@ |
12
index.js
@@ -194,3 +194,5 @@ 'use strict'; | ||
path.replaceWith(compileTemplate(state.opts.precompile, template)); | ||
let { precompile, isProduction } = state.opts; | ||
path.replaceWith(compileTemplate(precompile, template, { isProduction })); | ||
}, | ||
@@ -223,2 +225,3 @@ | ||
case 1: | ||
options = {}; | ||
break; | ||
@@ -243,4 +246,9 @@ case 2: { | ||
let { precompile } = state.opts; | ||
let { precompile, isProduction } = state.opts; | ||
// allow the user specified value to "win" over ours | ||
if (!('isProduction' in options)) { | ||
options.isProduction = isProduction; | ||
} | ||
path.replaceWith(compileTemplate(precompile, template.value, options)); | ||
@@ -247,0 +255,0 @@ }, |
{ | ||
"name": "babel-plugin-htmlbars-inline-precompile", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "Babel plugin to replace tagged template strings with precompiled HTMLBars templates", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/ember-cli/babel-plugin-htmlbars-inline-precompile", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40566
580