Support scoped packages as dependencies

This commit is contained in:
ahocevar
2019-01-11 18:16:23 +01:00
parent 138cc55b34
commit f0d3f80663

View File

@@ -100,7 +100,13 @@ function getDependencies(jsSource) {
if (importMatch) { if (importMatch) {
const imp = importMatch[1]; const imp = importMatch[1];
if (!imp.startsWith('ol/') && imp != 'ol') { if (!imp.startsWith('ol/') && imp != 'ol') {
const dep = imp.split('/')[0]; const parts = imp.split('/');
let dep;
if (imp.startsWith('@')) {
dep = parts.slice(0, 2).join('/');
} else {
dep = parts[0];
}
if (dep in pkg.devDependencies) { if (dep in pkg.devDependencies) {
dependencies[dep] = pkg.devDependencies[dep]; dependencies[dep] = pkg.devDependencies[dep];
} }