@rsdoctor/core 1.6.1 → 2.0.0-alpha.1

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 (411) hide show
  1. package/dist/build-utils/build/chunks/assetsModules.d.ts +1 -1
  2. package/dist/build-utils/build/chunks/assetsModules.js +1 -1
  3. package/dist/build-utils/build/chunks/index.d.ts +0 -1
  4. package/dist/build-utils/build/chunks/index.js +0 -1
  5. package/dist/build-utils/build/chunks/rspack/transform.d.ts +1 -1
  6. package/dist/build-utils/build/chunks/rspack/transform.js +1 -1
  7. package/dist/build-utils/build/envinfo.d.ts +13 -0
  8. package/dist/build-utils/build/envinfo.js +60 -0
  9. package/dist/build-utils/build/file/cache.d.ts +5 -0
  10. package/dist/build-utils/build/file/cache.js +24 -0
  11. package/dist/build-utils/build/file/index.d.ts +3 -0
  12. package/dist/build-utils/build/file/index.js +5 -0
  13. package/dist/build-utils/build/file/sharding.d.ts +21 -0
  14. package/dist/build-utils/build/file/sharding.js +38 -0
  15. package/dist/build-utils/build/index.d.ts +5 -0
  16. package/dist/build-utils/build/index.js +11 -6
  17. package/dist/build-utils/build/json.d.ts +3 -0
  18. package/dist/build-utils/build/json.js +67 -0
  19. package/dist/build-utils/build/loader/probeLoader.d.ts +2 -2
  20. package/dist/build-utils/build/loader/probeLoader.js +4 -4
  21. package/dist/build-utils/build/loader/probeLoaderPlugin.d.ts +1 -1
  22. package/dist/build-utils/build/loader/probeLoaderPlugin.js +1 -1
  23. package/dist/build-utils/build/module-graph/index.d.ts +0 -3
  24. package/dist/build-utils/build/module-graph/index.js +0 -3
  25. package/dist/build-utils/build/module-graph/parser.d.ts +1 -1
  26. package/dist/build-utils/build/module-graph/parser.js +1 -1
  27. package/dist/build-utils/build/module-graph/rspack/transform.d.ts +1 -1
  28. package/dist/build-utils/build/module-graph/rspack/transform.js +7 -5
  29. package/dist/build-utils/build/module-graph/utils.d.ts +1 -1
  30. package/dist/build-utils/build/module-graph/utils.js +5 -4
  31. package/dist/build-utils/build/process.d.ts +2 -0
  32. package/dist/build-utils/build/process.js +18 -0
  33. package/dist/build-utils/build/server.d.ts +15 -0
  34. package/dist/build-utils/build/server.js +107 -0
  35. package/dist/build-utils/build/utils/loader.d.ts +2 -2
  36. package/dist/build-utils/build/utils/loader.js +10 -19
  37. package/dist/build-utils/build/utils/parseBundle.d.ts +1 -1
  38. package/dist/build-utils/build/utils/parseBundle.js +6 -8
  39. package/dist/build-utils/build/utils/plugin.d.ts +1 -1
  40. package/dist/build-utils/build/utils/plugin.js +1 -2
  41. package/dist/build-utils/index.d.ts +10 -0
  42. package/dist/build-utils/index.js +12 -2
  43. package/dist/collection.d.ts +1 -0
  44. package/dist/collection.js +2 -0
  45. package/dist/common/file.d.ts +2 -0
  46. package/dist/common/file.js +8 -0
  47. package/dist/common/global-config.d.ts +21 -0
  48. package/dist/common/global-config.js +33 -0
  49. package/dist/common/index.d.ts +4 -0
  50. package/dist/common/index.js +6 -0
  51. package/dist/common-browser.d.ts +1 -0
  52. package/dist/common-browser.js +2 -0
  53. package/dist/error/error.d.ts +35 -0
  54. package/dist/error/error.js +143 -0
  55. package/dist/error/index.d.ts +2 -0
  56. package/dist/error/index.js +3 -0
  57. package/dist/error/transform.d.ts +3 -0
  58. package/dist/error/transform.js +138 -0
  59. package/dist/error/utils.d.ts +4 -0
  60. package/dist/error/utils.js +23 -0
  61. package/dist/graph/index.d.ts +1 -0
  62. package/dist/graph/index.js +2 -0
  63. package/dist/index.d.ts +2 -0
  64. package/dist/index.js +4 -2
  65. package/dist/inner-plugins/constants.d.ts +1 -1
  66. package/dist/inner-plugins/constants.js +1 -1
  67. package/dist/inner-plugins/loaders/proxy.d.ts +4 -4
  68. package/dist/inner-plugins/plugins/base.d.ts +1 -1
  69. package/dist/inner-plugins/plugins/bundle.d.ts +1 -1
  70. package/dist/inner-plugins/plugins/bundle.js +4 -20
  71. package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.ts +6 -8
  72. package/dist/inner-plugins/plugins/ensureModulesChunkGraph.js +12 -77
  73. package/dist/inner-plugins/plugins/errors.d.ts +3 -3
  74. package/dist/inner-plugins/plugins/errors.js +6 -6
  75. package/dist/inner-plugins/plugins/index.d.ts +0 -1
  76. package/dist/inner-plugins/plugins/index.js +0 -1
  77. package/dist/inner-plugins/plugins/loader.d.ts +1 -1
  78. package/dist/inner-plugins/plugins/loader.js +8 -20
  79. package/dist/inner-plugins/plugins/plugins.d.ts +1 -1
  80. package/dist/inner-plugins/plugins/plugins.js +3 -3
  81. package/dist/inner-plugins/plugins/progress.d.ts +3 -3
  82. package/dist/inner-plugins/plugins/progress.js +16 -18
  83. package/dist/inner-plugins/plugins/resolver.d.ts +2 -3
  84. package/dist/inner-plugins/plugins/resolver.js +2 -2
  85. package/dist/inner-plugins/plugins/rspack.d.ts +8 -3
  86. package/dist/inner-plugins/plugins/rspack.js +18 -4
  87. package/dist/inner-plugins/plugins/rules.d.ts +1 -1
  88. package/dist/inner-plugins/plugins/rules.js +6 -6
  89. package/dist/inner-plugins/plugins/sourcemapTool.d.ts +2 -2
  90. package/dist/inner-plugins/plugins/sourcemapTool.js +2 -2
  91. package/dist/inner-plugins/plugins/summary.d.ts +1 -1
  92. package/dist/inner-plugins/plugins/summary.js +3 -3
  93. package/dist/inner-plugins/utils/config.d.ts +3 -4
  94. package/dist/inner-plugins/utils/config.js +4 -17
  95. package/dist/inner-plugins/utils/loader.d.ts +4 -7
  96. package/dist/inner-plugins/utils/loader.js +10 -36
  97. package/dist/inner-plugins/utils/normalize-config.d.ts +4 -7
  98. package/dist/inner-plugins/utils/openBrowser.d.ts +1 -0
  99. package/dist/inner-plugins/utils/openBrowser.js +55 -0
  100. package/dist/inner-plugins/utils/plugin-common.js +4 -4
  101. package/dist/inner-plugins/utils/plugin.d.ts +1 -1
  102. package/dist/inner-plugins/utils/plugin.js +1 -1
  103. package/dist/inner-plugins/utils/sdk.d.ts +2 -3
  104. package/dist/inner-plugins/utils/sdk.js +2 -2
  105. package/dist/logger.d.ts +9 -0
  106. package/dist/logger.js +51 -0
  107. package/dist/{inner-plugins/constants.d.cts → rspack-plugin/constants.d.ts} +4 -1
  108. package/dist/rspack-plugin/constants.js +23 -0
  109. package/dist/rspack-plugin/index.d.ts +2 -0
  110. package/dist/rspack-plugin/index.js +3 -0
  111. package/dist/rspack-plugin/multiple.d.ts +8 -0
  112. package/dist/rspack-plugin/multiple.js +39 -0
  113. package/dist/rspack-plugin/plugin.d.ts +25 -0
  114. package/dist/rspack-plugin/plugin.js +133 -0
  115. package/dist/rule-utils/document/document.d.ts +16 -0
  116. package/dist/rule-utils/document/document.js +46 -0
  117. package/dist/rule-utils/document/index.d.ts +3 -0
  118. package/dist/rule-utils/document/index.js +4 -0
  119. package/dist/rule-utils/document/server.d.ts +4 -0
  120. package/dist/rule-utils/document/server.js +13 -0
  121. package/dist/rule-utils/document/types.d.ts +31 -0
  122. package/dist/rule-utils/index.d.ts +2 -0
  123. package/dist/rule-utils/index.js +3 -0
  124. package/dist/rule-utils/parser/asserts.d.ts +81 -0
  125. package/dist/rule-utils/parser/asserts.js +105 -0
  126. package/dist/rule-utils/parser/index.d.ts +4 -0
  127. package/dist/rule-utils/parser/index.js +5 -0
  128. package/dist/rule-utils/parser/parser.d.ts +118 -0
  129. package/dist/rule-utils/parser/parser.js +24 -0
  130. package/dist/rule-utils/parser/types.d.ts +30 -0
  131. package/dist/rule-utils/parser/types.js +8 -0
  132. package/dist/rule-utils/parser/utils.d.ts +30 -0
  133. package/dist/rule-utils/parser/utils.js +106 -0
  134. package/dist/rules/linter.d.ts +1 -1
  135. package/dist/rules/linter.js +1 -1
  136. package/dist/rules/rule.d.ts +2 -2
  137. package/dist/rules/rule.js +2 -2
  138. package/dist/rules/rules/cjs-require/index.d.ts +1 -1
  139. package/dist/rules/rules/cjs-require/index.js +3 -3
  140. package/dist/rules/rules/cross-chunks-package/index.d.ts +1 -1
  141. package/dist/rules/rules/cross-chunks-package/index.js +2 -2
  142. package/dist/rules/rules/default-import-check/index.d.ts +1 -1
  143. package/dist/rules/rules/default-import-check/index.js +2 -2
  144. package/dist/rules/rules/default-import-check/utils.d.ts +2 -2
  145. package/dist/rules/rules/default-import-check/utils.js +2 -2
  146. package/dist/rules/rules/duplicate-package/index.d.ts +3 -3
  147. package/dist/rules/rules/duplicate-package/index.js +3 -3
  148. package/dist/rules/rules/duplicate-package/utils.d.ts +1 -1
  149. package/dist/rules/rules/ecma-version-check/index.d.ts +3 -2
  150. package/dist/rules/rules/ecma-version-check/index.js +1 -1
  151. package/dist/rules/rules/ecma-version-check/types.d.ts +1 -2
  152. package/dist/rules/rules/ecma-version-check/utils.d.ts +1 -1
  153. package/dist/rules/rules/esm-resolved-to-cjs/index.d.ts +1 -1
  154. package/dist/rules/rules/esm-resolved-to-cjs/index.js +3 -18
  155. package/dist/rules/rules/index.d.ts +1 -1
  156. package/dist/rules/rules/loader-performance-optimization/index.d.ts +1 -1
  157. package/dist/rules/rules/loader-performance-optimization/index.js +3 -3
  158. package/dist/rules/rules/loader-performance-optimization/types.d.ts +1 -1
  159. package/dist/rules/rules/module-mixed-chunks/index.d.ts +1 -1
  160. package/dist/rules/rules/module-mixed-chunks/index.js +2 -2
  161. package/dist/rules/rules/side-effects-only-imports/index.d.ts +1 -1
  162. package/dist/rules/rules/side-effects-only-imports/index.js +2 -2
  163. package/dist/rules/utils.d.ts +1 -1
  164. package/dist/rules/utils.js +1 -1
  165. package/dist/sdk/index.d.ts +2 -0
  166. package/dist/sdk/index.js +3 -0
  167. package/dist/sdk/multiple/controller.d.ts +12 -0
  168. package/dist/sdk/multiple/controller.js +42 -0
  169. package/dist/sdk/multiple/index.d.ts +2 -0
  170. package/dist/sdk/multiple/index.js +3 -0
  171. package/dist/sdk/multiple/primary.d.ts +32 -0
  172. package/dist/sdk/multiple/primary.js +64 -0
  173. package/dist/sdk/multiple/server.d.ts +7 -0
  174. package/dist/sdk/multiple/server.js +14 -0
  175. package/dist/sdk/sdk/core.d.ts +33 -0
  176. package/dist/sdk/sdk/core.js +163 -0
  177. package/dist/sdk/sdk/index.d.ts +52 -0
  178. package/dist/sdk/sdk/index.js +435 -0
  179. package/dist/sdk/sdk/types.d.ts +26 -0
  180. package/dist/sdk/sdk/types.js +1 -0
  181. package/dist/sdk/server/apis/alerts.d.ts +5 -0
  182. package/dist/sdk/server/apis/alerts.js +30 -0
  183. package/dist/sdk/server/apis/base.d.ts +11 -0
  184. package/dist/sdk/server/apis/base.js +22 -0
  185. package/dist/sdk/server/apis/bundle-diff.d.ts +6 -0
  186. package/dist/sdk/server/apis/bundle-diff.js +51 -0
  187. package/dist/sdk/server/apis/data.d.ts +6 -0
  188. package/dist/sdk/server/apis/data.js +44 -0
  189. package/dist/sdk/server/apis/fs.d.ts +5 -0
  190. package/dist/sdk/server/apis/fs.js +28 -0
  191. package/dist/sdk/server/apis/graph.d.ts +12 -0
  192. package/dist/sdk/server/apis/graph.js +116 -0
  193. package/dist/sdk/server/apis/index.d.ts +10 -0
  194. package/dist/sdk/server/apis/index.js +11 -0
  195. package/dist/sdk/server/apis/loader.d.ts +15 -0
  196. package/dist/sdk/server/apis/loader.js +120 -0
  197. package/dist/sdk/server/apis/plugin.d.ts +6 -0
  198. package/dist/sdk/server/apis/plugin.js +39 -0
  199. package/dist/sdk/server/apis/project.d.ts +8 -0
  200. package/dist/sdk/server/apis/project.js +59 -0
  201. package/dist/sdk/server/apis/renderer.d.ts +6 -0
  202. package/dist/sdk/server/apis/renderer.js +33 -0
  203. package/dist/sdk/server/apis/resolver.d.ts +6 -0
  204. package/dist/sdk/server/apis/resolver.js +38 -0
  205. package/dist/sdk/server/client.d.ts +3 -0
  206. package/dist/sdk/server/client.js +8 -0
  207. package/dist/sdk/server/fakeServer.d.ts +9 -0
  208. package/dist/sdk/server/fakeServer.js +12 -0
  209. package/dist/sdk/server/index.d.ts +44 -0
  210. package/dist/sdk/server/index.js +292 -0
  211. package/dist/sdk/server/json-body.d.ts +6 -0
  212. package/dist/sdk/server/json-body.js +150 -0
  213. package/dist/sdk/server/router.d.ts +24 -0
  214. package/dist/sdk/server/router.js +83 -0
  215. package/dist/sdk/server/security.d.ts +5 -0
  216. package/dist/sdk/server/security.js +47 -0
  217. package/dist/sdk/server/socket/api.d.ts +15 -0
  218. package/dist/sdk/server/socket/api.js +22 -0
  219. package/dist/sdk/server/socket/index.d.ts +48 -0
  220. package/dist/sdk/server/socket/index.js +166 -0
  221. package/dist/sdk/server/utils.d.ts +6 -0
  222. package/dist/sdk/server/utils.js +19 -0
  223. package/dist/sdk/utils/base.d.ts +1 -0
  224. package/dist/sdk/utils/base.js +22 -0
  225. package/dist/sdk/utils/constant.d.ts +1 -0
  226. package/dist/sdk/utils/constant.js +4 -0
  227. package/dist/sdk/utils/index.d.ts +3 -0
  228. package/dist/sdk/utils/index.js +4 -0
  229. package/dist/sdk/utils/openBrowser.d.ts +4 -0
  230. package/dist/sdk/utils/openBrowser.js +53 -0
  231. package/dist/sdk/utils/upload.d.ts +2 -0
  232. package/dist/sdk/utils/upload.js +6 -0
  233. package/dist/sdk.d.ts +1 -0
  234. package/dist/sdk.js +2 -0
  235. package/dist/types/index.d.ts +0 -1
  236. package/dist/types/index.js +0 -1
  237. package/dist/types/loader.d.ts +1 -1
  238. package/dist/types/plugin.d.ts +7 -28
  239. package/dist/types/rules.d.ts +4 -4
  240. package/package.json +123 -55
  241. package/static/openChrome.applescript +95 -0
  242. package/dist/build-utils/build/chunks/assetsModules.cjs +0 -46
  243. package/dist/build-utils/build/chunks/assetsModules.d.cts +0 -17
  244. package/dist/build-utils/build/chunks/chunkTransform.cjs +0 -43
  245. package/dist/build-utils/build/chunks/chunkTransform.d.cts +0 -4
  246. package/dist/build-utils/build/chunks/chunkTransform.d.ts +0 -4
  247. package/dist/build-utils/build/chunks/chunkTransform.js +0 -6
  248. package/dist/build-utils/build/chunks/index.cjs +0 -76
  249. package/dist/build-utils/build/chunks/index.d.cts +0 -3
  250. package/dist/build-utils/build/chunks/rspack/transform.cjs +0 -84
  251. package/dist/build-utils/build/chunks/rspack/transform.d.cts +0 -13
  252. package/dist/build-utils/build/index.cjs +0 -56
  253. package/dist/build-utils/build/index.d.cts +0 -5
  254. package/dist/build-utils/build/loader/index.cjs +0 -69
  255. package/dist/build-utils/build/loader/index.d.cts +0 -2
  256. package/dist/build-utils/build/loader/probeLoader.cjs +0 -93
  257. package/dist/build-utils/build/loader/probeLoader.d.cts +0 -4
  258. package/dist/build-utils/build/loader/probeLoaderPlugin.cjs +0 -69
  259. package/dist/build-utils/build/loader/probeLoaderPlugin.d.cts +0 -5
  260. package/dist/build-utils/build/module-graph/index.cjs +0 -83
  261. package/dist/build-utils/build/module-graph/index.d.cts +0 -4
  262. package/dist/build-utils/build/module-graph/parser.cjs +0 -50
  263. package/dist/build-utils/build/module-graph/parser.d.cts +0 -2
  264. package/dist/build-utils/build/module-graph/rspack/transform.cjs +0 -155
  265. package/dist/build-utils/build/module-graph/rspack/transform.d.cts +0 -26
  266. package/dist/build-utils/build/module-graph/transform.cjs +0 -44
  267. package/dist/build-utils/build/module-graph/transform.d.cts +0 -4
  268. package/dist/build-utils/build/module-graph/transform.d.ts +0 -4
  269. package/dist/build-utils/build/module-graph/transform.js +0 -7
  270. package/dist/build-utils/build/module-graph/treeShaking.cjs +0 -110
  271. package/dist/build-utils/build/module-graph/treeShaking.d.cts +0 -2
  272. package/dist/build-utils/build/module-graph/treeShaking.d.ts +0 -2
  273. package/dist/build-utils/build/module-graph/treeShaking.js +0 -73
  274. package/dist/build-utils/build/module-graph/utils.cjs +0 -99
  275. package/dist/build-utils/build/module-graph/utils.d.cts +0 -3
  276. package/dist/build-utils/build/module-graph/webpack/transform.cjs +0 -174
  277. package/dist/build-utils/build/module-graph/webpack/transform.d.cts +0 -16
  278. package/dist/build-utils/build/module-graph/webpack/transform.d.ts +0 -16
  279. package/dist/build-utils/build/module-graph/webpack/transform.js +0 -124
  280. package/dist/build-utils/build/utils/index.cjs +0 -76
  281. package/dist/build-utils/build/utils/index.d.cts +0 -3
  282. package/dist/build-utils/build/utils/loader.cjs +0 -358
  283. package/dist/build-utils/build/utils/loader.d.cts +0 -20
  284. package/dist/build-utils/build/utils/parseBundle.cjs +0 -287
  285. package/dist/build-utils/build/utils/parseBundle.d.cts +0 -12
  286. package/dist/build-utils/build/utils/plugin.cjs +0 -65
  287. package/dist/build-utils/build/utils/plugin.d.cts +0 -5
  288. package/dist/build-utils/index.cjs +0 -40
  289. package/dist/build-utils/index.d.cts +0 -1
  290. package/dist/index.cjs +0 -85
  291. package/dist/index.d.cts +0 -3
  292. package/dist/inner-plugins/constants.cjs +0 -68
  293. package/dist/inner-plugins/index.cjs +0 -69
  294. package/dist/inner-plugins/index.d.cts +0 -2
  295. package/dist/inner-plugins/loaders/proxy.cjs +0 -108
  296. package/dist/inner-plugins/loaders/proxy.d.cts +0 -7
  297. package/dist/inner-plugins/plugins/base.cjs +0 -57
  298. package/dist/inner-plugins/plugins/base.d.cts +0 -12
  299. package/dist/inner-plugins/plugins/bundle.cjs +0 -116
  300. package/dist/inner-plugins/plugins/bundle.d.cts +0 -15
  301. package/dist/inner-plugins/plugins/bundleTagPlugin.cjs +0 -88
  302. package/dist/inner-plugins/plugins/bundleTagPlugin.d.cts +0 -6
  303. package/dist/inner-plugins/plugins/bundleTagPlugin.d.ts +0 -6
  304. package/dist/inner-plugins/plugins/bundleTagPlugin.js +0 -51
  305. package/dist/inner-plugins/plugins/ensureModulesChunkGraph.cjs +0 -182
  306. package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.cts +0 -36
  307. package/dist/inner-plugins/plugins/errors.cjs +0 -102
  308. package/dist/inner-plugins/plugins/errors.d.cts +0 -11
  309. package/dist/inner-plugins/plugins/index.cjs +0 -132
  310. package/dist/inner-plugins/plugins/index.d.cts +0 -11
  311. package/dist/inner-plugins/plugins/loader.cjs +0 -169
  312. package/dist/inner-plugins/plugins/loader.d.cts +0 -10
  313. package/dist/inner-plugins/plugins/plugins.cjs +0 -77
  314. package/dist/inner-plugins/plugins/plugins.d.cts +0 -8
  315. package/dist/inner-plugins/plugins/progress.cjs +0 -74
  316. package/dist/inner-plugins/plugins/progress.d.cts +0 -8
  317. package/dist/inner-plugins/plugins/resolver.cjs +0 -94
  318. package/dist/inner-plugins/plugins/resolver.d.cts +0 -13
  319. package/dist/inner-plugins/plugins/rspack.cjs +0 -122
  320. package/dist/inner-plugins/plugins/rspack.d.cts +0 -4
  321. package/dist/inner-plugins/plugins/rules.cjs +0 -101
  322. package/dist/inner-plugins/plugins/rules.d.cts +0 -8
  323. package/dist/inner-plugins/plugins/sourcemapTool.cjs +0 -279
  324. package/dist/inner-plugins/plugins/sourcemapTool.d.cts +0 -52
  325. package/dist/inner-plugins/plugins/summary.cjs +0 -129
  326. package/dist/inner-plugins/plugins/summary.d.cts +0 -14
  327. package/dist/inner-plugins/utils/circleDetect.cjs +0 -53
  328. package/dist/inner-plugins/utils/circleDetect.d.cts +0 -4
  329. package/dist/inner-plugins/utils/config.cjs +0 -207
  330. package/dist/inner-plugins/utils/config.d.cts +0 -5
  331. package/dist/inner-plugins/utils/index.cjs +0 -110
  332. package/dist/inner-plugins/utils/index.d.cts +0 -9
  333. package/dist/inner-plugins/utils/loader.cjs +0 -222
  334. package/dist/inner-plugins/utils/loader.d.cts +0 -13
  335. package/dist/inner-plugins/utils/normalize-config.cjs +0 -126
  336. package/dist/inner-plugins/utils/normalize-config.d.cts +0 -40
  337. package/dist/inner-plugins/utils/plugin-common.cjs +0 -147
  338. package/dist/inner-plugins/utils/plugin-common.d.cts +0 -11
  339. package/dist/inner-plugins/utils/plugin.cjs +0 -110
  340. package/dist/inner-plugins/utils/plugin.d.cts +0 -4
  341. package/dist/inner-plugins/utils/sdk.cjs +0 -59
  342. package/dist/inner-plugins/utils/sdk.d.cts +0 -8
  343. package/dist/rslib-runtime.js +0 -19
  344. package/dist/rules/index.cjs +0 -85
  345. package/dist/rules/index.d.cts +0 -3
  346. package/dist/rules/linter.cjs +0 -76
  347. package/dist/rules/linter.d.cts +0 -9
  348. package/dist/rules/rule.cjs +0 -141
  349. package/dist/rules/rule.d.cts +0 -27
  350. package/dist/rules/rules/cjs-require/index.cjs +0 -87
  351. package/dist/rules/rules/cjs-require/index.d.cts +0 -4
  352. package/dist/rules/rules/cjs-require/types.cjs +0 -18
  353. package/dist/rules/rules/cjs-require/types.d.cts +0 -7
  354. package/dist/rules/rules/cross-chunks-package/index.cjs +0 -78
  355. package/dist/rules/rules/cross-chunks-package/index.d.cts +0 -4
  356. package/dist/rules/rules/cross-chunks-package/types.cjs +0 -18
  357. package/dist/rules/rules/cross-chunks-package/types.d.cts +0 -3
  358. package/dist/rules/rules/cross-chunks-package/utils.cjs +0 -44
  359. package/dist/rules/rules/cross-chunks-package/utils.d.cts +0 -1
  360. package/dist/rules/rules/default-import-check/index.cjs +0 -120
  361. package/dist/rules/rules/default-import-check/index.d.cts +0 -4
  362. package/dist/rules/rules/default-import-check/types.cjs +0 -18
  363. package/dist/rules/rules/default-import-check/types.d.cts +0 -4
  364. package/dist/rules/rules/default-import-check/utils.cjs +0 -101
  365. package/dist/rules/rules/default-import-check/utils.d.cts +0 -10
  366. package/dist/rules/rules/duplicate-package/index.cjs +0 -76
  367. package/dist/rules/rules/duplicate-package/index.d.cts +0 -4
  368. package/dist/rules/rules/duplicate-package/types.cjs +0 -64
  369. package/dist/rules/rules/duplicate-package/types.d.cts +0 -24
  370. package/dist/rules/rules/duplicate-package/utils.cjs +0 -88
  371. package/dist/rules/rules/duplicate-package/utils.d.cts +0 -3
  372. package/dist/rules/rules/ecma-version-check/index.cjs +0 -100
  373. package/dist/rules/rules/ecma-version-check/index.d.cts +0 -4
  374. package/dist/rules/rules/ecma-version-check/types.cjs +0 -18
  375. package/dist/rules/rules/ecma-version-check/types.d.cts +0 -3
  376. package/dist/rules/rules/ecma-version-check/utils.cjs +0 -43
  377. package/dist/rules/rules/ecma-version-check/utils.d.cts +0 -2
  378. package/dist/rules/rules/esm-resolved-to-cjs/index.cjs +0 -256
  379. package/dist/rules/rules/esm-resolved-to-cjs/index.d.cts +0 -4
  380. package/dist/rules/rules/esm-resolved-to-cjs/types.cjs +0 -18
  381. package/dist/rules/rules/esm-resolved-to-cjs/types.d.cts +0 -8
  382. package/dist/rules/rules/index.cjs +0 -59
  383. package/dist/rules/rules/index.d.cts +0 -2
  384. package/dist/rules/rules/loader-performance-optimization/index.cjs +0 -123
  385. package/dist/rules/rules/loader-performance-optimization/index.d.cts +0 -4
  386. package/dist/rules/rules/loader-performance-optimization/types.cjs +0 -18
  387. package/dist/rules/rules/loader-performance-optimization/types.d.cts +0 -22
  388. package/dist/rules/rules/loader-performance-optimization/utils.cjs +0 -47
  389. package/dist/rules/rules/loader-performance-optimization/utils.d.cts +0 -1
  390. package/dist/rules/rules/module-mixed-chunks/index.cjs +0 -89
  391. package/dist/rules/rules/module-mixed-chunks/index.d.cts +0 -4
  392. package/dist/rules/rules/module-mixed-chunks/types.cjs +0 -18
  393. package/dist/rules/rules/module-mixed-chunks/types.d.cts +0 -3
  394. package/dist/rules/rules/side-effects-only-imports/index.cjs +0 -118
  395. package/dist/rules/rules/side-effects-only-imports/index.d.cts +0 -4
  396. package/dist/rules/rules/side-effects-only-imports/types.cjs +0 -18
  397. package/dist/rules/rules/side-effects-only-imports/types.d.cts +0 -9
  398. package/dist/rules/utils.cjs +0 -50
  399. package/dist/rules/utils.d.cts +0 -3
  400. package/dist/types/chunks.cjs +0 -18
  401. package/dist/types/chunks.d.cts +0 -6
  402. package/dist/types/chunks.d.ts +0 -6
  403. package/dist/types/index.cjs +0 -83
  404. package/dist/types/index.d.cts +0 -4
  405. package/dist/types/loader.cjs +0 -18
  406. package/dist/types/loader.d.cts +0 -19
  407. package/dist/types/plugin.cjs +0 -18
  408. package/dist/types/plugin.d.cts +0 -51
  409. package/dist/types/rules.cjs +0 -18
  410. package/dist/types/rules.d.cts +0 -7
  411. /package/dist/{types/chunks.js → rule-utils/document/types.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { SDK } from '@rsdoctor/types';
1
+ import { SDK } from '@rsdoctor/shared/types';
2
2
  /**
3
3
  * Collects module size data from bundle assets, using source maps when available
4
4
  * and falling back to AST parsing for assets without source maps.
@@ -1,5 +1,5 @@
1
1
  import "node:module";
2
- import { Chunks } from "@rsdoctor/graph";
2
+ import { Chunks } from "../../../graph/index.js";
3
3
  import { parseBundle } from "../utils/index.js";
4
4
  async function getAssetsModulesData(moduleGraph, chunkGraph, bundleDir, sourceMapSets, hasParseBundle = true, assetsWithoutSourceMap) {
5
5
  return Chunks.getAssetsModulesData(moduleGraph, chunkGraph, bundleDir, hasParseBundle ? {
@@ -1,3 +1,2 @@
1
1
  export * from './assetsModules.js';
2
- export * from './chunkTransform.js';
3
2
  export * from './rspack/transform.js';
@@ -1,4 +1,3 @@
1
1
  import "node:module";
2
2
  export * from "./assetsModules.js";
3
- export * from "./chunkTransform.js";
4
3
  export * from "./rspack/transform.js";
@@ -1,4 +1,4 @@
1
- import { Plugin, SDK } from '@rsdoctor/types';
1
+ import { Plugin, SDK } from '@rsdoctor/shared/types';
2
2
  /**
3
3
  * Patch native chunk graph data from Rspack into ChunkGraph instance
4
4
  * @param cg The ChunkGraph instance to be patched
@@ -1,5 +1,5 @@
1
1
  import "node:module";
2
- import { Asset, Chunk, EntryPoint } from "@rsdoctor/graph";
2
+ import { Asset, Chunk, EntryPoint } from "../../../../graph/index.js";
3
3
  function patchNativeChunkGraph(cg, rawChunkGraph) {
4
4
  const { chunks: rawChunks, entrypoints: rawEntrypoints } = rawChunkGraph;
5
5
  const chunks = rawChunks.map((chunk)=>new Chunk(chunk.ukey.toString(), chunk.name, 0, chunk.initial, chunk.entry));
@@ -0,0 +1,13 @@
1
+ export declare const getCPUInfo: () => Promise<string>;
2
+ export declare const getOSInfo: () => Promise<string>;
3
+ export declare const getMemoryInfo: () => Promise<string>;
4
+ export declare const getNodeVersion: () => Promise<string>;
5
+ export declare const getYarnVersion: () => Promise<string>;
6
+ export declare const getNpmVersion: () => Promise<string>;
7
+ export declare const getPnpmVersion: () => Promise<string>;
8
+ export declare function getNpmPackageVersion(pkg: string): Promise<string>;
9
+ export declare function getNpmPackageVersion(pkgs: string[]): Promise<string[]>;
10
+ export declare function getGlobalNpmPackageVersion(pkg: string): Promise<string>;
11
+ export declare function getGlobalNpmPackageVersion(pkgs: string[]): Promise<string[]>;
12
+ export declare function getGitBranch(): Promise<string>;
13
+ export declare function getGitRepo(): Promise<string>;
@@ -0,0 +1,60 @@
1
+ import "node:module";
2
+ import envinfo from "envinfo";
3
+ import { exec } from "child_process";
4
+ const helpers = envinfo.helpers;
5
+ const run = envinfo.run;
6
+ const getCPUInfo = ()=>helpers.getCPUInfo().then((res)=>res[1]);
7
+ const getOSInfo = ()=>helpers.getOSInfo().then((res)=>res[1]);
8
+ const getMemoryInfo = ()=>helpers.getMemoryInfo().then((res)=>res[1]);
9
+ const getNodeVersion = ()=>helpers.getNodeInfo().then((res)=>res[1]);
10
+ const getYarnVersion = ()=>helpers.getYarnInfo().then((res)=>res[1]);
11
+ const getNpmVersion = ()=>helpers.getnpmInfo().then((res)=>res[1]);
12
+ const getPnpmVersion = ()=>helpers.getpnpmInfo().then((res)=>res[1]);
13
+ function getNpmPackageVersion(pkg) {
14
+ const isArray = Array.isArray(pkg);
15
+ return run({
16
+ npmPackages: isArray ? pkg : [
17
+ pkg
18
+ ]
19
+ }, {
20
+ json: true,
21
+ showNotFound: true
22
+ }).then((res)=>{
23
+ const { npmPackages = {} } = JSON.parse(res) || {};
24
+ return isArray ? pkg.map((e)=>npmPackages[e] || 'Not Found') : npmPackages[pkg];
25
+ });
26
+ }
27
+ function getGlobalNpmPackageVersion(pkg) {
28
+ const isArray = Array.isArray(pkg);
29
+ return run({
30
+ npmGlobalPackages: isArray ? pkg : [
31
+ pkg
32
+ ]
33
+ }, {
34
+ json: true,
35
+ showNotFound: true
36
+ }).then((res)=>{
37
+ const { npmGlobalPackages = {} } = JSON.parse(res) || {};
38
+ return isArray ? pkg.map((e)=>npmGlobalPackages[e] || 'Not Found') : npmGlobalPackages[pkg];
39
+ });
40
+ }
41
+ function getGitBranch() {
42
+ return new Promise((resolve, reject)=>{
43
+ exec('git branch --show-current', (err, stdout)=>{
44
+ if (err) exec('git branch', (err, stdout)=>{
45
+ if (err) reject(err);
46
+ else resolve(stdout.split('\n').map((e)=>e.replace('* ', '')).join('').trim());
47
+ });
48
+ else resolve(stdout.trim());
49
+ });
50
+ });
51
+ }
52
+ function getGitRepo() {
53
+ return new Promise((resolve, reject)=>{
54
+ exec('git config --get remote.origin.url', (err, stdout)=>{
55
+ if (err) reject(err);
56
+ else resolve(stdout.trim());
57
+ });
58
+ });
59
+ }
60
+ export { getCPUInfo, getGitBranch, getGitRepo, getGlobalNpmPackageVersion, getMemoryInfo, getNodeVersion, getNpmPackageVersion, getNpmVersion, getOSInfo, getPnpmVersion, getYarnVersion };
@@ -0,0 +1,5 @@
1
+ import { Common } from '@rsdoctor/shared/types';
2
+ export declare function readFile(path: string): Promise<string>;
3
+ export declare function readFileSync(path: string): string;
4
+ export declare function readJSON<T extends Common.PlainObject>(path: string): Promise<T>;
5
+ export declare function readJSONSync<T extends Common.PlainObject>(path: string): T;
@@ -0,0 +1,24 @@
1
+ import "node:module";
2
+ import node_fs from "node:fs";
3
+ const cache = new Map();
4
+ async function readFile(path) {
5
+ if (cache.has(path)) return cache.get(path);
6
+ const res = await node_fs.promises.readFile(path, 'utf-8');
7
+ cache.set(path, res);
8
+ return res;
9
+ }
10
+ function readFileSync(path) {
11
+ if (cache.has(path)) return cache.get(path);
12
+ const res = node_fs.readFileSync(path, 'utf-8');
13
+ cache.set(path, res);
14
+ return res;
15
+ }
16
+ async function readJSON(path) {
17
+ const str = await readFile(path);
18
+ return JSON.parse(str);
19
+ }
20
+ function readJSONSync(path) {
21
+ const str = readFileSync(path);
22
+ return JSON.parse(str);
23
+ }
24
+ export { readFile, readFileSync, readJSON, readJSONSync };
@@ -0,0 +1,3 @@
1
+ export * from './sharding.js';
2
+ export { default as fse } from 'fs-extra';
3
+ export * as cache from './cache.js';
@@ -0,0 +1,5 @@
1
+ import "node:module";
2
+ import * as __rspack_external__cache_js_3b19274f from "./cache.js";
3
+ export * from "./sharding.js";
4
+ export { default as fse } from "fs-extra";
5
+ export { __rspack_external__cache_js_3b19274f as cache };
@@ -0,0 +1,21 @@
1
+ export declare class FileSharding {
2
+ protected content: string;
3
+ protected limitBytes: number;
4
+ protected encoding: BufferEncoding;
5
+ constructor(content: string, limitBytes?: number, encoding?: BufferEncoding);
6
+ /**
7
+ * @param ext the extension name of the output file (must starts with ".")
8
+ */
9
+ createVirtualShardingFiles(ext?: string, index?: number): {
10
+ filename: string;
11
+ content: Buffer<ArrayBufferLike>;
12
+ }[];
13
+ /**
14
+ * @param folder absolute path of folder which used to save string sharding files.
15
+ * @param ext the extension name of the output file (must starts with ".")
16
+ */
17
+ writeStringToFolder(folder: string, ext?: string, index?: number): Promise<{
18
+ filename: string;
19
+ content: Buffer<ArrayBufferLike>;
20
+ }[]>;
21
+ }
@@ -0,0 +1,38 @@
1
+ import "node:module";
2
+ import fs_extra from "fs-extra";
3
+ import fs from "fs";
4
+ import path from "path";
5
+ class FileSharding {
6
+ createVirtualShardingFiles(ext = '', index = 0) {
7
+ const bf = Buffer.from(this.content, this.encoding);
8
+ const res = [];
9
+ const threshold = this.limitBytes;
10
+ let tmpBytes = 0;
11
+ while(bf.byteLength > tmpBytes){
12
+ res.push(bf.subarray(tmpBytes, tmpBytes + threshold));
13
+ tmpBytes += threshold;
14
+ }
15
+ return res.map((e, i)=>({
16
+ filename: `${i + index}${ext}`,
17
+ content: e
18
+ }));
19
+ }
20
+ async writeStringToFolder(folder, ext = '', index) {
21
+ const dist = path.resolve(folder);
22
+ await fs_extra.ensureDir(dist);
23
+ const res = this.createVirtualShardingFiles(ext, index);
24
+ await Promise.all(res.map((e)=>new Promise((resolve, reject)=>{
25
+ const stream = fs.createWriteStream(path.join(dist, e.filename), this.encoding);
26
+ stream.end(e.content);
27
+ stream.once('close', ()=>resolve(void 0));
28
+ stream.once('error', (err)=>reject(err));
29
+ })));
30
+ return res;
31
+ }
32
+ constructor(content, limitBytes = 10485760, encoding = 'utf-8'){
33
+ this.content = content;
34
+ this.limitBytes = limitBytes;
35
+ this.encoding = encoding;
36
+ }
37
+ }
38
+ export { FileSharding };
@@ -1,3 +1,8 @@
1
+ export * as File from './file/index.js';
2
+ export * as Json from './json.js';
3
+ export * as Server from './server.js';
4
+ export * as EnvInfo from './envinfo.js';
5
+ export * as Process from './process.js';
1
6
  export * as Chunks from './chunks/index.js';
