Skip to content
This repository was archived by the owner on Dec 4, 2022. It is now read-only.

Commit fbbac5c

Browse files
author
David First
committed
bug fix - components that require dependencies with custom binding prefix were not recognized
1 parent 492fda0 commit fbbac5c

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [unreleased]
99

10+
11+
## [0.10.7-dev.6] - 2017-11-22
12+
13+
- bug fix - components that require dependencies with custom binding prefix were not recognized
14+
1015
## [0.10.7-dev.3] - 2017-11-17
1116

1217
- improve stability and performance of resolving dependencies
@@ -17,7 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1722

1823
## [0.10.7-dev.1] - 2017-11-13
1924

20-
- stylable support
25+
- Stylable support
2126

2227
## [0.10.6] - 2017-11-12
2328

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bit-javascript",
3-
"version": "0.10.7-dev.5",
3+
"version": "0.10.7-dev.6",
44
"scripts": {
55
"flow": "flow; test $? -eq 0 -o $? -eq 2",
66
"lint": "eslint src && flow check || true",

src/dependency-builder/build-tree.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -186,17 +186,6 @@ function groupDependencyTree(tree, cwd, bindingPrefix) {
186186
return result;
187187
}
188188

189-
/**
190-
* Group missing dependencies by types (files, bits, packages)
191-
* @param {Array} missing list of missing paths to group
192-
* @returns {Function} function which group the dependencies
193-
*/
194-
const byPathType = R.groupBy((missing) => {
195-
return missing.startsWith('bit/') ? 'bits' :
196-
missing.startsWith('.') ? 'files' :
197-
'packages';
198-
});
199-
200189
/**
201190
* Get an import statement path to node package and return the package name
202191
*
@@ -244,10 +233,23 @@ function resolveModulePath(nmPath, workingDir, root) {
244233
* to object with missing types
245234
*
246235
* @param {Array} missing
236+
* @param {string} cwd
237+
* @param {string} consumerPath
238+
* @param {string} bindingPrefix
247239
* @returns new object with grouped missing
248240
*/
249-
function groupMissing(missing, cwd, consumerPath) {
250-
const groups = byPathType(missing);
241+
function groupMissing(missing, cwd, consumerPath, bindingPrefix) {
242+
/**
243+
* Group missing dependencies by types (files, bits, packages)
244+
* @param {Array} missing list of missing paths to group
245+
* @returns {Function} function which group the dependencies
246+
*/
247+
const byPathType = R.groupBy((missing) => {
248+
return missing.startsWith(`${bindingPrefix}/`) ? 'bits' :
249+
missing.startsWith('.') ? 'files' :
250+
'packages';
251+
});
252+
const groups = byPathType(missing, bindingPrefix);
251253
const packages = groups.packages ? groups.packages.map(resolvePackageNameByPath) : [];
252254
// This is a hack to solve problems that madge has with packages for type script files
253255
// It see them as missing even if they are exists
@@ -370,7 +372,7 @@ export default async function getDependencyTree(baseDir: string, consumerPath: s
370372
Promise<{ missing: Object, tree: Tree}> {
371373
const config = { baseDir, includeNpm: true, requireConfig: null, webpackConfig: null, visited: {}, nonExistent: [] };
372374
const result = generateTree(filePaths, config);
373-
const { groups, foundPackages } = groupMissing(result.skipped, baseDir, consumerPath);
375+
const { groups, foundPackages } = groupMissing(result.skipped, baseDir, consumerPath, bindingPrefix);
374376
const tree: Tree = groupDependencyTree(result.tree, baseDir, bindingPrefix);
375377
const relativeFilePaths = filePaths.map(filePath => path.relative(baseDir, filePath));
376378
// Merge manually found packages with madge founded packages

0 commit comments

Comments
 (0)