webpack-node-externals
Advanced tools
Comparing version 1.2.0 to 1.3.0
14
index.js
@@ -42,2 +42,10 @@ var fs = require("fs"); | ||
function getModuleName(request, modulesDir) { | ||
var req = request; | ||
// in case absolute, strip all parts before */modulesDir/ | ||
req = req.replace(/^\/.*?node_modules\//, ''); | ||
// return the module name | ||
return req.split('/')[0]; | ||
} | ||
module.exports = function nodeExternals(options) { | ||
@@ -57,8 +65,8 @@ options = options || {}; | ||
// create the node modules list | ||
var nodeModules = modulesFromFile ? readFromPackageJson(): readDir(modulesDir).filter(isNotBinary); | ||
var nodeModules = modulesFromFile ? readFromPackageJson() : readDir(modulesDir).filter(isNotBinary); | ||
// return an externals function | ||
return function(context, request, callback) { | ||
var pathStart = request.split('/')[0]; | ||
if (contains(nodeModules, pathStart) && !containsPattern(whitelist, request)) { | ||
var moduleName = getModuleName(request); | ||
if (contains(nodeModules, moduleName) && !containsPattern(whitelist, request)) { | ||
// mark this module as external | ||
@@ -65,0 +73,0 @@ // https://webpack.github.io/docs/configuration.html#externals |
{ | ||
"name": "webpack-node-externals", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Easily exclude node_modules in Webpack bundle", | ||
@@ -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
7989
66