@wyw-in-js/transform 2.0.0-alpha.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 (270) hide show
  1. package/esm/cache.js +7 -0
  2. package/esm/cache.js.map +1 -1
  3. package/esm/debug/fileReporter.js +35 -1
  4. package/esm/debug/fileReporter.js.map +1 -1
  5. package/esm/eval/broker.js +230 -89
  6. package/esm/eval/broker.js.map +1 -1
  7. package/esm/eval/protocol.js.map +1 -1
  8. package/esm/eval/runner.js +143 -24
  9. package/esm/eval/runner.js.map +1 -1
  10. package/esm/module.js +70 -43
  11. package/esm/module.js.map +1 -1
  12. package/esm/transform/Entrypoint.types.js.map +1 -1
  13. package/esm/transform/generators/processEntrypoint.js +35 -20
  14. package/esm/transform/generators/processEntrypoint.js.map +1 -1
  15. package/esm/transform/generators/resolveImports.js +48 -2
  16. package/esm/transform/generators/resolveImports.js.map +1 -1
  17. package/esm/transform/generators/resolveStaticOxcValues/cache.js +182 -0
  18. package/esm/transform/generators/resolveStaticOxcValues/cache.js.map +1 -0
  19. package/esm/transform/generators/resolveStaticOxcValues/candidateResolver.js +146 -0
  20. package/esm/transform/generators/resolveStaticOxcValues/candidateResolver.js.map +1 -0
  21. package/esm/transform/generators/resolveStaticOxcValues/dependencies.js +33 -0
  22. package/esm/transform/generators/resolveStaticOxcValues/dependencies.js.map +1 -0
  23. package/esm/transform/generators/resolveStaticOxcValues/environment.js +29 -0
  24. package/esm/transform/generators/resolveStaticOxcValues/environment.js.map +1 -0
  25. package/esm/transform/generators/resolveStaticOxcValues/exportResolver.js +351 -0
  26. package/esm/transform/generators/resolveStaticOxcValues/exportResolver.js.map +1 -0
  27. package/esm/transform/generators/resolveStaticOxcValues/exportTargets.js +253 -0
  28. package/esm/transform/generators/resolveStaticOxcValues/exportTargets.js.map +1 -0
  29. package/esm/transform/generators/resolveStaticOxcValues/objectAssign.js +310 -0
  30. package/esm/transform/generators/resolveStaticOxcValues/objectAssign.js.map +1 -0
  31. package/esm/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.js +74 -0
  32. package/esm/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.js.map +1 -0
  33. package/esm/transform/generators/resolveStaticOxcValues/opaqueRuntime.js +229 -0
  34. package/esm/transform/generators/resolveStaticOxcValues/opaqueRuntime.js.map +1 -0
  35. package/esm/transform/generators/resolveStaticOxcValues/processorStaticExport.js +172 -0
  36. package/esm/transform/generators/resolveStaticOxcValues/processorStaticExport.js.map +1 -0
  37. package/esm/transform/generators/resolveStaticOxcValues/processorStaticModel.js +476 -0
  38. package/esm/transform/generators/resolveStaticOxcValues/processorStaticModel.js.map +1 -0
  39. package/esm/transform/generators/resolveStaticOxcValues/processorTarget.js +55 -0
  40. package/esm/transform/generators/resolveStaticOxcValues/processorTarget.js.map +1 -0
  41. package/esm/transform/generators/resolveStaticOxcValues/programAnalysis.js +123 -0
  42. package/esm/transform/generators/resolveStaticOxcValues/programAnalysis.js.map +1 -0
  43. package/esm/transform/generators/resolveStaticOxcValues/prune.js +186 -0
  44. package/esm/transform/generators/resolveStaticOxcValues/prune.js.map +1 -0
  45. package/esm/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.js +183 -0
  46. package/esm/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.js.map +1 -0
  47. package/esm/transform/generators/resolveStaticOxcValues/staticExpression.js +298 -0
  48. package/esm/transform/generators/resolveStaticOxcValues/staticExpression.js.map +1 -0
  49. package/esm/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.js +298 -0
  50. package/esm/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.js.map +1 -0
  51. package/esm/transform/generators/resolveStaticOxcValues/types.js +3 -0
  52. package/esm/transform/generators/resolveStaticOxcValues/types.js.map +1 -0
  53. package/esm/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.js +59 -0
  54. package/esm/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.js.map +1 -0
  55. package/esm/transform/generators/resolveStaticOxcValues.js +1 -2910
  56. package/esm/transform/generators/resolveStaticOxcValues.js.map +1 -1
  57. package/esm/transform/generators/transform.js +57 -45
  58. package/esm/transform/generators/transform.js.map +1 -1
  59. package/esm/transform/helpers/loadWywOptions.js +33 -4
  60. package/esm/transform/helpers/loadWywOptions.js.map +1 -1
  61. package/esm/transform.js +3 -1
  62. package/esm/transform.js.map +1 -1
  63. package/esm/utils/EventEmitter.js +42 -9
  64. package/esm/utils/EventEmitter.js.map +1 -1
  65. package/esm/utils/applyOxcProcessors/applyOxcProcessors.js +160 -0
  66. package/esm/utils/applyOxcProcessors/applyOxcProcessors.js.map +1 -0
  67. package/esm/utils/applyOxcProcessors/cleanupBindings.js +157 -0
  68. package/esm/utils/applyOxcProcessors/cleanupBindings.js.map +1 -0
  69. package/esm/utils/applyOxcProcessors/cleanupRemovals.js +431 -0
  70. package/esm/utils/applyOxcProcessors/cleanupRemovals.js.map +1 -0
  71. package/esm/utils/applyOxcProcessors/displayName.js +93 -0
  72. package/esm/utils/applyOxcProcessors/displayName.js.map +1 -0
  73. package/esm/utils/applyOxcProcessors/expressionValues.js +152 -0
  74. package/esm/utils/applyOxcProcessors/expressionValues.js.map +1 -0
  75. package/esm/utils/applyOxcProcessors/processorFactory.js +62 -0
  76. package/esm/utils/applyOxcProcessors/processorFactory.js.map +1 -0
  77. package/esm/utils/applyOxcProcessors/processorUsages.js +143 -0
  78. package/esm/utils/applyOxcProcessors/processorUsages.js.map +1 -0
  79. package/esm/utils/applyOxcProcessors/sameFileStaticValues.js +207 -0
  80. package/esm/utils/applyOxcProcessors/sameFileStaticValues.js.map +1 -0
  81. package/esm/utils/applyOxcProcessors/shared.js +29 -0
  82. package/esm/utils/applyOxcProcessors/shared.js.map +1 -0
  83. package/esm/utils/applyOxcProcessors/types.js +2 -0
  84. package/esm/utils/applyOxcProcessors/types.js.map +1 -0
  85. package/esm/utils/applyOxcProcessors.js +1 -1216
  86. package/esm/utils/applyOxcProcessors.js.map +1 -1
  87. package/esm/utils/collectOxcRuntime/normalizeRuntimeCode.js +157 -0
  88. package/esm/utils/collectOxcRuntime/normalizeRuntimeCode.js.map +1 -0
  89. package/esm/utils/collectOxcRuntime/sourceMap.js +36 -0
  90. package/esm/utils/collectOxcRuntime/sourceMap.js.map +1 -0
  91. package/esm/utils/collectOxcRuntime/types.js +2 -0
  92. package/esm/utils/collectOxcRuntime/types.js.map +1 -0
  93. package/esm/utils/collectOxcRuntime.js +5 -193
  94. package/esm/utils/collectOxcRuntime.js.map +1 -1
  95. package/esm/utils/collectOxcTemplateDependencies/expressionExtraction.js +496 -0
  96. package/esm/utils/collectOxcTemplateDependencies/expressionExtraction.js.map +1 -0
  97. package/esm/utils/collectOxcTemplateDependencies/expressionReplacements.js +113 -0
  98. package/esm/utils/collectOxcTemplateDependencies/expressionReplacements.js.map +1 -0
  99. package/esm/utils/collectOxcTemplateDependencies/scopeAnalysis.js +387 -0
  100. package/esm/utils/collectOxcTemplateDependencies/scopeAnalysis.js.map +1 -0
  101. package/esm/utils/collectOxcTemplateDependencies/staticBindings.js +17 -0
  102. package/esm/utils/collectOxcTemplateDependencies/staticBindings.js.map +1 -0
  103. package/esm/utils/collectOxcTemplateDependencies/staticEvaluator.js +540 -0
  104. package/esm/utils/collectOxcTemplateDependencies/staticEvaluator.js.map +1 -0
  105. package/esm/utils/collectOxcTemplateDependencies/types.js +2 -0
  106. package/esm/utils/collectOxcTemplateDependencies/types.js.map +1 -0
  107. package/esm/utils/collectOxcTemplateDependencies.js +3 -1397
  108. package/esm/utils/collectOxcTemplateDependencies.js.map +1 -1
  109. package/esm/utils/nativeResolver.js +93 -0
  110. package/esm/utils/nativeResolver.js.map +1 -0
  111. package/esm/utils/oxc/ast.js +28 -0
  112. package/esm/utils/oxc/ast.js.map +1 -0
  113. package/esm/utils/oxc/parse.js +3 -0
  114. package/esm/utils/oxc/parse.js.map +1 -0
  115. package/esm/utils/oxc/replacements.js +14 -0
  116. package/esm/utils/oxc/replacements.js.map +1 -0
  117. package/esm/utils/oxc/sourceLocations.js +59 -0
  118. package/esm/utils/oxc/sourceLocations.js.map +1 -0
  119. package/esm/utils/oxcPreevalStage/evalStrategy.js +3 -0
  120. package/esm/utils/oxcPreevalStage/evalStrategy.js.map +1 -0
  121. package/esm/utils/oxcPreevalStage/prepareCode.js +21 -0
  122. package/esm/utils/oxcPreevalStage/prepareCode.js.map +1 -0
  123. package/esm/utils/oxcPreevalStage/prevalExport.js +23 -0
  124. package/esm/utils/oxcPreevalStage/prevalExport.js.map +1 -0
  125. package/esm/utils/oxcPreevalStage/processors.js +17 -0
  126. package/esm/utils/oxcPreevalStage/processors.js.map +1 -0
  127. package/esm/utils/oxcPreevalStage/staticOverlay.js +18 -0
  128. package/esm/utils/oxcPreevalStage/staticOverlay.js.map +1 -0
  129. package/esm/utils/oxcPreevalStage/types.js +2 -0
  130. package/esm/utils/oxcPreevalStage/types.js.map +1 -0
  131. package/esm/utils/oxcPreevalStage.js +17 -73
  132. package/esm/utils/oxcPreevalStage.js.map +1 -1
  133. package/esm/utils/oxcPreevalTransforms.js +12 -1
  134. package/esm/utils/oxcPreevalTransforms.js.map +1 -1
  135. package/esm/utils/processorStaticSemantics.js +157 -0
  136. package/esm/utils/processorStaticSemantics.js.map +1 -0
  137. package/esm/utils/resolveWithConditions.js +3 -3
  138. package/esm/utils/resolveWithConditions.js.map +1 -1
  139. package/package.json +4 -3
  140. package/types/cache.js +8 -0
  141. package/types/debug/fileReporter.js +46 -1
  142. package/types/eval/broker.d.ts +6 -2
  143. package/types/eval/broker.js +244 -95
  144. package/types/eval/protocol.d.ts +15 -1
  145. package/types/module.d.ts +4 -1
  146. package/types/module.js +97 -48
  147. package/types/transform/Entrypoint.types.d.ts +3 -0
  148. package/types/transform/generators/resolveImports.d.ts +3 -1
  149. package/types/transform/generators/resolveImports.js +49 -2
  150. package/types/transform/generators/resolveStaticOxcValues/cache.d.ts +25 -0
  151. package/types/transform/generators/resolveStaticOxcValues/cache.js +182 -0
  152. package/types/transform/generators/resolveStaticOxcValues/candidateResolver.d.ts +5 -0
  153. package/types/transform/generators/resolveStaticOxcValues/candidateResolver.js +149 -0
  154. package/types/transform/generators/resolveStaticOxcValues/dependencies.d.ts +6 -0
  155. package/types/transform/generators/resolveStaticOxcValues/dependencies.js +37 -0
  156. package/types/transform/generators/resolveStaticOxcValues/environment.d.ts +12 -0
  157. package/types/transform/generators/resolveStaticOxcValues/environment.js +32 -0
  158. package/types/transform/generators/resolveStaticOxcValues/exportResolver.d.ts +4 -0
  159. package/types/transform/generators/resolveStaticOxcValues/exportResolver.js +358 -0
  160. package/types/transform/generators/resolveStaticOxcValues/exportTargets.d.ts +20 -0
  161. package/types/transform/generators/resolveStaticOxcValues/exportTargets.js +285 -0
  162. package/types/transform/generators/resolveStaticOxcValues/objectAssign.d.ts +41 -0
  163. package/types/transform/generators/resolveStaticOxcValues/objectAssign.js +352 -0
  164. package/types/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.d.ts +6 -0
  165. package/types/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.js +88 -0
  166. package/types/transform/generators/resolveStaticOxcValues/opaqueRuntime.d.ts +13 -0
  167. package/types/transform/generators/resolveStaticOxcValues/opaqueRuntime.js +263 -0
  168. package/types/transform/generators/resolveStaticOxcValues/processorStaticExport.d.ts +4 -0
  169. package/types/transform/generators/resolveStaticOxcValues/processorStaticExport.js +191 -0
  170. package/types/transform/generators/resolveStaticOxcValues/processorStaticModel.d.ts +40 -0
  171. package/types/transform/generators/resolveStaticOxcValues/processorStaticModel.js +516 -0
  172. package/types/transform/generators/resolveStaticOxcValues/processorTarget.d.ts +5 -0
  173. package/types/transform/generators/resolveStaticOxcValues/processorTarget.js +62 -0
  174. package/types/transform/generators/resolveStaticOxcValues/programAnalysis.d.ts +11 -0
  175. package/types/transform/generators/resolveStaticOxcValues/programAnalysis.js +133 -0
  176. package/types/transform/generators/resolveStaticOxcValues/prune.d.ts +15 -0
  177. package/types/transform/generators/resolveStaticOxcValues/prune.js +220 -0
  178. package/types/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.d.ts +2 -0
  179. package/types/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.js +197 -0
  180. package/types/transform/generators/resolveStaticOxcValues/staticExpression.d.ts +25 -0
  181. package/types/transform/generators/resolveStaticOxcValues/staticExpression.js +391 -0
  182. package/types/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.d.ts +14 -0
  183. package/types/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.js +304 -0
  184. package/types/transform/generators/resolveStaticOxcValues/types.d.ts +99 -0
  185. package/types/transform/generators/resolveStaticOxcValues/types.js +2 -0
  186. package/types/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.d.ts +7 -0
  187. package/types/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.js +64 -0
  188. package/types/transform/generators/resolveStaticOxcValues.d.ts +1 -2
  189. package/types/transform/generators/resolveStaticOxcValues.js +1 -3235
  190. package/types/transform/generators/transform.js +63 -49
  191. package/types/transform/helpers/loadWywOptions.js +23 -3
  192. package/types/transform.js +3 -1
  193. package/types/utils/EventEmitter.d.ts +16 -1
  194. package/types/utils/EventEmitter.js +44 -9
  195. package/types/utils/applyOxcProcessors/applyOxcProcessors.d.ts +8 -0
  196. package/types/utils/applyOxcProcessors/applyOxcProcessors.js +167 -0
  197. package/types/utils/applyOxcProcessors/cleanupBindings.d.ts +12 -0
  198. package/types/utils/applyOxcProcessors/cleanupBindings.js +189 -0
  199. package/types/utils/applyOxcProcessors/cleanupRemovals.d.ts +16 -0
  200. package/types/utils/applyOxcProcessors/cleanupRemovals.js +482 -0
  201. package/types/utils/applyOxcProcessors/displayName.d.ts +9 -0
  202. package/types/utils/applyOxcProcessors/displayName.js +113 -0
  203. package/types/utils/applyOxcProcessors/expressionValues.d.ts +11 -0
  204. package/types/utils/applyOxcProcessors/expressionValues.js +170 -0
  205. package/types/utils/applyOxcProcessors/processorFactory.d.ts +7 -0
  206. package/types/utils/applyOxcProcessors/processorFactory.js +70 -0
  207. package/types/utils/applyOxcProcessors/processorUsages.d.ts +16 -0
  208. package/types/utils/applyOxcProcessors/processorUsages.js +163 -0
  209. package/types/utils/applyOxcProcessors/sameFileStaticValues.d.ts +23 -0
  210. package/types/utils/applyOxcProcessors/sameFileStaticValues.js +211 -0
  211. package/types/utils/applyOxcProcessors/shared.d.ts +10 -0
  212. package/types/utils/applyOxcProcessors/shared.js +37 -0
  213. package/types/utils/applyOxcProcessors/types.d.ts +88 -0
  214. package/types/utils/applyOxcProcessors/types.js +1 -0
  215. package/types/utils/applyOxcProcessors.d.ts +1 -16
  216. package/types/utils/applyOxcProcessors.js +1 -1391
  217. package/types/utils/collectOxcRuntime/normalizeRuntimeCode.d.ts +1 -0
  218. package/types/utils/collectOxcRuntime/normalizeRuntimeCode.js +185 -0
  219. package/types/utils/collectOxcRuntime/sourceMap.d.ts +2 -0
  220. package/types/utils/collectOxcRuntime/sourceMap.js +37 -0
  221. package/types/utils/collectOxcRuntime/types.d.ts +16 -0
  222. package/types/utils/collectOxcRuntime/types.js +1 -0
  223. package/types/utils/collectOxcRuntime.d.ts +2 -12
  224. package/types/utils/collectOxcRuntime.js +5 -224
  225. package/types/utils/collectOxcTemplateDependencies/expressionExtraction.d.ts +6 -0
  226. package/types/utils/collectOxcTemplateDependencies/expressionExtraction.js +550 -0
  227. package/types/utils/collectOxcTemplateDependencies/expressionReplacements.d.ts +11 -0
  228. package/types/utils/collectOxcTemplateDependencies/expressionReplacements.js +131 -0
  229. package/types/utils/collectOxcTemplateDependencies/scopeAnalysis.d.ts +20 -0
  230. package/types/utils/collectOxcTemplateDependencies/scopeAnalysis.js +434 -0
  231. package/types/utils/collectOxcTemplateDependencies/staticBindings.d.ts +7 -0
  232. package/types/utils/collectOxcTemplateDependencies/staticBindings.js +13 -0
  233. package/types/utils/collectOxcTemplateDependencies/staticEvaluator.d.ts +13 -0
  234. package/types/utils/collectOxcTemplateDependencies/staticEvaluator.js +626 -0
  235. package/types/utils/collectOxcTemplateDependencies/types.d.ts +116 -0
  236. package/types/utils/collectOxcTemplateDependencies/types.js +1 -0
  237. package/types/utils/collectOxcTemplateDependencies.d.ts +4 -38
  238. package/types/utils/collectOxcTemplateDependencies.js +3 -1580
  239. package/types/utils/nativeResolver.d.ts +13 -0
  240. package/types/utils/nativeResolver.js +91 -0
  241. package/types/utils/oxc/ast.d.ts +4 -0
  242. package/types/utils/oxc/ast.js +37 -0
  243. package/types/utils/oxc/parse.d.ts +3 -0
  244. package/types/utils/oxc/parse.js +2 -0
  245. package/types/utils/oxc/replacements.d.ts +12 -0
  246. package/types/utils/oxc/replacements.js +18 -0
  247. package/types/utils/oxc/sourceLocations.d.ts +5 -0
  248. package/types/utils/oxc/sourceLocations.js +63 -0
  249. package/types/utils/oxcPreevalStage/evalStrategy.d.ts +3 -0
  250. package/types/utils/oxcPreevalStage/evalStrategy.js +2 -0
  251. package/types/utils/oxcPreevalStage/prepareCode.d.ts +3 -0
  252. package/types/utils/oxcPreevalStage/prepareCode.js +20 -0
  253. package/types/utils/oxcPreevalStage/prevalExport.d.ts +1 -0
  254. package/types/utils/oxcPreevalStage/prevalExport.js +22 -0
  255. package/types/utils/oxcPreevalStage/processors.d.ts +10 -0
  256. package/types/utils/oxcPreevalStage/processors.js +16 -0
  257. package/types/utils/oxcPreevalStage/staticOverlay.d.ts +3 -0
  258. package/types/utils/oxcPreevalStage/staticOverlay.js +23 -0
  259. package/types/utils/oxcPreevalStage/types.d.ts +22 -0
  260. package/types/utils/oxcPreevalStage/types.js +1 -0
  261. package/types/utils/oxcPreevalStage.d.ts +2 -18
  262. package/types/utils/oxcPreevalStage.js +17 -79
  263. package/types/utils/oxcPreevalTransforms.js +14 -1
  264. package/types/utils/processorStaticSemantics.d.ts +13 -0
  265. package/types/utils/processorStaticSemantics.js +191 -0
  266. package/types/utils/resolveWithConditions.js +3 -3
  267. package/esm/eval/resolverStrategy.js +0 -51
  268. package/esm/eval/resolverStrategy.js.map +0 -1
  269. package/types/eval/resolverStrategy.d.ts +0 -13
  270. package/types/eval/resolverStrategy.js +0 -46
