babel-plugin-htmlbars-inline-precompile
Advanced tools
Comparing version 0.0.5 to 0.1.0
22
index.js
@@ -1,3 +0,5 @@ | ||
module.exports = function(precompile) { | ||
return function(babel) { | ||
module.exports = function(precompile, _options) { | ||
var options = _options || {}; | ||
function htmlbarsInlineCompilerPlugin(babel) { | ||
var t = babel.types; | ||
@@ -76,2 +78,18 @@ | ||
} | ||
// used by broccoli-babel-transpiler to use this packages | ||
// files and deps as part of the cache key (when deps or | ||
// implementation changes it will bust the cache for already | ||
// transpiled files) | ||
htmlbarsInlineCompilerPlugin.baseDir = function() { | ||
return __dirname; | ||
}; | ||
// used by broccoli-babel-transpiler to bust the cache when | ||
// the template compiler being used changes | ||
htmlbarsInlineCompilerPlugin.cacheKey = function() { | ||
return options.cacheKey; | ||
}; | ||
return htmlbarsInlineCompilerPlugin; | ||
}; |
{ | ||
"name": "babel-plugin-htmlbars-inline-precompile", | ||
"version": "0.0.5", | ||
"version": "0.1.0", | ||
"description": "Babel plugin to replace tagged template strings with precompiled HTMLBars templates", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -69,3 +69,5 @@ # babel-plugin-htmlbars-inline-precompile [![Build Status](https://travis-ci.org/pangratz/babel-plugin-htmlbars-inline-precompile.svg?branch=master)](https://travis-ci.org/pangratz/babel-plugin-htmlbars-inline-precompile) | ||
var pluginConfiguredWithCompiler = HTMLBarsInlinePrecompile(HTMLBarsCompiler.precompile); | ||
var pluginConfiguredWithCompiler = HTMLBarsInlinePrecompile(HTMLBarsCompiler.precompile, { | ||
cacheKey: checksumOfTemplateCompilerContents | ||
}); | ||
@@ -76,1 +78,3 @@ require('babel').transform("code", { | ||
``` | ||
The provided `cacheKey` option is used to invalidate the broccoli-babel-transpiler cache. |
var assert = require('assert'); | ||
var path = require('path'); | ||
@@ -62,2 +63,16 @@ var babel = require('babel-core'); | ||
describe('caching', function() { | ||
it('passes through second argument as `cacheKey`', function() { | ||
var plugin = HTMLBarsInlinePrecompile(function() {}, { cacheKey: 'asdfasdf' }); | ||
assert.equal(plugin.cacheKey(), 'asdfasdf'); | ||
}); | ||
it('include `baseDir` function for caching', function() { | ||
var plugin = HTMLBarsInlinePrecompile(function() {}, 'asdfasdf'); | ||
assert.equal(plugin.baseDir(), path.resolve(__dirname, '..')); | ||
}); | ||
}); | ||
describe('single string argument', function() { | ||
@@ -64,0 +79,0 @@ it("works with a plain string as parameter hbs('string')", function() { |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
11287
160
79
1