2
7
  export * as Utils from './utils/index.js';
3
8
  export * as Loader from './loader/index.js';
@@ -1,7 +1,12 @@
1
1
  import "node:module";
2
- import * as __rspack_external__chunks_index_js_0dff7c47 from "./chunks/index.js";
3
- import * as __rspack_external__utils_index_js_1ffdce1c from "./utils/index.js";
4
- import * as __rspack_external__loader_index_js_7618f2f0 from "./loader/index.js";
5
- import * as __rspack_external__types_index_js_def0ea92 from "../../types/index.js";
6
- import * as __rspack_external__module_graph_index_js_3ee70f67 from "./module-graph/index.js";
7
- export { __rspack_external__chunks_index_js_0dff7c47 as Chunks, __rspack_external__loader_index_js_7618f2f0 as Loader, __rspack_external__module_graph_index_js_3ee70f67 as ModuleGraph, __rspack_external__types_index_js_def0ea92 as Types, __rspack_external__utils_index_js_1ffdce1c as Utils };
2
+ import * as __rspack_external__file_index_js_5cbcde29 from "./file/index.js";
3
+ import * as __rspack_external__json_js_faef839e from "./json.js";
4
+ import * as __rspack_external__server_js_186b33b9 from "./server.js";
5
+ import * as __rspack_external__envinfo_js_2b90a03d from "./envinfo.js";
6
+ import * as __rspack_external__process_js_7eda60d3 from "./process.js";
7
+ import * as __rspack_external__chunks_index_js_c4bbc2de from "./chunks/index.js";
8
+ import * as __rspack_external__utils_index_js_d2e4ad7a from "./utils/index.js";
9
+ import * as __rspack_external__loader_index_js_ef25077c from "./loader/index.js";
10
+ import * as __rspack_external__types_index_js_d78e4824 from "../../types/index.js";
11
+ import * as __rspack_external__module_graph_index_js_f91481f4 from "./module-graph/index.js";
12
+ export { __rspack_external__chunks_index_js_c4bbc2de as Chunks, __rspack_external__envinfo_js_2b90a03d as EnvInfo, __rspack_external__file_index_js_5cbcde29 as File, __rspack_external__json_js_faef839e as Json, __rspack_external__loader_index_js_ef25077c as Loader, __rspack_external__module_graph_index_js_f91481f4 as ModuleGraph, __rspack_external__process_js_7eda60d3 as Process, __rspack_external__server_js_186b33b9 as Server, __rspack_external__types_index_js_d78e4824 as Types, __rspack_external__utils_index_js_d2e4ad7a as Utils };
@@ -0,0 +1,3 @@
1
+ import { SDK } from '@rsdoctor/shared/types';
2
+ export declare function stringify<T, P = T extends undefined ? undefined : string>(json: T, replacer?: (this: any, key: string, value: any) => any, space?: string | number, cycle?: boolean): Promise<P>;
3
+ export declare const readPackageJson: (file: string, readFile?: SDK.GetPackageFile) => SDK.PackageBasicData | undefined;
@@ -0,0 +1,67 @@
1
+ import "node:module";
2
+ import { JsonStreamStringify } from "json-stream-stringify";
3
+ import { dirname, join } from "path";
4
+ import { Package } from "../../common/index.js";
5
+ import { Transform } from "stream";
6
+ const maxFileSize = 419430400;
7
+ function stringify(json, replacer, space, cycle) {
8
+ const jsonList = [];
9
+ if (json && 'object' == typeof json) return new Promise((resolve, reject)=>{
10
+ const stream = new JsonStreamStringify(json, replacer, space, cycle);
11
+ let currentLength = 0;
12
+ let currentContent = '';
13
+ const batchProcessor = new Transform({
14
+ readableObjectMode: true,
15
+ transform (chunk, _encoding, callback) {
16
+ const lines = chunk.toString().split('\\n');
17
+ lines.forEach((line)=>{
18
+ if (currentLength + line.length > maxFileSize) {
19
+ jsonList.push(currentContent);
20
+ currentContent = '';
21
+ currentLength = 0;
22
+ }
23
+ if (line.length) {
24
+ currentContent += line;
25
+ currentLength += line.length;
26
+ }
27
+ });
28
+ callback();
29
+ }
30
+ });
31
+ stream.pipe(batchProcessor).on('data', (line)=>{
32
+ if (currentLength + line.length > maxFileSize) {
33
+ jsonList.push(currentContent);
34
+ currentContent = '';
35
+ currentLength = 0;
36
+ }
37
+ if (line.length) {
38
+ currentContent += line;
39
+ currentLength += line.length;
40
+ }
41
+ }).on('end', ()=>{
42
+ if (jsonList.length < 1) jsonList.push(currentContent);
43
+ resolve(jsonList);
44
+ }).on('error', (err)=>reject(err));
45
+ });
46
+ return Promise.resolve(JSON.stringify(json, replacer, space));
47
+ }
48
+ const readPackageJson = (file, readFile)=>{
49
+ let result;
50
+ let current = file;
51
+ while('/' !== current && !result){
52
+ const parent = dirname(current);
53
+ if (parent === current) break;
54
+ current = parent;
55
+ if (readFile) result = readFile(join(current, 'package.json'));
56
+ if (readFile) {
57
+ if (!result?.name) result = void 0;
58
+ } else result = Package.getPackageMetaFromModulePath(file);
59
+ }
60
+ if (!result) return;
61
+ if (readFile && (!result.name || !result.version)) return readPackageJson(dirname(current), readFile);
62
+ return {
63
+ ...result,
64
+ root: current
65
+ };
66
+ };
67
+ export { readPackageJson, stringify };
@@ -1,4 +1,4 @@
1
- import { Plugin } from '@rsdoctor/types';
1
+ import type { Plugin } from '@rsdoctor/shared/types';
2
2
  import type { LoaderDefinitionFunction } from '@rspack/core';
