mendel-development
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -7,25 +7,24 @@ /* Copyright 2015, Yahoo Inc. | ||
var isRequire = require('./falafel-util').isRequire; | ||
var variationMatches = require('./variation-matches'); | ||
var regexExt = /(\.js|\.coffee|\.coffee.md|\.litcoffee|\.jsx|\.es|\.es6)$/; | ||
function mendelifyRequireTransform(filename, src, variations) { | ||
var opts = { | ||
ecmaVersion: 6, | ||
allowReturnOutsideFunction: true | ||
}; | ||
if (!regexExt.test(filename)) { | ||
return src; | ||
} | ||
return falafel(src, opts, function (node) { | ||
if (isRequire(node)) { | ||
var value = node.arguments[0].value; | ||
var match = variationMatches(variations, value); | ||
if (match) { | ||
if(match) node.update('require(\'' + match.file + '\')'); | ||
} | ||
function mendelifyRequireTransform(filename, src, transformerFn) { | ||
var opts = { | ||
ecmaVersion: 6, | ||
allowReturnOutsideFunction: true | ||
}; | ||
if (!regexExt.test(filename)) { | ||
return src; | ||
} | ||
}).toString(); | ||
return falafel(src, opts, function(node) { | ||
if (isRequire(node)) { | ||
var value = node.arguments[0].value; | ||
var newValue = transformerFn(value); | ||
if (newValue !== value) { | ||
node.update('require(\'' + newValue + '\')'); | ||
} | ||
} | ||
}).toString(); | ||
} | ||
module.exports = mendelifyRequireTransform; |
@@ -45,3 +45,3 @@ /* Copyright 2015, Yahoo Inc. | ||
if (!avoidMendelify(value) || shouldExternalize(externals, key)) { | ||
newKey = pathOrVariationMatch(key, variations); | ||
newKey = keyValue(key, variations, bundle); | ||
} | ||
@@ -55,3 +55,9 @@ | ||
if (!avoidMendelifyRow) { | ||
row.source = mendelifyRequireTransform(row.file, row.source, variations); | ||
row.source = mendelifyRequireTransform( | ||
row.file, | ||
row.source, | ||
function(requirePath) { | ||
return keyValue(requirePath, variations, bundle); | ||
} | ||
); | ||
} | ||
@@ -65,2 +71,6 @@ row.sha = shasum(row.source); | ||
function keyValue(key, variations, bundle) { | ||
return relativePath(pathOrVariationMatch(key, variations), bundle); | ||
} | ||
function avoidMendelify(file) { | ||
@@ -67,0 +77,0 @@ var isExternal = file === false; |
{ | ||
"name": "mendel-development", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Mendel shared dependencies for build and development", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
16253
440