@christiango/unbarrel 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ export interface BarrelFileReference {
3
3
  barrelFilePath: string;
4
4
  }
5
5
  /**
6
- * Analyzes the exports of the provided file and returns any references to barrel files.
6
+ * Analyzes the exports of the provided file and returns any references to barrel files within the current package. External packages are not included.
7
7
  * @param absoluteFilePath The absolute path the the file we will analyze
8
8
  * @returns An array of barrel file references found in the file
9
9
  */
@@ -1 +1 @@
1
- {"version":3,"file":"getBarrelFileReferencesInFile.d.ts","sourceRoot":"","sources":["../src/getBarrelFileReferencesInFile.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,mBAAmB;IAClC,0DAA0D;IAC1D,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,gBAAgB,EAAE,MAAM,GAAG,mBAAmB,EAAE,CA4B7F"}
1
+ {"version":3,"file":"getBarrelFileReferencesInFile.d.ts","sourceRoot":"","sources":["../src/getBarrelFileReferencesInFile.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,mBAAmB;IAClC,0DAA0D;IAC1D,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,gBAAgB,EAAE,MAAM,GAAG,mBAAmB,EAAE,CA6B7F"}
@@ -9,7 +9,7 @@ const node_path_1 = __importDefault(require("node:path"));
9
9
  const resolveModulePath_1 = require("./resolveModulePath");
10
10
  const importUtils_1 = require("./importUtils");
11
11
  /**
12
- * Analyzes the exports of the provided file and returns any references to barrel files.
12
+ * Analyzes the exports of the provided file and returns any references to barrel files within the current package. External packages are not included.
13
13
  * @param absoluteFilePath The absolute path the the file we will analyze
14
14
  * @returns An array of barrel file references found in the file
15
15
  */
@@ -17,20 +17,18 @@ function getBarrelFileReferencesInFile(absoluteFilePath) {
17
17
  const result = [];
18
18
  const exports = (0, getExportsFromModule_1.getExportsFromModule)(absoluteFilePath);
19
19
  for (const reExportToVisit of exports.reExports) {
20
+ // Only consider internal modules (relative paths)
20
21
  if ((0, importUtils_1.isInternalModule)(reExportToVisit.importPath)) {
21
22
  const potentialBarrelFilePath = (0, resolveModulePath_1.resolveModulePath)(node_path_1.default.resolve(node_path_1.default.dirname(absoluteFilePath), reExportToVisit.importPath));
22
23
  const exportsFromPotentialBarrel = (0, getExportsFromModule_1.getExportsFromModule)(potentialBarrelFilePath);
23
- if (exportsFromPotentialBarrel.reExports.length > 0) {
24
+ if (exportsFromPotentialBarrel.reExports.length > 0 &&
25
+ // Don't consider re-exports from external packages a barrel file reference
26
+ exportsFromPotentialBarrel.reExports.filter((e) => (0, importUtils_1.isInternalModule)(e.importPath)).length > 0) {
24
27
  result.push({
25
28
  barrelFilePath: (0, importUtils_1.convertAbsolutePathToRelativeImportPath)(potentialBarrelFilePath, node_path_1.default.dirname(absoluteFilePath)),
26
29
  });
27
30
  }
28
31
  }
29
- else {
30
- result.push({
31
- barrelFilePath: reExportToVisit.importPath,
32
- });
33
- }
34
32
  }
35
33
  return result;
36
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getBarrelFileReferencesInFile.js","sourceRoot":"","sources":["../src/getBarrelFileReferencesInFile.ts"],"names":[],"mappings":";;;;;AAeA,sEA4BC;AA3CD,iEAA8D;AAC9D,0DAA6B;AAC7B,2DAAwD;AACxD,+CAA0F;AAO1F;;;;GAIG;AACH,SAAgB,6BAA6B,CAAC,gBAAwB;IACpE,MAAM,MAAM,GAA0B,EAAE,CAAC;IAEzC,MAAM,OAAO,GAAG,IAAA,2CAAoB,EAAC,gBAAgB,CAAC,CAAC;IAEvD,KAAK,MAAM,eAAe,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QAChD,IAAI,IAAA,8BAAgB,EAAC,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC;YACjD,MAAM,uBAAuB,GAAG,IAAA,qCAAiB,EA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,2CAAoB,EAAC,uBAAuB,CAAC,CAAC;YAEjF,IACE,0BAA0B,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC;gBAC/C,2EAA2E;gBAC3E,0BAA0B,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,8BAAgB,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,EAC7F,CAAC;gBACD,MAAM,CAAC,IAAI,CAAC;oBACV,cAAc,EAAE,IAAA,qDAAuC,EACrD,uBAAuB,EACvB,mBAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAC/B;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@christiango/unbarrel",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Utilities for optimizing barrel files",
5
5
  "main": "lib/index.js",
6
6
  "bin": {