@wyw-in-js/transform 1.1.0 → 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 (801) hide show
  1. package/esm/cache.js +433 -289
  2. package/esm/cache.js.map +1 -1
  3. package/esm/debug/fileReporter.js +171 -134
  4. package/esm/debug/fileReporter.js.map +1 -1
  5. package/esm/eval/broker.js +2275 -0
  6. package/esm/eval/broker.js.map +1 -0
  7. package/esm/eval/lru.js +36 -0
  8. package/esm/eval/lru.js.map +1 -0
  9. package/esm/eval/prepareModuleOnDemand.js +21 -0
  10. package/esm/eval/prepareModuleOnDemand.js.map +1 -0
  11. package/esm/eval/protocol.js +2 -0
  12. package/esm/eval/protocol.js.map +1 -0
  13. package/esm/eval/runner.js +1878 -0
  14. package/esm/eval/runner.js.map +1 -0
  15. package/esm/eval/serialize.js +333 -0
  16. package/esm/eval/serialize.js.map +1 -0
  17. package/esm/eval/writeQueue.js +81 -0
  18. package/esm/eval/writeQueue.js.map +1 -0
  19. package/esm/evaluators/index.js +11 -12
  20. package/esm/evaluators/index.js.map +1 -1
  21. package/esm/index.js +25 -29
  22. package/esm/index.js.map +1 -1
  23. package/esm/module.js +923 -520
  24. package/esm/module.js.map +1 -1
  25. package/esm/shaker.js +14 -80
  26. package/esm/shaker.js.map +1 -1
  27. package/esm/transform/BaseEntrypoint.js +162 -164
  28. package/esm/transform/BaseEntrypoint.js.map +1 -1
  29. package/esm/transform/Entrypoint.helpers.js +96 -253
  30. package/esm/transform/Entrypoint.helpers.js.map +1 -1
  31. package/esm/transform/Entrypoint.js +336 -270
  32. package/esm/transform/Entrypoint.js.map +1 -1
  33. package/esm/transform/Entrypoint.types.js +1 -1
  34. package/esm/transform/Entrypoint.types.js.map +1 -1
  35. package/esm/transform/EvaluatedEntrypoint.js +10 -4
  36. package/esm/transform/EvaluatedEntrypoint.js.map +1 -1
  37. package/esm/transform/actions/AbortError.js +6 -6
  38. package/esm/transform/actions/AbortError.js.map +1 -1
  39. package/esm/transform/actions/BaseAction.js +140 -136
  40. package/esm/transform/actions/BaseAction.js.map +1 -1
  41. package/esm/transform/actions/UnprocessedEntrypointError.js +6 -6
  42. package/esm/transform/actions/UnprocessedEntrypointError.js.map +1 -1
  43. package/esm/transform/actions/actionRunner.js +63 -66
  44. package/esm/transform/actions/actionRunner.js.map +1 -1
  45. package/esm/transform/actions/types.js +1 -1
  46. package/esm/transform/actions/types.js.map +1 -1
  47. package/esm/transform/barrelManifest.types.js +2 -0
  48. package/esm/transform/barrelManifest.types.js.map +1 -0
  49. package/esm/transform/generators/baseProcessingHandlers.js +15 -17
  50. package/esm/transform/generators/baseProcessingHandlers.js.map +1 -1
  51. package/esm/transform/generators/collect.js +27 -55
  52. package/esm/transform/generators/collect.js.map +1 -1
  53. package/esm/transform/generators/createStylisPreprocessor.js +353 -321
  54. package/esm/transform/generators/createStylisPreprocessor.js.map +1 -1
  55. package/esm/transform/generators/evalFile.js +48 -47
  56. package/esm/transform/generators/evalFile.js.map +1 -1
  57. package/esm/transform/generators/extract.js +78 -90
  58. package/esm/transform/generators/extract.js.map +1 -1
  59. package/esm/transform/generators/getExports.js +57 -74
  60. package/esm/transform/generators/getExports.js.map +1 -1
  61. package/esm/transform/generators/index.js +11 -11
  62. package/esm/transform/generators/index.js.map +1 -1
  63. package/esm/transform/generators/processEntrypoint.js +93 -67
  64. package/esm/transform/generators/processEntrypoint.js.map +1 -1
  65. package/esm/transform/generators/processImports.js +102 -67
  66. package/esm/transform/generators/processImports.js.map +1 -1
  67. package/esm/transform/generators/resolveImports.js +212 -197
  68. package/esm/transform/generators/resolveImports.js.map +1 -1
  69. package/esm/transform/generators/resolveStaticOxcValues/cache.js +182 -0
  70. package/esm/transform/generators/resolveStaticOxcValues/cache.js.map +1 -0
  71. package/esm/transform/generators/resolveStaticOxcValues/candidateResolver.js +146 -0
  72. package/esm/transform/generators/resolveStaticOxcValues/candidateResolver.js.map +1 -0
  73. package/esm/transform/generators/resolveStaticOxcValues/dependencies.js +33 -0
  74. package/esm/transform/generators/resolveStaticOxcValues/dependencies.js.map +1 -0
  75. package/esm/transform/generators/resolveStaticOxcValues/environment.js +29 -0
  76. package/esm/transform/generators/resolveStaticOxcValues/environment.js.map +1 -0
  77. package/esm/transform/generators/resolveStaticOxcValues/exportResolver.js +351 -0
  78. package/esm/transform/generators/resolveStaticOxcValues/exportResolver.js.map +1 -0
  79. package/esm/transform/generators/resolveStaticOxcValues/exportTargets.js +253 -0
  80. package/esm/transform/generators/resolveStaticOxcValues/exportTargets.js.map +1 -0
  81. package/esm/transform/generators/resolveStaticOxcValues/objectAssign.js +310 -0
  82. package/esm/transform/generators/resolveStaticOxcValues/objectAssign.js.map +1 -0
  83. package/esm/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.js +74 -0
  84. package/esm/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.js.map +1 -0
  85. package/esm/transform/generators/resolveStaticOxcValues/opaqueRuntime.js +229 -0
  86. package/esm/transform/generators/resolveStaticOxcValues/opaqueRuntime.js.map +1 -0
  87. package/esm/transform/generators/resolveStaticOxcValues/processorStaticExport.js +172 -0
  88. package/esm/transform/generators/resolveStaticOxcValues/processorStaticExport.js.map +1 -0
  89. package/esm/transform/generators/resolveStaticOxcValues/processorStaticModel.js +476 -0
  90. package/esm/transform/generators/resolveStaticOxcValues/processorStaticModel.js.map +1 -0
  91. package/esm/transform/generators/resolveStaticOxcValues/processorTarget.js +55 -0
  92. package/esm/transform/generators/resolveStaticOxcValues/processorTarget.js.map +1 -0
  93. package/esm/transform/generators/resolveStaticOxcValues/programAnalysis.js +123 -0
  94. package/esm/transform/generators/resolveStaticOxcValues/programAnalysis.js.map +1 -0
  95. package/esm/transform/generators/resolveStaticOxcValues/prune.js +186 -0
  96. package/esm/transform/generators/resolveStaticOxcValues/prune.js.map +1 -0
  97. package/esm/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.js +183 -0
  98. package/esm/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.js.map +1 -0
  99. package/esm/transform/generators/resolveStaticOxcValues/staticExpression.js +298 -0
  100. package/esm/transform/generators/resolveStaticOxcValues/staticExpression.js.map +1 -0
  101. package/esm/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.js +298 -0
  102. package/esm/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.js.map +1 -0
  103. package/esm/transform/generators/resolveStaticOxcValues/types.js +3 -0
  104. package/esm/transform/generators/resolveStaticOxcValues/types.js.map +1 -0
  105. package/esm/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.js +59 -0
  106. package/esm/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.js.map +1 -0
  107. package/esm/transform/generators/resolveStaticOxcValues.js +2 -0
  108. package/esm/transform/generators/resolveStaticOxcValues.js.map +1 -0
  109. package/esm/transform/generators/rewriteOxcBarrelImports.js +822 -0
  110. package/esm/transform/generators/rewriteOxcBarrelImports.js.map +1 -0
  111. package/esm/transform/generators/transform.js +251 -248
  112. package/esm/transform/generators/transform.js.map +1 -1
  113. package/esm/transform/generators/workflow.js +87 -90
  114. package/esm/transform/generators/workflow.js.map +1 -1
  115. package/esm/transform/helpers/loadWywOptions.js +183 -74
  116. package/esm/transform/helpers/loadWywOptions.js.map +1 -1
  117. package/esm/transform/helpers/withDefaultServices.js +13 -22
  118. package/esm/transform/helpers/withDefaultServices.js.map +1 -1
  119. package/esm/transform/isStaticallyEvaluatableModule.js +140 -152
  120. package/esm/transform/isStaticallyEvaluatableModule.js.map +1 -1
  121. package/esm/transform/oxcBarrelManifest.js +349 -0
  122. package/esm/transform/oxcBarrelManifest.js.map +1 -0
  123. package/esm/transform/rootLog.js +3 -3
  124. package/esm/transform/rootLog.js.map +1 -1
  125. package/esm/transform/syntax.js +2 -0
  126. package/esm/transform/syntax.js.map +1 -0
  127. package/esm/transform/types.js +2 -2
  128. package/esm/transform/types.js.map +1 -1
  129. package/esm/transform.js +125 -147
  130. package/esm/transform.js.map +1 -1
  131. package/esm/types.js +4 -1
  132. package/esm/types.js.map +1 -1
  133. package/esm/utils/EventEmitter.js +79 -48
  134. package/esm/utils/EventEmitter.js.map +1 -1
  135. package/esm/utils/ShakerMetadata.js +2 -2
  136. package/esm/utils/ShakerMetadata.js.map +1 -1
  137. package/esm/utils/TransformDiagnostics.js +9 -9
  138. package/esm/utils/TransformDiagnostics.js.map +1 -1
  139. package/esm/utils/TransformMetadata.js +24 -26
  140. package/esm/utils/TransformMetadata.js.map +1 -1
  141. package/esm/utils/applyOxcProcessors/applyOxcProcessors.js +160 -0
  142. package/esm/utils/applyOxcProcessors/applyOxcProcessors.js.map +1 -0
  143. package/esm/utils/applyOxcProcessors/cleanupBindings.js +157 -0
  144. package/esm/utils/applyOxcProcessors/cleanupBindings.js.map +1 -0
  145. package/esm/utils/applyOxcProcessors/cleanupRemovals.js +431 -0
  146. package/esm/utils/applyOxcProcessors/cleanupRemovals.js.map +1 -0
  147. package/esm/utils/applyOxcProcessors/displayName.js +93 -0
  148. package/esm/utils/applyOxcProcessors/displayName.js.map +1 -0
  149. package/esm/utils/applyOxcProcessors/expressionValues.js +152 -0
  150. package/esm/utils/applyOxcProcessors/expressionValues.js.map +1 -0
  151. package/esm/utils/applyOxcProcessors/processorFactory.js +62 -0
  152. package/esm/utils/applyOxcProcessors/processorFactory.js.map +1 -0
  153. package/esm/utils/applyOxcProcessors/processorUsages.js +143 -0
  154. package/esm/utils/applyOxcProcessors/processorUsages.js.map +1 -0
  155. package/esm/utils/applyOxcProcessors/sameFileStaticValues.js +207 -0
  156. package/esm/utils/applyOxcProcessors/sameFileStaticValues.js.map +1 -0
  157. package/esm/utils/applyOxcProcessors/shared.js +29 -0
  158. package/esm/utils/applyOxcProcessors/shared.js.map +1 -0
  159. package/esm/utils/applyOxcProcessors/types.js +2 -0
  160. package/esm/utils/applyOxcProcessors/types.js.map +1 -0
  161. package/esm/utils/applyOxcProcessors.js +2 -0
  162. package/esm/utils/applyOxcProcessors.js.map +1 -0
  163. package/esm/utils/collectOxcExportsAndImports.js +934 -0
  164. package/esm/utils/collectOxcExportsAndImports.js.map +1 -0
  165. package/esm/utils/collectOxcRuntime/normalizeRuntimeCode.js +157 -0
  166. package/esm/utils/collectOxcRuntime/normalizeRuntimeCode.js.map +1 -0
  167. package/esm/utils/collectOxcRuntime/sourceMap.js +36 -0
  168. package/esm/utils/collectOxcRuntime/sourceMap.js.map +1 -0
  169. package/esm/utils/collectOxcRuntime/types.js +2 -0
  170. package/esm/utils/collectOxcRuntime/types.js.map +1 -0
  171. package/esm/utils/collectOxcRuntime.js +32 -0
  172. package/esm/utils/collectOxcRuntime.js.map +1 -0
  173. package/esm/utils/collectOxcTemplateDependencies/expressionExtraction.js +496 -0
  174. package/esm/utils/collectOxcTemplateDependencies/expressionExtraction.js.map +1 -0
  175. package/esm/utils/collectOxcTemplateDependencies/expressionReplacements.js +113 -0
  176. package/esm/utils/collectOxcTemplateDependencies/expressionReplacements.js.map +1 -0
  177. package/esm/utils/collectOxcTemplateDependencies/scopeAnalysis.js +387 -0
  178. package/esm/utils/collectOxcTemplateDependencies/scopeAnalysis.js.map +1 -0
  179. package/esm/utils/collectOxcTemplateDependencies/staticBindings.js +17 -0
  180. package/esm/utils/collectOxcTemplateDependencies/staticBindings.js.map +1 -0
  181. package/esm/utils/collectOxcTemplateDependencies/staticEvaluator.js +540 -0
  182. package/esm/utils/collectOxcTemplateDependencies/staticEvaluator.js.map +1 -0
  183. package/esm/utils/collectOxcTemplateDependencies/types.js +2 -0
  184. package/esm/utils/collectOxcTemplateDependencies/types.js.map +1 -0
  185. package/esm/utils/collectOxcTemplateDependencies.js +4 -0
  186. package/esm/utils/collectOxcTemplateDependencies.js.map +1 -0
  187. package/esm/utils/dispose-polyfill.js +3 -4
  188. package/esm/utils/dispose-polyfill.js.map +1 -1
  189. package/esm/utils/getFileIdx.js +6 -6
  190. package/esm/utils/getFileIdx.js.map +1 -1
  191. package/esm/utils/getPluginKey.js +12 -12
  192. package/esm/utils/getPluginKey.js.map +1 -1
  193. package/esm/utils/getVisitorKeys.js +9 -3
  194. package/esm/utils/getVisitorKeys.js.map +1 -1
  195. package/esm/utils/hasCachedWywPrevalExport.js +23 -0
  196. package/esm/utils/hasCachedWywPrevalExport.js.map +1 -0
  197. package/esm/utils/hasWywPreval.js +5 -5
  198. package/esm/utils/hasWywPreval.js.map +1 -1
  199. package/esm/utils/importOverrides.js +75 -90
  200. package/esm/utils/importOverrides.js.map +1 -1
  201. package/esm/utils/isNode.js +2 -2
  202. package/esm/utils/isNode.js.map +1 -1
  203. package/esm/utils/isNotNull.js +2 -2
  204. package/esm/utils/isNotNull.js.map +1 -1
  205. package/esm/utils/isSerializable.js +11 -11
  206. package/esm/utils/isSerializable.js.map +1 -1
  207. package/esm/utils/nativeResolver.js +93 -0
  208. package/esm/utils/nativeResolver.js.map +1 -0
  209. package/esm/utils/oxc/ast.js +28 -0
  210. package/esm/utils/oxc/ast.js.map +1 -0
  211. package/esm/utils/oxc/parse.js +3 -0
  212. package/esm/utils/oxc/parse.js.map +1 -0
  213. package/esm/utils/oxc/replacements.js +14 -0
  214. package/esm/utils/oxc/replacements.js.map +1 -0
  215. package/esm/utils/oxc/sourceLocations.js +59 -0
  216. package/esm/utils/oxc/sourceLocations.js.map +1 -0
  217. package/esm/utils/oxcAstService.js +121 -0
  218. package/esm/utils/oxcAstService.js.map +1 -0
  219. package/esm/utils/oxcEmit.js +447 -0
  220. package/esm/utils/oxcEmit.js.map +1 -0
  221. package/esm/utils/oxcPreevalStage/evalStrategy.js +3 -0
  222. package/esm/utils/oxcPreevalStage/evalStrategy.js.map +1 -0
  223. package/esm/utils/oxcPreevalStage/prepareCode.js +21 -0
  224. package/esm/utils/oxcPreevalStage/prepareCode.js.map +1 -0
  225. package/esm/utils/oxcPreevalStage/prevalExport.js +23 -0
  226. package/esm/utils/oxcPreevalStage/prevalExport.js.map +1 -0
  227. package/esm/utils/oxcPreevalStage/processors.js +17 -0
  228. package/esm/utils/oxcPreevalStage/processors.js.map +1 -0
  229. package/esm/utils/oxcPreevalStage/staticOverlay.js +18 -0
  230. package/esm/utils/oxcPreevalStage/staticOverlay.js.map +1 -0
  231. package/esm/utils/oxcPreevalStage/types.js +2 -0
  232. package/esm/utils/oxcPreevalStage/types.js.map +1 -0
  233. package/esm/utils/oxcPreevalStage.js +41 -0
  234. package/esm/utils/oxcPreevalStage.js.map +1 -0
  235. package/esm/utils/oxcPreevalTransforms.js +1065 -0
  236. package/esm/utils/oxcPreevalTransforms.js.map +1 -0
  237. package/esm/utils/oxcShaker.js +662 -0
  238. package/esm/utils/oxcShaker.js.map +1 -0
  239. package/esm/utils/parseOxc.js +37 -0
  240. package/esm/utils/parseOxc.js.map +1 -0
  241. package/esm/utils/parseRequest.js +27 -27
  242. package/esm/utils/parseRequest.js.map +1 -1
  243. package/esm/utils/peek.js +1 -1
  244. package/esm/utils/peek.js.map +1 -1
  245. package/esm/utils/processorLookup.js +125 -0
  246. package/esm/utils/processorLookup.js.map +1 -0
  247. package/esm/utils/processorStaticSemantics.js +157 -0
  248. package/esm/utils/processorStaticSemantics.js.map +1 -0
  249. package/esm/utils/resolveWithConditions.js +99 -0
  250. package/esm/utils/resolveWithConditions.js.map +1 -0
  251. package/esm/vm/createVmContext.js +140 -141
  252. package/esm/vm/createVmContext.js.map +1 -1
  253. package/esm/vm/process.js +11 -13
  254. package/esm/vm/process.js.map +1 -1
  255. package/package.json +19 -26
  256. package/types/cache.d.ts +17 -8
  257. package/types/cache.js +245 -95
  258. package/types/debug/fileReporter.js +68 -23
  259. package/types/eval/broker.d.ts +92 -0
  260. package/types/eval/broker.js +2411 -0
  261. package/types/eval/lru.d.ts +10 -0
  262. package/types/eval/lru.js +36 -0
  263. package/types/eval/prepareModuleOnDemand.d.ts +7 -0
  264. package/types/eval/prepareModuleOnDemand.js +24 -0
  265. package/types/eval/protocol.d.ts +111 -0
  266. package/types/eval/protocol.js +1 -0
  267. package/types/eval/serialize.d.ts +78 -0
  268. package/types/eval/serialize.js +357 -0
  269. package/types/eval/writeQueue.d.ts +13 -0
  270. package/types/eval/writeQueue.js +80 -0
  271. package/types/evaluators/index.d.ts +2 -2
  272. package/types/evaluators/index.js +6 -9
  273. package/types/index.d.ts +3 -6
  274. package/types/index.js +24 -82
  275. package/types/module.d.ts +38 -7
  276. package/types/module.js +613 -192
  277. package/types/shaker.d.ts +2 -10
  278. package/types/shaker.js +10 -100
  279. package/types/transform/BaseEntrypoint.js +6 -11
  280. package/types/transform/Entrypoint.d.ts +15 -15
  281. package/types/transform/Entrypoint.helpers.d.ts +2 -5
  282. package/types/transform/Entrypoint.helpers.js +43 -203
  283. package/types/transform/Entrypoint.js +130 -53
  284. package/types/transform/Entrypoint.types.d.ts +31 -6
  285. package/types/transform/Entrypoint.types.js +1 -2
  286. package/types/transform/EvaluatedEntrypoint.d.ts +13 -2
  287. package/types/transform/EvaluatedEntrypoint.js +7 -6
  288. package/types/transform/actions/AbortError.js +2 -7
  289. package/types/transform/actions/BaseAction.js +4 -8
  290. package/types/transform/actions/UnprocessedEntrypointError.js +2 -7
  291. package/types/transform/actions/actionRunner.js +8 -12
  292. package/types/transform/actions/types.d.ts +2 -2
  293. package/types/transform/actions/types.js +1 -2
  294. package/types/transform/{barrelManifest.d.ts → barrelManifest.types.d.ts} +0 -2
  295. package/types/transform/barrelManifest.types.js +1 -0
  296. package/types/transform/generators/baseProcessingHandlers.d.ts +4 -5
  297. package/types/transform/generators/baseProcessingHandlers.js +10 -14
  298. package/types/transform/generators/collect.js +13 -39
  299. package/types/transform/generators/createStylisPreprocessor.js +19 -60
  300. package/types/transform/generators/evalFile.d.ts +2 -2
  301. package/types/transform/generators/evalFile.js +26 -28
  302. package/types/transform/generators/extract.js +5 -8
  303. package/types/transform/generators/getExports.js +23 -30
  304. package/types/transform/generators/index.d.ts +2 -2
  305. package/types/transform/generators/index.js +11 -14
  306. package/types/transform/generators/processEntrypoint.d.ts +2 -2
  307. package/types/transform/generators/processEntrypoint.js +60 -26
  308. package/types/transform/generators/processImports.d.ts +0 -3
  309. package/types/transform/generators/processImports.js +60 -20
  310. package/types/transform/generators/resolveImports.d.ts +3 -1
  311. package/types/transform/generators/resolveImports.js +66 -23
  312. package/types/transform/generators/resolveStaticOxcValues/cache.d.ts +25 -0
  313. package/types/transform/generators/resolveStaticOxcValues/cache.js +182 -0
  314. package/types/transform/generators/resolveStaticOxcValues/candidateResolver.d.ts +5 -0
  315. package/types/transform/generators/resolveStaticOxcValues/candidateResolver.js +149 -0
  316. package/types/transform/generators/resolveStaticOxcValues/dependencies.d.ts +6 -0
  317. package/types/transform/generators/resolveStaticOxcValues/dependencies.js +37 -0
  318. package/types/transform/generators/resolveStaticOxcValues/environment.d.ts +12 -0
  319. package/types/transform/generators/resolveStaticOxcValues/environment.js +32 -0
  320. package/types/transform/generators/resolveStaticOxcValues/exportResolver.d.ts +4 -0
  321. package/types/transform/generators/resolveStaticOxcValues/exportResolver.js +358 -0
  322. package/types/transform/generators/resolveStaticOxcValues/exportTargets.d.ts +20 -0
  323. package/types/transform/generators/resolveStaticOxcValues/exportTargets.js +285 -0
  324. package/types/transform/generators/resolveStaticOxcValues/objectAssign.d.ts +41 -0
  325. package/types/transform/generators/resolveStaticOxcValues/objectAssign.js +352 -0
  326. package/types/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.d.ts +6 -0
  327. package/types/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.js +88 -0
  328. package/types/transform/generators/resolveStaticOxcValues/opaqueRuntime.d.ts +13 -0
  329. package/types/transform/generators/resolveStaticOxcValues/opaqueRuntime.js +263 -0
  330. package/types/transform/generators/resolveStaticOxcValues/processorStaticExport.d.ts +4 -0
  331. package/types/transform/generators/resolveStaticOxcValues/processorStaticExport.js +191 -0
  332. package/types/transform/generators/resolveStaticOxcValues/processorStaticModel.d.ts +40 -0
  333. package/types/transform/generators/resolveStaticOxcValues/processorStaticModel.js +516 -0
  334. package/types/transform/generators/resolveStaticOxcValues/processorTarget.d.ts +5 -0
  335. package/types/transform/generators/resolveStaticOxcValues/processorTarget.js +62 -0
  336. package/types/transform/generators/resolveStaticOxcValues/programAnalysis.d.ts +11 -0
  337. package/types/transform/generators/resolveStaticOxcValues/programAnalysis.js +133 -0
  338. package/types/transform/generators/resolveStaticOxcValues/prune.d.ts +15 -0
  339. package/types/transform/generators/resolveStaticOxcValues/prune.js +220 -0
  340. package/types/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.d.ts +2 -0
  341. package/types/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.js +197 -0
  342. package/types/transform/generators/resolveStaticOxcValues/staticExpression.d.ts +25 -0
  343. package/types/transform/generators/resolveStaticOxcValues/staticExpression.js +391 -0
  344. package/types/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.d.ts +14 -0
  345. package/types/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.js +304 -0
  346. package/types/transform/generators/resolveStaticOxcValues/types.d.ts +99 -0
  347. package/types/transform/generators/resolveStaticOxcValues/types.js +2 -0
  348. package/types/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.d.ts +7 -0
  349. package/types/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.js +64 -0
  350. package/types/transform/generators/resolveStaticOxcValues.d.ts +1 -0
  351. package/types/transform/generators/resolveStaticOxcValues.js +1 -0
  352. package/types/transform/generators/{rewriteBarrelImports.d.ts → rewriteOxcBarrelImports.d.ts} +2 -3
  353. package/types/transform/generators/{rewriteBarrelImports.js → rewriteOxcBarrelImports.js} +282 -225
  354. package/types/transform/generators/transform.d.ts +3 -7
  355. package/types/transform/generators/transform.js +217 -199
  356. package/types/transform/generators/workflow.js +62 -45
  357. package/types/transform/helpers/loadWywOptions.js +115 -21
  358. package/types/transform/helpers/withDefaultServices.d.ts +1 -1
  359. package/types/transform/helpers/withDefaultServices.js +6 -44
  360. package/types/transform/isStaticallyEvaluatableModule.d.ts +1 -2
  361. package/types/transform/isStaticallyEvaluatableModule.js +125 -126
  362. package/types/transform/oxcBarrelManifest.d.ts +2 -0
  363. package/types/transform/{barrelManifest.js → oxcBarrelManifest.js} +156 -97
  364. package/types/transform/rootLog.js +2 -5
  365. package/types/transform/syntax.d.ts +38 -0
  366. package/types/transform/syntax.js +1 -0
  367. package/types/transform/types.d.ts +9 -6
  368. package/types/transform/types.js +1 -4
  369. package/types/transform.d.ts +2 -2
  370. package/types/transform.js +90 -101
  371. package/types/types.d.ts +0 -23
  372. package/types/types.js +1 -2
  373. package/types/utils/EventEmitter.d.ts +16 -1
  374. package/types/utils/EventEmitter.js +47 -18
  375. package/types/utils/ShakerMetadata.js +1 -5
  376. package/types/utils/TransformDiagnostics.js +3 -7
  377. package/types/utils/TransformMetadata.js +8 -16
  378. package/types/utils/applyOxcProcessors/applyOxcProcessors.d.ts +8 -0
  379. package/types/utils/applyOxcProcessors/applyOxcProcessors.js +167 -0
  380. package/types/utils/applyOxcProcessors/cleanupBindings.d.ts +12 -0
  381. package/types/utils/applyOxcProcessors/cleanupBindings.js +189 -0
  382. package/types/utils/applyOxcProcessors/cleanupRemovals.d.ts +16 -0
  383. package/types/utils/applyOxcProcessors/cleanupRemovals.js +482 -0
  384. package/types/utils/applyOxcProcessors/displayName.d.ts +9 -0
  385. package/types/utils/applyOxcProcessors/displayName.js +113 -0
  386. package/types/utils/applyOxcProcessors/expressionValues.d.ts +11 -0
  387. package/types/utils/applyOxcProcessors/expressionValues.js +170 -0
  388. package/types/utils/applyOxcProcessors/processorFactory.d.ts +7 -0
  389. package/types/utils/applyOxcProcessors/processorFactory.js +70 -0
  390. package/types/utils/applyOxcProcessors/processorUsages.d.ts +16 -0
  391. package/types/utils/applyOxcProcessors/processorUsages.js +163 -0
  392. package/types/utils/applyOxcProcessors/sameFileStaticValues.d.ts +23 -0
  393. package/types/utils/applyOxcProcessors/sameFileStaticValues.js +211 -0
  394. package/types/utils/applyOxcProcessors/shared.d.ts +10 -0
  395. package/types/utils/applyOxcProcessors/shared.js +37 -0
  396. package/types/utils/applyOxcProcessors/types.d.ts +88 -0
  397. package/types/utils/applyOxcProcessors/types.js +1 -0
  398. package/types/utils/applyOxcProcessors.d.ts +1 -0
  399. package/types/utils/applyOxcProcessors.js +1 -0
  400. package/types/utils/collectOxcExportsAndImports.d.ts +35 -0
  401. package/types/utils/collectOxcExportsAndImports.js +957 -0
  402. package/types/utils/collectOxcRuntime/normalizeRuntimeCode.d.ts +1 -0
  403. package/types/utils/collectOxcRuntime/normalizeRuntimeCode.js +185 -0
  404. package/types/utils/collectOxcRuntime/sourceMap.d.ts +2 -0
  405. package/types/utils/collectOxcRuntime/sourceMap.js +37 -0
  406. package/types/utils/collectOxcRuntime/types.d.ts +16 -0
  407. package/types/utils/collectOxcRuntime/types.js +1 -0
  408. package/types/utils/collectOxcRuntime.d.ts +4 -0
  409. package/types/utils/collectOxcRuntime.js +31 -0
  410. package/types/utils/collectOxcTemplateDependencies/expressionExtraction.d.ts +6 -0
  411. package/types/utils/collectOxcTemplateDependencies/expressionExtraction.js +550 -0
  412. package/types/utils/collectOxcTemplateDependencies/expressionReplacements.d.ts +11 -0
  413. package/types/utils/collectOxcTemplateDependencies/expressionReplacements.js +131 -0
  414. package/types/utils/collectOxcTemplateDependencies/scopeAnalysis.d.ts +20 -0
  415. package/types/utils/collectOxcTemplateDependencies/scopeAnalysis.js +434 -0
  416. package/types/utils/collectOxcTemplateDependencies/staticBindings.d.ts +7 -0
  417. package/types/utils/collectOxcTemplateDependencies/staticBindings.js +13 -0
  418. package/types/utils/collectOxcTemplateDependencies/staticEvaluator.d.ts +13 -0
  419. package/types/utils/collectOxcTemplateDependencies/staticEvaluator.js +626 -0
  420. package/types/utils/collectOxcTemplateDependencies/types.d.ts +116 -0
  421. package/types/utils/collectOxcTemplateDependencies/types.js +1 -0
  422. package/types/utils/collectOxcTemplateDependencies.d.ts +4 -0
  423. package/types/utils/collectOxcTemplateDependencies.js +3 -0
  424. package/types/utils/getFileIdx.js +1 -4
  425. package/types/utils/getPluginKey.d.ts +5 -2
  426. package/types/utils/getPluginKey.js +2 -6
  427. package/types/utils/getVisitorKeys.d.ts +4 -4
  428. package/types/utils/getVisitorKeys.js +9 -6
  429. package/types/utils/hasCachedWywPrevalExport.d.ts +14 -0
  430. package/types/utils/hasCachedWywPrevalExport.js +30 -0
  431. package/types/utils/hasWywPreval.js +1 -4
  432. package/types/utils/importOverrides.js +17 -27
  433. package/types/utils/isNode.d.ts +2 -2
  434. package/types/utils/isNode.js +2 -6
  435. package/types/utils/isNotNull.js +1 -4
  436. package/types/utils/isSerializable.js +3 -6
  437. package/types/utils/nativeResolver.d.ts +13 -0
  438. package/types/utils/nativeResolver.js +91 -0
  439. package/types/utils/oxc/ast.d.ts +4 -0
  440. package/types/utils/oxc/ast.js +37 -0
  441. package/types/utils/oxc/parse.d.ts +3 -0
  442. package/types/utils/oxc/parse.js +2 -0
  443. package/types/utils/oxc/replacements.d.ts +12 -0
  444. package/types/utils/oxc/replacements.js +18 -0
  445. package/types/utils/oxc/sourceLocations.d.ts +5 -0
  446. package/types/utils/oxc/sourceLocations.js +63 -0
  447. package/types/utils/oxcAstService.d.ts +11 -0
  448. package/types/utils/oxcAstService.js +79 -0
  449. package/types/utils/oxcEmit.d.ts +19 -0
  450. package/types/utils/oxcEmit.js +506 -0
  451. package/types/utils/oxcPreevalStage/evalStrategy.d.ts +3 -0
  452. package/types/utils/oxcPreevalStage/evalStrategy.js +2 -0
  453. package/types/utils/oxcPreevalStage/prepareCode.d.ts +3 -0
  454. package/types/utils/oxcPreevalStage/prepareCode.js +20 -0
  455. package/types/utils/oxcPreevalStage/prevalExport.d.ts +1 -0
  456. package/types/utils/oxcPreevalStage/prevalExport.js +22 -0
  457. package/types/utils/oxcPreevalStage/processors.d.ts +10 -0
  458. package/types/utils/oxcPreevalStage/processors.js +16 -0
  459. package/types/utils/oxcPreevalStage/staticOverlay.d.ts +3 -0
  460. package/types/utils/oxcPreevalStage/staticOverlay.js +23 -0
  461. package/types/utils/oxcPreevalStage/types.d.ts +22 -0
  462. package/types/utils/oxcPreevalStage/types.js +1 -0
  463. package/types/utils/oxcPreevalStage.d.ts +4 -0
  464. package/types/utils/oxcPreevalStage.js +40 -0
  465. package/types/utils/oxcPreevalTransforms.d.ts +13 -0
  466. package/types/utils/oxcPreevalTransforms.js +1192 -0
  467. package/types/utils/oxcShaker.d.ts +13 -0
  468. package/types/utils/oxcShaker.js +751 -0
  469. package/types/utils/parseOxc.d.ts +11 -0
  470. package/types/utils/parseOxc.js +38 -0
  471. package/types/utils/parseRequest.js +2 -7
  472. package/types/utils/peek.js +1 -5
  473. package/types/utils/processorLookup.d.ts +8 -0
  474. package/types/utils/processorLookup.js +135 -0
  475. package/types/utils/processorStaticSemantics.d.ts +13 -0
  476. package/types/utils/processorStaticSemantics.js +191 -0
  477. package/types/utils/resolveWithConditions.d.ts +12 -0
  478. package/types/utils/resolveWithConditions.js +103 -0
  479. package/types/vm/createVmContext.d.ts +2 -2
  480. package/types/vm/createVmContext.js +25 -62
  481. package/types/vm/process.js +20 -26
  482. package/esm/babel.js +0 -2
  483. package/esm/babel.js.map +0 -1
  484. package/esm/options/buildOptions.js +0 -168
  485. package/esm/options/buildOptions.js.map +0 -1
  486. package/esm/options/buildOptions.test.js +0 -138
  487. package/esm/options/buildOptions.test.js.map +0 -1
  488. package/esm/options/loadBabelOptions.js +0 -24
  489. package/esm/options/loadBabelOptions.js.map +0 -1
  490. package/esm/plugins/babel-transform.js +0 -53
  491. package/esm/plugins/babel-transform.js.map +0 -1
  492. package/esm/plugins/collector.js +0 -60
  493. package/esm/plugins/collector.js.map +0 -1
  494. package/esm/plugins/dynamic-import.js +0 -56
  495. package/esm/plugins/dynamic-import.js.map +0 -1
  496. package/esm/plugins/preeval.js +0 -73
  497. package/esm/plugins/preeval.js.map +0 -1
  498. package/esm/plugins/shaker.js +0 -680
  499. package/esm/plugins/shaker.js.map +0 -1
  500. package/esm/transform/barrelManifest.js +0 -291
  501. package/esm/transform/barrelManifest.js.map +0 -1
  502. package/esm/transform/generators/explodeReexports.js +0 -64
  503. package/esm/transform/generators/explodeReexports.js.map +0 -1
  504. package/esm/transform/generators/rewriteBarrelImports.js +0 -733
  505. package/esm/transform/generators/rewriteBarrelImports.js.map +0 -1
  506. package/esm/utils/addIdentifierToWywPreval.js +0 -68
  507. package/esm/utils/addIdentifierToWywPreval.js.map +0 -1
  508. package/esm/utils/collectExportsAndImports.js +0 -1157
  509. package/esm/utils/collectExportsAndImports.js.map +0 -1
  510. package/esm/utils/collectTemplateDependencies.js +0 -228
  511. package/esm/utils/collectTemplateDependencies.js.map +0 -1
  512. package/esm/utils/createId.js +0 -6
  513. package/esm/utils/createId.js.map +0 -1
  514. package/esm/utils/findIdentifiers.js +0 -62
  515. package/esm/utils/findIdentifiers.js.map +0 -1
  516. package/esm/utils/getConstantStringValue.js +0 -58
  517. package/esm/utils/getConstantStringValue.js.map +0 -1
  518. package/esm/utils/getMemberExpressionPropertyName.js +0 -11
  519. package/esm/utils/getMemberExpressionPropertyName.js.map +0 -1
  520. package/esm/utils/getScope.js +0 -6
  521. package/esm/utils/getScope.js.map +0 -1
  522. package/esm/utils/getSource.js +0 -15
  523. package/esm/utils/getSource.js.map +0 -1
  524. package/esm/utils/getTagProcessor.js +0 -404
  525. package/esm/utils/getTagProcessor.js.map +0 -1
  526. package/esm/utils/isExports.js +0 -22
  527. package/esm/utils/isExports.js.map +0 -1
  528. package/esm/utils/isGlobal.js +0 -6
  529. package/esm/utils/isGlobal.js.map +0 -1
  530. package/esm/utils/isNodePath.js +0 -4
  531. package/esm/utils/isNodePath.js.map +0 -1
  532. package/esm/utils/isRemoved.js +0 -46
  533. package/esm/utils/isRemoved.js.map +0 -1
  534. package/esm/utils/isRequire.js +0 -13
  535. package/esm/utils/isRequire.js.map +0 -1
  536. package/esm/utils/isTypedNode.js +0 -6
  537. package/esm/utils/isTypedNode.js.map +0 -1
  538. package/esm/utils/isUnnecessaryReactCall.js +0 -72
  539. package/esm/utils/isUnnecessaryReactCall.js.map +0 -1
  540. package/esm/utils/removeDangerousCode.js +0 -276
  541. package/esm/utils/removeDangerousCode.js.map +0 -1
  542. package/esm/utils/replaceImportMetaEnv.js +0 -44
  543. package/esm/utils/replaceImportMetaEnv.js.map +0 -1
  544. package/esm/utils/scopeHelpers.js +0 -527
  545. package/esm/utils/scopeHelpers.js.map +0 -1
  546. package/esm/utils/traversalCache.js +0 -23
  547. package/esm/utils/traversalCache.js.map +0 -1
  548. package/esm/utils/unwrapExpression.js +0 -18
  549. package/esm/utils/unwrapExpression.js.map +0 -1
  550. package/esm/utils/unwrapSequence.js +0 -14
  551. package/esm/utils/unwrapSequence.js.map +0 -1
  552. package/esm/utils/valueToLiteral.js +0 -59
  553. package/esm/utils/valueToLiteral.js.map +0 -1
  554. package/esm/utils/visitors/JSXElementsRemover.js +0 -51
  555. package/esm/utils/visitors/JSXElementsRemover.js.map +0 -1
  556. package/lib/babel.js +0 -2
  557. package/lib/babel.js.map +0 -1
  558. package/lib/cache.js +0 -308
  559. package/lib/cache.js.map +0 -1
  560. package/lib/debug/fileReporter.js +0 -153
  561. package/lib/debug/fileReporter.js.map +0 -1
  562. package/lib/evaluators/index.js +0 -20
  563. package/lib/evaluators/index.js.map +0 -1
  564. package/lib/index.js +0 -286
  565. package/lib/index.js.map +0 -1
  566. package/lib/module.js +0 -552
  567. package/lib/module.js.map +0 -1
  568. package/lib/options/buildOptions.js +0 -176
  569. package/lib/options/buildOptions.js.map +0 -1
  570. package/lib/options/buildOptions.test.js +0 -141
  571. package/lib/options/buildOptions.test.js.map +0 -1
  572. package/lib/options/loadBabelOptions.js +0 -31
  573. package/lib/options/loadBabelOptions.js.map +0 -1
  574. package/lib/plugins/babel-transform.js +0 -60
  575. package/lib/plugins/babel-transform.js.map +0 -1
  576. package/lib/plugins/collector.js +0 -70
  577. package/lib/plugins/collector.js.map +0 -1
  578. package/lib/plugins/dynamic-import.js +0 -61
  579. package/lib/plugins/dynamic-import.js.map +0 -1
  580. package/lib/plugins/preeval.js +0 -81
  581. package/lib/plugins/preeval.js.map +0 -1
  582. package/lib/plugins/shaker.js +0 -691
  583. package/lib/plugins/shaker.js.map +0 -1
  584. package/lib/shaker.js +0 -95
  585. package/lib/shaker.js.map +0 -1
  586. package/lib/transform/BaseEntrypoint.js +0 -179
  587. package/lib/transform/BaseEntrypoint.js.map +0 -1
  588. package/lib/transform/Entrypoint.helpers.js +0 -279
  589. package/lib/transform/Entrypoint.helpers.js.map +0 -1
  590. package/lib/transform/Entrypoint.js +0 -289
  591. package/lib/transform/Entrypoint.js.map +0 -1
  592. package/lib/transform/Entrypoint.types.js +0 -2
  593. package/lib/transform/Entrypoint.types.js.map +0 -1
  594. package/lib/transform/EvaluatedEntrypoint.js +0 -13
  595. package/lib/transform/EvaluatedEntrypoint.js.map +0 -1
  596. package/lib/transform/actions/AbortError.js +0 -16
  597. package/lib/transform/actions/AbortError.js.map +0 -1
  598. package/lib/transform/actions/BaseAction.js +0 -150
  599. package/lib/transform/actions/BaseAction.js.map +0 -1
  600. package/lib/transform/actions/UnprocessedEntrypointError.js +0 -16
  601. package/lib/transform/actions/UnprocessedEntrypointError.js.map +0 -1
  602. package/lib/transform/actions/actionRunner.js +0 -82
  603. package/lib/transform/actions/actionRunner.js.map +0 -1
  604. package/lib/transform/actions/types.js +0 -2
  605. package/lib/transform/actions/types.js.map +0 -1
  606. package/lib/transform/barrelManifest.js +0 -300
  607. package/lib/transform/barrelManifest.js.map +0 -1
  608. package/lib/transform/generators/baseProcessingHandlers.js +0 -27
  609. package/lib/transform/generators/baseProcessingHandlers.js.map +0 -1
  610. package/lib/transform/generators/collect.js +0 -66
  611. package/lib/transform/generators/collect.js.map +0 -1
  612. package/lib/transform/generators/createStylisPreprocessor.js +0 -372
  613. package/lib/transform/generators/createStylisPreprocessor.js.map +0 -1
  614. package/lib/transform/generators/evalFile.js +0 -57
  615. package/lib/transform/generators/evalFile.js.map +0 -1
  616. package/lib/transform/generators/explodeReexports.js +0 -71
  617. package/lib/transform/generators/explodeReexports.js.map +0 -1
  618. package/lib/transform/generators/extract.js +0 -102
  619. package/lib/transform/generators/extract.js.map +0 -1
  620. package/lib/transform/generators/getExports.js +0 -85
  621. package/lib/transform/generators/getExports.js.map +0 -1
  622. package/lib/transform/generators/index.js +0 -19
  623. package/lib/transform/generators/index.js.map +0 -1
  624. package/lib/transform/generators/processEntrypoint.js +0 -76
  625. package/lib/transform/generators/processEntrypoint.js.map +0 -1
  626. package/lib/transform/generators/processImports.js +0 -82
  627. package/lib/transform/generators/processImports.js.map +0 -1
  628. package/lib/transform/generators/resolveImports.js +0 -221
  629. package/lib/transform/generators/resolveImports.js.map +0 -1
  630. package/lib/transform/generators/rewriteBarrelImports.js +0 -743
  631. package/lib/transform/generators/rewriteBarrelImports.js.map +0 -1
  632. package/lib/transform/generators/transform.js +0 -272
  633. package/lib/transform/generators/transform.js.map +0 -1
  634. package/lib/transform/generators/workflow.js +0 -100
  635. package/lib/transform/generators/workflow.js.map +0 -1
  636. package/lib/transform/helpers/loadWywOptions.js +0 -88
  637. package/lib/transform/helpers/loadWywOptions.js.map +0 -1
  638. package/lib/transform/helpers/withDefaultServices.js +0 -31
  639. package/lib/transform/helpers/withDefaultServices.js.map +0 -1
  640. package/lib/transform/isStaticallyEvaluatableModule.js +0 -159
  641. package/lib/transform/isStaticallyEvaluatableModule.js.map +0 -1
  642. package/lib/transform/rootLog.js +0 -9
  643. package/lib/transform/rootLog.js.map +0 -1
  644. package/lib/transform/types.js +0 -8
  645. package/lib/transform/types.js.map +0 -1
  646. package/lib/transform.js +0 -160
  647. package/lib/transform.js.map +0 -1
  648. package/lib/types.js +0 -2
  649. package/lib/types.js.map +0 -1
  650. package/lib/utils/EventEmitter.js +0 -61
  651. package/lib/utils/EventEmitter.js.map +0 -1
  652. package/lib/utils/ShakerMetadata.js +0 -9
  653. package/lib/utils/ShakerMetadata.js.map +0 -1
  654. package/lib/utils/TransformDiagnostics.js +0 -20
  655. package/lib/utils/TransformDiagnostics.js.map +0 -1
  656. package/lib/utils/TransformMetadata.js +0 -45
  657. package/lib/utils/TransformMetadata.js.map +0 -1
  658. package/lib/utils/addIdentifierToWywPreval.js +0 -75
  659. package/lib/utils/addIdentifierToWywPreval.js.map +0 -1
  660. package/lib/utils/collectExportsAndImports.js +0 -1173
  661. package/lib/utils/collectExportsAndImports.js.map +0 -1
  662. package/lib/utils/collectTemplateDependencies.js +0 -242
  663. package/lib/utils/collectTemplateDependencies.js.map +0 -1
  664. package/lib/utils/createId.js +0 -13
  665. package/lib/utils/createId.js.map +0 -1
  666. package/lib/utils/dispose-polyfill.js +0 -9
  667. package/lib/utils/dispose-polyfill.js.map +0 -1
  668. package/lib/utils/findIdentifiers.js +0 -73
  669. package/lib/utils/findIdentifiers.js.map +0 -1
  670. package/lib/utils/getConstantStringValue.js +0 -66
  671. package/lib/utils/getConstantStringValue.js.map +0 -1
  672. package/lib/utils/getFileIdx.js +0 -16
  673. package/lib/utils/getFileIdx.js.map +0 -1
  674. package/lib/utils/getMemberExpressionPropertyName.js +0 -18
  675. package/lib/utils/getMemberExpressionPropertyName.js.map +0 -1
  676. package/lib/utils/getPluginKey.js +0 -21
  677. package/lib/utils/getPluginKey.js.map +0 -1
  678. package/lib/utils/getScope.js +0 -12
  679. package/lib/utils/getScope.js.map +0 -1
  680. package/lib/utils/getSource.js +0 -24
  681. package/lib/utils/getSource.js.map +0 -1
  682. package/lib/utils/getTagProcessor.js +0 -424
  683. package/lib/utils/getTagProcessor.js.map +0 -1
  684. package/lib/utils/getVisitorKeys.js +0 -11
  685. package/lib/utils/getVisitorKeys.js.map +0 -1
  686. package/lib/utils/hasWywPreval.js +0 -13
  687. package/lib/utils/hasWywPreval.js.map +0 -1
  688. package/lib/utils/importOverrides.js +0 -119
  689. package/lib/utils/importOverrides.js.map +0 -1
  690. package/lib/utils/isExports.js +0 -27
  691. package/lib/utils/isExports.js.map +0 -1
  692. package/lib/utils/isGlobal.js +0 -13
  693. package/lib/utils/isGlobal.js.map +0 -1
  694. package/lib/utils/isNode.js +0 -9
  695. package/lib/utils/isNode.js.map +0 -1
  696. package/lib/utils/isNodePath.js +0 -10
  697. package/lib/utils/isNodePath.js.map +0 -1
  698. package/lib/utils/isNotNull.js +0 -10
  699. package/lib/utils/isNotNull.js.map +0 -1
  700. package/lib/utils/isRemoved.js +0 -52
  701. package/lib/utils/isRemoved.js.map +0 -1
  702. package/lib/utils/isRequire.js +0 -18
  703. package/lib/utils/isRequire.js.map +0 -1
  704. package/lib/utils/isSerializable.js +0 -19
  705. package/lib/utils/isSerializable.js.map +0 -1
  706. package/lib/utils/isTypedNode.js +0 -13
  707. package/lib/utils/isTypedNode.js.map +0 -1
  708. package/lib/utils/isUnnecessaryReactCall.js +0 -81
  709. package/lib/utils/isUnnecessaryReactCall.js.map +0 -1
  710. package/lib/utils/parseRequest.js +0 -37
  711. package/lib/utils/parseRequest.js.map +0 -1
  712. package/lib/utils/peek.js +0 -9
  713. package/lib/utils/peek.js.map +0 -1
  714. package/lib/utils/removeDangerousCode.js +0 -284
  715. package/lib/utils/removeDangerousCode.js.map +0 -1
  716. package/lib/utils/replaceImportMetaEnv.js +0 -50
  717. package/lib/utils/replaceImportMetaEnv.js.map +0 -1
  718. package/lib/utils/scopeHelpers.js +0 -557
  719. package/lib/utils/scopeHelpers.js.map +0 -1
  720. package/lib/utils/traversalCache.js +0 -31
  721. package/lib/utils/traversalCache.js.map +0 -1
  722. package/lib/utils/unwrapExpression.js +0 -25
  723. package/lib/utils/unwrapExpression.js.map +0 -1
  724. package/lib/utils/unwrapSequence.js +0 -20
  725. package/lib/utils/unwrapSequence.js.map +0 -1
  726. package/lib/utils/valueToLiteral.js +0 -65
  727. package/lib/utils/valueToLiteral.js.map +0 -1
  728. package/lib/utils/visitors/JSXElementsRemover.js +0 -57
  729. package/lib/utils/visitors/JSXElementsRemover.js.map +0 -1
  730. package/lib/vm/createVmContext.js +0 -166
  731. package/lib/vm/createVmContext.js.map +0 -1
  732. package/lib/vm/process.js +0 -38
  733. package/lib/vm/process.js.map +0 -1
  734. package/types/babel.d.ts +0 -2
  735. package/types/babel.js +0 -2
  736. package/types/options/buildOptions.d.ts +0 -6
  737. package/types/options/buildOptions.js +0 -178
  738. package/types/options/loadBabelOptions.d.ts +0 -3
  739. package/types/options/loadBabelOptions.js +0 -26
  740. package/types/plugins/babel-transform.d.ts +0 -4
  741. package/types/plugins/babel-transform.js +0 -49
  742. package/types/plugins/collector.d.ts +0 -23
  743. package/types/plugins/collector.js +0 -62
  744. package/types/plugins/dynamic-import.d.ts +0 -6
  745. package/types/plugins/dynamic-import.js +0 -60
  746. package/types/plugins/preeval.d.ts +0 -16
  747. package/types/plugins/preeval.js +0 -69
  748. package/types/plugins/shaker.d.ts +0 -14
  749. package/types/plugins/shaker.js +0 -724
  750. package/types/transform/generators/explodeReexports.d.ts +0 -7
  751. package/types/transform/generators/explodeReexports.js +0 -65
  752. package/types/utils/addIdentifierToWywPreval.d.ts +0 -4
  753. package/types/utils/addIdentifierToWywPreval.js +0 -74
  754. package/types/utils/collectExportsAndImports.d.ts +0 -31
  755. package/types/utils/collectExportsAndImports.js +0 -1147
  756. package/types/utils/collectTemplateDependencies.d.ts +0 -17
  757. package/types/utils/collectTemplateDependencies.js +0 -220
  758. package/types/utils/createId.d.ts +0 -2
  759. package/types/utils/createId.js +0 -9
  760. package/types/utils/findIdentifiers.d.ts +0 -6
  761. package/types/utils/findIdentifiers.js +0 -67
  762. package/types/utils/getConstantStringValue.d.ts +0 -2
  763. package/types/utils/getConstantStringValue.js +0 -94
  764. package/types/utils/getMemberExpressionPropertyName.d.ts +0 -2
  765. package/types/utils/getMemberExpressionPropertyName.js +0 -46
  766. package/types/utils/getScope.d.ts +0 -2
  767. package/types/utils/getScope.js +0 -10
  768. package/types/utils/getSource.d.ts +0 -2
  769. package/types/utils/getSource.js +0 -22
  770. package/types/utils/getTagProcessor.d.ts +0 -13
  771. package/types/utils/getTagProcessor.js +0 -411
  772. package/types/utils/isExports.d.ts +0 -6
  773. package/types/utils/isExports.js +0 -19
  774. package/types/utils/isGlobal.d.ts +0 -2
  775. package/types/utils/isGlobal.js +0 -9
  776. package/types/utils/isNodePath.d.ts +0 -3
  777. package/types/utils/isNodePath.js +0 -6
  778. package/types/utils/isRemoved.d.ts +0 -5
  779. package/types/utils/isRemoved.js +0 -41
  780. package/types/utils/isRequire.d.ts +0 -6
  781. package/types/utils/isRequire.js +0 -14
  782. package/types/utils/isTypedNode.d.ts +0 -5
  783. package/types/utils/isTypedNode.js +0 -9
  784. package/types/utils/isUnnecessaryReactCall.d.ts +0 -3
  785. package/types/utils/isUnnecessaryReactCall.js +0 -75
  786. package/types/utils/removeDangerousCode.d.ts +0 -4
  787. package/types/utils/removeDangerousCode.js +0 -326
  788. package/types/utils/replaceImportMetaEnv.d.ts +0 -3
  789. package/types/utils/replaceImportMetaEnv.js +0 -39
  790. package/types/utils/scopeHelpers.d.ts +0 -12
  791. package/types/utils/scopeHelpers.js +0 -580
  792. package/types/utils/traversalCache.d.ts +0 -4
  793. package/types/utils/traversalCache.js +0 -27
  794. package/types/utils/unwrapExpression.d.ts +0 -2
  795. package/types/utils/unwrapExpression.js +0 -57
  796. package/types/utils/unwrapSequence.d.ts +0 -8
  797. package/types/utils/unwrapSequence.js +0 -16
  798. package/types/utils/valueToLiteral.d.ts +0 -3
  799. package/types/utils/valueToLiteral.js +0 -63
  800. package/types/utils/visitors/JSXElementsRemover.d.ts +0 -3
  801. package/types/utils/visitors/JSXElementsRemover.js +0 -51
