Skip to content

Commit

Permalink
fix(bootstrap): Omit local bundled dependencies (#1805)
Browse files Browse the repository at this point in the history
Fixes #1775
  • Loading branch information
tanhauhau authored and evocateur committed Dec 6, 2018
1 parent 25572af commit 8f5bdbb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
24 changes: 23 additions & 1 deletion utils/npm-install/__tests__/npm-install.test.js
Expand Up @@ -121,11 +121,25 @@ describe("npm-install", () => {
exact: "1.0.0", // will be removed
"local-dev-dependency": "^1.0.0",
},
optionalDependencies: {
"@scoped/others": "1.0.0", // will be removed
caret: "^1.0.0",
"local-dependency": "^1.0.0",
},
bundledDependencies: ["local-dependency", "@scoped/exact", "others"],
bundleDependencies: ["local-dependency", "@scoped/exact", "others"],
},
path.normalize("/test/npm-install-deps")
);
const backupManifest = `${pkg.manifestLocation}.lerna_backup`;
const dependencies = ["@scoped/caret@^2.0.0", "@scoped/exact@2.0.0", "caret@^1.0.0", "exact@1.0.0"];
const dependencies = [
"@scoped/caret@^2.0.0",
"@scoped/exact@2.0.0",
"caret@^1.0.0",
"exact@1.0.0",
"@scoped/others@1.0.0",
"others@1.0.0",
];

await npmInstall.dependencies(pkg, dependencies, {});

Expand All @@ -144,6 +158,14 @@ describe("npm-install", () => {
caret: "^1.0.0",
// removed local-dev-dependency
},
optionalDependencies: {
"@scoped/others": "1.0.0",
// removed caret, local-dependency
},
bundledDependencies: [/* removed local-dependency */ "others"],
bundleDependencies: [
/* removed */
],
});
expect(ChildProcessUtilities.exec).toHaveBeenLastCalledWith("npm", ["install"], {
cwd: pkg.location,
Expand Down
14 changes: 14 additions & 0 deletions utils/npm-install/npm-install.js
Expand Up @@ -126,6 +126,20 @@ function transformManifest(pkg, dependencies) {
}
});

["bundledDependencies", "bundleDependencies"].forEach(depType => {
const collection = json[depType];
if (collection) {
const newCollection = [];
for (const depName of collection) {
if (depMap.has(depName)) {
newCollection.push(depName);
depMap.delete(depName);
}
}
json[depType] = newCollection;
}
});

// add all leftovers (root hoisted)
if (depMap.size) {
if (!json.dependencies) {
Expand Down

0 comments on commit 8f5bdbb

Please sign in to comment.