@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,557 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.applyAction = applyAction;
7
- exports.dereference = dereference;
8
- exports.findActionForNode = findActionForNode;
9
- exports.mutate = mutate;
10
- exports.reference = reference;
11
- exports.referenceAll = referenceAll;
12
- exports.removeWithRelated = removeWithRelated;
13
- var _types = require("@babel/types");
14
- var _findIdentifiers = require("./findIdentifiers");
15
- var _getScope = require("./getScope");
16
- var _isNotNull = require("./isNotNull");
17
- var _isRemoved = require("./isRemoved");
18
- /* eslint-disable no-restricted-syntax */
19
- /* eslint @typescript-eslint/no-use-before-define: ["error", { "functions": false }] */
20
-
21
- function validateField(node, key, val, field) {
22
- if (!(field != null && field.validate)) return true;
23
- if (field.optional && val == null) return true;
24
- try {
25
- field.validate(node, key, val);
26
- return true;
27
- } catch {
28
- return false;
29
- }
30
- }
31
- function getBinding(path) {
32
- const binding = (0, _getScope.getScope)(path).getBinding(path.node.name);
33
- if (!binding) {
34
- return undefined;
35
- }
36
- return binding;
37
- }
38
- function reference(path, referencePath = path, force = false) {
39
- if (!force && !path.isReferencedIdentifier()) return;
40
- const binding = getBinding(path);
41
- if (!binding) return;
42
- if (binding.referencePaths.includes(referencePath)) {
43
- return;
44
- }
45
- binding.referenced = true;
46
- binding.referencePaths.push(referencePath !== null && referencePath !== void 0 ? referencePath : path);
47
- binding.references = binding.referencePaths.length;
48
- }
49
- function isReferenced(binding) {
50
- const {
51
- kind,
52
- referenced,
53
- referencePaths,
54
- path
55
- } = binding;
56
- if (path.isFunctionExpression() && path.key === 'init' && path.parentPath.isVariableDeclarator()) {
57
- // It is a function expression in a variable declarator
58
- const id = path.parentPath.get('id');
59
- if (id.isIdentifier()) {
60
- const idBinding = getBinding(id);
61
- return idBinding ? isReferenced(idBinding) : true;
62
- }
63
- return true;
64
- }
65
- if (!referenced) {
66
- return false;
67
- }
68
-
69
- // If it's a param binding, we can't just remove it
70
- // because it brakes the function signature. Keep it alive for now.
71
- if (kind === 'param') {
72
- return true;
73
- }
74
-
75
- // If all remaining references are in TS/Flow types, binding is unreferenced
76
- return referencePaths.length > 0 || referencePaths.every(i => i.find(ancestor => ancestor.isTSType() || ancestor.isFlowType()));
77
- }
78
- function isReferencedConstantViolation(path, binding) {
79
- if (path.find(p => p === binding.path)) {
80
- // function a(flag) { return (a = function(flag) { flag ? 1 : 2 }) }
81
- // ^ Looks crazy, yeh? Welcome to the wonderful world of transpilers!
82
- // `a = …` here isn't a reference.
83
- return false;
84
- }
85
- if (!path.isReferenced()) {
86
- return false;
87
- }
88
- if (path.isAssignmentExpression() && path.parentPath.isExpressionStatement()) {
89
- // A root assignment without a parent expression statement is not a reference
90
- return false;
91
- }
92
- return true;
93
- }
94
- function dereference(path) {
95
- const binding = getBinding(path);
96
- if (!binding) return null;
97
- const isReference = binding.referencePaths.includes(path);
98
- let referencesInConstantViolations = binding.constantViolations.filter(i => isReferencedConstantViolation(i, binding));
99
- const isConstantViolation = referencesInConstantViolations.includes(path);
100
- if (!isReference && !isConstantViolation) {
101
- return null;
102
- }
103
- if (isReference) {
104
- binding.referencePaths = binding.referencePaths.filter(i => i !== path);
105
- binding.references -= 1;
106
- } else {
107
- referencesInConstantViolations = referencesInConstantViolations.filter(i => i !== path);
108
- }
109
- const nonTypeReferences = binding.referencePaths.filter(_findIdentifiers.nonType);
110
- binding.referenced = nonTypeReferences.length + referencesInConstantViolations.length > 0;
111
- return binding;
112
- }
113
- function dereferenceAll(path) {
114
- return (0, _findIdentifiers.findIdentifiers)([path]).map(identifierPath => dereference(identifierPath)).filter(_isNotNull.isNotNull);
115
- }
116
- function referenceAll(path) {
117
- (0, _findIdentifiers.findIdentifiers)([path]).forEach(identifierPath => reference(identifierPath));
118
- }
119
- const deletingNodes = new WeakSet();
120
- const isEmptyList = list => list.length === 0 || list.every(i => deletingNodes.has(i));
121
- const getPathFromAction = action => {
122
- if (!Array.isArray(action)) {
123
- return action;
124
- }
125
- if (action[0] === 'replace' || action[0] === 'remove') {
126
- return action[1];
127
- }
128
- throw new Error(`Unknown action type: ${action[0]}`);
129
- };
130
- function isPrototypeAssignment(path) {
131
- if (!path.isAssignmentExpression()) {
132
- return false;
133
- }
134
- const {
135
- left
136
- } = path.node;
137
- if (!left) {
138
- return false;
139
- }
140
- if (left.type !== 'MemberExpression') {
141
- return false;
142
- }
143
- const {
144
- object,
145
- property
146
- } = left;
147
- if (!object || !property) {
148
- return false;
149
- }
150
- return object.type === 'MemberExpression' && object.property.type === 'Identifier' && object.property.name === 'prototype';
151
- }
152
- function canFunctionBeDelete(fnPath) {
153
- if (isPrototypeAssignment(fnPath.parentPath)) {
154
- // It is a prototype assignment, we can't delete it since we can't find all usages
155
- return false;
156
- }
157
- const fnScope = fnPath.scope;
158
- const parentScope = fnScope.parent;
159
- if (parentScope.parent) {
160
- // It isn't a top-level function, so we can't delete it
161
- return true;
162
- }
163
- if (fnPath.listKey === 'arguments') {
164
- // It is passed as an argument to another function, we can't delete it
165
- return true;
166
- }
167
- return false;
168
- }
169
- function findActionForNode(path) {
170
- if ((0, _isRemoved.isRemoved)(path)) return null;
171
- deletingNodes.add(path);
172
- const parent = path.parentPath;
173
- if (!parent) return ['remove', path];
174
- if (parent.isProgram()) {
175
- // Do not delete Program node
176
- return ['remove', path];
177
- }
178
- if (parent.isClassDeclaration() || parent.isClassExpression()) {
179
- if (path.key === 'body') {
180
- return ['replace', path, {
181
- type: 'ClassBody',
182
- body: []
183
- }];
184
- }
185
- }
186
- if (parent.isFunction()) {
187
- if (path.listKey === 'params') {
188
- // Do not remove params of functions
189
- return null;
190
- }
191
- if (path.isBlockStatement() && isEmptyList(path.get('body')) || path === parent.get('body')) {
192
- if (!canFunctionBeDelete(parent)) {
193
- return ['replace', parent, {
194
- ...parent.node,
195
- async: false,
196
- body: {
197
- type: 'BlockStatement',
198
- body: [],
199
- directives: []
200
- },
201
- generator: false,
202
- params: []
203
- }];
204
- }
205
- }
206
- }
207
- if (parent.isConditionalExpression()) {
208
- if (path.key === 'test') {
209
- return ['replace', parent, parent.node.alternate];
210
- }
211
- if (path.key === 'consequent') {
212
- return ['replace', path, {
213
- type: 'Identifier',
214
- name: 'undefined'
215
- }];
216
- }
217
- if (path.key === 'alternate') {
218
- return ['replace', path, {
219
- type: 'Identifier',
220
- name: 'undefined'
221
- }];
222
- }
223
- }
224
- if (parent.isLogicalExpression({
225
- operator: '&&'
226
- })) {
227
- return ['replace', parent, {
228
- type: 'BooleanLiteral',
229
- value: false
230
- }];
231
- }
232
- if (parent.isLogicalExpression({
233
- operator: '||'
234
- })) {
235
- return ['replace', parent, path.key === 'left' ? parent.node.right : parent.node.left];
236
- }
237
- if (parent.isObjectProperty()) {
238
- // let's check if it is a special case with Object.defineProperty
239
- const key = parent.get('key');
240
- if (key.isIdentifier({
241
- name: 'get'
242
- })) {
243
- const maybeDefineProperty = parent.parentPath.parentPath;
244
- if (maybeDefineProperty !== null && maybeDefineProperty !== void 0 && maybeDefineProperty.isCallExpression() && maybeDefineProperty.get('callee').matchesPattern('Object.defineProperty')) {
245
- return findActionForNode(maybeDefineProperty);
246
- }
247
- }
248
- return findActionForNode(parent);
249
- }
250
- if (parent.isTemplateLiteral()) {
251
- return ['replace', path, {
252
- type: 'StringLiteral',
253
- value: ''
254
- }];
255
- }
256
- if (parent.isAssignmentExpression()) {
257
- if (path.isAssignmentExpression()) {
258
- // `foo = bar = 42` should be replaced with `foo = 42`
259
- return ['replace', path, path.node.right];
260
- }
261
- return findActionForNode(parent);
262
- }
263
- if (parent.isCallExpression()) {
264
- return findActionForNode(parent);
265
- }
266
- if (parent.isForInStatement({
267
- left: path.node
268
- })) {
269
- return findActionForNode(parent);
270
- }
271
- if (parent.isFunctionExpression({
272
- body: path.node
273
- }) || parent.isFunctionDeclaration() || parent.isObjectMethod() || parent.isClassMethod()) {
274
- return findActionForNode(parent);
275
- }
276
- if (parent.isBlockStatement()) {
277
- const body = parent.get('body');
278
- if (isEmptyList(body)) {
279
- return findActionForNode(parent);
280
- }
281
- if (path.listKey === 'body' && typeof path.key === 'number') {
282
- if (path.key > 0) {
283
- // We can check whether the previous one can be removed
284
- const prevStatement = body[path.key - 1];
285
- if (prevStatement.isIfStatement() && prevStatement.get('consequent').isReturnStatement()) {
286
- // It's `if (…) return …`, we can remove it.
287
- return findActionForNode(prevStatement);
288
- }
289
- } else if (body.slice(1).every(statement => deletingNodes.has(statement))) {
290
- // If it is the first statement and all other statements
291
- // are marked for deletion, we can remove the whole block.
292
- return findActionForNode(parent);
293
- }
294
- }
295
- }
296
- if (parent.isVariableDeclarator()) {
297
- if (path.key === 'init' && path.isAssignmentExpression()) {
298
- // We are removing `bar` in `var foo = bar = 42`. Path should be replaced with `var foo = 42`
299
- return ['replace', path, path.node.right];
300
- }
301
- const init = parent.get('init');
302
- if (path.key === 'id' && init.isAssignmentExpression()) {
303
- // We are removing `foo` in `var foo = bar = 42`. Ignore it.
304
- return null;
305
- }
306
- return findActionForNode(parent);
307
- }
308
- if (parent.isExportNamedDeclaration() && (path.key === 'specifiers' && isEmptyList(parent.get('specifiers')) || path.key === 'declaration' && parent.node.declaration === path.node)) {
309
- return findActionForNode(parent);
310
- }
311
- for (const key of ['body', 'declarations', 'specifiers']) {
312
- if (path.listKey === key && typeof path.key === 'number') {
313
- const list = parent.get(key);
314
- if (isEmptyList(list)) {
315
- return findActionForNode(parent);
316
- }
317
- }
318
- }
319
- if (parent.isTryStatement()) {
320
- return findActionForNode(parent);
321
- }
322
- if (!path.listKey && path.key) {
323
- const field = _types.NODE_FIELDS[parent.type][path.key];
324
- if (!validateField(parent.node, path.key, null, field)) {
325
- // The parent node isn't valid without this field, so we should remove it also.
326
- return findActionForNode(parent);
327
- }
328
- }
329
- for (const key of ['argument', 'block', 'body', 'callee', 'discriminant', 'expression', 'id', 'left', 'object', 'property', 'right', 'test']) {
330
- if (path.key === key && parent.get(key) === path) {
331
- return findActionForNode(parent);
332
- }
333
- }
334
- return ['remove', path];
335
- }
336
-
337
- // @babel/preset-typescript transpiles enums, but doesn't reference used identifiers.
338
- function referenceEnums(program) {
339
- /*
340
- * We are looking for transpiled enums.
341
- * (function (Colors) {
342
- * Colors["BLUE"] = "#27509A";
343
- * })(Colors || (Colors = {}));
344
- */
345
- program.traverse({
346
- ExpressionStatement(expressionStatement) {
347
- const expression = expressionStatement.get('expression');
348
- if (!expression.isCallExpression()) return;
349
- const callee = expression.get('callee');
350
- const args = expression.get('arguments');
351
- if (!callee.isFunctionExpression() || args.length !== 1) return;
352
- const [arg] = args;
353
- if (arg.isLogicalExpression({
354
- operator: '||'
355
- })) {
356
- referenceAll(arg);
357
- }
358
- }
359
- });
360
- }
361
- const fixed = new WeakSet();
362
- function removeUnreferenced(items) {
363
- const referenced = new Set();
364
- items.forEach(item => {
365
- if (!item.node || (0, _isRemoved.isRemoved)(item)) return;
366
- const binding = (0, _getScope.getScope)(item).getBinding(item.node.name);
367
- if (!binding) return;
368
- const hasReferences = binding.referencePaths.filter(i => !(0, _isRemoved.isRemoved)(i)).length > 0;
369
- if (hasReferences) {
370
- referenced.add(item);
371
- return;
372
- }
373
- const forDeleting = [binding.path, ...binding.constantViolations].map(findActionForNode).filter(_isNotNull.isNotNull).map(getPathFromAction);
374
- if (forDeleting.length === 0) return;
375
- (0, _findIdentifiers.findIdentifiers)(forDeleting).forEach(identifier => {
376
- referenced.add(identifier);
377
- });
378
- removeWithRelated(forDeleting);
379
- });
380
- const result = [...referenced];
381
- result.sort((a, b) => {
382
- var _a$node, _b$node;
383
- return (_a$node = a.node) === null || _a$node === void 0 ? void 0 : _a$node.name.localeCompare((_b$node = b.node) === null || _b$node === void 0 ? void 0 : _b$node.name);
384
- });
385
- return result;
386
- }
387
- function getNodeForValue(value) {
388
- if (typeof value === 'string') {
389
- return {
390
- type: 'StringLiteral',
391
- value
392
- };
393
- }
394
- if (typeof value === 'number') {
395
- return {
396
- type: 'NumericLiteral',
397
- value
398
- };
399
- }
400
- if (typeof value === 'boolean') {
401
- return {
402
- type: 'BooleanLiteral',
403
- value
404
- };
405
- }
406
- if (value === null) {
407
- return {
408
- type: 'NullLiteral'
409
- };
410
- }
411
- if (value === undefined) {
412
- return {
413
- type: 'Identifier',
414
- name: 'undefined'
415
- };
416
- }
417
- return undefined;
418
- }
419
- function staticEvaluate(path) {
420
- if (!path) return;
421
- const evaluated = path.evaluate();
422
- if (evaluated.confident) {
423
- const node = getNodeForValue(evaluated.value);
424
- if (node) {
425
- applyAction(['replace', path, node]);
426
- return;
427
- }
428
- }
429
- if (path.isIfStatement()) {
430
- const test = path.get('test');
431
- if (!test.isBooleanLiteral()) {
432
- return;
433
- }
434
- const {
435
- consequent,
436
- alternate
437
- } = path.node;
438
- if (test.node.value) {
439
- applyAction(['replace', path, consequent]);
440
- } else if (alternate) {
441
- applyAction(['replace', path, alternate]);
442
- } else {
443
- applyAction(['remove', path]);
444
- }
445
- }
446
- }
447
- function applyAction(action) {
448
- mutate(action[1], p => {
449
- if ((0, _isRemoved.isRemoved)(p)) return;
450
- const parent = p.parentPath;
451
- if (action[0] === 'remove') {
452
- p.remove();
453
- }
454
- if (action[0] === 'replace') {
455
- p.replaceWith(action[2]);
456
- }
457
- staticEvaluate(parent);
458
- });
459
- }
460
- function removeWithRelated(paths) {
461
- if (paths.length === 0) return;
462
- const rootPath = (0, _getScope.getScope)(paths[0]).getProgramParent().path;
463
- if (!fixed.has(rootPath)) {
464
- // Some libraries don't care about bindings, references, and other staff
465
- // So we have to fix the scope before we can detect unused code
466
- referenceEnums(rootPath);
467
- fixed.add(rootPath);
468
- }
469
- const actions = paths.map(findActionForNode).filter(_isNotNull.isNotNull);
470
- const affectedPaths = actions.map(getPathFromAction);
471
- let referencedIdentifiers = (0, _findIdentifiers.findIdentifiers)(affectedPaths, 'reference');
472
- referencedIdentifiers.sort((a, b) => {
473
- var _a$node2, _b$node2;
474
- return (_a$node2 = a.node) === null || _a$node2 === void 0 ? void 0 : _a$node2.name.localeCompare((_b$node2 = b.node) === null || _b$node2 === void 0 ? void 0 : _b$node2.name);
475
- });
476
- const referencesOfBinding = (0, _findIdentifiers.findIdentifiers)(affectedPaths, 'declaration').map(i => {
477
- var _ref;
478
- return (_ref = i.node && (0, _getScope.getScope)(i).getBinding(i.node.name)) !== null && _ref !== void 0 ? _ref : null;
479
- }).filter(_isNotNull.isNotNull).reduce((acc, i) => [...acc, ...i.referencePaths.filter(_findIdentifiers.nonType)], []).filter(ref =>
480
- // Do not remove `export default function`
481
- !ref.isExportDefaultDeclaration() || !ref.get('declaration').isFunctionDeclaration());
482
- actions.forEach(applyAction);
483
- removeWithRelated(referencesOfBinding);
484
- let clean = false;
485
- while (!clean && referencedIdentifiers.length > 0) {
486
- const referenced = removeUnreferenced(referencedIdentifiers);
487
- clean = referenced.map(i => {
488
- var _i$node;
489
- return (_i$node = i.node) === null || _i$node === void 0 ? void 0 : _i$node.name;
490
- }).join('|') === referencedIdentifiers.map(i => {
491
- var _i$node2;
492
- return (_i$node2 = i.node) === null || _i$node2 === void 0 ? void 0 : _i$node2.name;
493
- }).join('|');
494
- referencedIdentifiers = referenced;
495
- }
496
- }
497
- function mutate(path, fn) {
498
- const dereferenced = dereferenceAll(path);
499
- const mutated = fn(path);
500
- referenceAll(path);
501
- mutated === null || mutated === void 0 || mutated.forEach(p => referenceAll(p));
502
- const dead = dereferenced.filter(p => !isReferenced(p));
503
- const forDeleting = [];
504
- dead.forEach(binding => {
505
- const assignments = [binding.path, ...binding.constantViolations];
506
- assignments.forEach(assignment => {
507
- const {
508
- scope
509
- } = assignment;
510
- const declared = Object.values(assignment.getOuterBindingIdentifiers(false));
511
- if (declared.length === 1 && 'name' in declared[0] && declared[0].name === binding.identifier.name) {
512
- const init = assignment.get('init');
513
- if (!Array.isArray(init) && init !== null && init !== void 0 && init.isAssignmentExpression()) {
514
- var _assignment$parentPat;
515
- // `const a = b = 1` → `b = 1`
516
- (_assignment$parentPat = assignment.parentPath) === null || _assignment$parentPat === void 0 || _assignment$parentPat.replaceWith({
517
- type: 'ExpressionStatement',
518
- expression: init.node
519
- });
520
- const left = init.get('left');
521
- if (left.isIdentifier()) {
522
- // If it was forcefully referenced in the shaker
523
- dereference(left);
524
- }
525
- return;
526
- }
527
- // Only one identifier is declared, so we can remove the whole declaration
528
- forDeleting.push(assignment);
529
- return;
530
- }
531
- if (declared.every(identifier => {
532
- var _scope$getBinding;
533
- return identifier.type === 'Identifier' && !((_scope$getBinding = scope.getBinding(identifier.name)) !== null && _scope$getBinding !== void 0 && _scope$getBinding.referenced);
534
- })) {
535
- // No other identifier is referenced, so we can remove the whole declaration
536
- forDeleting.push(assignment);
537
- return;
538
- }
539
-
540
- // We can't remove the binding, but we can remove the part of it
541
- assignment.traverse({
542
- Identifier(identifier) {
543
- if (identifier.node.name === binding.identifier.name) {
544
- const parent = identifier.parentPath;
545
- if (parent.isArrayPattern() && identifier.listKey === 'elements' && typeof identifier.key === 'number') {
546
- parent.node.elements[identifier.key] = null;
547
- } else if (parent.isObjectProperty()) {
548
- forDeleting.push(parent);
549
- }
550
- }
551
- }
552
- });
553
- });
554
- });
555
- removeWithRelated(forDeleting);
556
- }
557
- //# sourceMappingURL=scopeHelpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scopeHelpers.js","names":["_types","require","_findIdentifiers","_getScope","_isNotNull","_isRemoved","validateField","node","key","val","field","validate","optional","getBinding","path","binding","getScope","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","nonType","dereferenceAll","findIdentifiers","map","identifierPath","isNotNull","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","isRemoved","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","NODE_FIELDS","referenceEnums","program","traverse","ExpressionStatement","expressionStatement","expression","callee","args","arg","fixed","removeUnreferenced","items","Set","item","hasReferences","forDeleting","identifier","removeWithRelated","result","sort","a","b","_a$node","_b$node","localeCompare","getNodeForValue","staticEvaluate","evaluated","evaluate","confident","applyAction","test","isBooleanLiteral","consequent","mutate","remove","replaceWith","paths","rootPath","getProgramParent","actions","affectedPaths","referencedIdentifiers","_a$node2","_b$node2","referencesOfBinding","_ref","reduce","acc","ref","isExportDefaultDeclaration","clean","_i$node","join","_i$node2","fn","dereferenced","mutated","dead","assignments","assignment","declared","Object","values","getOuterBindingIdentifiers","_assignment$parentPat","_scope$getBinding","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":";;;;;;;;;;;;AAYA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAjBA;AACA;;AAkBA,SAASK,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,GAAG,IAAAC,kBAAQ,EAACF,IAAI,CAAC,CAACD,UAAU,CAACC,IAAI,CAACP,IAAI,CAACU,IAAI,CAAC;EACzD,IAAI,CAACF,OAAO,EAAE;IACZ,OAAOG,SAAS;EAClB;EAEA,OAAOH,OAAO;AAChB;AAEO,SAASI,SAASA,CACvBL,IAA0C,EAC1CM,aAAuB,GAAGN,IAAI,EAC9BO,KAAK,GAAG,KAAK,EACP;EACN,IAAI,CAACA,KAAK,IAAI,CAACP,IAAI,CAACQ,sBAAsB,CAAC,CAAC,EAAE;EAE9C,MAAMP,OAAO,GAAGF,UAAU,CAACC,IAAI,CAAC;EAChC,IAAI,CAACC,OAAO,EAAE;EAEd,IAAIA,OAAO,CAACQ,cA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