rollup-plugin-auto-external
Advanced tools
Comparing version 2.0.0 to 3.0.0-alpha.0
36
index.js
const getBuiltins = require('builtins'); | ||
const path = require('path'); | ||
const readPkg = require('read-pkg'); | ||
@@ -29,19 +30,30 @@ const safeResolve = require('safe-resolve'); | ||
let external = ids; | ||
ids = ids.map(safeResolve).filter(Boolean); | ||
if (typeof opts.external === 'function') { | ||
external = id => | ||
opts.external(id) || | ||
ids | ||
.map(safeResolve) | ||
.filter(Boolean) | ||
.includes(id); | ||
} | ||
const external = id => { | ||
if (typeof opts.external === 'function' && opts.external(id)) { | ||
return true; | ||
} | ||
if (Array.isArray(opts.external)) { | ||
external = Array.from(new Set(opts.external.concat(ids))); | ||
} | ||
if (Array.isArray(opts.external) && opts.external.includes(id)) { | ||
return true; | ||
} | ||
/** | ||
* The `id` argument is a resolved path if `rollup-plugin-node-resolve` | ||
* and `rollup-plugin-commonjs` are included. | ||
*/ | ||
const resolvedPath = safeResolve(id); | ||
if (resolvedPath === null) { | ||
return false; | ||
} | ||
const resolvedDirname = path.dirname(resolvedPath); | ||
return ids.some(idx => resolvedDirname.startsWith(path.dirname(idx))); | ||
}; | ||
return Object.assign({}, opts, { external }); | ||
}, | ||
}); |
{ | ||
"name": "rollup-plugin-auto-external", | ||
"version": "2.0.0", | ||
"version": "3.0.0-alpha.0", | ||
"description": "Rollup plugin to automatically exclude package.json dependencies and peerDependencies from your bundle", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"prepublishOnly": "npm test", | ||
"test": "$(npm bin)/jest" | ||
"test": "$(npm bin)/jest --modulePaths=__fixtures__/node_modules" | ||
}, | ||
@@ -30,3 +30,7 @@ "keywords": [ | ||
"devDependencies": { | ||
"jest": "^20.0.4" | ||
"jest": "^24.1.0", | ||
"rollup": "^1.3.2", | ||
"rollup-plugin-node-resolve": "^4.0.1", | ||
"rollup-plugin-commonjs": "^9.2.1", | ||
"rollup-plugin-node-builtins": "^2.1.2" | ||
}, | ||
@@ -40,3 +44,3 @@ "peerDependencies": { | ||
"safe-resolve": "^1.0.0", | ||
"semver": "^5.5.0" | ||
"semver": "^5.6.0" | ||
}, | ||
@@ -43,0 +47,0 @@ "files": [ |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
6095
46
5
1
Updatedsemver@^5.6.0