@@ -1,527 +0,0 @@
1
- /* eslint-disable no-restricted-syntax */
2
- /* eslint @typescript-eslint/no-use-before-define: ["error", { "functions": false }] */
3
-
4
- import { NODE_FIELDS } from '@babel/types';
5
- import { findIdentifiers, nonType } from './findIdentifiers';
6
- import { getScope } from './getScope';
7
- import { isNotNull } from './isNotNull';
8
- import { isRemoved } from './isRemoved';
9
- function validateField(node, key, val, field) {
10
- if (!(field != null && field.validate)) return true;
11
- if (field.optional && val == null) return true;
12
- try {
13
- field.validate(node, key, val);
14
- return true;
15
- } catch {
16
- return false;
17
- }
18
- }
19
- function getBinding(path) {
20
- const binding = getScope(path).getBinding(path.node.name);
21
- if (!binding) {
22
- return undefined;
23
- }
24
- return binding;
25
- }
26
- export function reference(path, referencePath = path, force = false) {
27
- if (!force && !path.isReferencedIdentifier()) return;
28
- const binding = getBinding(path);
29
- if (!binding) return;
30
- if (binding.referencePaths.includes(referencePath)) {
31
- return;
32
- }
33
- binding.referenced = true;
34
- binding.referencePaths.push(referencePath ?? path);
35
- binding.references = binding.referencePaths.length;
36
- }
37
- function isReferenced(binding) {
38
- const {
39
- kind,
40
- referenced,
41
- referencePaths,
42
- path
43
- } = binding;
44
- if (path.isFunctionExpression() && path.key === 'init' && path.parentPath.isVariableDeclarator()) {
45
- // It is a function expression in a variable declarator
46
- const id = path.parentPath.get('id');
47
- if (id.isIdentifier()) {
48
- const idBinding = getBinding(id);
49
- return idBinding ? isReferenced(idBinding) : true;
50
- }
51
- return true;
52
- }
53
- if (!referenced) {
54
- return false;
55
- }
56
-
57
- // If it's a param binding, we can't just remove it
58
- // because it brakes the function signature. Keep it alive for now.
59
- if (kind === 'param') {
60
- return true;
61
- }
62
-
63
- // If all remaining references are in TS/Flow types, binding is unreferenced
64
- return referencePaths.length > 0 || referencePaths.every(i => i.find(ancestor => ancestor.isTSType() || ancestor.isFlowType()));
65
- }
66
- function isReferencedConstantViolation(path, binding) {
67
- if (path.find(p => p === binding.path)) {
68
- // function a(flag) { return (a = function(flag) { flag ? 1 : 2 }) }
69
- // ^ Looks crazy, yeh? Welcome to the wonderful world of transpilers!
70
- // `a = …` here isn't a reference.
71
- return false;
72
- }
73
- if (!path.isReferenced()) {
74
- return false;
75
- }
76
- if (path.isAssignmentExpression() && path.parentPath.isExpressionStatement()) {
77
- // A root assignment without a parent expression statement is not a reference
78
- return false;
79
- }
80
- return true;
81
- }
82
- export function dereference(path) {
83
- const binding = getBinding(path);
84
- if (!binding) return null;
85
- const isReference = binding.referencePaths.includes(path);
86
- let referencesInConstantViolations = binding.constantViolations.filter(i => isReferencedConstantViolation(i, binding));
87
- const isConstantViolation = referencesInConstantViolations.includes(path);
88
- if (!isReference && !isConstantViolation) {
89
- return null;
90
- }
91
- if (isReference) {
92
- binding.referencePaths = binding.referencePaths.filter(i => i !== path);
93
- binding.references -= 1;
94
- } else {
95
- referencesInConstantViolations = referencesInConstantViolations.filter(i => i !== path);
96
- }
97
- const nonTypeReferences = binding.referencePaths.filter(nonType);
98
- binding.referenced = nonTypeReferences.length + referencesInConstantViolations.length > 0;
99
- return binding;
100
- }
101
- function dereferenceAll(path) {
102
- return findIdentifiers([path]).map(identifierPath => dereference(identifierPath)).filter(isNotNull);
103
- }
104
- export function referenceAll(path) {
105
- findIdentifiers([path]).forEach(identifierPath => reference(identifierPath));
106
- }
107
- const deletingNodes = new WeakSet();
108
- const isEmptyList = list => list.length === 0 || list.every(i => deletingNodes.has(i));
109
- const getPathFromAction = action => {
110
- if (!Array.isArray(action)) {
111
- return action;
112
- }
113
- if (action[0] === 'replace' || action[0] === 'remove') {
114
- return action[1];
115
- }
116
- throw new Error(`Unknown action type: ${action[0]}`);
117
- };
118
- function isPrototypeAssignment(path) {
119
- if (!path.isAssignmentExpression()) {
120
- return false;
121
- }
122
- const {
123
- left
124
- } = path.node;
125
- if (!left) {
126
- return false;
127
- }
128
- if (left.type !== 'MemberExpression') {
129
- return false;
130
- }
131
- const {
132
- object,
133
- property
134
- } = left;
135
- if (!object || !property) {
136
- return false;
137
- }
138
- return object.type === 'MemberExpression' && object.property.type === 'Identifier' && object.property.name === 'prototype';
139
- }
140
- function canFunctionBeDelete(fnPath) {
141
- if (isPrototypeAssignment(fnPath.parentPath)) {
142
- // It is a prototype assignment, we can't delete it since we can't find all usages
143
- return false;
144
- }
145
- const fnScope = fnPath.scope;
146
- const parentScope = fnScope.parent;
147
- if (parentScope.parent) {
148
- // It isn't a top-level function, so we can't delete it
149
- return true;
150
- }
151
- if (fnPath.listKey === 'arguments') {
152
- // It is passed as an argument to another function, we can't delete it
153
- return true;
154
- }
155
- return false;
156
- }
157
- export function findActionForNode(path) {
158
- if (isRemoved(path)) return null;
159
- deletingNodes.add(path);
160
- const parent = path.parentPath;
161
- if (!parent) return ['remove', path];
162
- if (parent.isProgram()) {
163
- // Do not delete Program node
164
- return ['remove', path];
165
- }
166
- if (parent.isClassDeclaration() || parent.isClassExpression()) {
167
- if (path.key === 'body') {
168
- return ['replace', path, {
169
- type: 'ClassBody',
170
- body: []
171
- }];
172
- }
173
- }
174
- if (parent.isFunction()) {
175
- if (path.listKey === 'params') {
176
- // Do not remove params of functions
177
- return null;
178
- }
179
- if (path.isBlockStatement() && isEmptyList(path.get('body')) || path === parent.get('body')) {
180
- if (!canFunctionBeDelete(parent)) {
181
- return ['replace', parent, {
182
- ...parent.node,
183
- async: false,
184
- body: {
185
- type: 'BlockStatement',
186
- body: [],
187
- directives: []
188
- },
189
- generator: false,
190
- params: []
191
- }];
192
- }
193
- }
194
- }
195
- if (parent.isConditionalExpression()) {
196
- if (path.key === 'test') {
197
- return ['replace', parent, parent.node.alternate];
198
- }
199
- if (path.key === 'consequent') {
200
- return ['replace', path, {
201
- type: 'Identifier',
202
- name: 'undefined'
203
- }];
204
- }
205
- if (path.key === 'alternate') {
206
- return ['replace', path, {
207
- type: 'Identifier',
208
- name: 'undefined'
209
- }];
210
- }
211
- }
212
- if (parent.isLogicalExpression({
213
- operator: '&&'
214
- })) {
215
- return ['replace', parent, {
216
- type: 'BooleanLiteral',
217
- value: false
218
- }];
219
- }
220
- if (parent.isLogicalExpression({
221
- operator: '||'
222
- })) {
223
- return ['replace', parent, path.key === 'left' ? parent.node.right : parent.node.left];
224
- }
225
- if (parent.isObjectProperty()) {
226
- // let's check if it is a special case with Object.defineProperty
227
- const key = parent.get('key');
228
- if (key.isIdentifier({
229
- name: 'get'
230
- })) {
231
- const maybeDefineProperty = parent.parentPath.parentPath;
232
- if (maybeDefineProperty?.isCallExpression() && maybeDefineProperty.get('callee').matchesPattern('Object.defineProperty')) {
233
- return findActionForNode(maybeDefineProperty);
234
- }
235
- }
236
- return findActionForNode(parent);
237
- }
238
- if (parent.isTemplateLiteral()) {
239
- return ['replace', path, {
240
- type: 'StringLiteral',
241
- value: ''
242
- }];
243
- }
244
- if (parent.isAssignmentExpression()) {
245
- if (path.isAssignmentExpression()) {
246
- // `foo = bar = 42` should be replaced with `foo = 42`
247
- return ['replace', path, path.node.right];
248
- }
249
- return findActionForNode(parent);
250
- }
251
- if (parent.isCallExpression()) {
252
- return findActionForNode(parent);
253
- }
254
- if (parent.isForInStatement({
255
- left: path.node
256
- })) {
257
- return findActionForNode(parent);
258
- }
259
- if (parent.isFunctionExpression({
260
- body: path.node
261
- }) || parent.isFunctionDeclaration() || parent.isObjectMethod() || parent.isClassMethod()) {
262
- return findActionForNode(parent);
263
- }
264
- if (parent.isBlockStatement()) {
265
- const body = parent.get('body');
266
- if (isEmptyList(body)) {
267
- return findActionForNode(parent);
268
- }
269
- if (path.listKey === 'body' && typeof path.key === 'number') {
270
- if (path.key > 0) {
271
- // We can check whether the previous one can be removed
272
- const prevStatement = body[path.key - 1];
273
- if (prevStatement.isIfStatement() && prevStatement.get('consequent').isReturnStatement()) {
274
- // It's `if (…) return …`, we can remove it.
275
- return findActionForNode(prevStatement);
276
- }
277
- } else if (body.slice(1).every(statement => deletingNodes.has(statement))) {
278
- // If it is the first statement and all other statements
279
- // are marked for deletion, we can remove the whole block.
280
- return findActionForNode(parent);
281
- }
282
- }
283
- }
284
- if (parent.isVariableDeclarator()) {
285
- if (path.key === 'init' && path.isAssignmentExpression()) {
286
- // We are removing `bar` in `var foo = bar = 42`. Path should be replaced with `var foo = 42`
287
- return ['replace', path, path.node.right];
288
- }
289
- const init = parent.get('init');
290
- if (path.key === 'id' && init.isAssignmentExpression()) {
291
- // We are removing `foo` in `var foo = bar = 42`. Ignore it.
292
- return null;
293
- }
294
- return findActionForNode(parent);
295
- }
296
- if (parent.isExportNamedDeclaration() && (path.key === 'specifiers' && isEmptyList(parent.get('specifiers')) || path.key === 'declaration' && parent.node.declaration === path.node)) {
297
- return findActionForNode(parent);
298
- }
299
- for (const key of ['body', 'declarations', 'specifiers']) {
300
- if (path.listKey === key && typeof path.key === 'number') {
301
- const list = parent.get(key);
302
- if (isEmptyList(list)) {
303
- return findActionForNode(parent);
304
- }
305
- }
306
- }
307
- if (parent.isTryStatement()) {
308
- return findActionForNode(parent);
309
- }
310
- if (!path.listKey && path.key) {
311
- const field = NODE_FIELDS[parent.type][path.key];
312
- if (!validateField(parent.node, path.key, null, field)) {
313
- // The parent node isn't valid without this field, so we should remove it also.
314
- return findActionForNode(parent);
315
- }
316
- }
317
- for (const key of ['argument', 'block', 'body', 'callee', 'discriminant', 'expression', 'id', 'left', 'object', 'property', 'right', 'test']) {
318
- if (path.key === key && parent.get(key) === path) {
319
- return findActionForNode(parent);
320
- }
321
- }
322
- return ['remove', path];
323
- }
324
-
325
- // @babel/preset-typescript transpiles enums, but doesn't reference used identifiers.
326
- function referenceEnums(program) {
327
- /*
328
- * We are looking for transpiled enums.
329
- * (function (Colors) {
330
- * Colors["BLUE"] = "#27509A";
331
- * })(Colors || (Colors = {}));
332
- */
333
- program.traverse({
334
- ExpressionStatement(expressionStatement) {
335
- const expression = expressionStatement.get('expression');
336
- if (!expression.isCallExpression()) return;
337
- const callee = expression.get('callee');
338
- const args = expression.get('arguments');
339
- if (!callee.isFunctionExpression() || args.length !== 1) return;
340
- const [arg] = args;
341
- if (arg.isLogicalExpression({
342
- operator: '||'
343
- })) {
344
- referenceAll(arg);
345
- }
346
- }
347
- });
348
- }
349
- const fixed = new WeakSet();
350
- function removeUnreferenced(items) {
351
- const referenced = new Set();
352
- items.forEach(item => {
353
- if (!item.node || isRemoved(item)) return;
354
- const binding = getScope(item).getBinding(item.node.name);
355
- if (!binding) return;
356
- const hasReferences = binding.referencePaths.filter(i => !isRemoved(i)).length > 0;
357
- if (hasReferences) {
358
- referenced.add(item);
359
- return;
360
- }
361
- const forDeleting = [binding.path, ...binding.constantViolations].map(findActionForNode).filter(isNotNull).map(getPathFromAction);
362
- if (forDeleting.length === 0) return;
363
- findIdentifiers(forDeleting).forEach(identifier => {
364
- referenced.add(identifier);
365
- });
366
- removeWithRelated(forDeleting);
367
- });
368
- const result = [...referenced];
369
- result.sort((a, b) => a.node?.name.localeCompare(b.node?.name));
370
- return result;
371
- }
372
- function getNodeForValue(value) {
373
- if (typeof value === 'string') {
374
- return {
375
- type: 'StringLiteral',
376
- value
377
- };
378
- }
379
- if (typeof value === 'number') {
380
- return {
381
- type: 'NumericLiteral',
382
- value
383
- };
384
- }
385
- if (typeof value === 'boolean') {
386
- return {
387
- type: 'BooleanLiteral',
388
- value
389
- };
390
- }
391
- if (value === null) {
392
- return {
393
- type: 'NullLiteral'
394
- };
395
- }
396
- if (value === undefined) {
397
- return {
398
- type: 'Identifier',
399
- name: 'undefined'
400
- };
401
- }
402
- return undefined;
403
- }
404
- function staticEvaluate(path) {
405
- if (!path) return;
406
- const evaluated = path.evaluate();
407
- if (evaluated.confident) {
408
- const node = getNodeForValue(evaluated.value);
409
- if (node) {
410
- applyAction(['replace', path, node]);
411
- return;
412
- }
413
- }
414
- if (path.isIfStatement()) {
415
- const test = path.get('test');
416
- if (!test.isBooleanLiteral()) {
417
- return;
418
- }
419
- const {
420
- consequent,
421
- alternate
422
- } = path.node;
423
- if (test.node.value) {
424
- applyAction(['replace', path, consequent]);
425
- } else if (alternate) {
426
- applyAction(['replace', path, alternate]);
427
- } else {
428
- applyAction(['remove', path]);
429
- }
430
- }
431
- }
432
- function applyAction(action) {
433
- mutate(action[1], p => {
434
- if (isRemoved(p)) return;
435
- const parent = p.parentPath;
436
- if (action[0] === 'remove') {
437
- p.remove();
438
- }
439
- if (action[0] === 'replace') {
440
- p.replaceWith(action[2]);
441
- }
442
- staticEvaluate(parent);
443
- });
444
- }
445
- function removeWithRelated(paths) {
446
- if (paths.length === 0) return;
447
- const rootPath = getScope(paths[0]).getProgramParent().path;
448
- if (!fixed.has(rootPath)) {
449
- // Some libraries don't care about bindings, references, and other staff
450
- // So we have to fix the scope before we can detect unused code
451
- referenceEnums(rootPath);
452
- fixed.add(rootPath);
453
- }
454
- const actions = paths.map(findActionForNode).filter(isNotNull);
455
- const affectedPaths = actions.map(getPathFromAction);
456
- let referencedIdentifiers = findIdentifiers(affectedPaths, 'reference');
457
- referencedIdentifiers.sort((a, b) => a.node?.name.localeCompare(b.node?.name));
458
- const referencesOfBinding = findIdentifiers(affectedPaths, 'declaration').map(i => (i.node && getScope(i).getBinding(i.node.name)) ?? null).filter(isNotNull).reduce((acc, i) => [...acc, ...i.referencePaths.filter(nonType)], []).filter(ref =>
459
- // Do not remove `export default function`
460
- !ref.isExportDefaultDeclaration() || !ref.get('declaration').isFunctionDeclaration());
461
- actions.forEach(applyAction);
462
- removeWithRelated(referencesOfBinding);
463
- let clean = false;
464
- while (!clean && referencedIdentifiers.length > 0) {
465
- const referenced = removeUnreferenced(referencedIdentifiers);
466
- clean = referenced.map(i => i.node?.name).join('|') === referencedIdentifiers.map(i => i.node?.name).join('|');
467
- referencedIdentifiers = referenced;
468
- }
469
- }
470
- function mutate(path, fn) {
471
- const dereferenced = dereferenceAll(path);
472
- const mutated = fn(path);
473
- referenceAll(path);
474
- mutated?.forEach(p => referenceAll(p));
475
- const dead = dereferenced.filter(p => !isReferenced(p));
476
- const forDeleting = [];
477
- dead.forEach(binding => {
478
- const assignments = [binding.path, ...binding.constantViolations];
479
- assignments.forEach(assignment => {
480
- const {
481
- scope
482
- } = assignment;
483
- const declared = Object.values(assignment.getOuterBindingIdentifiers(false));
484
- if (declared.length === 1 && 'name' in declared[0] && declared[0].name === binding.identifier.name) {
485
- const init = assignment.get('init');
486
- if (!Array.isArray(init) && init?.isAssignmentExpression()) {
487
- // `const a = b = 1` → `b = 1`
488
- assignment.parentPath?.replaceWith({
489
- type: 'ExpressionStatement',
490
- expression: init.node
491
- });
492
- const left = init.get('left');
493
- if (left.isIdentifier()) {
494
- // If it was forcefully referenced in the shaker
495
- dereference(left);
496
- }
497
- return;
498
- }
499
- // Only one identifier is declared, so we can remove the whole declaration
500
- forDeleting.push(assignment);
501
- return;
502
- }
503
- if (declared.every(identifier => identifier.type === 'Identifier' && !scope.getBinding(identifier.name)?.referenced)) {
504
- // No other identifier is referenced, so we can remove the whole declaration
505
- forDeleting.push(assignment);
506
- return;
507
- }
508
-
509
- // We can't remove the binding, but we can remove the part of it
510
- assignment.traverse({
511
- Identifier(identifier) {
512
- if (identifier.node.name === binding.identifier.name) {
513
- const parent = identifier.parentPath;
514
- if (parent.isArrayPattern() && identifier.listKey === 'elements' && typeof identifier.key === 'number') {
515
- parent.node.elements[identifier.key] = null;
516
- } else if (parent.isObjectProperty()) {
517
- forDeleting.push(parent);
518
- }
519
- }
520
- }
521
- });
522
- });
523
- });
524
- removeWithRelated(forDeleting);
525
- }
526
- export { applyAction, mutate, removeWithRelated };
527
- //# sourceMappingURL=scopeHelpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scopeHelpers.js","names":["NODE_FIELDS","findIdentifiers","nonType","getScope","isNotNull","isRemoved","validateField","node","key","val","field","validate","optional","getBinding","path","binding","name","undefined","reference","referencePath","force","isReferencedIdentifier","referencePaths","includes","referenced","push","references","length","isReferenced","kind","isFunctionExpression","parentPath","isVariableDeclarator","id","get","isIdentifier","idBinding","every","i","find","ancestor","isTSType","isFlowType","isReferencedConstantViolation","p","isAssignmentExpression","isExpressionStatement","dereference","isReference","referencesInConstantViolations","constantViolations","filter","isConstantViolation","nonTypeReferences","dereferenceAll","map","identifierPath","referenceAll","forEach","deletingNodes","WeakSet","isEmptyList","list","has","getPathFromAction","action","Array","isArray","Error","isPrototypeAssignment","left","type","object","property","canFunctionBeDelete","fnPath","fnScope","scope","parentScope","parent","listKey","findActionForNode","add","isProgram","isClassDeclaration","isClassExpression","body","isFunction","isBlockStatement","async","directives","generator","params","isConditionalExpression","alternate","isLogicalExpression","operator","value","right","isObjectProperty","maybeDefineProperty","isCallExpression","matchesPattern","isTemplateLiteral","isForInStatement","isFunctionDeclaration","isObjectMethod","isClassMethod","prevStatement","isIfStatement","isReturnStatement","slice","statement","init","isExportNamedDeclaration","declaration","isTryStatement","referenceEnums","program","traverse","ExpressionStatement","expressionStatement","expression","callee","args","arg","fixed","removeUnreferenced","items","Set","item","hasReferences","forDeleting","identifier","removeWithRelated","result","sort","a","b","localeCompare","getNodeForValue","staticEvaluate","evaluated","evaluate","confident","applyAction","test","isBooleanLiteral","consequent","mutate","remove","replaceWith","paths","rootPath","getProgramParent","actions","affectedPaths","referencedIdentifiers","referencesOfBinding","reduce","acc","ref","isExportDefaultDeclaration","clean","join","fn","dereferenced","mutated","dead","assignments","assignment","declared","Object","values","getOuterBindingIdentifiers","Identifier","isArrayPattern","elements"],"sources":["../../src/utils/scopeHelpers.ts"],"sourcesContent":["/* eslint-disable no-restricted-syntax */\n/* eslint @typescript-eslint/no-use-before-define: [\"error\", { \"functions\": false }] */\n\nimport type { Binding, NodePath } from '@babel/traverse';\nimport type {\n FieldOptions,\n Function as FunctionNode,\n Identifier,\n JSXIdentifier,\n Node,\n Program,\n} from '@babel/types';\nimport { NODE_FIELDS } from '@babel/types';\n\nimport { findIdentifiers, nonType } from './findIdentifiers';\nimport { getScope } from './getScope';\nimport { isNotNull } from './isNotNull';\nimport { isRemoved } from './isRemoved';\n\nfunction validateField(\n node: Node,\n key: string,\n val: unknown,\n field: FieldOptions\n) {\n if (!(field != null && field.validate)) return true;\n if (field.optional && val == null) return true;\n try {\n field.validate(node, key, val);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction getBinding(path: NodePath<Identifier | JSXIdentifier>) {\n const binding = getScope(path).getBinding(path.node.name);\n if (!binding) {\n return undefined;\n }\n\n return binding;\n}\n\nexport function reference(\n path: NodePath<Identifier | JSXIdentifier>,\n referencePath: NodePath = path,\n force = false\n): void {\n if (!force && !path.isReferencedIdentifier()) return;\n\n const binding = getBinding(path);\n if (!binding) return;\n\n if (binding.referencePaths.includes(referencePath)) {\n return;\n }\n\n binding.referenced = true;\n binding.referencePaths.push(referencePath ?? path);\n binding.references = binding.referencePaths.length;\n}\n\nfunction isReferenced(binding: Binding): boolean {\n const { kind, referenced, referencePaths, path } = binding;\n\n if (\n path.isFunctionExpression() &&\n path.key === 'init' &&\n path.parentPath.isVariableDeclarator()\n ) {\n // It is a function expression in a variable declarator\n const id = path.parentPath.get('id');\n if (id.isIdentifier()) {\n const idBinding = getBinding(id);\n return idBinding ? isReferenced(idBinding) : true;\n }\n\n return true;\n }\n\n if (!referenced) {\n return false;\n }\n\n // If it's a param binding, we can't just remove it\n // because it brakes the function signature. Keep it alive for now.\n if ((kind as string) === 'param') {\n return true;\n }\n\n // If all remaining references are in TS/Flow types, binding is unreferenced\n return (\n referencePaths.length > 0 ||\n referencePaths.every((i) =>\n i.find((ancestor) => ancestor.isTSType() || ancestor.isFlowType())\n )\n );\n}\n\nfunction isReferencedConstantViolation(path: NodePath, binding: Binding) {\n if (path.find((p) => p === binding.path)) {\n // function a(flag) { return (a = function(flag) { flag ? 1 : 2 }) }\n // ^ Looks crazy, yeh? Welcome to the wonderful world of transpilers!\n // `a = …` here isn't a reference.\n return false;\n }\n\n if (!path.isReferenced()) {\n return false;\n }\n\n if (\n path.isAssignmentExpression() &&\n path.parentPath.isExpressionStatement()\n ) {\n // A root assignment without a parent expression statement is not a reference\n return false;\n }\n\n return true;\n}\n\nexport function dereference(\n path: NodePath<Identifier | JSXIdentifier>\n): Binding | null {\n const binding = getBinding(path);\n if (!binding) return null;\n\n const isReference = binding.referencePaths.includes(path);\n let referencesInConstantViolations = binding.constantViolations.filter((i) =>\n isReferencedConstantViolation(i, binding)\n );\n\n const isConstantViolation = referencesInConstantViolations.includes(path);\n\n if (!isReference && !isConstantViolation) {\n return null;\n }\n\n if (isReference) {\n binding.referencePaths = binding.referencePaths.filter((i) => i !== path);\n binding.references -= 1;\n } else {\n referencesInConstantViolations = referencesInConstantViolations.filter(\n (i) => i !== path\n );\n }\n\n const nonTypeReferences = binding.referencePaths.filter(nonType);\n binding.referenced =\n nonTypeReferences.length + referencesInConstantViolations.length > 0;\n\n return binding;\n}\n\nfunction dereferenceAll(path: NodePath): Binding[] {\n return findIdentifiers([path])\n .map((identifierPath) => dereference(identifierPath))\n .filter(isNotNull);\n}\n\nexport function referenceAll(path: NodePath): void {\n findIdentifiers([path]).forEach((identifierPath) =>\n reference(identifierPath)\n );\n}\n\nconst deletingNodes = new WeakSet<NodePath>();\n\nconst isEmptyList = (list: NodePath[]) =>\n list.length === 0 || list.every((i) => deletingNodes.has(i));\n\ntype ReplaceAction = [action: 'replace', what: NodePath, by: Node];\ntype RemoveAction = [action: 'remove', what: NodePath];\n\nconst getPathFromAction = (action: RemoveAction | ReplaceAction) => {\n if (!Array.isArray(action)) {\n return action;\n }\n\n if (action[0] === 'replace' || action[0] === 'remove') {\n return action[1];\n }\n\n throw new Error(`Unknown action type: ${action[0]}`);\n};\n\nfunction isPrototypeAssignment(path: NodePath) {\n if (!path.isAssignmentExpression()) {\n return false;\n }\n\n const { left } = path.node;\n if (!left) {\n return false;\n }\n\n if (left.type !== 'MemberExpression') {\n return false;\n }\n\n const { object, property } = left;\n if (!object || !property) {\n return false;\n }\n\n return (\n object.type === 'MemberExpression' &&\n object.property.type === 'Identifier' &&\n object.property.name === 'prototype'\n );\n}\n\nfunction canFunctionBeDelete(fnPath: NodePath<FunctionNode>) {\n if (isPrototypeAssignment(fnPath.parentPath)) {\n // It is a prototype assignment, we can't delete it since we can't find all usages\n return false;\n }\n\n const fnScope = fnPath.scope;\n const parentScope = fnScope.parent;\n if (parentScope.parent) {\n // It isn't a top-level function, so we can't delete it\n return true;\n }\n\n if (fnPath.listKey === 'arguments') {\n // It is passed as an argument to another function, we can't delete it\n return true;\n }\n\n return false;\n}\n\nexport function findActionForNode(\n path: NodePath\n): RemoveAction | ReplaceAction | null {\n if (isRemoved(path)) return null;\n\n deletingNodes.add(path);\n\n const parent = path.parentPath;\n\n if (!parent) return ['remove', path];\n\n if (parent.isProgram()) {\n // Do not delete Program node\n return ['remove', path];\n }\n\n if (parent.isClassDeclaration() || parent.isClassExpression()) {\n if (path.key === 'body') {\n return ['replace', path, { type: 'ClassBody', body: [] }];\n }\n }\n\n if (parent.isFunction()) {\n if (path.listKey === 'params') {\n // Do not remove params of functions\n return null;\n }\n\n if (\n (path.isBlockStatement() && isEmptyList(path.get('body'))) ||\n path === parent.get('body')\n ) {\n if (!canFunctionBeDelete(parent)) {\n return [\n 'replace',\n parent,\n {\n ...parent.node,\n async: false,\n body: {\n type: 'BlockStatement',\n body: [],\n directives: [],\n },\n generator: false,\n params: [],\n },\n ];\n }\n }\n }\n\n if (parent.isConditionalExpression()) {\n if (path.key === 'test') {\n return ['replace', parent, parent.node.alternate];\n }\n\n if (path.key === 'consequent') {\n return ['replace', path, { type: 'Identifier', name: 'undefined' }];\n }\n\n if (path.key === 'alternate') {\n return ['replace', path, { type: 'Identifier', name: 'undefined' }];\n }\n }\n\n if (parent.isLogicalExpression({ operator: '&&' })) {\n return [\n 'replace',\n parent,\n {\n type: 'BooleanLiteral',\n value: false,\n },\n ];\n }\n\n if (parent.isLogicalExpression({ operator: '||' })) {\n return [\n 'replace',\n parent,\n path.key === 'left' ? parent.node.right : parent.node.left,\n ];\n }\n\n if (parent.isObjectProperty()) {\n // let's check if it is a special case with Object.defineProperty\n const key = parent.get('key');\n if (key.isIdentifier({ name: 'get' })) {\n const maybeDefineProperty = parent.parentPath.parentPath;\n if (\n maybeDefineProperty?.isCallExpression() &&\n maybeDefineProperty\n .get('callee')\n .matchesPattern('Object.defineProperty')\n ) {\n return findActionForNode(maybeDefineProperty);\n }\n }\n\n return findActionForNode(parent);\n }\n\n if (parent.isTemplateLiteral()) {\n return [\n 'replace',\n path,\n {\n type: 'StringLiteral',\n value: '',\n },\n ];\n }\n\n if (parent.isAssignmentExpression()) {\n if (path.isAssignmentExpression()) {\n // `foo = bar = 42` should be replaced with `foo = 42`\n return ['replace', path, path.node.right];\n }\n\n return findActionForNode(parent);\n }\n\n if (parent.isCallExpression()) {\n return findActionForNode(parent);\n }\n\n if (parent.isForInStatement({ left: path.node })) {\n return findActionForNode(parent);\n }\n\n if (\n parent.isFunctionExpression({ body: path.node }) ||\n parent.isFunctionDeclaration() ||\n parent.isObjectMethod() ||\n parent.isClassMethod()\n ) {\n return findActionForNode(parent);\n }\n\n if (parent.isBlockStatement()) {\n const body = parent.get('body');\n if (isEmptyList(body)) {\n return findActionForNode(parent);\n }\n\n if (path.listKey === 'body' && typeof path.key === 'number') {\n if (path.key > 0) {\n // We can check whether the previous one can be removed\n const prevStatement = body[path.key - 1];\n if (\n prevStatement.isIfStatement() &&\n prevStatement.get('consequent').isReturnStatement()\n ) {\n // It's `if (…) return …`, we can remove it.\n return findActionForNode(prevStatement);\n }\n } else if (\n body.slice(1).every((statement) => deletingNodes.has(statement))\n ) {\n // If it is the first statement and all other statements\n // are marked for deletion, we can remove the whole block.\n return findActionForNode(parent);\n }\n }\n }\n\n if (parent.isVariableDeclarator()) {\n if (path.key === 'init' && path.isAssignmentExpression()) {\n // We are removing `bar` in `var foo = bar = 42`. Path should be replaced with `var foo = 42`\n return ['replace', path, path.node.right];\n }\n\n const init = parent.get('init');\n if (path.key === 'id' && init.isAssignmentExpression()) {\n // We are removing `foo` in `var foo = bar = 42`. Ignore it.\n return null;\n }\n\n return findActionForNode(parent);\n }\n\n if (\n parent.isExportNamedDeclaration() &&\n ((path.key === 'specifiers' && isEmptyList(parent.get('specifiers'))) ||\n (path.key === 'declaration' && parent.node.declaration === path.node))\n ) {\n return findActionForNode(parent);\n }\n\n for (const key of ['body', 'declarations', 'specifiers']) {\n if (path.listKey === key && typeof path.key === 'number') {\n const list = parent.get(key) as NodePath[];\n if (isEmptyList(list)) {\n return findActionForNode(parent);\n }\n }\n }\n\n if (parent.isTryStatement()) {\n return findActionForNode(parent);\n }\n\n if (!path.listKey && path.key) {\n const field = NODE_FIELDS[parent.type][path.key];\n if (!validateField(parent.node, path.key as string, null, field)) {\n // The parent node isn't valid without this field, so we should remove it also.\n return findActionForNode(parent);\n }\n }\n\n for (const key of [\n 'argument',\n 'block',\n 'body',\n 'callee',\n 'discriminant',\n 'expression',\n 'id',\n 'left',\n 'object',\n 'property',\n 'right',\n 'test',\n ]) {\n if (path.key === key && parent.get(key) === path) {\n return findActionForNode(parent);\n }\n }\n\n return ['remove', path];\n}\n\n// @babel/preset-typescript transpiles enums, but doesn't reference used identifiers.\nfunction referenceEnums(program: NodePath<Program>) {\n /*\n * We are looking for transpiled enums.\n * (function (Colors) {\n * Colors[\"BLUE\"] = \"#27509A\";\n * })(Colors || (Colors = {}));\n */\n program.traverse({\n ExpressionStatement(expressionStatement) {\n const expression = expressionStatement.get('expression');\n if (!expression.isCallExpression()) return;\n\n const callee = expression.get('callee');\n const args = expression.get('arguments');\n if (!callee.isFunctionExpression() || args.length !== 1) return;\n const [arg] = args;\n if (arg.isLogicalExpression({ operator: '||' })) {\n referenceAll(arg);\n }\n },\n });\n}\n\nconst fixed = new WeakSet<NodePath<Program>>();\n\nfunction removeUnreferenced(items: NodePath<Identifier | JSXIdentifier>[]) {\n const referenced = new Set<NodePath<Identifier | JSXIdentifier>>();\n items.forEach((item) => {\n if (!item.node || isRemoved(item)) return;\n const binding = getScope(item).getBinding(item.node.name);\n if (!binding) return;\n const hasReferences =\n binding.referencePaths.filter((i) => !isRemoved(i)).length > 0;\n if (hasReferences) {\n referenced.add(item);\n return;\n }\n\n const forDeleting = [binding.path, ...binding.constantViolations]\n .map(findActionForNode)\n .filter(isNotNull)\n .map(getPathFromAction);\n\n if (forDeleting.length === 0) return;\n\n findIdentifiers(forDeleting).forEach((identifier) => {\n referenced.add(identifier);\n });\n\n removeWithRelated(forDeleting);\n });\n\n const result = [...referenced];\n result.sort((a, b) => a.node?.name.localeCompare(b.node?.name));\n\n return result;\n}\n\nfunction getNodeForValue(value: unknown): Node | undefined {\n if (typeof value === 'string') {\n return {\n type: 'StringLiteral',\n value,\n };\n }\n\n if (typeof value === 'number') {\n return {\n type: 'NumericLiteral',\n value,\n };\n }\n\n if (typeof value === 'boolean') {\n return {\n type: 'BooleanLiteral',\n value,\n };\n }\n\n if (value === null) {\n return {\n type: 'NullLiteral',\n };\n }\n\n if (value === undefined) {\n return {\n type: 'Identifier',\n name: 'undefined',\n };\n }\n\n return undefined;\n}\n\nfunction staticEvaluate(path: NodePath | null | undefined): void {\n if (!path) return;\n const evaluated = path.evaluate();\n if (evaluated.confident) {\n const node = getNodeForValue(evaluated.value);\n if (node) {\n applyAction(['replace', path, node]);\n return;\n }\n }\n\n if (path.isIfStatement()) {\n const test = path.get('test');\n if (!test.isBooleanLiteral()) {\n return;\n }\n\n const { consequent, alternate } = path.node;\n if (test.node.value) {\n applyAction(['replace', path, consequent]);\n } else if (alternate) {\n applyAction(['replace', path, alternate]);\n } else {\n applyAction(['remove', path]);\n }\n }\n}\n\nfunction applyAction(action: ReplaceAction | RemoveAction) {\n mutate(action[1], (p) => {\n if (isRemoved(p)) return;\n\n const parent = p.parentPath;\n\n if (action[0] === 'remove') {\n p.remove();\n }\n\n if (action[0] === 'replace') {\n p.replaceWith(action[2]);\n }\n\n staticEvaluate(parent);\n });\n}\n\nfunction removeWithRelated(paths: NodePath[]) {\n if (paths.length === 0) return;\n\n const rootPath = getScope(paths[0]).getProgramParent()\n .path as NodePath<Program>;\n\n if (!fixed.has(rootPath)) {\n // Some libraries don't care about bindings, references, and other staff\n // So we have to fix the scope before we can detect unused code\n referenceEnums(rootPath);\n fixed.add(rootPath);\n }\n\n const actions: (ReplaceAction | RemoveAction)[] = paths\n .map(findActionForNode)\n .filter(isNotNull);\n\n const affectedPaths = actions.map(getPathFromAction);\n\n let referencedIdentifiers = findIdentifiers(affectedPaths, 'reference');\n referencedIdentifiers.sort(\n (a, b) => a.node?.name.localeCompare(b.node?.name)\n );\n\n const referencesOfBinding = findIdentifiers(affectedPaths, 'declaration')\n .map((i) => (i.node && getScope(i).getBinding(i.node.name)) ?? null)\n .filter(isNotNull)\n .reduce(\n (acc, i) => [...acc, ...i.referencePaths.filter(nonType)],\n [] as NodePath[]\n )\n .filter(\n (ref) =>\n // Do not remove `export default function`\n !ref.isExportDefaultDeclaration() ||\n !ref.get('declaration').isFunctionDeclaration()\n );\n\n actions.forEach(applyAction);\n\n removeWithRelated(referencesOfBinding);\n\n let clean = false;\n while (!clean && referencedIdentifiers.length > 0) {\n const referenced = removeUnreferenced(referencedIdentifiers);\n clean =\n referenced.map((i) => i.node?.name).join('|') ===\n referencedIdentifiers.map((i) => i.node?.name).join('|');\n referencedIdentifiers = referenced;\n }\n}\n\nfunction mutate<T extends NodePath>(path: T, fn: (p: T) => NodePath[] | void) {\n const dereferenced = dereferenceAll(path);\n\n const mutated = fn(path);\n\n referenceAll(path);\n mutated?.forEach((p) => referenceAll(p));\n\n const dead = dereferenced.filter((p) => !isReferenced(p));\n\n const forDeleting: NodePath[] = [];\n dead.forEach((binding) => {\n const assignments = [binding.path, ...binding.constantViolations];\n assignments.forEach((assignment) => {\n const { scope } = assignment;\n const declared = Object.values(\n assignment.getOuterBindingIdentifiers(false)\n );\n if (\n declared.length === 1 &&\n 'name' in declared[0] &&\n declared[0].name === binding.identifier.name\n ) {\n const init = assignment.get('init');\n if (!Array.isArray(init) && init?.isAssignmentExpression()) {\n // `const a = b = 1` → `b = 1`\n assignment.parentPath?.replaceWith({\n type: 'ExpressionStatement',\n expression: init.node,\n });\n\n const left = init.get('left');\n if (left.isIdentifier()) {\n // If it was forcefully referenced in the shaker\n dereference(left);\n }\n\n return;\n }\n // Only one identifier is declared, so we can remove the whole declaration\n forDeleting.push(assignment);\n return;\n }\n\n if (\n declared.every(\n (identifier) =>\n identifier.type === 'Identifier' &&\n !scope.getBinding(identifier.name)?.referenced\n )\n ) {\n // No other identifier is referenced, so we can remove the whole declaration\n forDeleting.push(assignment);\n return;\n }\n\n // We can't remove the binding, but we can remove the part of it\n assignment.traverse({\n Identifier(identifier) {\n if (identifier.node.name === binding.identifier.name) {\n const parent = identifier.parentPath;\n if (\n parent.isArrayPattern() &&\n identifier.listKey === 'elements' &&\n typeof identifier.key === 'number'\n ) {\n parent.node.elements[identifier.key] = null;\n } else if (parent.isObjectProperty()) {\n forDeleting.push(parent);\n }\n }\n },\n });\n });\n });\n\n removeWithRelated(forDeleting);\n}\n\nexport { applyAction, mutate, removeWithRelated };\n"],"mappings":"AAAA;AACA;;AAWA,SAASA,WAAW,QAAQ,cAAc;AAE1C,SAASC,eAAe,EAAEC,OAAO,QAAQ,mBAAmB;AAC5D,SAASC,QAAQ,QAAQ,YAAY;AACrC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,SAAS,QAAQ,aAAa;AAEvC,SAASC,aAAaA,CACpBC,IAAU,EACVC,GAAW,EACXC,GAAY,EACZC,KAAmB,EACnB;EACA,IAAI,EAAEA,KAAK,IAAI,IAAI,IAAIA,KAAK,CAACC,QAAQ,CAAC,EAAE,OAAO,IAAI;EACnD,IAAID,KAAK,CAACE,QAAQ,IAAIH,GAAG,IAAI,IAAI,EAAE,OAAO,IAAI;EAC9C,IAAI;IACFC,KAAK,CAACC,QAAQ,CAACJ,IAAI,EAAEC,GAAG,EAAEC,GAAG,CAAC;IAC9B,OAAO,IAAI;EACb,CAAC,CAAC,MAAM;IACN,OAAO,KAAK;EACd;AACF;AAEA,SAASI,UAAUA,CAACC,IAA0C,EAAE;EAC9D,MAAMC,OAAO,GAAGZ,QAAQ,CAACW,IAAI,CAAC,CAACD,UAAU,CAACC,IAAI,CAACP,IAAI,CAACS,IAAI,CAAC;EACzD,IAAI,CAACD,OAAO,EAAE;IACZ,OAAOE,SAAS;EAClB;EAEA,OAAOF,OAAO;AAChB;AAEA,OAAO,SAASG,SAASA,CACvBJ,IAA0C,EAC1CK,aAAuB,GAAGL,IAAI,EAC9BM,KAAK,GAAG,KAAK,EACP;EACN,IAAI,CAACA,KAAK,IAAI,CAACN,IAAI,CAACO,sBAAsB,CAAC,CAAC,EAAE;E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,IAAI,CAAC;UACnB;UAEA;QACF;QACA;QACA8D,WAAW,CAAC3G,IAAI,CAACiJ,UAAU,CAAC;QAC5B;MACF;MAEA,IACEC,QAAQ,CAACtI,KAAK,CACXgG,UAAU,IACTA,UAAU,CAAC9D,IAAI,KAAK,YAAY,IAChC,CAACM,KAAK,CAAChE,UAAU,CAACwH,UAAU,CAACrH,IAAI,CAAC,EAAEQ,UACxC,CAAC,EACD;QACA;QACA4G,WAAW,CAAC3G,IAAI,CAACiJ,UAAU,CAAC;QAC5B;MACF;;MAEA;MACAA,UAAU,CAACnD,QAAQ,CAAC;QAClBwD,UAAUA,CAAC1C,UAAU,EAAE;UACrB,IAAIA,UAAU,CAAC9H,IAAI,CAACS,IAAI,KAAKD,OAAO,CAACsH,UAAU,CAACrH,IAAI,EAAE;YACpD,MAAM+D,MAAM,GAAGsD,UAAU,CAACtG,UAAU;YACpC,IACEgD,MAAM,CAACiG,cAAc,CAAC,CAAC,IACvB3C,UAAU,CAACrD,OAAO,KAAK,UAAU,IACjC,OAAOqD,UAAU,CAAC7H,GAAG,KAAK,QAAQ,EAClC;cACAuE,MAAM,CAACxE,IAAI,CAAC0K,QAAQ,CAAC5C,UAAU,CAAC7H,GAAG,CAAC,GAAG,IAAI;YAC7C,CAAC,MAAM,IAAIuE,MAAM,CAACoB,gBAAgB,CAAC,CAAC,EAAE;cACpCiC,WAAW,CAAC3G,IAAI,CAACsD,MAAM,CAAC;YAC1B;UACF;QACF;MACF,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,CAAC;EAEFuD,iBAAiB,CAACF,WAAW,CAAC;AAChC;AAEA,SAASa,WAAW,EAAEI,MAAM,EAAEf,iBAAiB","ignoreList":[]}
@@ -1,23 +0,0 @@
1
- const caches = new WeakMap();
2
- export const getTraversalCache = (path, name) => {
3
- const programPath = path.find(p => p.isProgram());
4
- if (!programPath) {
5
- throw new Error(`Could not find program for ${path.node.type}`);
6
- }
7
- if (!caches.has(programPath)) {
8
- caches.set(programPath, new Map());
9
- }
10
- const cache = caches.get(programPath);
11
- if (!cache.has(name)) {
12
- cache.set(name, new WeakMap());
13
- }
14
- return cache.get(name);
15
- };
16
- export const invalidateTraversalCache = path => {
17
- const programPath = path.find(p => p.isProgram());
18
- if (!programPath) {
19
- throw new Error(`Could not find program for ${path.node.type}`);
20
- }
21
- caches.delete(programPath);
22
- };
23
- //# sourceMappingURL=traversalCache.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"traversalCache.js","names":["caches","WeakMap","getTraversalCache","path","name","programPath","find","p","isProgram","Error","node","type","has","set","Map","cache","get","invalidateTraversalCache","delete"],"sources":["../../src/utils/traversalCache.ts"],"sourcesContent":["import type { NodePath } from '@babel/traverse';\nimport type { Node } from '@babel/types';\n\nconst caches = new WeakMap<\n NodePath,\n Map<string, WeakMap<NodePath | Node, unknown>>\n>();\n\nexport const getTraversalCache = <\n TValue,\n TKey extends NodePath | Node = NodePath,\n>(\n path: NodePath,\n name: string\n) => {\n const programPath = path.find((p) => p.isProgram());\n if (!programPath) {\n throw new Error(`Could not find program for ${path.node.type}`);\n }\n\n if (!caches.has(programPath)) {\n caches.set(programPath, new Map());\n }\n\n const cache = caches.get(programPath)!;\n if (!cache.has(name)) {\n cache.set(name, new WeakMap());\n }\n\n return cache.get(name) as WeakMap<TKey, TValue>;\n};\n\nexport const invalidateTraversalCache = (path: NodePath) => {\n const programPath = path.find((p) => p.isProgram());\n if (!programPath) {\n throw new Error(`Could not find program for ${path.node.type}`);\n }\n\n caches.delete(programPath);\n};\n"],"mappings":"AAGA,MAAMA,MAAM,GAAG,IAAIC,OAAO,CAGxB,CAAC;AAEH,OAAO,MAAMC,iBAAiB,GAAGA,CAI/BC,IAAc,EACdC,IAAY,KACT;EACH,MAAMC,WAAW,GAAGF,IAAI,CAACG,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,SAAS,CAAC,CAAC,CAAC;EACnD,IAAI,CAACH,WAAW,EAAE;IAChB,MAAM,IAAII,KAAK,CAAC,8BAA8BN,IAAI,CAACO,IAAI,CAACC,IAAI,EAAE,CAAC;EACjE;EAEA,IAAI,CAACX,MAAM,CAACY,GAAG,CAACP,WAAW,CAAC,EAAE;IAC5BL,MAAM,CAACa,GAAG,CAACR,WAAW,EAAE,IAAIS,GAAG,CAAC,CAAC,CAAC;EACpC;EAEA,MAAMC,KAAK,GAAGf,MAAM,CAACgB,GAAG,CAACX,WAAW,CAAE;EACtC,IAAI,CAACU,KAAK,CAACH,GAAG,CAACR,IAAI,CAAC,EAAE;IACpBW,KAAK,CAACF,GAAG,CAACT,IAAI,EAAE,IAAIH,OAAO,CAAC,CAAC,CAAC;EAChC;EAEA,OAAOc,KAAK,CAACC,GAAG,CAACZ,IAAI,CAAC;AACxB,CAAC;AAED,OAAO,MAAMa,wBAAwB,GAAId,IAAc,IAAK;EAC1D,MAAME,WAAW,GAAGF,IAAI,CAACG,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,SAAS,CAAC,CAAC,CAAC;EACnD,IAAI,CAACH,WAAW,EAAE;IAChB,MAAM,IAAII,KAAK,CAAC,8BAA8BN,IAAI,CAACO,IAAI,CAACC,IAAI,EAAE,CAAC;EACjE;EAEAX,MAAM,CAACkB,MAAM,CAACb,WAAW,CAAC;AAC5B,CAAC","ignoreList":[]}
@@ -1,18 +0,0 @@
1
- import * as t from '@babel/types';
2
- const unwrapOnce = node => {
3
- if (t.isTSAsExpression(node)) return node.expression;
4
- if (t.isTSTypeAssertion(node)) return node.expression;
5
- if (t.isTSNonNullExpression(node)) return node.expression;
6
- if (t.isParenthesizedExpression(node)) return node.expression;
7
- return node;
8
- };
9
- export function unwrapExpression(node) {
10
- let current = node;
11
- let next = unwrapOnce(current);
12
- while (next !== current) {
13
- current = next;
14
- next = unwrapOnce(current);
15
- }
16
- return current;
17
- }
18
- //# sourceMappingURL=unwrapExpression.js.map