debowerify
Advanced tools
Comparing version 1.3.1 to 1.4.0
17
index.js
@@ -103,2 +103,7 @@ var bower = require('bower'); | ||
var preferNPM = (typeof options.preferNPM === 'boolean') ? options.preferNPM : | ||
(typeof options.preferNPM === 'object' && options.preferNPM.length && options.preferNPM.indexOf(moduleName) !== -1); | ||
if(preferNPM && nodeCanResolve(moduleName)) return; | ||
var module = getModule(moduleName); | ||
@@ -145,5 +150,5 @@ if (!module) return; | ||
} | ||
paths.forEach(function (p) { | ||
paths.forEach(function (p, i) { | ||
var st = '\nrequire(' + p + ')' | ||
chunks[node.range[1] + 1] = st | ||
chunks[node.range[1] + (i + 1)] = st | ||
}) | ||
@@ -162,4 +167,12 @@ } | ||
function nodeCanResolve(moduleName) { | ||
try { | ||
return !!require.resolve(moduleName); | ||
} catch(e) { | ||
return false; | ||
} | ||
} | ||
return chunks.join(''); | ||
} | ||
}; |
{ | ||
"name": "debowerify", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "A browserify transform to enable the easy use of bower components in browserify client javascript projects. This can be used in conjunction with deamdify to require AMD components from bower as well.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -56,2 +56,8 @@ # debowerify | ||
## Options | ||
### preferNPM | ||
Set `preferNPM` option to `true`, or an array of module names, to have `debowerify` prefer NPM modules over bower components. This is useful for when you have a module that is installed both as a node module and as a bower component. | ||
# How to use with AMD components | ||
@@ -58,0 +64,0 @@ |
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
13736
154
132
1