babel-deps
Advanced tools
Comparing version 2.0.0 to 2.1.0
33
index.js
@@ -36,2 +36,16 @@ 'use strict'; | ||
function cacheFile(filePath, babel, contents, namespace) { | ||
if (!namespace) { | ||
return; | ||
} | ||
namespace = namespace === true ? 'default' : namespace; | ||
if (!cache[namespace]) { | ||
cache[namespace] = {}; | ||
} | ||
cache[namespace][filePath] = { | ||
babel: babel, | ||
contents: contents | ||
}; | ||
} | ||
function clearCache() { | ||
@@ -65,2 +79,10 @@ cache = {}; | ||
function getCached(filePath, namespace) { | ||
namespace = namespace === true ? 'default' : namespace; | ||
if (!namespace || !cache[namespace]) { | ||
return null; | ||
} | ||
return cache[namespace][filePath]; | ||
} | ||
function getFullPath(source, filename) { | ||
@@ -80,4 +102,4 @@ var fullPath = source; | ||
var cached = cache[filePath]; | ||
if (options.cache && cached && (!file.contents || cached.contents === file.contents)) { | ||
var cached = getCached(filePath, options.cache); | ||
if (cached && (!file.contents || cached.contents === file.contents)) { | ||
// We have the file on cache and its contents didn't change. | ||
@@ -98,8 +120,3 @@ return options.skipCachedFiles ? null : cached.babel; | ||
var result = babel.transform(file.contents, currOptions); | ||
if (options.cache) { | ||
cache[filePath] = { | ||
babel: result, | ||
contents: file.contents | ||
}; | ||
} | ||
cacheFile(filePath, result, file.contents, options.cache); | ||
return result; | ||
@@ -106,0 +123,0 @@ } |
{ | ||
"name": "babel-deps", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Compiles javascript files and all their dependencies with babel.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
6988
107