mendel-manifest-extract-bundles
Advanced tools
Comparing version 4.0.0-alpha.0 to 4.0.0-alpha.1
@@ -13,6 +13,6 @@ /* Copyright 2015, Yahoo Inc. | ||
var fromFiles = function() { | ||
var fromFiles = function () { | ||
return Object.keys(fromManifest.indexes); | ||
}; | ||
var externalFiles = function() { | ||
var externalFiles = function () { | ||
return Object.keys(externalManifest.indexes); | ||
@@ -22,13 +22,17 @@ }; | ||
// Modules that are exposed on "external" should be removed from main | ||
filterFilesFromManifest(fromManifest, function(file) { | ||
var modIndex = externalFiles().indexOf(file); | ||
var isExposedOnExternalBundle = false; | ||
if (-1 !== modIndex) { | ||
var externalMod = externalManifest.bundles[modIndex]; | ||
if (externalMod.expose) { | ||
isExposedOnExternalBundle = true; | ||
filterFilesFromManifest( | ||
fromManifest, | ||
function (file) { | ||
var modIndex = externalFiles().indexOf(file); | ||
var isExposedOnExternalBundle = false; | ||
if (-1 !== modIndex) { | ||
var externalMod = externalManifest.bundles[modIndex]; | ||
if (externalMod.expose) { | ||
isExposedOnExternalBundle = true; | ||
} | ||
} | ||
} | ||
return !isExposedOnExternalBundle; | ||
}, options.from); | ||
return !isExposedOnExternalBundle; | ||
}, | ||
options.from | ||
); | ||
@@ -40,9 +44,13 @@ // Cleanup potetial sub-dependencies of removed files | ||
var removedFromExternal = []; | ||
filterFilesFromManifest(externalManifest, function(file) { | ||
if (fromFiles().indexOf(file) >= 1) { | ||
removedFromExternal.push(file); | ||
return false; | ||
} | ||
return true; | ||
}, options.external); | ||
filterFilesFromManifest( | ||
externalManifest, | ||
function (file) { | ||
if (fromFiles().indexOf(file) >= 1) { | ||
removedFromExternal.push(file); | ||
return false; | ||
} | ||
return true; | ||
}, | ||
options.external | ||
); | ||
@@ -54,3 +62,3 @@ // Cleanup potetial sub-dependencies of removed files | ||
// should be exposed on main | ||
fromFiles().forEach(function(file) { | ||
fromFiles().forEach(function (file) { | ||
var moduleIndex = fromManifest.indexes[file]; | ||
@@ -60,3 +68,3 @@ var bundle = fromManifest.bundles[moduleIndex]; | ||
bundle.expose = bundle.id; | ||
bundle.variations.forEach(function(variation, index) { | ||
bundle.variations.forEach(function (variation, index) { | ||
bundle.data[index].expose = bundle.id; | ||
@@ -68,10 +76,18 @@ }); | ||
debug([ | ||
fromFiles().length, 'files remaining in', | ||
options.from, 'after extraction', | ||
].join(' ')); | ||
debug([ | ||
externalFiles().length, 'files remaining in', | ||
options.external, 'after extraction', | ||
].join(' ')); | ||
debug( | ||
[ | ||
fromFiles().length, | ||
'files remaining in', | ||
options.from, | ||
'after extraction', | ||
].join(' ') | ||
); | ||
debug( | ||
[ | ||
externalFiles().length, | ||
'files remaining in', | ||
options.external, | ||
'after extraction', | ||
].join(' ') | ||
); | ||
@@ -89,4 +105,6 @@ next(manifests); | ||
var removedFiles = []; | ||
manifest.indexes = Object.keys(manifest.indexes) | ||
.reduce(function(indexes, file) { | ||
manifest.indexes = Object.keys(manifest.indexes).reduce(function ( | ||
indexes, | ||
file | ||
) { | ||
if (selector(file)) { | ||
@@ -103,8 +121,8 @@ indexes[file] = manifest.indexes[file]; | ||
// the dep as external | ||
Object.keys(manifest.indexes).forEach(function(file) { | ||
Object.keys(manifest.indexes).forEach(function (file) { | ||
var bundle = manifest.bundles[manifest.indexes[file]]; | ||
bundle.data.forEach(function(module) { | ||
Object.keys(module.deps).forEach(function(key) { | ||
bundle.data.forEach(function (module) { | ||
Object.keys(module.deps).forEach(function (key) { | ||
var value = module.deps[key]; | ||
if (removedFiles.indexOf(value) >=0) { | ||
if (removedFiles.indexOf(value) >= 0) { | ||
module.deps[key] = false; | ||
@@ -124,3 +142,3 @@ } | ||
// hashtable for number of time a bundle was visited | ||
var visitedIndexes = originalIndexes.reduce(function(indexes, file) { | ||
var visitedIndexes = originalIndexes.reduce(function (indexes, file) { | ||
indexes[file] = false; | ||
@@ -138,6 +156,6 @@ return indexes; | ||
var bundle = manifest.bundles[manifest.indexes[file]]; | ||
bundle.data.forEach(function(module) { | ||
Object.keys(module.deps).forEach(function(key) { | ||
bundle.data.forEach(function (module) { | ||
Object.keys(module.deps).forEach(function (key) { | ||
var value = module.deps[key]; | ||
if (visitedIndexes.hasOwnProperty(value)) { | ||
if (Object.hasOwn(visitedIndexes, value)) { | ||
visitBundle(value); | ||
@@ -150,3 +168,3 @@ } | ||
// start visiting from entries and exposed | ||
originalIndexes.forEach(function(file) { | ||
originalIndexes.forEach(function (file) { | ||
var bundle = manifest.bundles[manifest.indexes[file]]; | ||
@@ -158,6 +176,9 @@ if (bundle.expose || bundle.entry) { | ||
filterFilesFromManifest(manifest, function(file) { | ||
return visitedIndexes.hasOwnProperty(file) && visitedIndexes[file]; | ||
}, logName); | ||
filterFilesFromManifest( | ||
manifest, | ||
function (file) { | ||
return Object.hasOwn(visitedIndexes, file) && visitedIndexes[file]; | ||
}, | ||
logName | ||
); | ||
} | ||
{ | ||
"name": "mendel-manifest-extract-bundles", | ||
"version": "4.0.0-alpha.0", | ||
"version": "4.0.0-alpha.1", | ||
"description": "Parses a list of manifests, extract common dependencies and expose them from the parent bundle.", | ||
"main": "manifest-extract.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [ | ||
@@ -14,2 +11,5 @@ "mendel", | ||
], | ||
"scripts": { | ||
"test": "tap test/*.js --coverage-map=../../.tap.coverage.map.js --no-check-coverage" | ||
}, | ||
"author": "Irae Carvalho <irae@irae.pro.br>", | ||
@@ -19,9 +19,13 @@ "license": "MIT", | ||
"type": "git", | ||
"url": "https://github.com/yahoo/mendel" | ||
"url": "https://github.com/considerinc/mendel" | ||
}, | ||
"dependencies": { | ||
"debug": "^4.3.4", | ||
"mendel-development": "^4.0.0-alpha.0" | ||
"mendel-development": "^4.0.0-alpha.1" | ||
}, | ||
"gitHead": "e91812ab9f13c60d431be5ce5e024d3a68073f42" | ||
"devDependencies": { | ||
"tap": "^16.3.8", | ||
"tmp": "^0.2.1" | ||
}, | ||
"gitHead": "6e24d114f4ff273753654df1aa5e6c124f626e25" | ||
} |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
23811
9
239
2
2
3