@teambit/dependencies 1.0.330 → 1.0.331

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.
Files changed (276) hide show
  1. package/artifacts/__bit_junit.xml +203 -5
  2. package/artifacts/schema.json +2016 -1173
  3. package/dependencies-loader/apply-overrides.ts +3 -3
  4. package/dependencies-loader/auto-detect-deps.ts +16 -13
  5. package/dependencies-loader/dependencies-loader.ts +1 -1
  6. package/dist/dependencies-loader/apply-overrides.js +12 -5
  7. package/dist/dependencies-loader/apply-overrides.js.map +1 -1
  8. package/dist/dependencies-loader/auto-detect-deps.d.ts +4 -4
  9. package/dist/dependencies-loader/auto-detect-deps.js +14 -14
  10. package/dist/dependencies-loader/auto-detect-deps.js.map +1 -1
  11. package/dist/dependencies-loader/dependencies-loader.js +4 -4
  12. package/dist/dependencies-loader/dependencies-loader.js.map +1 -1
  13. package/dist/files-dependency-builder/build-tree.d.ts +11 -0
  14. package/dist/files-dependency-builder/build-tree.js +233 -0
  15. package/dist/files-dependency-builder/build-tree.js.map +1 -0
  16. package/dist/files-dependency-builder/build-tree.spec.d.ts +1 -0
  17. package/dist/files-dependency-builder/build-tree.spec.js +154 -0
  18. package/dist/files-dependency-builder/build-tree.spec.js.map +1 -0
  19. package/dist/files-dependency-builder/dependency-tree/Config.d.ts +4 -0
  20. package/dist/files-dependency-builder/dependency-tree/Config.js +74 -0
  21. package/dist/files-dependency-builder/dependency-tree/Config.js.map +1 -0
  22. package/dist/files-dependency-builder/dependency-tree/index.d.ts +15 -0
  23. package/dist/files-dependency-builder/dependency-tree/index.js +272 -0
  24. package/dist/files-dependency-builder/dependency-tree/index.js.map +1 -0
  25. package/dist/files-dependency-builder/dependency-tree/index.spec.d.ts +1 -0
  26. package/dist/files-dependency-builder/dependency-tree/index.spec.js +877 -0
  27. package/dist/files-dependency-builder/dependency-tree/index.spec.js.map +1 -0
  28. package/dist/files-dependency-builder/detectives/detective-css/index.d.ts +1 -0
  29. package/dist/files-dependency-builder/detectives/detective-css/index.js +18 -0
  30. package/dist/files-dependency-builder/detectives/detective-css/index.js.map +1 -0
  31. package/dist/files-dependency-builder/detectives/detective-es6/index.d.ts +1 -0
  32. package/dist/files-dependency-builder/detectives/detective-es6/index.js +18 -0
  33. package/dist/files-dependency-builder/detectives/detective-es6/index.js.map +1 -0
  34. package/dist/files-dependency-builder/detectives/detective-less/index.d.ts +1 -0
  35. package/dist/files-dependency-builder/detectives/detective-less/index.js +18 -0
  36. package/dist/files-dependency-builder/detectives/detective-less/index.js.map +1 -0
  37. package/dist/files-dependency-builder/detectives/detective-sass/index.d.ts +1 -0
  38. package/dist/files-dependency-builder/detectives/detective-sass/index.js +18 -0
  39. package/dist/files-dependency-builder/detectives/detective-sass/index.js.map +1 -0
  40. package/dist/files-dependency-builder/detectives/detective-scss/index.d.ts +1 -0
  41. package/dist/files-dependency-builder/detectives/detective-scss/index.js +18 -0
  42. package/dist/files-dependency-builder/detectives/detective-scss/index.js.map +1 -0
  43. package/dist/files-dependency-builder/detectives/detective-typescript/index.d.ts +1 -0
  44. package/dist/files-dependency-builder/detectives/detective-typescript/index.js +18 -0
  45. package/dist/files-dependency-builder/detectives/detective-typescript/index.js.map +1 -0
  46. package/dist/files-dependency-builder/detector-hook.d.ts +47 -0
  47. package/dist/files-dependency-builder/detector-hook.js +29 -0
  48. package/dist/files-dependency-builder/detector-hook.js.map +1 -0
  49. package/dist/files-dependency-builder/filing-cabinet/index.d.ts +17 -0
  50. package/dist/files-dependency-builder/filing-cabinet/index.js +140 -0
  51. package/dist/files-dependency-builder/filing-cabinet/index.js.map +1 -0
  52. package/dist/files-dependency-builder/filing-cabinet/index.spec.d.ts +1 -0
  53. package/dist/files-dependency-builder/filing-cabinet/index.spec.js +651 -0
  54. package/dist/files-dependency-builder/filing-cabinet/index.spec.js.map +1 -0
  55. package/dist/files-dependency-builder/fixtures/build-tree/a.d.ts +1 -0
  56. package/dist/files-dependency-builder/fixtures/build-tree/a.js +6 -0
  57. package/dist/files-dependency-builder/fixtures/build-tree/a.js.map +1 -0
  58. package/dist/files-dependency-builder/fixtures/build-tree/b.d.ts +1 -0
  59. package/dist/files-dependency-builder/fixtures/build-tree/b.js +6 -0
  60. package/dist/files-dependency-builder/fixtures/build-tree/b.js.map +1 -0
  61. package/dist/files-dependency-builder/fixtures/build-tree/not-link-file/file-a.d.ts +1 -0
  62. package/dist/files-dependency-builder/fixtures/build-tree/not-link-file/file-a.js +3 -0
  63. package/dist/files-dependency-builder/fixtures/build-tree/not-link-file/file-a.js.map +1 -0
  64. package/dist/files-dependency-builder/fixtures/build-tree/not-link-file/file-b.d.ts +1 -0
  65. package/dist/files-dependency-builder/fixtures/build-tree/not-link-file/file-b.js +3 -0
  66. package/dist/files-dependency-builder/fixtures/build-tree/not-link-file/file-b.js.map +1 -0
  67. package/dist/files-dependency-builder/fixtures/build-tree/not-link-file/file-c.d.ts +1 -0
  68. package/dist/files-dependency-builder/fixtures/build-tree/not-link-file/file-c.js +10 -0
  69. package/dist/files-dependency-builder/fixtures/build-tree/not-link-file/file-c.js.map +1 -0
  70. package/dist/files-dependency-builder/fixtures/build-tree/tree-shaking-cycle/foo.d.ts +1 -0
  71. package/dist/files-dependency-builder/fixtures/build-tree/tree-shaking-cycle/foo.js +3 -0
  72. package/dist/files-dependency-builder/fixtures/build-tree/tree-shaking-cycle/foo.js.map +1 -0
  73. package/dist/files-dependency-builder/fixtures/build-tree/tree-shaking-cycle/index.d.ts +1 -0
  74. package/dist/files-dependency-builder/fixtures/build-tree/tree-shaking-cycle/index.js +21 -0
  75. package/dist/files-dependency-builder/fixtures/build-tree/tree-shaking-cycle/index.js.map +1 -0
  76. package/dist/files-dependency-builder/fixtures/build-tree/tree-shaking-cycle/is-string.d.ts +2 -0
  77. package/dist/files-dependency-builder/fixtures/build-tree/tree-shaking-cycle/is-string.js +18 -0
  78. package/dist/files-dependency-builder/fixtures/build-tree/tree-shaking-cycle/is-string.js.map +1 -0
  79. package/dist/files-dependency-builder/fixtures/build-tree/tree-shaking-cycle/self-cycle.d.ts +2 -0
  80. package/dist/files-dependency-builder/fixtures/build-tree/tree-shaking-cycle/self-cycle.js +20 -0
  81. package/dist/files-dependency-builder/fixtures/build-tree/tree-shaking-cycle/self-cycle.js.map +1 -0
  82. package/dist/files-dependency-builder/fixtures/build-tree/unparsed.d.ts +0 -0
  83. package/dist/files-dependency-builder/fixtures/build-tree/unparsed.js +5 -0
  84. package/dist/files-dependency-builder/fixtures/build-tree/unparsed.js.map +1 -0
  85. package/dist/files-dependency-builder/fixtures/dependency-tree/amd/a.d.ts +0 -0
  86. package/dist/files-dependency-builder/fixtures/dependency-tree/amd/a.js +10 -0
  87. package/dist/files-dependency-builder/fixtures/dependency-tree/amd/a.js.map +1 -0
  88. package/dist/files-dependency-builder/fixtures/dependency-tree/amd/b.d.ts +0 -0
  89. package/dist/files-dependency-builder/fixtures/dependency-tree/amd/b.js +10 -0
  90. package/dist/files-dependency-builder/fixtures/dependency-tree/amd/b.js.map +1 -0
  91. package/dist/files-dependency-builder/fixtures/dependency-tree/amd/c.d.ts +0 -0
  92. package/dist/files-dependency-builder/fixtures/dependency-tree/amd/c.js +6 -0
  93. package/dist/files-dependency-builder/fixtures/dependency-tree/amd/c.js.map +1 -0
  94. package/dist/files-dependency-builder/fixtures/dependency-tree/commonjs/a.d.ts +1 -0
  95. package/dist/files-dependency-builder/fixtures/dependency-tree/commonjs/a.js +6 -0
  96. package/dist/files-dependency-builder/fixtures/dependency-tree/commonjs/a.js.map +1 -0
  97. package/dist/files-dependency-builder/fixtures/dependency-tree/commonjs/b.d.ts +1 -0
  98. package/dist/files-dependency-builder/fixtures/dependency-tree/commonjs/b.js +6 -0
  99. package/dist/files-dependency-builder/fixtures/dependency-tree/commonjs/b.js.map +1 -0
  100. package/dist/files-dependency-builder/fixtures/dependency-tree/commonjs/c.d.ts +1 -0
  101. package/dist/files-dependency-builder/fixtures/dependency-tree/commonjs/c.js +6 -0
  102. package/dist/files-dependency-builder/fixtures/dependency-tree/commonjs/c.js.map +1 -0
  103. package/dist/files-dependency-builder/fixtures/dependency-tree/onlyRealDeps/a.d.ts +1 -0
  104. package/dist/files-dependency-builder/fixtures/dependency-tree/onlyRealDeps/a.js +8 -0
  105. package/dist/files-dependency-builder/fixtures/dependency-tree/onlyRealDeps/a.js.map +1 -0
  106. package/dist/files-dependency-builder/fixtures/dependency-tree/webpack/aliased.d.ts +1 -0
  107. package/dist/files-dependency-builder/fixtures/dependency-tree/webpack/aliased.js +6 -0
  108. package/dist/files-dependency-builder/fixtures/dependency-tree/webpack/aliased.js.map +1 -0
  109. package/dist/files-dependency-builder/fixtures/dependency-tree/webpack/unaliased.d.ts +1 -0
  110. package/dist/files-dependency-builder/fixtures/dependency-tree/webpack/unaliased.js +6 -0
  111. package/dist/files-dependency-builder/fixtures/dependency-tree/webpack/unaliased.js.map +1 -0
  112. package/dist/files-dependency-builder/fixtures/filing-cabinet/ast.d.ts +221 -0
  113. package/dist/files-dependency-builder/fixtures/filing-cabinet/ast.js +259 -0
  114. package/dist/files-dependency-builder/fixtures/filing-cabinet/ast.js.map +1 -0
  115. package/dist/files-dependency-builder/fixtures/filing-cabinet/foo.d.ts +2 -0
  116. package/dist/files-dependency-builder/fixtures/filing-cabinet/foo.js +12 -0
  117. package/dist/files-dependency-builder/fixtures/filing-cabinet/foo.js.map +1 -0
  118. package/dist/files-dependency-builder/fixtures/filing-cabinet/foo.scss +1 -0
  119. package/dist/files-dependency-builder/fixtures/filing-cabinet/foo2.scss +0 -0
  120. package/dist/files-dependency-builder/fixtures/filing-cabinet/mockedJSFiles.d.ts +59 -0
  121. package/dist/files-dependency-builder/fixtures/filing-cabinet/mockedJSFiles.js +65 -0
  122. package/dist/files-dependency-builder/fixtures/filing-cabinet/mockedJSFiles.js.map +1 -0
  123. package/dist/files-dependency-builder/fixtures/filing-cabinet/root1/mod1.d.ts +1 -0
  124. package/dist/files-dependency-builder/fixtures/filing-cabinet/root1/mod1.js +5 -0
  125. package/dist/files-dependency-builder/fixtures/filing-cabinet/root1/mod1.js.map +1 -0
  126. package/dist/files-dependency-builder/fixtures/filing-cabinet/root2/mod2.d.ts +1 -0
  127. package/dist/files-dependency-builder/fixtures/filing-cabinet/root2/mod2.js +5 -0
  128. package/dist/files-dependency-builder/fixtures/filing-cabinet/root2/mod2.js.map +1 -0
  129. package/dist/files-dependency-builder/fixtures/filing-cabinet/webpack.config.d.ts +6 -0
  130. package/dist/files-dependency-builder/fixtures/filing-cabinet/webpack.config.js +12 -0
  131. package/dist/files-dependency-builder/fixtures/filing-cabinet/webpack.config.js.map +1 -0
  132. package/dist/files-dependency-builder/fixtures/missing-deps.d.ts +0 -0
  133. package/dist/files-dependency-builder/fixtures/missing-deps.js +5 -0
  134. package/dist/files-dependency-builder/fixtures/missing-deps.js.map +1 -0
  135. package/dist/files-dependency-builder/fixtures/precinct/Gruntfile.d.ts +2 -0
  136. package/dist/files-dependency-builder/fixtures/precinct/Gruntfile.js +24 -0
  137. package/dist/files-dependency-builder/fixtures/precinct/Gruntfile.js.map +1 -0
  138. package/dist/files-dependency-builder/fixtures/precinct/amd.d.ts +0 -0
  139. package/dist/files-dependency-builder/fixtures/precinct/amd.js +6 -0
  140. package/dist/files-dependency-builder/fixtures/precinct/amd.js.map +1 -0
  141. package/dist/files-dependency-builder/fixtures/precinct/bar.foo +1 -0
  142. package/dist/files-dependency-builder/fixtures/precinct/cjsExportLazy.d.ts +6 -0
  143. package/dist/files-dependency-builder/fixtures/precinct/cjsExportLazy.js +11 -0
  144. package/dist/files-dependency-builder/fixtures/precinct/cjsExportLazy.js.map +1 -0
  145. package/dist/files-dependency-builder/fixtures/precinct/commonjs.d.ts +1 -0
  146. package/dist/files-dependency-builder/fixtures/precinct/commonjs.js +7 -0
  147. package/dist/files-dependency-builder/fixtures/precinct/commonjs.js.map +1 -0
  148. package/dist/files-dependency-builder/fixtures/precinct/coreModules.d.ts +1 -0
  149. package/dist/files-dependency-builder/fixtures/precinct/coreModules.js +9 -0
  150. package/dist/files-dependency-builder/fixtures/precinct/coreModules.js.map +1 -0
  151. package/dist/files-dependency-builder/fixtures/precinct/es6.d.ts +1 -0
  152. package/dist/files-dependency-builder/fixtures/precinct/es6.js +15 -0
  153. package/dist/files-dependency-builder/fixtures/precinct/es6.js.map +1 -0
  154. package/dist/files-dependency-builder/fixtures/precinct/es6MixedExportLazy.d.ts +5 -0
  155. package/dist/files-dependency-builder/fixtures/precinct/es6MixedExportLazy.js +15 -0
  156. package/dist/files-dependency-builder/fixtures/precinct/es6MixedExportLazy.js.map +1 -0
  157. package/dist/files-dependency-builder/fixtures/precinct/es7.d.ts +1 -0
  158. package/dist/files-dependency-builder/fixtures/precinct/es7.js +7 -0
  159. package/dist/files-dependency-builder/fixtures/precinct/es7.js.map +1 -0
  160. package/dist/files-dependency-builder/fixtures/precinct/exampleAST.d.ts +24 -0
  161. package/dist/files-dependency-builder/fixtures/precinct/exampleAST.js +30 -0
  162. package/dist/files-dependency-builder/fixtures/precinct/exampleAST.js.map +1 -0
  163. package/dist/files-dependency-builder/fixtures/precinct/foo.foo +1 -0
  164. package/dist/files-dependency-builder/fixtures/precinct/styles.css +6 -0
  165. package/dist/files-dependency-builder/fixtures/precinct/styles.less +4 -0
  166. package/dist/files-dependency-builder/fixtures/precinct/styles.sass +2 -0
  167. package/dist/files-dependency-builder/fixtures/precinct/styles.scss +3 -0
  168. package/dist/files-dependency-builder/fixtures/precinct/styles.styl +5 -0
  169. package/dist/files-dependency-builder/fixtures/precinct/typescript.d.ts +0 -0
  170. package/dist/files-dependency-builder/fixtures/precinct/typescript.js +11 -0
  171. package/dist/files-dependency-builder/fixtures/precinct/typescript.js.map +1 -0
  172. package/dist/files-dependency-builder/fixtures/precinct/unparseable.d.ts +0 -0
  173. package/dist/files-dependency-builder/fixtures/precinct/unparseable.js +9 -0
  174. package/dist/files-dependency-builder/fixtures/precinct/unparseable.js.map +1 -0
  175. package/dist/files-dependency-builder/fixtures/unsupported-file.pdf +0 -0
  176. package/dist/files-dependency-builder/generate-tree-madge.d.ts +31 -0
  177. package/dist/files-dependency-builder/generate-tree-madge.js +196 -0
  178. package/dist/files-dependency-builder/generate-tree-madge.js.map +1 -0
  179. package/dist/files-dependency-builder/index.d.ts +3 -0
  180. package/dist/files-dependency-builder/index.js +34 -0
  181. package/dist/files-dependency-builder/index.js.map +1 -0
  182. package/dist/files-dependency-builder/missing-handler.d.ts +34 -0
  183. package/dist/files-dependency-builder/missing-handler.js +107 -0
  184. package/dist/files-dependency-builder/missing-handler.js.map +1 -0
  185. package/dist/files-dependency-builder/path-map.d.ts +20 -0
  186. package/dist/files-dependency-builder/path-map.js +46 -0
  187. package/dist/files-dependency-builder/path-map.js.map +1 -0
  188. package/dist/files-dependency-builder/precinct/index.d.ts +22 -0
  189. package/dist/files-dependency-builder/precinct/index.js +306 -0
  190. package/dist/files-dependency-builder/precinct/index.js.map +1 -0
  191. package/dist/files-dependency-builder/precinct/index.spec.d.ts +1 -0
  192. package/dist/files-dependency-builder/precinct/index.spec.js +300 -0
  193. package/dist/files-dependency-builder/precinct/index.spec.js.map +1 -0
  194. package/dist/files-dependency-builder/types/dependency-tree-type.d.ts +35 -0
  195. package/dist/files-dependency-builder/types/dependency-tree-type.js +34 -0
  196. package/dist/files-dependency-builder/types/dependency-tree-type.js.map +1 -0
  197. package/dist/files-dependency-builder/types/index.d.ts +0 -0
  198. package/dist/files-dependency-builder/types/index.js +7 -0
  199. package/dist/files-dependency-builder/types/index.js.map +1 -0
  200. package/dist/index.d.ts +1 -0
  201. package/dist/index.js +25 -0
  202. package/dist/index.js.map +1 -1
  203. package/dist/resolve-pkg-data.d.ts +23 -0
  204. package/dist/resolve-pkg-data.js +157 -0
  205. package/dist/resolve-pkg-data.js.map +1 -0
  206. package/files-dependency-builder/build-tree.spec.ts +130 -0
  207. package/files-dependency-builder/build-tree.ts +185 -0
  208. package/files-dependency-builder/dependency-tree/Config.ts +68 -0
  209. package/files-dependency-builder/dependency-tree/index.spec.ts +893 -0
  210. package/files-dependency-builder/dependency-tree/index.ts +244 -0
  211. package/files-dependency-builder/detectives/detective-css/index.ts +1 -0
  212. package/files-dependency-builder/detectives/detective-es6/index.ts +1 -0
  213. package/files-dependency-builder/detectives/detective-less/index.ts +1 -0
  214. package/files-dependency-builder/detectives/detective-sass/index.ts +1 -0
  215. package/files-dependency-builder/detectives/detective-scss/index.ts +1 -0
  216. package/files-dependency-builder/detectives/detective-typescript/index.ts +1 -0
  217. package/files-dependency-builder/detector-hook.ts +69 -0
  218. package/files-dependency-builder/filing-cabinet/index.spec.ts +718 -0
  219. package/files-dependency-builder/filing-cabinet/index.ts +119 -0
  220. package/files-dependency-builder/fixtures/build-tree/a.js +2 -0
  221. package/files-dependency-builder/fixtures/build-tree/b.js +2 -0
  222. package/files-dependency-builder/fixtures/build-tree/not-link-file/file-a.js +2 -0
  223. package/files-dependency-builder/fixtures/build-tree/not-link-file/file-b.js +4 -0
  224. package/files-dependency-builder/fixtures/build-tree/not-link-file/file-c.js +3 -0
  225. package/files-dependency-builder/fixtures/build-tree/tree-shaking-cycle/foo.js +2 -0
  226. package/files-dependency-builder/fixtures/build-tree/tree-shaking-cycle/index.js +2 -0
  227. package/files-dependency-builder/fixtures/build-tree/tree-shaking-cycle/is-string.js +3 -0
  228. package/files-dependency-builder/fixtures/build-tree/tree-shaking-cycle/self-cycle.js +3 -0
  229. package/files-dependency-builder/fixtures/build-tree/unparsed.js +2 -0
  230. package/files-dependency-builder/fixtures/dependency-tree/amd/a.js +6 -0
  231. package/files-dependency-builder/fixtures/dependency-tree/amd/b.js +6 -0
  232. package/files-dependency-builder/fixtures/dependency-tree/amd/c.js +2 -0
  233. package/files-dependency-builder/fixtures/dependency-tree/commonjs/a.js +2 -0
  234. package/files-dependency-builder/fixtures/dependency-tree/commonjs/b.js +3 -0
  235. package/files-dependency-builder/fixtures/dependency-tree/commonjs/c.js +3 -0
  236. package/files-dependency-builder/fixtures/dependency-tree/onlyRealDeps/a.js +4 -0
  237. package/files-dependency-builder/fixtures/dependency-tree/webpack/aliased.js +2 -0
  238. package/files-dependency-builder/fixtures/dependency-tree/webpack/unaliased.js +2 -0
  239. package/files-dependency-builder/fixtures/filing-cabinet/ast.js +266 -0
  240. package/files-dependency-builder/fixtures/filing-cabinet/foo.jsx +3 -0
  241. package/files-dependency-builder/fixtures/filing-cabinet/foo.scss +1 -0
  242. package/files-dependency-builder/fixtures/filing-cabinet/foo2.scss +0 -0
  243. package/files-dependency-builder/fixtures/filing-cabinet/mockedJSFiles.js +61 -0
  244. package/files-dependency-builder/fixtures/filing-cabinet/root1/mod1.js +1 -0
  245. package/files-dependency-builder/fixtures/filing-cabinet/root2/mod2.js +1 -0
  246. package/files-dependency-builder/fixtures/filing-cabinet/webpack.config.js +8 -0
  247. package/files-dependency-builder/fixtures/missing-deps.js +2 -0
  248. package/files-dependency-builder/fixtures/precinct/Gruntfile.js +22 -0
  249. package/files-dependency-builder/fixtures/precinct/amd.js +2 -0
  250. package/files-dependency-builder/fixtures/precinct/bar.foo +1 -0
  251. package/files-dependency-builder/fixtures/precinct/cjsExportLazy.js +7 -0
  252. package/files-dependency-builder/fixtures/precinct/commonjs.js +3 -0
  253. package/files-dependency-builder/fixtures/precinct/coreModules.js +5 -0
  254. package/files-dependency-builder/fixtures/precinct/es6.js +4 -0
  255. package/files-dependency-builder/fixtures/precinct/es6MixedExportLazy.js +7 -0
  256. package/files-dependency-builder/fixtures/precinct/es7.js +3 -0
  257. package/files-dependency-builder/fixtures/precinct/exampleAST.js +32 -0
  258. package/files-dependency-builder/fixtures/precinct/foo.foo +1 -0
  259. package/files-dependency-builder/fixtures/precinct/styles.css +6 -0
  260. package/files-dependency-builder/fixtures/precinct/styles.less +4 -0
  261. package/files-dependency-builder/fixtures/precinct/styles.sass +2 -0
  262. package/files-dependency-builder/fixtures/precinct/styles.scss +3 -0
  263. package/files-dependency-builder/fixtures/precinct/styles.styl +5 -0
  264. package/files-dependency-builder/fixtures/precinct/typescript.ts +8 -0
  265. package/files-dependency-builder/fixtures/precinct/unparseable.js +6 -0
  266. package/files-dependency-builder/fixtures/unsupported-file.pdf +0 -0
  267. package/files-dependency-builder/generate-tree-madge.ts +200 -0
  268. package/files-dependency-builder/index.ts +5 -0
  269. package/files-dependency-builder/missing-handler.ts +76 -0
  270. package/files-dependency-builder/path-map.ts +38 -0
  271. package/files-dependency-builder/precinct/index.spec.ts +342 -0
  272. package/files-dependency-builder/precinct/index.ts +250 -0
  273. package/files-dependency-builder/types/dependency-tree-type.ts +46 -0
  274. package/files-dependency-builder/types/index.ts +3 -0
  275. package/package.json +37 -13
  276. /package/dist/{preview-1720513025675.js → preview-1720667996237.js} +0 -0
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ entry: './index.js',
5
+ resolve: {
6
+ alias: {
7
+ R: './node_modules/resolve'
8
+ }
9
+ }
10
+ };
11
+
12
+ //# sourceMappingURL=webpack.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["module","exports","entry","resolve","alias","R"],"sources":["webpack.config.js"],"sourcesContent":["module.exports = {\n entry: './index.js',\n resolve: {\n alias: {\n R: './node_modules/resolve'\n }\n }\n};\n"],"mappings":";;AAAAA,MAAM,CAACC,OAAO,GAAG;EACfC,KAAK,EAAE,YAAY;EACnBC,OAAO,EAAE;IACPC,KAAK,EAAE;MACLC,CAAC,EAAE;IACL;EACF;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ // const a = require('non-exist-package'); // missing package
2
+ // const b = require('../non-exist-dep'); // missing dependency
3
+ "use strict";
4
+
5
+ //# sourceMappingURL=missing-deps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["missing-deps.js"],"sourcesContent":["// const a = require('non-exist-package'); // missing package\n// const b = require('../non-exist-dep'); // missing dependency\n"],"mappings":"AAAA;AACA;AAAA","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ declare function _exports(grunt: any): void;
2
+ export = _exports;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ // @bit-no-check
4
+ module.exports = function (grunt) {
5
+ grunt.initConfig({
6
+ jshint: {
7
+ files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
8
+ options: {
9
+ globals: {
10
+ jQuery: true
11
+ }
12
+ }
13
+ },
14
+ watch: {
15
+ files: ['<%= jshint.files %>'],
16
+ tasks: ['jshint']
17
+ }
18
+ });
19
+ grunt.loadNpmTasks('grunt-contrib-jshint');
20
+ grunt.loadNpmTasks('grunt-contrib-watch');
21
+ grunt.registerTask('default', ['jshint']);
22
+ };
23
+
24
+ //# sourceMappingURL=Gruntfile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["module","exports","grunt","initConfig","jshint","files","options","globals","jQuery","watch","tasks","loadNpmTasks","registerTask"],"sources":["Gruntfile.js"],"sourcesContent":["// @bit-no-check\nmodule.exports = function(grunt) {\n grunt.initConfig({\n jshint: {\n files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],\n options: {\n globals: {\n jQuery: true\n }\n }\n },\n watch: {\n files: ['<%= jshint.files %>'],\n tasks: ['jshint']\n }\n });\n\n grunt.loadNpmTasks('grunt-contrib-jshint');\n grunt.loadNpmTasks('grunt-contrib-watch');\n\n grunt.registerTask('default', ['jshint']);\n};\n"],"mappings":";;AAAA;AACAA,MAAM,CAACC,OAAO,GAAG,UAASC,KAAK,EAAE;EAC/BA,KAAK,CAACC,UAAU,CAAC;IACfC,MAAM,EAAE;MACNC,KAAK,EAAE,CAAC,cAAc,EAAE,aAAa,EAAE,cAAc,CAAC;MACtDC,OAAO,EAAE;QACPC,OAAO,EAAE;UACPC,MAAM,EAAE;QACV;MACF;IACF,CAAC;IACDC,KAAK,EAAE;MACLJ,KAAK,EAAE,CAAC,qBAAqB,CAAC;MAC9BK,KAAK,EAAE,CAAC,QAAQ;IAClB;EACF,CAAC,CAAC;EAEFR,KAAK,CAACS,YAAY,CAAC,sBAAsB,CAAC;EAC1CT,KAAK,CAACS,YAAY,CAAC,qBAAqB,CAAC;EAEzCT,KAAK,CAACU,YAAY,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,CAAC;AAC3C,CAAC","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ // @bit-no-check
4
+ define(['./a', './b'], function (a, b) {});
5
+
6
+ //# sourceMappingURL=amd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["define","a","b"],"sources":["amd.js"],"sourcesContent":["// @bit-no-check\ndefine(['./a', './b'], function(a, b) {});\n"],"mappings":";;AAAA;AACAA,MAAM,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,UAASC,CAAC,EAAEC,CAAC,EAAE,CAAC,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ keywords: foo foo foo
@@ -0,0 +1,6 @@
1
+ declare function _exports({ amd, es6, es7 }: {
2
+ amd?: any;
3
+ es6?: any;
4
+ es7?: typeof import("./es7") | undefined;
5
+ }): void;
6
+ export = _exports;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ // @bit-no-check
4
+ module.exports = function ({
5
+ // Just requiring any files that exist
6
+ amd = require('./amd'),
7
+ es6 = require('./es6').foo,
8
+ es7 = require('./es7')
9
+ }) {};
10
+
11
+ //# sourceMappingURL=cjsExportLazy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["module","exports","amd","require","es6","foo","es7"],"sources":["cjsExportLazy.js"],"sourcesContent":["// @bit-no-check\nmodule.exports = function({\n // Just requiring any files that exist\n amd = require('./amd'),\n es6 = require('./es6').foo,\n es7 = require('./es7')\n}) {};\n"],"mappings":";;AAAA;AACAA,MAAM,CAACC,OAAO,GAAG,UAAS;EACxB;EACAC,GAAG,GAAGC,OAAO,CAAC,OAAO,CAAC;EACtBC,GAAG,GAAGD,OAAO,CAAC,OAAO,CAAC,CAACE,GAAG;EAC1BC,GAAG,GAAGH,OAAO,CAAC,OAAO;AACvB,CAAC,EAAE,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ // @bit-no-check
4
+ var a = require('./a'),
5
+ b = require('./b');
6
+
7
+ //# sourceMappingURL=commonjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["a","require","b"],"sources":["commonjs.js"],"sourcesContent":["// @bit-no-check\nvar a = require('./a'),\n b = require('./b');\n"],"mappings":";;AAAA;AACA,IAAIA,CAAC,GAAGC,OAAO,CAAC,KAAK,CAAC;EACpBC,CAAC,GAAGD,OAAO,CAAC,KAAK,CAAC","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ // @bit-no-check
4
+ var assert = require('assert');
5
+ var path = require('path');
6
+ var fs = require('fs');
7
+ var nodeFs = require('node:fs');
8
+
9
+ //# sourceMappingURL=coreModules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["assert","require","path","fs","nodeFs"],"sources":["coreModules.js"],"sourcesContent":["// @bit-no-check\nvar assert = require('assert');\nvar path = require('path');\nvar fs = require('fs');\nvar nodeFs = require('node:fs');\n"],"mappings":";;AAAA;AACA,IAAIA,MAAM,GAAGC,OAAO,CAAC,QAAQ,CAAC;AAC9B,IAAIC,IAAI,GAAGD,OAAO,CAAC,MAAM,CAAC;AAC1B,IAAIE,EAAE,GAAGF,OAAO,CAAC,IAAI,CAAC;AACtB,IAAIG,MAAM,GAAGH,OAAO,CAAC,SAAS,CAAC","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ function _lib() {
4
+ const data = require("lib");
5
+ _lib = function () {
6
+ return data;
7
+ };
8
+ return data;
9
+ }
10
+ // @bit-no-check
11
+
12
+ console.log((0, _lib().square)(11)); // 121
13
+ console.log((0, _lib().diag)(4, 3)); // 5
14
+
15
+ //# sourceMappingURL=es6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_lib","data","require","console","log","square","diag"],"sources":["es6.js"],"sourcesContent":["// @bit-no-check\nimport { square, diag } from 'lib';\nconsole.log(square(11)); // 121\nconsole.log(diag(4, 3)); // 5\n"],"mappings":";;AACA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AADA;;AAEAE,OAAO,CAACC,GAAG,CAAC,IAAAC,aAAM,EAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACzBF,OAAO,CAACC,GAAG,CAAC,IAAAE,WAAI,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ export default function _default({ amd, es6, es7 }: {
2
+ amd?: any;
3
+ es6?: typeof import("./es6") | undefined;
4
+ es7?: typeof import("./es7") | undefined;
5
+ }): void;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = _default;
7
+ // @bit-no-check
8
+ function _default({
9
+ // Just requiring any files that exist
10
+ amd = require('./amd'),
11
+ es6 = require('./es6'),
12
+ es7 = require('./es7')
13
+ }) {}
14
+
15
+ //# sourceMappingURL=es6MixedExportLazy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_default","amd","require","es6","es7"],"sources":["es6MixedExportLazy.js"],"sourcesContent":["// @bit-no-check\nexport default function({\n // Just requiring any files that exist\n amd = require('./amd'),\n es6 = require('./es6'),\n es7 = require('./es7')\n}) {}\n"],"mappings":";;;;;;AAAA;AACe,SAAAA,SAAS;EACtB;EACAC,GAAG,GAAGC,OAAO,CAAC,OAAO,CAAC;EACtBC,GAAG,GAAGD,OAAO,CAAC,OAAO,CAAC;EACtBE,GAAG,GAAGF,OAAO,CAAC,OAAO;AACvB,CAAC,EAAE,CAAC","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ // @bit-no-check
4
+
5
+ async function foo() {}
6
+
7
+ //# sourceMappingURL=es7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["foo"],"sources":["es7.js"],"sourcesContent":["// @bit-no-check\nimport { square, diag } from 'lib';\nasync function foo() {}\n"],"mappings":";;AAAA;;AAEA,eAAeA,GAAGA,CAAA,EAAG,CAAC","ignoreList":[]}
@@ -0,0 +1,24 @@
1
+ export let type: string;
2
+ export let body: {
3
+ type: string;
4
+ declarations: {
5
+ type: string;
6
+ id: {
7
+ type: string;
8
+ name: string;
9
+ };
10
+ init: {
11
+ type: string;
12
+ callee: {
13
+ type: string;
14
+ name: string;
15
+ };
16
+ arguments: {
17
+ type: string;
18
+ value: string;
19
+ raw: string;
20
+ }[];
21
+ };
22
+ }[];
23
+ kind: string;
24
+ }[];
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ type: 'Program',
5
+ body: [{
6
+ type: 'VariableDeclaration',
7
+ declarations: [{
8
+ type: 'VariableDeclarator',
9
+ id: {
10
+ type: 'Identifier',
11
+ name: 'a'
12
+ },
13
+ init: {
14
+ type: 'CallExpression',
15
+ callee: {
16
+ type: 'Identifier',
17
+ name: 'require'
18
+ },
19
+ arguments: [{
20
+ type: 'Literal',
21
+ value: './a',
22
+ raw: './a'
23
+ }]
24
+ }
25
+ }],
26
+ kind: 'var'
27
+ }]
28
+ };
29
+
30
+ //# sourceMappingURL=exampleAST.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["module","exports","type","body","declarations","id","name","init","callee","arguments","value","raw","kind"],"sources":["exampleAST.js"],"sourcesContent":["module.exports = {\n type: 'Program',\n body: [\n {\n type: 'VariableDeclaration',\n declarations: [\n {\n type: 'VariableDeclarator',\n id: {\n type: 'Identifier',\n name: 'a'\n },\n init: {\n type: 'CallExpression',\n callee: {\n type: 'Identifier',\n name: 'require'\n },\n arguments: [\n {\n type: 'Literal',\n value: './a',\n raw: './a'\n }\n ]\n }\n }\n ],\n kind: 'var'\n }\n ]\n};\n"],"mappings":";;AAAAA,MAAM,CAACC,OAAO,GAAG;EACfC,IAAI,EAAE,SAAS;EACfC,IAAI,EAAE,CACJ;IACED,IAAI,EAAE,qBAAqB;IAC3BE,YAAY,EAAE,CACZ;MACEF,IAAI,EAAE,oBAAoB;MAC1BG,EAAE,EAAE;QACFH,IAAI,EAAE,YAAY;QAClBI,IAAI,EAAE;MACR,CAAC;MACDC,IAAI,EAAE;QACJL,IAAI,EAAE,gBAAgB;QACtBM,MAAM,EAAE;UACNN,IAAI,EAAE,YAAY;UAClBI,IAAI,EAAE;QACR,CAAC;QACDG,SAAS,EAAE,CACT;UACEP,IAAI,EAAE,SAAS;UACfQ,KAAK,EAAE,KAAK;UACZC,GAAG,EAAE;QACP,CAAC;MAEL;IACF,CAAC,CACF;IACDC,IAAI,EAAE;EACR,CAAC;AAEL,CAAC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ There is no keywords matched.
@@ -0,0 +1,6 @@
1
+ /* @bit-no-check */
2
+
3
+ @import "foo.css";
4
+ @import url("baz.css");
5
+ @value a from 'bla.css';
6
+ @value a, b as x from url(another.css);
@@ -0,0 +1,4 @@
1
+ /* @bit-no-check */
2
+ @import "_foo";
3
+ @import "_bar.css";
4
+ @import "baz.less";
@@ -0,0 +1,2 @@
1
+ /* @bit-no-check */
2
+ @import _foo
@@ -0,0 +1,3 @@
1
+ /* @bit-no-check */
2
+ @import "_foo";
3
+ @import "baz.scss";
@@ -0,0 +1,5 @@
1
+ /* @bit-no-check */
2
+ @import "mystyles"
3
+ @import "styles2.styl"
4
+ @require "styles3.styl";
5
+ @require "styles4";
@@ -0,0 +1,11 @@
1
+ // import * as fs from 'fs';
2
+ // import { square, diag } from 'lib';
3
+ // import foo from './bar';
4
+ // import './my-module.js'; // Import a module for side-effects only
5
+ // import zip = require('./ZipCodeValidator'); // needed when importing a module using `export =` syntax
6
+
7
+ // console.log(square(11)); // 121
8
+ // console.log(diag(4, 3)); // 5
9
+ "use strict";
10
+
11
+ //# sourceMappingURL=typescript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["typescript.ts"],"sourcesContent":["// import * as fs from 'fs';\n// import { square, diag } from 'lib';\n// import foo from './bar';\n// import './my-module.js'; // Import a module for side-effects only\n// import zip = require('./ZipCodeValidator'); // needed when importing a module using `export =` syntax\n\n// console.log(square(11)); // 121\n// console.log(diag(4, 3)); // 5\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AAAA","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ // // @bit-no-check
2
+ // {
3
+ // "very invalid": "javascript",
4
+ // "this", "is actually json",
5
+ // "But" not even valid json.
6
+ // }
7
+ "use strict";
8
+
9
+ //# sourceMappingURL=unparseable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["unparseable.js"],"sourcesContent":["// // @bit-no-check\n// {\n// \t\"very invalid\": \"javascript\",\n// \t\"this\", \"is actually json\",\n// \t\"But\" not even valid json.\n// }\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AAAA","ignoreList":[]}
@@ -0,0 +1,31 @@
1
+ import { PathLinuxRelative } from '@teambit/toolbox.path.path';
2
+ /**
3
+ * Process absolute path and return a shorter one.
4
+ * @param {String} absPath
5
+ * @param {Object} cache
6
+ * @param {String} baseDir
7
+ * @return {String}
8
+ */
9
+ export declare function processPath(absPath: any, cache: any, baseDir: any): any;
10
+ export type MadgeTree = {
11
+ [relativePath: string]: PathLinuxRelative[];
12
+ };
13
+ export type Missing = {
14
+ [absolutePath: string]: string[];
15
+ };
16
+ type GenerateTreeResults = {
17
+ madgeTree: MadgeTree;
18
+ skipped: Missing;
19
+ pathMap: any;
20
+ errors: {
21
+ [filePath: string]: Error;
22
+ };
23
+ };
24
+ /**
25
+ * Generate the tree from the given files
26
+ * @param {Array} files
27
+ * @param config
28
+ * @return {Object}
29
+ */
30
+ export default function generateTree(files: string[] | undefined, config: any): GenerateTreeResults;
31
+ export {};
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = generateTree;
7
+ exports.processPath = processPath;
8
+ function _os() {
9
+ const data = _interopRequireDefault(require("os"));
10
+ _os = function () {
11
+ return data;
12
+ };
13
+ return data;
14
+ }
15
+ function _path() {
16
+ const data = _interopRequireDefault(require("path"));
17
+ _path = function () {
18
+ return data;
19
+ };
20
+ return data;
21
+ }
22
+ function _dependencyTree() {
23
+ const data = _interopRequireDefault(require("./dependency-tree"));
24
+ _dependencyTree = function () {
25
+ return data;
26
+ };
27
+ return data;
28
+ }
29
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
30
+ // most of the functions in this file were taken from the Madge project: https://github.com/pahen/madge
31
+ // reasons for not using Madge directly: 1) it has issues with TypeScript on Windows. 2) it has issues with tsx files
32
+
33
+ /**
34
+ * Check if running on Windows.
35
+ * @type {Boolean}
36
+ */
37
+ const isWin = _os().default.platform() === 'win32';
38
+
39
+ /**
40
+ * Check if path is from NPM folder
41
+ * @param {String} path
42
+ * @return {Boolean}
43
+ */
44
+ function isNpmPathFunc(pathStr) {
45
+ return pathStr.indexOf('node_modules') >= 0;
46
+ }
47
+
48
+ /**
49
+ * Sort tree.
50
+ * @param {Object} tree
51
+ * @return {Object}
52
+ */
53
+ function sort(tree) {
54
+ return Object.keys(tree).sort().reduce((acc, id) => {
55
+ acc[id] = tree[id].sort();
56
+ return acc;
57
+ }, {});
58
+ }
59
+
60
+ /**
61
+ * Exclude modules from tree using RegExp.
62
+ * @param {Object} tree
63
+ * @param {Array} excludeRegExp
64
+ * @return {Object}
65
+ */
66
+ function exclude(tree, excludeRegExp) {
67
+ const regExpList = excludeRegExp.map(re => new RegExp(re));
68
+ function regExpFilter(id) {
69
+ return regExpList.findIndex(regexp => regexp.test(id)) < 0;
70
+ }
71
+ return Object.keys(tree).filter(regExpFilter).reduce((acc, id) => {
72
+ acc[id] = tree[id].filter(regExpFilter);
73
+ return acc;
74
+ }, {});
75
+ }
76
+
77
+ /**
78
+ * Process absolute path and return a shorter one.
79
+ * @param {String} absPath
80
+ * @param {Object} cache
81
+ * @param {String} baseDir
82
+ * @return {String}
83
+ */
84
+ function processPath(absPath, cache, baseDir) {
85
+ if (cache[absPath]) {
86
+ return cache[absPath];
87
+ }
88
+ let relPath = _path().default.relative(baseDir, absPath);
89
+ if (isWin) {
90
+ relPath = relPath.replace(/\\/g, '/');
91
+ }
92
+ cache[absPath] = relPath;
93
+ return relPath;
94
+ }
95
+
96
+ /**
97
+ * Convert deep tree produced by dependency-tree to a
98
+ * shallow (one level deep) tree used by madge.
99
+ * @param {Object} depTree
100
+ * @param {Object} tree
101
+ * @param {Object} pathCache
102
+ * @param {String} baseDir
103
+ * @return {Object}
104
+ */
105
+ function convertTreePaths(depTree, pathCache, baseDir) {
106
+ const tree = {};
107
+ Object.keys(depTree).forEach(file => {
108
+ tree[processPath(file, pathCache, baseDir)] = depTree[file].map(d => processPath(d, pathCache, baseDir));
109
+ });
110
+ return tree;
111
+ }
112
+
113
+ // e.g. { 'index.ts': ['foo.ts', '../node_modules/react/index.js'] }
114
+ // all paths are normalized to Linux
115
+
116
+ // e.g. { '/tmp/workspace': ['lodash', 'underscore'] };
117
+
118
+ /**
119
+ * Generate the tree from the given files
120
+ * @param {Array} files
121
+ * @param config
122
+ * @return {Object}
123
+ */
124
+ function generateTree(files = [], config) {
125
+ const depTree = {};
126
+ const nonExistent = {};
127
+ const npmPaths = {};
128
+ const pathCache = {};
129
+ const pathMap = [];
130
+ const errors = {};
131
+ files.forEach(file => {
132
+ if (depTree[file]) {
133
+ return;
134
+ }
135
+ const detective = config.detectiveOptions;
136
+ try {
137
+ const dependencyTreeResult = (0, _dependencyTree().default)({
138
+ filename: file,
139
+ directory: config.baseDir,
140
+ requireConfig: config.requireConfig,
141
+ webpackConfig: config.webpackConfig,
142
+ resolveConfig: config.resolveConfig,
143
+ visited: config.visited,
144
+ errors,
145
+ filter: (dependencyFilePath, traversedFilePath) => {
146
+ let dependencyFilterRes = true;
147
+ const isNpmPath = isNpmPathFunc(dependencyFilePath);
148
+ if (config.dependencyFilter) {
149
+ dependencyFilterRes = config.dependencyFilter(dependencyFilePath, traversedFilePath, config.baseDir);
150
+ }
151
+ if (config.includeNpm && isNpmPath) {
152
+ (npmPaths[traversedFilePath] = npmPaths[traversedFilePath] || []).push(dependencyFilePath);
153
+ }
154
+ return !isNpmPath && (dependencyFilterRes || dependencyFilterRes === undefined);
155
+ },
156
+ detective,
157
+ nonExistent,
158
+ pathMap,
159
+ cacheProjectAst: config.cacheProjectAst,
160
+ envDetectors: config.envDetectors
161
+ });
162
+ Object.assign(depTree, dependencyTreeResult);
163
+ } catch (err) {
164
+ errors[file] = err;
165
+ }
166
+ });
167
+ let tree = convertTreePaths(depTree, pathCache, config.baseDir);
168
+
169
+ // rename errors keys from absolute paths to relative paths
170
+ Object.keys(errors).forEach(file => {
171
+ const relativeFile = processPath(file, pathCache, config.baseDir);
172
+ if (relativeFile !== file) {
173
+ errors[relativeFile] = errors[file];
174
+ delete errors[file];
175
+ }
176
+ });
177
+ Object.keys(npmPaths).forEach(npmKey => {
178
+ const id = processPath(npmKey, pathCache, config.baseDir);
179
+ // a file might not be in the tree if it has errors or errors found with its parents
180
+ if (!tree[id]) return;
181
+ npmPaths[npmKey].forEach(npmPath => {
182
+ tree[id].push(processPath(npmPath, pathCache, config.baseDir));
183
+ });
184
+ });
185
+ if (config.excludeRegExp) {
186
+ tree = exclude(tree, config.excludeRegExp);
187
+ }
188
+ return {
189
+ madgeTree: sort(tree),
190
+ skipped: nonExistent,
191
+ pathMap,
192
+ errors
193
+ };
194
+ }
195
+
196
+ //# sourceMappingURL=generate-tree-madge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_os","data","_interopRequireDefault","require","_path","_dependencyTree","e","__esModule","default","isWin","os","platform","isNpmPathFunc","pathStr","indexOf","sort","tree","Object","keys","reduce","acc","id","exclude","excludeRegExp","regExpList","map","re","RegExp","regExpFilter","findIndex","regexp","test","filter","processPath","absPath","cache","baseDir","relPath","path","relative","replace","convertTreePaths","depTree","pathCache","forEach","file","d","generateTree","files","config","nonExistent","npmPaths","pathMap","errors","detective","detectiveOptions","dependencyTreeResult","dependencyTree","filename","directory","requireConfig","webpackConfig","resolveConfig","visited","dependencyFilePath","traversedFilePath","dependencyFilterRes","isNpmPath","dependencyFilter","includeNpm","push","undefined","cacheProjectAst","envDetectors","assign","err","relativeFile","npmKey","npmPath","madgeTree","skipped"],"sources":["generate-tree-madge.ts"],"sourcesContent":["// most of the functions in this file were taken from the Madge project: https://github.com/pahen/madge\n// reasons for not using Madge directly: 1) it has issues with TypeScript on Windows. 2) it has issues with tsx files\n\nimport os from 'os';\nimport path from 'path';\n\nimport dependencyTree from './dependency-tree';\nimport { PathLinuxRelative } from '@teambit/toolbox.path.path';\n\n/**\n * Check if running on Windows.\n * @type {Boolean}\n */\nconst isWin = os.platform() === 'win32';\n\n/**\n * Check if path is from NPM folder\n * @param {String} path\n * @return {Boolean}\n */\nfunction isNpmPathFunc(pathStr) {\n return pathStr.indexOf('node_modules') >= 0;\n}\n\n/**\n * Sort tree.\n * @param {Object} tree\n * @return {Object}\n */\nfunction sort(tree) {\n return Object.keys(tree)\n .sort()\n .reduce((acc, id) => {\n acc[id] = tree[id].sort();\n return acc;\n }, {});\n}\n\n/**\n * Exclude modules from tree using RegExp.\n * @param {Object} tree\n * @param {Array} excludeRegExp\n * @return {Object}\n */\nfunction exclude(tree, excludeRegExp) {\n const regExpList = excludeRegExp.map((re) => new RegExp(re));\n\n function regExpFilter(id) {\n return regExpList.findIndex((regexp) => regexp.test(id)) < 0;\n }\n\n return Object.keys(tree)\n .filter(regExpFilter)\n .reduce((acc, id) => {\n acc[id] = tree[id].filter(regExpFilter);\n return acc;\n }, {});\n}\n\n/**\n * Process absolute path and return a shorter one.\n * @param {String} absPath\n * @param {Object} cache\n * @param {String} baseDir\n * @return {String}\n */\nexport function processPath(absPath, cache, baseDir) {\n if (cache[absPath]) {\n return cache[absPath];\n }\n\n let relPath = path.relative(baseDir, absPath);\n\n if (isWin) {\n relPath = relPath.replace(/\\\\/g, '/');\n }\n\n cache[absPath] = relPath;\n\n return relPath;\n}\n\n/**\n * Convert deep tree produced by dependency-tree to a\n * shallow (one level deep) tree used by madge.\n * @param {Object} depTree\n * @param {Object} tree\n * @param {Object} pathCache\n * @param {String} baseDir\n * @return {Object}\n */\nfunction convertTreePaths(depTree, pathCache, baseDir) {\n const tree = {};\n Object.keys(depTree).forEach((file) => {\n tree[processPath(file, pathCache, baseDir)] = depTree[file].map((d) => processPath(d, pathCache, baseDir));\n });\n\n return tree;\n}\n\n// e.g. { 'index.ts': ['foo.ts', '../node_modules/react/index.js'] }\n// all paths are normalized to Linux\nexport type MadgeTree = { [relativePath: string]: PathLinuxRelative[] };\n\n// e.g. { '/tmp/workspace': ['lodash', 'underscore'] };\nexport type Missing = { [absolutePath: string]: string[] };\n\ntype GenerateTreeResults = {\n madgeTree: MadgeTree;\n skipped: Missing;\n pathMap: any;\n errors: { [filePath: string]: Error };\n};\n\n/**\n * Generate the tree from the given files\n * @param {Array} files\n * @param config\n * @return {Object}\n */\nexport default function generateTree(files: string[] = [], config): GenerateTreeResults {\n const depTree = {};\n const nonExistent = {};\n const npmPaths = {};\n const pathCache = {};\n const pathMap = [];\n const errors = {};\n\n files.forEach((file) => {\n if (depTree[file]) {\n return;\n }\n\n const detective = config.detectiveOptions;\n try {\n const dependencyTreeResult = dependencyTree({\n filename: file,\n directory: config.baseDir,\n requireConfig: config.requireConfig,\n webpackConfig: config.webpackConfig,\n resolveConfig: config.resolveConfig,\n visited: config.visited,\n errors,\n filter: (dependencyFilePath, traversedFilePath) => {\n let dependencyFilterRes = true;\n const isNpmPath = isNpmPathFunc(dependencyFilePath);\n\n if (config.dependencyFilter) {\n dependencyFilterRes = config.dependencyFilter(dependencyFilePath, traversedFilePath, config.baseDir);\n }\n\n if (config.includeNpm && isNpmPath) {\n (npmPaths[traversedFilePath] = npmPaths[traversedFilePath] || []).push(dependencyFilePath);\n }\n\n return !isNpmPath && (dependencyFilterRes || dependencyFilterRes === undefined);\n },\n detective,\n nonExistent,\n pathMap,\n cacheProjectAst: config.cacheProjectAst,\n envDetectors: config.envDetectors,\n });\n Object.assign(depTree, dependencyTreeResult);\n } catch (err: any) {\n errors[file] = err;\n }\n });\n\n let tree = convertTreePaths(depTree, pathCache, config.baseDir);\n\n // rename errors keys from absolute paths to relative paths\n Object.keys(errors).forEach((file) => {\n const relativeFile = processPath(file, pathCache, config.baseDir);\n if (relativeFile !== file) {\n errors[relativeFile] = errors[file];\n delete errors[file];\n }\n });\n\n Object.keys(npmPaths).forEach((npmKey) => {\n const id = processPath(npmKey, pathCache, config.baseDir);\n // a file might not be in the tree if it has errors or errors found with its parents\n if (!tree[id]) return;\n npmPaths[npmKey].forEach((npmPath) => {\n tree[id].push(processPath(npmPath, pathCache, config.baseDir));\n });\n });\n\n if (config.excludeRegExp) {\n tree = exclude(tree, config.excludeRegExp);\n }\n\n return {\n madgeTree: sort(tree),\n skipped: nonExistent,\n pathMap,\n errors,\n };\n}\n"],"mappings":";;;;;;;AAGA,SAAAA,IAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,GAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,gBAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,eAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA+C,SAAAC,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EA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
+ import { getDependencyTree } from './build-tree';
2
+ import getDependenciesFromSource from './precinct';
3
+ export { getDependencyTree, getDependenciesFromSource };
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "getDependenciesFromSource", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _precinct().default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "getDependencyTree", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _buildTree().getDependencyTree;
16
+ }
17
+ });
18
+ function _buildTree() {
19
+ const data = require("./build-tree");
20
+ _buildTree = function () {
21
+ return data;
22
+ };
23
+ return data;
24
+ }
25
+ function _precinct() {
26
+ const data = _interopRequireDefault(require("./precinct"));
27
+ _precinct = function () {
28
+ return data;
29
+ };
30
+ return data;
31
+ }
32
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
33
+
34
+ //# sourceMappingURL=index.js.map