@@ -1,1217 +1,2 @@
1
- /* eslint-disable no-restricted-syntax */
2
- import { basename, dirname } from "path";
3
- import { BaseProcessor, expressionToCode } from "@wyw-in-js/processor-utils";
4
- import { ValueType } from "@wyw-in-js/shared";
5
- import { collectOxcProcessorImportsFromProgram } from "./collectOxcExportsAndImports.js";
6
- import { EventEmitter } from "./EventEmitter.js";
7
- import { collectOxcExpressionDependencies } from "./collectOxcTemplateDependencies.js";
8
- import { isNotNull } from "./isNotNull.js";
9
- import { createOxcAstService, printOxcAstServiceImport } from "./oxcAstService.js";
10
- import { parseOxcProgramCached } from "./parseOxc.js";
11
- import { getProcessorForImport } from "./processorLookup.js";
12
- let didWarnSkipSymbolMismatch = false;
13
- const GENERATED_HELPER_NAME_RE = /^_exp\d*$/;
14
- const isNode = (value) => !!value && typeof value === "object" && "type" in value && typeof value.type === "string";
15
- const getChildren = (node) => {
16
- const result = [];
17
- const record = node;
18
- Object.keys(record).forEach((key) => {
19
- if (key === "type" || key === "start" || key === "end" || key === "range") {
20
- return;
21
- }
22
- const value = record[key];
23
- if (isNode(value)) {
24
- result.push(value);
25
- return;
26
- }
27
- if (Array.isArray(value)) {
28
- value.forEach((item) => {
29
- if (isNode(item)) {
30
- result.push(item);
31
- }
32
- });
33
- }
34
- });
35
- return result;
36
- };
37
- const parseOxc = (code, filename) => {
38
- return parseOxcProgramCached(filename, code, "module");
39
- };
40
- const visit = (node, enter, parent = null) => {
41
- enter(node, parent);
42
- getChildren(node).forEach((child) => visit(child, enter, node));
43
- };
44
- const applyReplacements = (code, replacements) => {
45
- let result = code;
46
- replacements.sort((a, b) => b.start - a.start).forEach((replacement) => {
47
- result = result.slice(0, replacement.start) + replacement.value + result.slice(replacement.end);
48
- });
49
- return result;
50
- };
51
- const insertAddedImports = (code, program, addedImports) => {
52
- if (addedImports.length === 0) {
53
- return code;
54
- }
55
- const uniqueImports = [...new Map(addedImports.map((item) => [`${item.source}\0${item.imported}\0${item.local}`, item])).values()];
56
- const importBlock = uniqueImports.map(printOxcAstServiceImport).join("\n");
57
- const lastImport = [...program.body].reverse().find((statement) => statement.type === "ImportDeclaration");
58
- const hashbangEnd = code.startsWith("#!") ? (() => {
59
- const newline = code.indexOf("\n");
60
- return newline === -1 ? code.length : newline + 1;
61
- })() : 0;
62
- const insertionPoint = lastImport?.end ?? hashbangEnd;
63
- const prefix = code.slice(0, insertionPoint);
64
- const suffix = code.slice(insertionPoint);
65
- const leadingBreak = prefix.length > 0 && !prefix.endsWith("\n") ? "\n" : "";
66
- const trailingBreak = suffix.length > 0 && !suffix.startsWith("\n") ? "\n" : "";
67
- return `${prefix}${leadingBreak}${importBlock}${trailingBreak}${suffix}`;
68
- };
69
- const createLocationLookup = (code) => {
70
- const lineStarts = [0];
71
- for (let idx = 0; idx < code.length; idx += 1) {
72
- if (code[idx] === "\n") {
73
- lineStarts.push(idx + 1);
74
- }
75
- }
76
- return (offset) => {
77
- let low = 0;
78
- let high = lineStarts.length - 1;
79
- while (low <= high) {
80
- const mid = Math.floor((low + high) / 2);
81
- const next = lineStarts[mid + 1] ?? Infinity;
82
- if (lineStarts[mid] <= offset && offset < next) {
83
- return {
84
- column: offset - lineStarts[mid],
85
- line: mid + 1
86
- };
87
- }
88
- if (offset < lineStarts[mid]) {
89
- high = mid - 1;
90
- } else {
91
- low = mid + 1;
92
- }
93
- }
94
- const lastLine = lineStarts.length - 1;
95
- return {
96
- column: Math.max(0, offset - lineStarts[lastLine]),
97
- line: lastLine + 1
98
- };
99
- };
100
- };
101
- const getSourceLocation = (start, end, loc, filename) => ({
102
- end: loc(end),
103
- filename: filename ?? undefined,
104
- start: loc(start)
105
- });
106
- const buildCodeFrameError = (code, location, message) => {
107
- const lines = code.split("\n");
108
- const startLine = location.start.line;
109
- const endLine = location.end.line;
110
- const frameStart = Math.max(1, startLine - 2);
111
- const frameEnd = Math.min(lines.length, endLine + 2);
112
- const lineNoWidth = String(frameEnd).length;
113
- const frame = [];
114
- for (let lineNo = frameStart; lineNo <= frameEnd; lineNo += 1) {
115
- const marker = lineNo === startLine ? ">" : " ";
116
- const line = lines[lineNo - 1] ?? "";
117
- frame.push(line.length > 0 ? `${marker} ${String(lineNo).padStart(lineNoWidth)} | ${line}` : `${marker} ${String(lineNo).padStart(lineNoWidth)} |`);
118
- if (lineNo === startLine) {
119
- const pointerLength = startLine === endLine ? Math.max(1, location.end.column - location.start.column) : 1;
120
- frame.push(` ${" ".repeat(lineNoWidth)} | ${" ".repeat(location.start.column)}${"^".repeat(pointerLength)}`);
121
- }
122
- }
123
- const prefix = location.filename ? `${location.filename}: ` : "";
124
- return new Error(`${prefix}${message}\n${frame.join("\n")}`);
125
- };
126
- const collectUsedNames = (program) => {
127
- const names = new Set();
128
- visit(program, (node) => {
129
- if (node.type === "Identifier") {
130
- names.add(node.name);
131
- }
132
- });
133
- return names;
134
- };
135
- const isNodeReference = (node, parent) => {
136
- if (node.type === "Identifier") {
137
- const parentRecord = parent;
138
- if (!parentRecord) {
139
- return true;
140
- }
141
- if (parent?.type === "ImportDeclaration" || parent?.type === "ImportSpecifier" || parent?.type === "ImportDefaultSpecifier" || parent?.type === "ImportNamespaceSpecifier") {
142
- return false;
143
- }
144
- if (parent?.type === "MemberExpression" && parentRecord.property === node && !parentRecord.computed) {
145
- return false;
146
- }
147
- if ((parent?.type === "VariableDeclarator" || parent?.type === "FunctionDeclaration" || parent?.type === "ClassDeclaration" || parent?.type === "ClassExpression") && parentRecord.id === node) {
148
- return false;
149
- }
150
- if ((parent?.type === "PropertyDefinition" || parent?.type === "MethodDefinition") && parentRecord.key === node && !parentRecord.computed) {
151
- return false;
152
- }
153
- if (parent?.type === "Property" && parentRecord.key === node && parentRecord.value !== node && !parentRecord.computed) {
154
- return false;
155
- }
156
- return true;
157
- }
158
- if (node.type === "JSXIdentifier") {
159
- const parentRecord = parent;
160
- if (parent?.type === "JSXAttribute" && parentRecord?.name === node) {
161
- return false;
162
- }
163
- return true;
164
- }
165
- return false;
166
- };
167
- const collectReferencedNames = (root) => {
168
- const names = new Set();
169
- const walk = (node, parent = null) => {
170
- if (node.type === "ImportDeclaration") {
171
- return;
172
- }
173
- if (isNodeReference(node, parent) && "name" in node && typeof node.name === "string") {
174
- names.add(node.name);
175
- }
176
- getChildren(node).forEach((child) => walk(child, node));
177
- };
178
- walk(root);
179
- return names;
180
- };
181
- const collectImportLocalNames = (node) => {
182
- if (node.type !== "ImportDeclaration") {
183
- return [];
184
- }
185
- const { specifiers } = node;
186
- if (!Array.isArray(specifiers)) {
187
- return [];
188
- }
189
- return specifiers.map((specifier) => {
190
- const { local } = specifier;
191
- return isNode(local) && "name" in local && typeof local.name === "string" ? local.name : null;
192
- }).filter(isNotNull);
193
- };
194
- const getImportSpecifierLocalName = (node) => {
195
- const { local } = node;
196
- return isNode(local) && "name" in local && typeof local.name === "string" ? local.name : null;
197
- };
198
- const collectDeclaredNames = (node) => {
199
- if (node.type === "Identifier") {
200
- return [node.name];
201
- }
202
- if (node.type === "RestElement") {
203
- return collectDeclaredNames(node.argument);
204
- }
205
- if (node.type === "AssignmentPattern") {
206
- return collectDeclaredNames(node.left);
207
- }
208
- if (node.type === "ObjectPattern") {
209
- return node.properties.flatMap((property) => property.type === "RestElement" ? collectDeclaredNames(property.argument) : collectDeclaredNames(property.value));
210
- }
211
- if (node.type === "ArrayPattern") {
212
- return node.elements.flatMap((element) => element ? collectDeclaredNames(element) : []);
213
- }
214
- if (node.type === "TSParameterProperty") {
215
- return collectDeclaredNames(node.parameter);
216
- }
217
- return [];
218
- };
219
- const collectTopLevelBindings = (statement) => {
220
- const bindings = new Set();
221
- if (statement.type === "ImportDeclaration") {
222
- collectImportLocalNames(statement).forEach((name) => bindings.add(name));
223
- return bindings;
224
- }
225
- if (statement.type === "VariableDeclaration") {
226
- const { declarations } = statement;
227
- if (!Array.isArray(declarations)) {
228
- return bindings;
229
- }
230
- declarations.forEach((declarator) => {
231
- const { id } = declarator;
232
- if (isNode(id)) {
233
- collectDeclaredNames(id).forEach((name) => bindings.add(name));
234
- }
235
- });
236
- return bindings;
237
- }
238
- if ((statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration" || statement.type === "TSEnumDeclaration") && "id" in statement) {
239
- const { id } = statement;
240
- if (isNode(id) && id.type === "Identifier") {
241
- bindings.add(id.name);
242
- }
243
- return bindings;
244
- }
245
- if (statement.type === "ExportNamedDeclaration") {
246
- const { declaration } = statement;
247
- return isNode(declaration) ? collectTopLevelBindings(declaration) : bindings;
248
- }
249
- return bindings;
250
- };
251
- const collectTopLevelStatementInfos = (program) => program.body.map((statement) => ({
252
- bindings: collectTopLevelBindings(statement),
253
- node: statement,
254
- references: collectReferencedNames(statement)
255
- }));
256
- const collectTopLevelBindingsFromStatements = (statements) => new Set(statements.flatMap((statement) => [...statement.bindings]));
257
- const collectRemovableNamesFromStatements = (statements, initialNames) => {
258
- const removable = new Set(initialNames);
259
- const bindingToStatement = new Map();
260
- statements.forEach((statement) => {
261
- statement.bindings.forEach((name) => {
262
- bindingToStatement.set(name, statement);
263
- });
264
- });
265
- const queue = [...removable];
266
- while (queue.length > 0) {
267
- const name = queue.shift();
268
- const statement = bindingToStatement.get(name);
269
- if (statement) {
270
- statement.references.forEach((reference) => {
271
- if (bindingToStatement.has(reference) && !removable.has(reference)) {
272
- removable.add(reference);
273
- queue.push(reference);
274
- }
275
- });
276
- }
277
- }
278
- return removable;
279
- };
280
- const createScopedCleanupScope = (parent) => ({
281
- bindings: new Map(),
282
- parent
283
- });
284
- const resolveScopedBinding = (scope, name) => {
285
- let current = scope;
286
- while (current) {
287
- const bindingId = current.bindings.get(name);
288
- if (bindingId) {
289
- return bindingId;
290
- }
291
- current = current.parent;
292
- }
293
- return null;
294
- };
295
- const collectScopedBindingInfos = (program) => {
296
- const bindings = new Map();
297
- let sequence = 0;
298
- const addBinding = (scope, name, kind, declaration) => {
299
- const id = `${kind}:${name}:${declaration.start}:${sequence}`;
300
- sequence += 1;
301
- bindings.set(id, {
302
- declaration,
303
- dependencies: new Set(),
304
- externalReferences: 0,
305
- id,
306
- incomingFromBindings: new Set(),
307
- kind,
308
- name
309
- });
310
- scope.bindings.set(name, id);
311
- return id;
312
- };
313
- const addPatternBindings = (scope, pattern, kind, declaration) => {
314
- collectDeclaredNames(pattern).forEach((name) => {
315
- addBinding(scope, name, kind, declaration);
316
- });
317
- };
318
- const recordReference = (scope, name, ownerBindingId) => {
319
- const targetId = resolveScopedBinding(scope, name);
320
- if (!targetId) {
321
- return;
322
- }
323
- const target = bindings.get(targetId);
324
- if (!target) {
325
- return;
326
- }
327
- if (ownerBindingId && ownerBindingId !== targetId) {
328
- target.incomingFromBindings.add(ownerBindingId);
329
- bindings.get(ownerBindingId)?.dependencies.add(targetId);
330
- return;
331
- }
332
- target.externalReferences += 1;
333
- };
334
- let walk;
335
- function walkPatternReferenceSubexpressions(node, scope, ownerBindingId) {
336
- if (node.type === "Identifier") {
337
- return;
338
- }
339
- if (node.type === "TSParameterProperty") {
340
- walkPatternReferenceSubexpressions(node.parameter, scope, ownerBindingId);
341
- return;
342
- }
343
- if (node.type === "RestElement") {
344
- walkPatternReferenceSubexpressions(node.argument, scope, ownerBindingId);
345
- return;
346
- }
347
- if (node.type === "AssignmentPattern") {
348
- walkPatternReferenceSubexpressions(node.left, scope, ownerBindingId);
349
- walk(node.right, scope, node, ownerBindingId);
350
- return;
351
- }
352
- if (node.type === "ObjectPattern") {
353
- node.properties.forEach((property) => {
354
- if (property.type === "RestElement") {
355
- walkPatternReferenceSubexpressions(property.argument, scope, ownerBindingId);
356
- return;
357
- }
358
- if (property.computed && isNode(property.key)) {
359
- walk(property.key, scope, property, ownerBindingId);
360
- }
361
- walkPatternReferenceSubexpressions(property.value, scope, ownerBindingId);
362
- });
363
- return;
364
- }
365
- if (node.type === "ArrayPattern") {
366
- node.elements.forEach((element) => {
367
- if (element && isNode(element)) {
368
- walkPatternReferenceSubexpressions(element, scope, ownerBindingId);
369
- }
370
- });
371
- }
372
- }
373
- walk = (node, scope, parent = null, ownerBindingId = null) => {
374
- if (node.type === "ImportDeclaration") {
375
- const { specifiers } = node;
376
- if (Array.isArray(specifiers)) {
377
- specifiers.forEach((specifier) => {
378
- const { local } = specifier;
379
- if (isNode(local) && local.type === "Identifier" && typeof local.name === "string") {
380
- addBinding(scope, local.name, "import", node);
381
- }
382
- });
383
- }
384
- return;
385
- }
386
- if (node.type === "ExportNamedDeclaration" && node.declaration) {
387
- walk(node.declaration, scope, node, ownerBindingId);
388
- collectTopLevelBindings(node).forEach((name) => {
389
- recordReference(scope, name, ownerBindingId);
390
- });
391
- return;
392
- }
393
- if (node.type === "ExportDefaultDeclaration") {
394
- const { declaration } = node;
395
- if (isNode(declaration)) {
396
- walk(declaration, scope, node, ownerBindingId);
397
- if ((declaration.type === "FunctionDeclaration" || declaration.type === "ClassDeclaration") && declaration.id) {
398
- recordReference(scope, declaration.id.name, ownerBindingId);
399
- }
400
- }
401
- return;
402
- }
403
- if (node.type === "VariableDeclaration") {
404
- const { declarations } = node;
405
- if (!Array.isArray(declarations)) {
406
- return;
407
- }
408
- declarations.forEach((declarator) => {
409
- const { id } = declarator;
410
- if (isNode(id)) {
411
- addPatternBindings(scope, id, "variable", node);
412
- }
413
- });
414
- declarations.forEach((declarator) => {
415
- const { id } = declarator;
416
- const { init } = declarator;
417
- if (!isNode(id) || !isNode(init)) {
418
- return;
419
- }
420
- const ownerName = collectDeclaredNames(id)[0] ?? null;
421
- const nextOwner = ownerName !== null ? resolveScopedBinding(scope, ownerName) : null;
422
- walk(init, scope, declarator, nextOwner);
423
- });
424
- return;
425
- }
426
- if (node.type === "FunctionDeclaration" && node.id) {
427
- const functionBindingId = addBinding(scope, node.id.name, "function", node);
428
- const fnScope = createScopedCleanupScope(scope);
429
- node.params.forEach((param) => {
430
- addPatternBindings(fnScope, param, "param", param);
431
- walkPatternReferenceSubexpressions(param, fnScope, functionBindingId);
432
- });
433
- if (node.body) {
434
- walk(node.body, fnScope, node, functionBindingId);
435
- }
436
- return;
437
- }
438
- if (node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") {
439
- const fnScope = createScopedCleanupScope(scope);
440
- if (node.type === "FunctionExpression" && node.id) {
441
- addBinding(fnScope, node.id.name, "function", node);
442
- }
443
- node.params.forEach((param) => {
444
- addPatternBindings(fnScope, param, "param", param);
445
- walkPatternReferenceSubexpressions(param, fnScope, ownerBindingId);
446
- });
447
- if (node.body) {
448
- walk(node.body, fnScope, node, ownerBindingId);
449
- }
450
- return;
451
- }
452
- if (node.type === "BlockStatement") {
453
- const blockScope = createScopedCleanupScope(scope);
454
- getChildren(node).forEach((child) => walk(child, blockScope, node, ownerBindingId));
455
- return;
456
- }
457
- if (isNodeReference(node, parent) && "name" in node && typeof node.name === "string") {
458
- recordReference(scope, node.name, ownerBindingId);
459
- }
460
- getChildren(node).forEach((child) => walk(child, scope, node, ownerBindingId));
461
- };
462
- walk(program, createScopedCleanupScope(null));
463
- return bindings;
464
- };
465
- const collectScopedRemovableBindingIds = (bindings, initialNames) => {
466
- const removable = new Set();
467
- let changed = true;
468
- while (changed) {
469
- changed = false;
470
- for (const binding of bindings.values()) {
471
- if (!removable.has(binding.id) && binding.kind !== "import" && binding.kind !== "param" && binding.externalReferences === 0) {
472
- const seededByName = initialNames.has(binding.name) || GENERATED_HELPER_NAME_RE.test(binding.name) && binding.incomingFromBindings.size === 0;
473
- const allIncomingRemovable = binding.incomingFromBindings.size > 0 && [...binding.incomingFromBindings].every((sourceId) => removable.has(sourceId));
474
- if (seededByName && binding.incomingFromBindings.size === 0 || allIncomingRemovable) {
475
- removable.add(binding.id);
476
- changed = true;
477
- }
478
- }
479
- }
480
- }
481
- return removable;
482
- };
483
- function expandImportRemovalRange(code, start, end) {
484
- let removalStart = start;
485
- while (removalStart > 0 && (code[removalStart - 1] === " " || code[removalStart - 1] === " ")) {
486
- removalStart -= 1;
487
- }
488
- let removalEnd = end;
489
- if (code[removalEnd] === ";") {
490
- removalEnd += 1;
491
- }
492
- while (removalEnd < code.length && (code[removalEnd] === " " || code[removalEnd] === " ")) {
493
- removalEnd += 1;
494
- }
495
- if (code[removalEnd] === "\r" && code[removalEnd + 1] === "\n") {
496
- removalEnd += 2;
497
- } else if (code[removalEnd] === "\n") {
498
- removalEnd += 1;
499
- }
500
- return {
501
- end: removalEnd,
502
- start: removalStart,
503
- value: ""
504
- };
505
- }
506
- const collectUnusedScopedDeclarationRemovals = (code, bindings, initialRemovableNames) => {
507
- const removableBindingIds = collectScopedRemovableBindingIds(bindings, initialRemovableNames);
508
- const removals = new Map();
509
- bindings.forEach((binding) => {
510
- if (!removableBindingIds.has(binding.id) || binding.kind === "import" || binding.kind === "param" || binding.externalReferences > 0 || [...binding.incomingFromBindings].some((sourceId) => !removableBindingIds.has(sourceId))) {
511
- return;
512
- }
513
- if (binding.kind === "function" && binding.declaration.type === "FunctionDeclaration") {
514
- const range = expandImportRemovalRange(code, binding.declaration.start, binding.declaration.end);
515
- removals.set(`${range.start}:${range.end}`, range);
516
- return;
517
- }
518
- if (binding.declaration.type !== "VariableDeclaration") {
519
- return;
520
- }
521
- const { declarations } = binding.declaration;
522
- if (!Array.isArray(declarations) || declarations.length !== 1) {
523
- return;
524
- }
525
- const range = expandImportRemovalRange(code, binding.declaration.start, binding.declaration.end);
526
- removals.set(`${range.start}:${range.end}`, range);
527
- });
528
- return [...removals.values()];
529
- };
530
- const expandImportSpecifierRemovalRange = (code, start, end) => {
531
- let removalStart = start;
532
- let removalEnd = end;
533
- let whitespaceStart = removalStart;
534
- while (whitespaceStart > 0 && (code[whitespaceStart - 1] === " " || code[whitespaceStart - 1] === " ")) {
535
- whitespaceStart -= 1;
536
- }
537
- if (code[whitespaceStart - 1] !== "{") {
538
- removalStart = whitespaceStart;
539
- }
540
- while (removalEnd < code.length && (code[removalEnd] === " " || code[removalEnd] === " ")) {
541
- removalEnd += 1;
542
- }
543
- if (code[removalEnd] === ",") {
544
- removalEnd += 1;
545
- while (removalEnd < code.length && (code[removalEnd] === " " || code[removalEnd] === " ")) {
546
- removalEnd += 1;
547
- }
548
- } else {
549
- while (removalStart > 0 && (code[removalStart - 1] === " " || code[removalStart - 1] === " ")) {
550
- removalStart -= 1;
551
- }
552
- if (code[removalStart - 1] === ",") {
553
- removalStart -= 1;
554
- while (removalStart > 0 && (code[removalStart - 1] === " " || code[removalStart - 1] === " ")) {
555
- removalStart -= 1;
556
- }
557
- }
558
- }
559
- return {
560
- end: removalEnd,
561
- start: removalStart,
562
- value: ""
563
- };
564
- };
565
- const mergeEmptyRemovalRanges = (removals) => {
566
- if (removals.length <= 1) {
567
- return removals;
568
- }
569
- const sorted = [...removals].sort((a, b) => a.start - b.start);
570
- const merged = [];
571
- sorted.forEach((removal) => {
572
- const previous = merged[merged.length - 1];
573
- if (previous && previous.value === "" && removal.value === "" && removal.start <= previous.end) {
574
- previous.end = Math.max(previous.end, removal.end);
575
- return;
576
- }
577
- merged.push({ ...removal });
578
- });
579
- return merged;
580
- };
581
- const collectUnusedImportRemovals = (code, program, referencedNames, removableNames, preserveSideEffectImportLocals) => {
582
- const removals = [];
583
- program.body.forEach((statement) => {
584
- if (statement.type !== "ImportDeclaration") {
585
- return;
586
- }
587
- const localNames = collectImportLocalNames(statement);
588
- const removableLocalNames = localNames.filter((localName) => removableNames.has(localName));
589
- if (removableLocalNames.length > 0 && removableLocalNames.length === localNames.length && removableLocalNames.every((localName) => !referencedNames.has(localName))) {
590
- if (removableLocalNames.some((localName) => preserveSideEffectImportLocals.has(localName))) {
591
- removals.push({
592
- end: statement.end,
593
- start: statement.start,
594
- value: `import ${code.slice(statement.source.start, statement.source.end)};`
595
- });
596
- return;
597
- }
598
- removals.push(expandImportRemovalRange(code, statement.start, statement.end));
599
- return;
600
- }
601
- const { specifiers } = statement;
602
- if (!Array.isArray(specifiers) || specifiers.length <= 1) {
603
- return;
604
- }
605
- specifiers.forEach((specifier) => {
606
- if (!isNode(specifier)) {
607
- return;
608
- }
609
- const localName = getImportSpecifierLocalName(specifier);
610
- if (localName && removableNames.has(localName) && !referencedNames.has(localName)) {
611
- removals.push(expandImportSpecifierRemovalRange(code, specifier.start, specifier.end));
612
- }
613
- });
614
- });
615
- return removals;
616
- };
617
- const collectUnusedTopLevelDeclarationRemovals = (code, program, referencedNames, removableNames) => {
618
- const removals = [];
619
- program.body.forEach((statement) => {
620
- if (statement.type !== "VariableDeclaration") {
621
- return;
622
- }
623
- const localNames = [...collectTopLevelBindings(statement)];
624
- if (localNames.length > 0 && localNames.every((localName) => removableNames.has(localName)) && localNames.every((localName) => !referencedNames.has(localName))) {
625
- removals.push(expandImportRemovalRange(code, statement.start, statement.end));
626
- }
627
- });
628
- return removals;
629
- };
630
- const collectUnusedGeneratedHelperDeclarationRemovals = (code, program, referencedNames) => {
631
- const removals = [];
632
- program.body.forEach((statement) => {
633
- if (statement.type !== "VariableDeclaration") {
634
- return;
635
- }
636
- const localNames = [...collectTopLevelBindings(statement)];
637
- if (localNames.length > 0 && localNames.every((localName) => GENERATED_HELPER_NAME_RE.test(localName)) && localNames.every((localName) => !referencedNames.has(localName))) {
638
- removals.push(expandImportRemovalRange(code, statement.start, statement.end));
639
- }
640
- });
641
- return removals;
642
- };
643
- const collectTopLevelExpressionStatementRemovals = (code, statements, topLevelBindings, removableExpressionRefs) => {
644
- const removals = [];
645
- statements.forEach((statement) => {
646
- if (statement.node.type !== "ExpressionStatement") {
647
- return;
648
- }
649
- const { expression } = statement.node;
650
- const isPureExpression = expression.type === "Identifier" || expression.type === "Literal" || expression.type === "ObjectExpression" || expression.type === "ArrayExpression" || expression.type === "ArrowFunctionExpression" || expression.type === "FunctionExpression" || expression.type === "TemplateLiteral" && expression.expressions.length === 0;
651
- if (!isPureExpression) {
652
- return;
653
- }
654
- const localReferences = [...statement.references].filter((name) => topLevelBindings.has(name));
655
- if (localReferences.length > 0 && localReferences.every((name) => removableExpressionRefs.has(name))) {
656
- removals.push(expandImportRemovalRange(code, statement.node.start, statement.node.end));
657
- }
658
- });
659
- return removals;
660
- };
661
- const collectEmptyTopLevelBlockRemovals = (code, program) => {
662
- const removals = [];
663
- program.body.forEach((statement) => {
664
- if (statement.type !== "BlockStatement" || statement.body.length > 0) {
665
- return;
666
- }
667
- removals.push(expandImportRemovalRange(code, statement.start, statement.end));
668
- });
669
- return removals;
670
- };
671
- const removeUnusedAfterReplacement = (code, filename, initialRemovableNames, removableExpressionRefs, preserveSideEffectImportLocals) => {
672
- let current = code;
673
- const cumulativeRemovableNames = new Set(initialRemovableNames);
674
- const applyIfParsable = (next) => {
675
- try {
676
- parseOxc(next, filename);
677
- return next;
678
- } catch {
679
- return current;
680
- }
681
- };
682
- for (let idx = 0; idx < 5; idx += 1) {
683
- const previous = current;
684
- const program = parseOxc(current, filename);
685
- const statements = collectTopLevelStatementInfos(program);
686
- const removableNames = collectRemovableNamesFromStatements(statements, cumulativeRemovableNames);
687
- removableNames.forEach((name) => cumulativeRemovableNames.add(name));
688
- const referencedNames = collectReferencedNames(program);
689
- const topLevelBindings = collectTopLevelBindingsFromStatements(statements);
690
- const scopedBindings = collectScopedBindingInfos(program);
691
- const removals = mergeEmptyRemovalRanges([
692
- ...collectUnusedScopedDeclarationRemovals(current, scopedBindings, cumulativeRemovableNames),
693
- ...collectUnusedTopLevelDeclarationRemovals(current, program, referencedNames, cumulativeRemovableNames),
694
- ...collectUnusedGeneratedHelperDeclarationRemovals(current, program, referencedNames),
695
- ...collectUnusedImportRemovals(current, program, referencedNames, cumulativeRemovableNames, preserveSideEffectImportLocals),
696
- ...collectTopLevelExpressionStatementRemovals(current, statements, topLevelBindings, removableExpressionRefs),
697
- ...collectEmptyTopLevelBlockRemovals(current, program)
698
- ]);
699
- current = removals.length > 0 ? applyIfParsable(applyReplacements(current, removals)) : current;
700
- if (current === previous) {
701
- return current;
702
- }
703
- }
704
- return current;
705
- };
706
- const getMemberName = (node) => {
707
- if (node.computed) {
708
- return node.property.type === "Literal" && typeof node.property.value === "string" ? node.property.value : null;
709
- }
710
- return node.property.type === "Identifier" ? node.property.name : null;
711
- };
712
- const unwrapQualifiedExpression = (node) => {
713
- if (node.type === "TSAsExpression" || node.type === "TSSatisfiesExpression" || node.type === "TSNonNullExpression" || node.type === "TSTypeAssertion" || node.type === "ParenthesizedExpression") {
714
- return unwrapQualifiedExpression(node.expression);
715
- }
716
- if (node.type === "SequenceExpression") {
717
- const sequence = node;
718
- return unwrapQualifiedExpression(sequence.expressions[sequence.expressions.length - 1] ?? node);
719
- }
720
- return node;
721
- };
722
- const getRootIdentifier = (node) => {
723
- const expression = unwrapQualifiedExpression(node);
724
- if (expression.type === "Identifier") {
725
- return expression;
726
- }
727
- if (expression.type === "MemberExpression") {
728
- return getRootIdentifier(expression.object);
729
- }
730
- if (expression.type === "CallExpression") {
731
- return getRootIdentifier(expression.callee);
732
- }
733
- return null;
734
- };
735
- const getQualifiedName = (node) => {
736
- const expression = unwrapQualifiedExpression(node);
737
- if (expression.type === "Identifier") {
738
- return expression.name;
739
- }
740
- if (expression.type === "MemberExpression") {
741
- const object = getQualifiedName(expression.object);
742
- const member = getMemberName(expression);
743
- return object && member ? `${object}.${member}` : null;
744
- }
745
- if (expression.type === "CallExpression") {
746
- return getQualifiedName(expression.callee);
747
- }
748
- return null;
749
- };
750
- const resolveDefinedProcessor = (callee, definedProcessors) => {
751
- const qualified = getQualifiedName(callee);
752
- if (qualified) {
753
- const definedProcessor = definedProcessors.get(qualified);
754
- if (definedProcessor) {
755
- return {
756
- collapseQualifiedCallee: qualified.includes("."),
757
- definedProcessor
758
- };
759
- }
760
- }
761
- const root = getRootIdentifier(callee);
762
- if (!root) {
763
- return null;
764
- }
765
- const definedProcessor = definedProcessors.get(root.name);
766
- return definedProcessor ? {
767
- collapseQualifiedCallee: false,
768
- definedProcessor
769
- } : null;
770
- };
771
- const isCallTagOfTaggedTemplate = (node, parent) => parent?.type === "TaggedTemplateExpression" && parent.tag === node;
772
- const expandReplacementTarget = (target, ancestors) => {
773
- let current = target;
774
- for (let idx = ancestors.length - 1; idx >= 0; idx -= 1) {
775
- const ancestor = ancestors[idx];
776
- if (ancestor.type === "SequenceExpression" && ancestor.expressions[ancestor.expressions.length - 1] === current) {
777
- current = ancestor;
778
- } else if (ancestor.type === "ParenthesizedExpression" && ancestor.expression === current) {
779
- current = ancestor;
780
- } else {
781
- break;
782
- }
783
- }
784
- return current;
785
- };
786
- const collectProcessorUsages = (program, definedProcessors) => {
787
- const usages = [];
788
- const walk = (node, ancestors, parent = null) => {
789
- if (node.type === "TaggedTemplateExpression") {
790
- const callee = node.tag;
791
- const resolvedProcessor = resolveDefinedProcessor(callee, definedProcessors);
792
- if (resolvedProcessor) {
793
- usages.push({
794
- ancestors,
795
- callee,
796
- collapseQualifiedCallee: resolvedProcessor.collapseQualifiedCallee,
797
- definedProcessor: resolvedProcessor.definedProcessor,
798
- kind: "template",
799
- replacementTarget: expandReplacementTarget(node, ancestors),
800
- target: node
801
- });
802
- }
803
- } else if (node.type === "CallExpression" && !isCallTagOfTaggedTemplate(node, parent)) {
804
- const { callee } = node;
805
- const resolvedProcessor = resolveDefinedProcessor(callee, definedProcessors);
806
- if (resolvedProcessor) {
807
- usages.push({
808
- ancestors,
809
- callee,
810
- collapseQualifiedCallee: resolvedProcessor.collapseQualifiedCallee,
811
- definedProcessor: resolvedProcessor.definedProcessor,
812
- kind: "call",
813
- replacementTarget: expandReplacementTarget(node, ancestors),
814
- target: node
815
- });
816
- }
817
- }
818
- getChildren(node).forEach((child) => walk(child, [...ancestors, node], node));
819
- };
820
- walk(program, []);
821
- return usages.sort((a, b) => a.target.start - b.target.start);
822
- };
823
- const expressionSpan = (expression) => ({
824
- end: expression.end,
825
- start: expression.start
826
- });
827
- const collectCallArgumentSpans = (node) => {
828
- const expression = unwrapQualifiedExpression(node);
829
- if (expression.type === "CallExpression") {
830
- const call = expression;
831
- const calleeSpans = collectCallArgumentSpans(call.callee);
832
- const argumentSpans = call.arguments.flatMap((arg) => arg.type === "SpreadElement" ? [] : [expressionSpan(arg)]);
833
- return [...calleeSpans, ...argumentSpans];
834
- }
835
- if (expression.type === "MemberExpression") {
836
- return collectCallArgumentSpans(expression.object);
837
- }
838
- return [];
839
- };
840
- const collectUsageExpressionSpans = (usage) => {
841
- const calleeSpans = collectCallArgumentSpans(usage.callee);
842
- if (usage.kind === "template") {
843
- return [...calleeSpans, ...usage.target.quasi.expressions.map((expression) => expressionSpan(expression))];
844
- }
845
- return [...calleeSpans, ...usage.target.arguments.flatMap((arg) => arg.type === "SpreadElement" ? [] : [expressionSpan(arg)])];
846
- };
847
- const literalExpressionValue = (expression, code, source, location) => {
848
- if (expression.type !== "Literal") {
849
- return null;
850
- }
851
- if (expression.value === null || typeof expression.value === "string" || typeof expression.value === "number" || typeof expression.value === "boolean") {
852
- let type;
853
- if (expression.value === null) {
854
- type = "NullLiteral";
855
- } else if (typeof expression.value === "string") {
856
- type = "StringLiteral";
857
- } else if (typeof expression.value === "number") {
858
- type = "NumericLiteral";
859
- } else {
860
- type = "BooleanLiteral";
861
- }
862
- const ex = expression.value === null ? {
863
- loc: location,
864
- type
865
- } : {
866
- loc: location,
867
- type,
868
- value: expression.value
869
- };
870
- return {
871
- buildCodeFrameError: (message) => buildCodeFrameError(code, location, message),
872
- ex,
873
- kind: ValueType.CONST,
874
- source,
875
- value: expression.value
876
- };
877
- }
878
- return null;
879
- };
880
- const expressionValue = (expression, code, loc, filename) => {
881
- const source = code.slice(expression.start, expression.end);
882
- const location = getSourceLocation(expression.start, expression.end, loc, filename);
883
- const literal = literalExpressionValue(expression, code, source, location);
884
- if (literal) {
885
- return literal;
886
- }
887
- const helperCallName = expression.type === "CallExpression" && expression.arguments.length === 0 && expression.callee.type === "Identifier" && GENERATED_HELPER_NAME_RE.test(expression.callee.name) ? expression.callee.name : null;
888
- let ex;
889
- if (expression.type === "Identifier") {
890
- ex = {
891
- loc: location,
892
- name: expression.name,
893
- type: "Identifier"
894
- };
895
- } else if (helperCallName) {
896
- ex = {
897
- loc: location,
898
- name: helperCallName,
899
- type: "Identifier"
900
- };
901
- } else {
902
- ex = {
903
- loc: location,
904
- name: code.slice(expression.start, expression.end),
905
- type: "Identifier"
906
- };
907
- }
908
- return {
909
- buildCodeFrameError: (message) => buildCodeFrameError(code, location, message),
910
- ex,
911
- kind: expression.type === "ArrowFunctionExpression" || expression.type === "FunctionExpression" ? ValueType.FUNCTION : ValueType.LAZY,
912
- source
913
- };
914
- };
915
- const withCurrentExpressionLocation = (value, expression, loc, filename) => {
916
- const location = getSourceLocation(expression.start, expression.end, loc, filename);
917
- if (value.kind === ValueType.CONST) {
918
- return {
919
- ...value,
920
- ex: {
921
- ...value.ex,
922
- loc: location
923
- }
924
- };
925
- }
926
- if (value.kind === ValueType.FUNCTION) {
927
- return {
928
- ...value,
929
- ex: {
930
- ...value.ex,
931
- loc: location
932
- }
933
- };
934
- }
935
- return {
936
- ...value,
937
- ex: {
938
- ...value.ex,
939
- loc: location
940
- }
941
- };
942
- };
943
- const shiftExpressionValue = (expressionValues, expression, code, loc, filename) => expressionValues.length > 0 ? withCurrentExpressionLocation(expressionValues.shift(), expression, loc, filename) : expressionValue(expression, code, loc, filename);
944
- const zipTemplate = (template, code, loc, filename, expressionValues) => {
945
- const parts = template.quasi.quasis.flatMap((quasi, idx) => {
946
- const expression = template.quasi.expressions[idx];
947
- const templateElement = {
948
- ...quasi,
949
- loc: getSourceLocation(quasi.start, quasi.end, loc, filename)
950
- };
951
- return [templateElement, expression ? shiftExpressionValue(expressionValues, expression, code, loc, filename) : null].filter(isNotNull);
952
- });
953
- return ["template", parts];
954
- };
955
- const buildCalleeParams = (node, code, loc, filename, expressionValues, collapseQualifiedCallee = false) => {
956
- const expression = unwrapQualifiedExpression(node);
957
- if (collapseQualifiedCallee && (expression.type === "Identifier" || expression.type === "MemberExpression")) {
958
- return [["callee", expression]];
959
- }
960
- if (expression.type === "Identifier") {
961
- return [["callee", {
962
- name: expression.name,
963
- type: "Identifier"
964
- }]];
965
- }
966
- if (expression.type === "MemberExpression") {
967
- const params = buildCalleeParams(expression.object, code, loc, filename, expressionValues, collapseQualifiedCallee);
968
- const member = getMemberName(expression);
969
- return params && member ? [...params, ["member", member]] : null;
970
- }
971
- if (expression.type === "CallExpression") {
972
- const call = expression;
973
- const params = buildCalleeParams(call.callee, code, loc, filename, expressionValues, collapseQualifiedCallee);
974
- if (!params) {
975
- return null;
976
- }
977
- const callValues = call.arguments.filter((arg) => arg.type !== "SpreadElement").map((arg) => shiftExpressionValue(expressionValues, arg, code, loc, filename));
978
- return [...params, ["call", ...callValues]];
979
- }
980
- return null;
981
- };
982
- const buildParams = (usage, code, loc, filename, expressionValues, collapseQualifiedCallee) => {
983
- const params = buildCalleeParams(usage.callee, code, loc, filename, expressionValues, collapseQualifiedCallee);
984
- if (!params) {
985
- return null;
986
- }
987
- if (usage.kind === "template") {
988
- return [...params, zipTemplate(usage.target, code, loc, filename, expressionValues)];
989
- }
990
- const callValues = usage.target.arguments.filter((arg) => arg.type !== "SpreadElement").map((arg) => shiftExpressionValue(expressionValues, arg, code, loc, filename));
991
- return [...params, ["call", ...callValues]];
992
- };
993
- const getPropertyKeyName = (property, code) => {
994
- const { key } = property;
995
- if (!isNode(key)) {
996
- return null;
997
- }
998
- if (key.type === "Identifier") {
999
- return key.name;
1000
- }
1001
- if (key.type === "Literal") {
1002
- return String(key.value);
1003
- }
1004
- return typeof key.start === "number" && typeof key.end === "number" ? code.slice(key.start, key.end) : null;
1005
- };
1006
- const getDisplayName = (ancestors, idx, code, filename) => {
1007
- const owner = [...ancestors].reverse().find((node) => {
1008
- return node.type === "Property" || node.type === "JSXOpeningElement" || node.type === "VariableDeclarator";
1009
- });
1010
- if (owner?.type === "Property") {
1011
- const keyName = getPropertyKeyName(owner, code);
1012
- if (keyName) {
1013
- return keyName;
1014
- }
1015
- } else if (owner?.type === "JSXOpeningElement") {
1016
- const { name } = owner;
1017
- if (isNode(name) && name.type === "JSXIdentifier") {
1018
- return name.name;
1019
- }
1020
- } else if (owner?.type === "VariableDeclarator") {
1021
- const { id } = owner;
1022
- if (isNode(id) && id.type === "Identifier") {
1023
- return id.name;
1024
- }
1025
- }
1026
- let displayName = basename(filename ?? "unknown").replace(/\.[a-z\d]+$/, "");
1027
- if (filename && /^index\.[a-z\d]+$/.test(basename(filename))) {
1028
- displayName = basename(dirname(filename));
1029
- }
1030
- if (!displayName) {
1031
- throw new Error("Couldn't determine a name for the component. Ensure that it's either:\n" + "- Assigned to a variable\n" + "- Is an object property\n" + "- Is a prop in a JSX element\n");
1032
- }
1033
- return `${displayName}${idx}`;
1034
- };
1035
- const getTagOwner = (ancestors) => {
1036
- const owner = [...ancestors].reverse().find((node) => node.type === "Property" || node.type === "JSXOpeningElement" || node.type === "VariableDeclarator");
1037
- return owner ?? null;
1038
- };
1039
- const isTagReferenced = (program, ancestors) => {
1040
- const owner = getTagOwner(ancestors);
1041
- if (owner?.type !== "VariableDeclarator") {
1042
- return true;
1043
- }
1044
- const { id } = owner;
1045
- if (!isNode(id) || id.type !== "Identifier") {
1046
- return true;
1047
- }
1048
- if (ancestors.some((node) => node.type === "ExportNamedDeclaration")) {
1049
- return true;
1050
- }
1051
- let referenced = false;
1052
- visit(program, (node, parent) => {
1053
- const referenceName = node.type === "Identifier" || node.type === "JSXIdentifier" ? node.name : null;
1054
- if (referenced || referenceName !== id.name || node.type === "Identifier" && node.start === id.start && node.end === id.end) {
1055
- return;
1056
- }
1057
- referenced = isNodeReference(node, parent);
1058
- });
1059
- return referenced;
1060
- };
1061
- const isReplacementPure = (replacement) => replacement.type === "CallExpression";
1062
- const createProcessor = (definedProcessor, params, target, replacementTarget, ancestors, fileContext, options, code, loc, idx, isReferenced, usedNames, replacements) => {
1063
- const [Processor, tagSource] = definedProcessor;
1064
- const astService = createOxcAstService(usedNames);
1065
- const replacer = (replacement, isPure) => {
1066
- const next = typeof replacement === "function" ? replacement(target) : replacement;
1067
- const replacementCode = expressionToCode(next);
1068
- replacements.push({
1069
- start: replacementTarget.start,
1070
- end: replacementTarget.end,
1071
- value: isPure && isReplacementPure(next) ? `/*#__PURE__*/${replacementCode}` : replacementCode
1072
- });
1073
- };
1074
- try {
1075
- let displayName;
1076
- try {
1077
- displayName = getDisplayName(ancestors, idx, code, fileContext.filename);
1078
- } catch (error) {
1079
- if (error instanceof Error && error.message.startsWith("Couldn't determine a name for the component")) {
1080
- let displayNameNode = target;
1081
- if (target.type === "TaggedTemplateExpression") {
1082
- displayNameNode = target.tag;
1083
- } else if (target.type === "CallExpression") {
1084
- displayNameNode = target.callee;
1085
- }
1086
- const pointerNode = displayNameNode.type === "MemberExpression" ? getRootIdentifier(displayNameNode) ?? displayNameNode : displayNameNode;
1087
- throw buildCodeFrameError(code, getSourceLocation(pointerNode.start, pointerNode.end, loc, fileContext.filename), error.message);
1088
- }
1089
- throw error;
1090
- }
1091
- return {
1092
- astService,
1093
- processor: new Processor(params, tagSource, astService, getSourceLocation(target.start, target.end, loc, fileContext.filename), replacer, displayName, isReferenced, idx, options, fileContext)
1094
- };
1095
- } catch (e) {
1096
- if (e === BaseProcessor.SKIP) {
1097
- return null;
1098
- }
1099
- if (typeof e === "symbol" && e.description === BaseProcessor.SKIP.description) {
1100
- if (!didWarnSkipSymbolMismatch) {
1101
- didWarnSkipSymbolMismatch = true;
1102
- // eslint-disable-next-line no-console
1103
- console.warn([
1104
- "[wyw-in-js] Processor threw Symbol('skip') that does not match BaseProcessor.SKIP identity.",
1105
- "This usually means duplicate copies of @wyw-in-js/processor-utils (or the processor) are bundled/installed.",
1106
- "Consider deduping dependencies to avoid subtle issues (instanceof checks, sentinels, etc)."
1107
- ].join("\n"));
1108
- }
1109
- return null;
1110
- }
1111
- throw e;
1112
- }
1113
- };
1114
- export const applyOxcProcessors = (code, fileContext, options, callback, cleanupUnused = false) => {
1115
- const filename = fileContext.filename ?? "unknown.js";
1116
- const eventEmitter = options.eventEmitter ?? EventEmitter.dummy;
1117
- let workingCode = code;
1118
- let program = parseOxc(workingCode, filename);
1119
- const definedProcessors = new Map();
1120
- const removableImportLocals = new Set();
1121
- const removableExpressionRefs = new Set();
1122
- eventEmitter.perf("transform:preeval:processTemplate:imports", () => {
1123
- const imports = eventEmitter.perf("transform:preeval:processTemplate:imports:analysis", () => collectOxcProcessorImportsFromProgram(program, workingCode));
1124
- eventEmitter.perf("transform:preeval:processTemplate:imports:lookup", () => {
1125
- imports.forEach((item) => {
1126
- const localName = item.local.name ?? item.local.code;
1127
- if (item.imported === "side-effect" || !localName) {
1128
- return;
1129
- }
1130
- const [processor, tagSource] = getProcessorForImport({
1131
- imported: item.imported,
1132
- source: item.source
1133
- }, filename, options);
1134
- if (processor) {
1135
- definedProcessors.set(localName, [processor, tagSource]);
1136
- removableImportLocals.add(localName);
1137
- const rootLocalName = localName.split(".")[0];
1138
- if (rootLocalName) {
1139
- removableImportLocals.add(rootLocalName);
1140
- }
1141
- }
1142
- });
1143
- });
1144
- });
1145
- if (definedProcessors.size === 0) {
1146
- return {
1147
- code: workingCode,
1148
- processors: [],
1149
- staticValueCandidates: [],
1150
- staticValues: []
1151
- };
1152
- }
1153
- let processorUsages = eventEmitter.perf("transform:preeval:processTemplate:usages", () => collectProcessorUsages(program, definedProcessors));
1154
- if (processorUsages.length === 0) {
1155
- return {
1156
- code: workingCode,
1157
- processors: [],
1158
- staticValueCandidates: [],
1159
- staticValues: []
1160
- };
1161
- }
1162
- const targetExpressionSpans = processorUsages.flatMap(collectUsageExpressionSpans);
1163
- const extracted = targetExpressionSpans.length > 0 ? eventEmitter.perf("transform:preeval:processTemplate:deps", () => collectOxcExpressionDependencies(workingCode, filename, options.evaluate, targetExpressionSpans)) : {
1164
- code: workingCode,
1165
- dependencyNames: [],
1166
- expressionValues: [],
1167
- staticValueCandidates: [],
1168
- staticValues: []
1169
- };
1170
- if (extracted.code !== workingCode) {
1171
- workingCode = extracted.code;
1172
- program = eventEmitter.perf("transform:preeval:processTemplate:reparse", () => parseOxc(workingCode, filename));
1173
- processorUsages = eventEmitter.perf("transform:preeval:processTemplate:usages", () => collectProcessorUsages(program, definedProcessors));
1174
- }
1175
- const templateExpressionValues = extracted.expressionValues.map((value) => ({
1176
- ...value,
1177
- buildCodeFrameError: (message) => buildCodeFrameError(code, value.ex.loc, message)
1178
- }));
1179
- const loc = createLocationLookup(workingCode);
1180
- const usedNames = eventEmitter.perf("transform:preeval:processTemplate:usedNames", () => collectUsedNames(program));
1181
- const addedImports = [];
1182
- const replacements = [];
1183
- const processors = [];
1184
- extracted.dependencyNames.forEach((name) => removableImportLocals.add(name));
1185
- eventEmitter.perf("transform:preeval:processTemplate:processors", () => {
1186
- processorUsages.forEach((usage, idx) => {
1187
- const params = buildParams(usage, workingCode, loc, filename, templateExpressionValues, usage.collapseQualifiedCallee);
1188
- if (!params) {
1189
- return;
1190
- }
1191
- const created = createProcessor(usage.definedProcessor, params, usage.target, usage.replacementTarget, usage.ancestors, fileContext, options, workingCode, loc, idx, isTagReferenced(program, usage.ancestors), usedNames, replacements);
1192
- if (!created) {
1193
- return;
1194
- }
1195
- const { astService, processor } = created;
1196
- const owner = getTagOwner(usage.ancestors);
1197
- if (owner?.type === "VariableDeclarator") {
1198
- const { id } = owner;
1199
- if (isNode(id) && id.type === "Identifier") {
1200
- removableExpressionRefs.add(id.name);
1201
- }
1202
- }
1203
- processors.push(processor);
1204
- callback(processor);
1205
- addedImports.push(...astService.getAddedImports());
1206
- });
1207
- });
1208
- const replacedCode = applyReplacements(workingCode, replacements);
1209
- const codeWithAddedImports = insertAddedImports(replacedCode, program, addedImports);
1210
- return {
1211
- code: cleanupUnused ? eventEmitter.perf("transform:preeval:processTemplate:cleanup", () => removeUnusedAfterReplacement(codeWithAddedImports, filename, removableImportLocals, new Set([...removableExpressionRefs, ...extracted.dependencyNames]), options.preserveSideEffectImportLocals ?? new Set())) : codeWithAddedImports,
1212
- processors,
1213
- staticValueCandidates: extracted.staticValueCandidates,
1214
- staticValues: extracted.staticValues
1215
- };
1216
- };
1
+ export { applyOxcProcessors } from "./applyOxcProcessors/applyOxcProcessors.js";
1217
2
  //# sourceMappingURL=applyOxcProcessors.js.map