3
- export declare const loaderModule: Plugin.LoaderDefinition<Parameters<LoaderDefinitionFunction>, {}>;
3
+ export declare const loaderModule: Plugin.LoaderDefinition<Parameters<LoaderDefinitionFunction>, object>;
4
4
  export default loaderModule;
@@ -1,7 +1,7 @@
1
1
  import "node:module";
2
- import { Build } from "../../index.js";
3
- import { getSDK } from "../../../inner-plugins/index.js";
4
- import { omit } from "es-toolkit/compat";
2
+ import { parseQuery } from "../utils/index.js";
3
+ import { getSDK } from "../../../inner-plugins/utils/sdk.js";
4
+ import { omit } from "../../../collection.js";
5
5
  import path from "path";
6
6
  const loaderModule = function(...args) {
7
7
  const time = Date.now();
@@ -11,7 +11,7 @@ const loaderModule = function(...args) {
11
11
  const loaderData = {
12
12
  resource: {
13
13
  path: this._module?.layer ? `${this.resourcePath}[${this._module.layer}]` : this.resourcePath,
14
- query: Build.Utils.parseQuery(this.resourceQuery),
14
+ query: parseQuery(this.resourceQuery),
15
15
  queryRaw: this.resourceQuery,
16
16
  ext: path.extname(this.resourcePath).slice(1),
17
17
  ...this._module?.layer ? {
@@ -1,4 +1,4 @@
1
- import { Plugin } from '@rsdoctor/types';
1
+ import type { Plugin } from '@rsdoctor/shared/types';
2
2
  export declare class ProbeLoaderPlugin {
3
3
  apply(compiler: Plugin.BaseCompiler): void;
4
4
  private addProbeLoader;
@@ -1,5 +1,5 @@
1
1
  import "node:module";
2
- import { Loader } from "@rsdoctor/utils/common";
2
+ import { Loader } from "../../../common/index.js";
3
3
  import { Build } from "../../index.js";
4
4
  import { Utils } from "../index.js";
5
5
  const BuiltinLoaderName = 'builtin:swc-loader';
@@ -1,4 +1 @@
1
- export * from './webpack/transform.js';
2
- export * from './transform.js';
3
- export * from './treeShaking.js';
4
1
  export * from './rspack/transform.js';
@@ -1,5 +1,2 @@
1
1
  import "node:module";
2
- export * from "./webpack/transform.js";
3
- export * from "./transform.js";
4
- export * from "./treeShaking.js";
5
2
  export * from "./rspack/transform.js";
@@ -1,2 +1,2 @@
1
- import { Node } from '@rsdoctor/utils/ruleUtils';
1
+ import { Node } from '../../../rule-utils/index.js';
2
2
  export declare function hasSetEsModuleStatement(program: Node.Program): boolean;
@@ -1,5 +1,5 @@
1
1
  import "node:module";
2
- import { parser } from "@rsdoctor/utils/ruleUtils";
2
+ import { parser } from "../../../rule-utils/index.js";
3
3
  const esmLabelStatement = parser.internal.parseExpressionAt('Object.defineProperty(exports, "__esModule", { value: true })', 0, {
4
4
  ecmaVersion: 6,
5
5
  ranges: false,
@@ -1,4 +1,4 @@
1
- import { Plugin, SDK } from '@rsdoctor/types';
1
+ import { Plugin, SDK } from '@rsdoctor/shared/types';
2
2
  /**
3
3
  * Patch native module graph data from Rspack into ModuleGraph instance
4
4
  * @param mg The ModuleGraph instance to be patched
@@ -1,6 +1,6 @@
1
1
  import "node:module";
2
- import { Dependency, Module, extractCodeFromLocation, parseLocation } from "@rsdoctor/graph";
3
- import { SDK } from "@rsdoctor/types";
2
+ import { Dependency, Module, extractCodeFromSourceLines, parseLocation } from "../../../../graph/index.js";
3
+ import { SDK } from "@rsdoctor/shared/types";
4
4
  const createDependencyKind = (type)=>{
5
5
  if (type.includes('harmony') || 'esm import' === type) return SDK.DependencyKind.ImportStatement;
6
6
  if (type.includes('cjs')) return SDK.DependencyKind.RequireCall;
@@ -81,7 +81,7 @@ function patchNativeModuleSources(mg, rawModuleSourcesPatch) {
81
81
  }
82
82
  const jsonModuleSizes = rawModuleSourcesPatch.jsonModuleSizes;
83
83
  if (jsonModuleSizes && jsonModuleSizes.length > 0) for (const jsonModuleSize of jsonModuleSizes){
84
- const module = mg.getModuleByWebpackId(jsonModuleSize.identifier);
84
+ const module = mg.getModuleByIdentifier(jsonModuleSize.identifier);
85
85
  if (module) module.setSize({
86
86
  parsedSize: jsonModuleSize.size
87
87
  });
@@ -94,10 +94,12 @@ function extractSideEffectCodes(mg) {
94
94
  if (!sideEffectLocations.length) continue;
95
95
  const moduleSource = module.getSource();
96
96
  const source = moduleSource.source || moduleSource.parsedSource;
97
- if (source) for (const sideEffectLocation of sideEffectLocations){
97
+ if (!source) continue;
98
+ const sourceLines = source.split('\n');
99
+ for (const sideEffectLocation of sideEffectLocations){
98
100
  const parsedLocation = parseLocation(sideEffectLocation.location);
99
101
  if (!parsedLocation) continue;
100
- const code = extractCodeFromLocation(source, parsedLocation);
102
+ const code = extractCodeFromSourceLines(sourceLines, parsedLocation);
101
103
  if (code) module.addSideEffectCode({
102
104
  moduleId: module.id,
103
105
  startLine: parsedLocation.startLine,
@@ -1,3 +1,3 @@
1
- import { SDK } from '@rsdoctor/types';
1
+ import { SDK } from '@rsdoctor/shared/types';
2
2
  export declare function getExportIdentifierStatement(name: string, module: SDK.ModuleInstance): SDK.StatementInstance | undefined;
3
3
  export declare function getDeclarationIdentifier(name: string, module: SDK.ModuleInstance): SDK.StatementInstance | undefined;
@@ -1,6 +1,5 @@
1
1
  import "node:module";
2
- import { isNumber } from "es-toolkit/compat";
3
- import { parser } from "@rsdoctor/utils/ruleUtils";
2
+ import { parser } from "../../../rule-utils/index.js";
4
3
  function getDefaultExportIdentifier(node, module, searchId) {
5
4
  const { declaration } = node;
6
5
  if (parser.asserts.isLiteral(declaration) && declaration.loc) return module.getStatement(declaration.loc);
@@ -14,9 +13,11 @@ function getDefaultExportIdentifier(node, module, searchId) {
14
13
  if (declaration.id?.loc) return module.getStatement(declaration.id.loc);
15
14
  }
16
15
  const startLine = node.declaration.loc?.start.line;
17
- if (!isNumber(startLine)) return;
16
+ if ('number' != typeof startLine) return;
18
17
  const { transformed } = module.getSource();
19
- const endColumn = transformed.split('\n')[startLine - 1].length - 1;
18
+ const line = transformed.split('\n')[startLine - 1];
19
+ if (void 0 === line) return;
20
+ const endColumn = line.length - 1;
20
21
  return module.getStatement({
21
22
  start: {
22
23
  line: startLine,
@@ -0,0 +1,2 @@
1
+ export declare function getMemoryUsage(): NodeJS.MemoryUsage;
2
+ export declare function getMemoryUsageMessage(): string;
@@ -0,0 +1,18 @@
1
+ import "node:module";
2
+ import { filesize } from "filesize";
3
+ import { memoryUsage, pid } from "process";
4
+ function getMemoryUsage() {
5
+ return memoryUsage();
6
+ }
7
+ function getMemoryUsageMessage() {
8
+ const usage = getMemoryUsage();
9
+ const msgs = [
10
+ `RSS: ${filesize(usage.rss)}`,
11
+ `Heap Total: ${filesize(usage.heapTotal)}`,
12
+ `Heap Used: ${filesize(usage.heapUsed)}`
13
+ ];
14
+ if (usage.arrayBuffers) msgs.push(`ArrayBuffers: ${filesize(usage.arrayBuffers)}`);
15
+ if (usage.external) msgs.push(`External: ${filesize(usage.external)}`);
16
+ return `["${pid}" Memory Usage] ${msgs.join(', ')}`;
17
+ }
18
+ export { getMemoryUsage, getMemoryUsageMessage };
@@ -0,0 +1,15 @@
1
+ import connect from 'connect';
2
+ import http from 'http';
3
+ import { Thirdparty } from '@rsdoctor/shared/types';
4
+ export declare const defaultHost = "127.0.0.1";
5
+ export declare const defaultPort: number;
6
+ export declare function getPort(expectPort: number, host?: string): Promise<number>;
7
+ export declare const createGetPortSyncFunctionString: (expectPort: number, host?: string) => string;
8
+ export declare function getPortSync(expectPort: number, host?: string): number | never;
9
+ export declare function createApp(): connect.Server;
10
+ export declare function createServer(port: number, host?: string): Promise<{
11
+ app: Thirdparty.connect.Server;
12
+ server: http.Server;
13
+ port: number;
14
+ close(): Promise<void> | never;
15
+ }>;
@@ -0,0 +1,107 @@
1
+ import "node:module";
2
+ import connect from "connect";
3
+ import http from "http";
4
+ import os from "os";
5
+ import get_port from "get-port";
6
+ import { execFileSync } from "child_process";
7
+ import { Algorithm } from "../../common/index.js";
8
+ const RESTRICTED_PORTS = [
9
+ 3659,
10
+ 4045,
11
+ 6000,
12
+ 6665,
13
+ 6666,
14
+ 6667,
15
+ 6668,
16
+ 6669
17
+ ];
18
+ const defaultHost = '127.0.0.1';
19
+ function getRandomPort(min, max) {
20
+ let port;
21
+ do port = Algorithm.random(min, max);
22
+ while (RESTRICTED_PORTS.includes(port));
23
+ return port;
24
+ }
25
+ const defaultPort = getRandomPort(3000, 8999);
26
+ async function getPort(expectPort, host = defaultHost) {
27
+ return get_port({
28
+ port: expectPort,
29
+ host
30
+ });
31
+ }
32
+ const createGetPortSyncFunctionString = (expectPort, host = defaultHost)=>`
33
+ (() => {
34
+ const net = require('net');
35
+
36
+ function getPort(expectPort, host) {
37
+ return new Promise((resolve, reject) => {
38
+ const server = net.createServer();
39
+ server.unref();
40
+ server.on('error', reject);
41
+ server.listen(expectPort, host, () => {
42
+ const { port } = server.address();
43
+ server.close(() => {
44
+ resolve(port);
45
+ });
46
+ });
47
+ });
48
+ }
49
+
50
+ async function getAvailablePort(expectPort) {
51
+ let port = expectPort;
52
+ while (true) {
53
+ try {
54
+ const res = await getPort(port, ${JSON.stringify(host)});
55
+ return res;
56
+ } catch (error) {
57
+ port += Math.floor(Math.random() * 100 + 1);
58
+ }
59
+ }
60
+ }
61
+
62
+ getAvailablePort(${expectPort}).then(port => process.stdout.write(port.toString()));
63
+ })();
64
+ `.trim();
65
+ function getPortSync(expectPort, host = defaultHost) {
66
+ const statement = '\n' === os.EOL ? createGetPortSyncFunctionString(expectPort, host) : createGetPortSyncFunctionString(expectPort, host).replace(/\n/g, '');
67
+ const port = execFileSync(process.execPath, [
68
+ '-e',
69
+ statement
70
+ ], {
71
+ encoding: 'utf-8'
72
+ });
73
+ return Number(port);
74
+ }
75
+ function createApp() {
76
+ return connect();
77
+ }
78
+ async function createServer(port, host = defaultHost) {
79
+ const app = createApp();
80
+ const server = http.createServer(app);
81
+ const res = {
82
+ app,
83
+ server,
84
+ port,
85
+ close () {
86
+ return new Promise((resolve, reject)=>{
87
+ if ('closeAllConnections' in server) server.closeAllConnections();
88
+ if ('closeIdleConnections' in server) server.closeIdleConnections();
89
+ server.close((err)=>{
90
+ if (err) reject(err);
91
+ resolve();
92
+ });
93
+ });
94
+ }
95
+ };
96
+ return new Promise((resolve, reject)=>{
97
+ const onError = (error)=>{
98
+ reject(error);
99
+ };
100
+ server.once('error', onError);
101
+ server.listen(port, host, ()=>{
102
+ server.off('error', onError);
103
+ resolve(res);
104
+ });
105
+ });
106
+ }
107
+ export { createApp, createGetPortSyncFunctionString, createServer, defaultHost, defaultPort, getPort, getPortSync };
@@ -1,11 +1,11 @@
1
- import type { Common, Plugin } from '@rsdoctor/types';
1
+ import type { Common, Plugin } from '@rsdoctor/shared/types';
2
2
  export declare function parsePathQueryFragment(str: string): {
3
3
  path: string;
4
4
  query: string;
5
5
  fragment: string;
6
6
  };
7
7
  export declare function loadLoaderModule(loaderPath: string, cwd?: string): {
8
- default: Plugin.LoaderDefinition<Common.PlainObject, {}>;
8
+ default: Plugin.LoaderDefinition<Common.PlainObject, object>;
9
9
  pitch: Plugin.PitchLoaderDefinitionFunction;
10
10
  raw: boolean | void;
11
11
  };