@wyw-in-js/transform 2.0.0-alpha.0 → 2.0.0

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 (279) 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/collect.js +1 -0
  14. package/esm/transform/generators/collect.js.map +1 -1
  15. package/esm/transform/generators/processEntrypoint.js +35 -20
  16. package/esm/transform/generators/processEntrypoint.js.map +1 -1
  17. package/esm/transform/generators/resolveImports.js +48 -2
  18. package/esm/transform/generators/resolveImports.js.map +1 -1
  19. package/esm/transform/generators/resolveStaticOxcValues/cache.js +182 -0
  20. package/esm/transform/generators/resolveStaticOxcValues/cache.js.map +1 -0
  21. package/esm/transform/generators/resolveStaticOxcValues/candidateResolver.js +146 -0
  22. package/esm/transform/generators/resolveStaticOxcValues/candidateResolver.js.map +1 -0
  23. package/esm/transform/generators/resolveStaticOxcValues/dependencies.js +33 -0
  24. package/esm/transform/generators/resolveStaticOxcValues/dependencies.js.map +1 -0
  25. package/esm/transform/generators/resolveStaticOxcValues/environment.js +29 -0
  26. package/esm/transform/generators/resolveStaticOxcValues/environment.js.map +1 -0
  27. package/esm/transform/generators/resolveStaticOxcValues/exportResolver.js +351 -0
  28. package/esm/transform/generators/resolveStaticOxcValues/exportResolver.js.map +1 -0
  29. package/esm/transform/generators/resolveStaticOxcValues/exportTargets.js +253 -0
  30. package/esm/transform/generators/resolveStaticOxcValues/exportTargets.js.map +1 -0
  31. package/esm/transform/generators/resolveStaticOxcValues/objectAssign.js +310 -0
  32. package/esm/transform/generators/resolveStaticOxcValues/objectAssign.js.map +1 -0
  33. package/esm/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.js +74 -0
  34. package/esm/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.js.map +1 -0
  35. package/esm/transform/generators/resolveStaticOxcValues/opaqueRuntime.js +229 -0
  36. package/esm/transform/generators/resolveStaticOxcValues/opaqueRuntime.js.map +1 -0
  37. package/esm/transform/generators/resolveStaticOxcValues/processorStaticExport.js +172 -0
  38. package/esm/transform/generators/resolveStaticOxcValues/processorStaticExport.js.map +1 -0
  39. package/esm/transform/generators/resolveStaticOxcValues/processorStaticModel.js +476 -0
  40. package/esm/transform/generators/resolveStaticOxcValues/processorStaticModel.js.map +1 -0
  41. package/esm/transform/generators/resolveStaticOxcValues/processorTarget.js +55 -0
  42. package/esm/transform/generators/resolveStaticOxcValues/processorTarget.js.map +1 -0
  43. package/esm/transform/generators/resolveStaticOxcValues/programAnalysis.js +123 -0
  44. package/esm/transform/generators/resolveStaticOxcValues/programAnalysis.js.map +1 -0
  45. package/esm/transform/generators/resolveStaticOxcValues/prune.js +272 -0
  46. package/esm/transform/generators/resolveStaticOxcValues/prune.js.map +1 -0
  47. package/esm/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.js +184 -0
  48. package/esm/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.js.map +1 -0
  49. package/esm/transform/generators/resolveStaticOxcValues/staticExpression.js +298 -0
  50. package/esm/transform/generators/resolveStaticOxcValues/staticExpression.js.map +1 -0
  51. package/esm/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.js +298 -0
  52. package/esm/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.js.map +1 -0
  53. package/esm/transform/generators/resolveStaticOxcValues/types.js +3 -0
  54. package/esm/transform/generators/resolveStaticOxcValues/types.js.map +1 -0
  55. package/esm/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.js +59 -0
  56. package/esm/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.js.map +1 -0
  57. package/esm/transform/generators/resolveStaticOxcValues.js +1 -2910
  58. package/esm/transform/generators/resolveStaticOxcValues.js.map +1 -1
  59. package/esm/transform/generators/transform.js +58 -45
  60. package/esm/transform/generators/transform.js.map +1 -1
  61. package/esm/transform/helpers/loadWywOptions.js +33 -4
  62. package/esm/transform/helpers/loadWywOptions.js.map +1 -1
  63. package/esm/transform.js +3 -1
  64. package/esm/transform.js.map +1 -1
  65. package/esm/utils/EventEmitter.js +55 -9
  66. package/esm/utils/EventEmitter.js.map +1 -1
  67. package/esm/utils/applyOxcProcessors/applyOxcProcessors.js +160 -0
  68. package/esm/utils/applyOxcProcessors/applyOxcProcessors.js.map +1 -0
  69. package/esm/utils/applyOxcProcessors/cleanupBindings.js +157 -0
  70. package/esm/utils/applyOxcProcessors/cleanupBindings.js.map +1 -0
  71. package/esm/utils/applyOxcProcessors/cleanupRemovals.js +517 -0
  72. package/esm/utils/applyOxcProcessors/cleanupRemovals.js.map +1 -0
  73. package/esm/utils/applyOxcProcessors/displayName.js +93 -0
  74. package/esm/utils/applyOxcProcessors/displayName.js.map +1 -0
  75. package/esm/utils/applyOxcProcessors/expressionValues.js +152 -0
  76. package/esm/utils/applyOxcProcessors/expressionValues.js.map +1 -0
  77. package/esm/utils/applyOxcProcessors/processorFactory.js +62 -0
  78. package/esm/utils/applyOxcProcessors/processorFactory.js.map +1 -0
  79. package/esm/utils/applyOxcProcessors/processorUsages.js +143 -0
  80. package/esm/utils/applyOxcProcessors/processorUsages.js.map +1 -0
  81. package/esm/utils/applyOxcProcessors/sameFileStaticValues.js +207 -0
  82. package/esm/utils/applyOxcProcessors/sameFileStaticValues.js.map +1 -0
  83. package/esm/utils/applyOxcProcessors/shared.js +29 -0
  84. package/esm/utils/applyOxcProcessors/shared.js.map +1 -0
  85. package/esm/utils/applyOxcProcessors/types.js +2 -0
  86. package/esm/utils/applyOxcProcessors/types.js.map +1 -0
  87. package/esm/utils/applyOxcProcessors.js +1 -1216
  88. package/esm/utils/applyOxcProcessors.js.map +1 -1
  89. package/esm/utils/collectOxcExportsAndImports.js +8 -0
  90. package/esm/utils/collectOxcExportsAndImports.js.map +1 -1
  91. package/esm/utils/collectOxcRuntime/normalizeRuntimeCode.js +157 -0
  92. package/esm/utils/collectOxcRuntime/normalizeRuntimeCode.js.map +1 -0
  93. package/esm/utils/collectOxcRuntime/sourceMap.js +36 -0
  94. package/esm/utils/collectOxcRuntime/sourceMap.js.map +1 -0
  95. package/esm/utils/collectOxcRuntime/types.js +2 -0
  96. package/esm/utils/collectOxcRuntime/types.js.map +1 -0
  97. package/esm/utils/collectOxcRuntime.js +5 -193
  98. package/esm/utils/collectOxcRuntime.js.map +1 -1
  99. package/esm/utils/collectOxcTemplateDependencies/expressionExtraction.js +496 -0
  100. package/esm/utils/collectOxcTemplateDependencies/expressionExtraction.js.map +1 -0
  101. package/esm/utils/collectOxcTemplateDependencies/expressionReplacements.js +113 -0
  102. package/esm/utils/collectOxcTemplateDependencies/expressionReplacements.js.map +1 -0
  103. package/esm/utils/collectOxcTemplateDependencies/scopeAnalysis.js +387 -0
  104. package/esm/utils/collectOxcTemplateDependencies/scopeAnalysis.js.map +1 -0
  105. package/esm/utils/collectOxcTemplateDependencies/staticBindings.js +17 -0
  106. package/esm/utils/collectOxcTemplateDependencies/staticBindings.js.map +1 -0
  107. package/esm/utils/collectOxcTemplateDependencies/staticEvaluator.js +540 -0
  108. package/esm/utils/collectOxcTemplateDependencies/staticEvaluator.js.map +1 -0
  109. package/esm/utils/collectOxcTemplateDependencies/types.js +2 -0
  110. package/esm/utils/collectOxcTemplateDependencies/types.js.map +1 -0
  111. package/esm/utils/collectOxcTemplateDependencies.js +3 -1397
  112. package/esm/utils/collectOxcTemplateDependencies.js.map +1 -1
  113. package/esm/utils/nativeResolver.js +93 -0
  114. package/esm/utils/nativeResolver.js.map +1 -0
  115. package/esm/utils/oxc/ast.js +58 -0
  116. package/esm/utils/oxc/ast.js.map +1 -0
  117. package/esm/utils/oxc/parse.js +3 -0
  118. package/esm/utils/oxc/parse.js.map +1 -0
  119. package/esm/utils/oxc/replacements.js +14 -0
  120. package/esm/utils/oxc/replacements.js.map +1 -0
  121. package/esm/utils/oxc/sourceLocations.js +59 -0
  122. package/esm/utils/oxc/sourceLocations.js.map +1 -0
  123. package/esm/utils/oxcPreevalStage/evalStrategy.js +3 -0
  124. package/esm/utils/oxcPreevalStage/evalStrategy.js.map +1 -0
  125. package/esm/utils/oxcPreevalStage/prepareCode.js +21 -0
  126. package/esm/utils/oxcPreevalStage/prepareCode.js.map +1 -0
  127. package/esm/utils/oxcPreevalStage/prevalExport.js +23 -0
  128. package/esm/utils/oxcPreevalStage/prevalExport.js.map +1 -0
  129. package/esm/utils/oxcPreevalStage/processors.js +17 -0
  130. package/esm/utils/oxcPreevalStage/processors.js.map +1 -0
  131. package/esm/utils/oxcPreevalStage/staticOverlay.js +18 -0
  132. package/esm/utils/oxcPreevalStage/staticOverlay.js.map +1 -0
  133. package/esm/utils/oxcPreevalStage/types.js +2 -0
  134. package/esm/utils/oxcPreevalStage/types.js.map +1 -0
  135. package/esm/utils/oxcPreevalStage.js +17 -73
  136. package/esm/utils/oxcPreevalStage.js.map +1 -1
  137. package/esm/utils/oxcPreevalTransforms.js +106 -66
  138. package/esm/utils/oxcPreevalTransforms.js.map +1 -1
  139. package/esm/utils/parseOxc.js +6 -1
  140. package/esm/utils/parseOxc.js.map +1 -1
  141. package/esm/utils/processorStaticSemantics.js +157 -0
  142. package/esm/utils/processorStaticSemantics.js.map +1 -0
  143. package/esm/utils/resolveWithConditions.js +3 -3
  144. package/esm/utils/resolveWithConditions.js.map +1 -1
  145. package/package.json +6 -5
  146. package/types/cache.js +8 -0
  147. package/types/debug/fileReporter.js +46 -1
  148. package/types/eval/broker.d.ts +6 -2
  149. package/types/eval/broker.js +244 -95
  150. package/types/eval/protocol.d.ts +15 -1
  151. package/types/module.d.ts +4 -1
  152. package/types/module.js +97 -48
  153. package/types/transform/Entrypoint.types.d.ts +4 -0
  154. package/types/transform/generators/collect.js +1 -0
  155. package/types/transform/generators/resolveImports.d.ts +3 -1
  156. package/types/transform/generators/resolveImports.js +49 -2
  157. package/types/transform/generators/resolveStaticOxcValues/cache.d.ts +25 -0
  158. package/types/transform/generators/resolveStaticOxcValues/cache.js +182 -0
  159. package/types/transform/generators/resolveStaticOxcValues/candidateResolver.d.ts +5 -0
  160. package/types/transform/generators/resolveStaticOxcValues/candidateResolver.js +149 -0
  161. package/types/transform/generators/resolveStaticOxcValues/dependencies.d.ts +6 -0
  162. package/types/transform/generators/resolveStaticOxcValues/dependencies.js +37 -0
  163. package/types/transform/generators/resolveStaticOxcValues/environment.d.ts +12 -0
  164. package/types/transform/generators/resolveStaticOxcValues/environment.js +32 -0
  165. package/types/transform/generators/resolveStaticOxcValues/exportResolver.d.ts +4 -0
  166. package/types/transform/generators/resolveStaticOxcValues/exportResolver.js +358 -0
  167. package/types/transform/generators/resolveStaticOxcValues/exportTargets.d.ts +20 -0
  168. package/types/transform/generators/resolveStaticOxcValues/exportTargets.js +285 -0
  169. package/types/transform/generators/resolveStaticOxcValues/objectAssign.d.ts +41 -0
  170. package/types/transform/generators/resolveStaticOxcValues/objectAssign.js +352 -0
  171. package/types/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.d.ts +6 -0
  172. package/types/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.js +88 -0
  173. package/types/transform/generators/resolveStaticOxcValues/opaqueRuntime.d.ts +13 -0
  174. package/types/transform/generators/resolveStaticOxcValues/opaqueRuntime.js +263 -0
  175. package/types/transform/generators/resolveStaticOxcValues/processorStaticExport.d.ts +4 -0
  176. package/types/transform/generators/resolveStaticOxcValues/processorStaticExport.js +191 -0
  177. package/types/transform/generators/resolveStaticOxcValues/processorStaticModel.d.ts +40 -0
  178. package/types/transform/generators/resolveStaticOxcValues/processorStaticModel.js +516 -0
  179. package/types/transform/generators/resolveStaticOxcValues/processorTarget.d.ts +5 -0
  180. package/types/transform/generators/resolveStaticOxcValues/processorTarget.js +62 -0
  181. package/types/transform/generators/resolveStaticOxcValues/programAnalysis.d.ts +11 -0
  182. package/types/transform/generators/resolveStaticOxcValues/programAnalysis.js +133 -0
  183. package/types/transform/generators/resolveStaticOxcValues/prune.d.ts +15 -0
  184. package/types/transform/generators/resolveStaticOxcValues/prune.js +312 -0
  185. package/types/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.d.ts +2 -0
  186. package/types/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.js +198 -0
  187. package/types/transform/generators/resolveStaticOxcValues/staticExpression.d.ts +25 -0
  188. package/types/transform/generators/resolveStaticOxcValues/staticExpression.js +391 -0
  189. package/types/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.d.ts +14 -0
  190. package/types/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.js +304 -0
  191. package/types/transform/generators/resolveStaticOxcValues/types.d.ts +99 -0
  192. package/types/transform/generators/resolveStaticOxcValues/types.js +2 -0
  193. package/types/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.d.ts +7 -0
  194. package/types/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.js +64 -0
  195. package/types/transform/generators/resolveStaticOxcValues.d.ts +1 -2
  196. package/types/transform/generators/resolveStaticOxcValues.js +1 -3235
  197. package/types/transform/generators/transform.js +64 -49
  198. package/types/transform/helpers/loadWywOptions.js +23 -3
  199. package/types/transform.js +3 -1
  200. package/types/utils/EventEmitter.d.ts +16 -1
  201. package/types/utils/EventEmitter.js +57 -9
  202. package/types/utils/applyOxcProcessors/applyOxcProcessors.d.ts +9 -0
  203. package/types/utils/applyOxcProcessors/applyOxcProcessors.js +169 -0
  204. package/types/utils/applyOxcProcessors/cleanupBindings.d.ts +12 -0
  205. package/types/utils/applyOxcProcessors/cleanupBindings.js +189 -0
  206. package/types/utils/applyOxcProcessors/cleanupRemovals.d.ts +16 -0
  207. package/types/utils/applyOxcProcessors/cleanupRemovals.js +567 -0
  208. package/types/utils/applyOxcProcessors/displayName.d.ts +9 -0
  209. package/types/utils/applyOxcProcessors/displayName.js +113 -0
  210. package/types/utils/applyOxcProcessors/expressionValues.d.ts +11 -0
  211. package/types/utils/applyOxcProcessors/expressionValues.js +170 -0
  212. package/types/utils/applyOxcProcessors/processorFactory.d.ts +7 -0
  213. package/types/utils/applyOxcProcessors/processorFactory.js +70 -0
  214. package/types/utils/applyOxcProcessors/processorUsages.d.ts +16 -0
  215. package/types/utils/applyOxcProcessors/processorUsages.js +163 -0
  216. package/types/utils/applyOxcProcessors/sameFileStaticValues.d.ts +23 -0
  217. package/types/utils/applyOxcProcessors/sameFileStaticValues.js +211 -0
  218. package/types/utils/applyOxcProcessors/shared.d.ts +10 -0
  219. package/types/utils/applyOxcProcessors/shared.js +37 -0
  220. package/types/utils/applyOxcProcessors/types.d.ts +88 -0
  221. package/types/utils/applyOxcProcessors/types.js +1 -0
  222. package/types/utils/applyOxcProcessors.d.ts +1 -16
  223. package/types/utils/applyOxcProcessors.js +1 -1391
  224. package/types/utils/collectOxcExportsAndImports.js +8 -0
  225. package/types/utils/collectOxcRuntime/normalizeRuntimeCode.d.ts +1 -0
  226. package/types/utils/collectOxcRuntime/normalizeRuntimeCode.js +185 -0
  227. package/types/utils/collectOxcRuntime/sourceMap.d.ts +2 -0
  228. package/types/utils/collectOxcRuntime/sourceMap.js +37 -0
  229. package/types/utils/collectOxcRuntime/types.d.ts +17 -0
  230. package/types/utils/collectOxcRuntime/types.js +1 -0
  231. package/types/utils/collectOxcRuntime.d.ts +2 -12
  232. package/types/utils/collectOxcRuntime.js +5 -224
  233. package/types/utils/collectOxcTemplateDependencies/expressionExtraction.d.ts +6 -0
  234. package/types/utils/collectOxcTemplateDependencies/expressionExtraction.js +550 -0
  235. package/types/utils/collectOxcTemplateDependencies/expressionReplacements.d.ts +11 -0
  236. package/types/utils/collectOxcTemplateDependencies/expressionReplacements.js +131 -0
  237. package/types/utils/collectOxcTemplateDependencies/scopeAnalysis.d.ts +20 -0
  238. package/types/utils/collectOxcTemplateDependencies/scopeAnalysis.js +434 -0
  239. package/types/utils/collectOxcTemplateDependencies/staticBindings.d.ts +7 -0
  240. package/types/utils/collectOxcTemplateDependencies/staticBindings.js +13 -0
  241. package/types/utils/collectOxcTemplateDependencies/staticEvaluator.d.ts +13 -0
  242. package/types/utils/collectOxcTemplateDependencies/staticEvaluator.js +626 -0
  243. package/types/utils/collectOxcTemplateDependencies/types.d.ts +116 -0
  244. package/types/utils/collectOxcTemplateDependencies/types.js +1 -0
  245. package/types/utils/collectOxcTemplateDependencies.d.ts +4 -38
  246. package/types/utils/collectOxcTemplateDependencies.js +3 -1580
  247. package/types/utils/nativeResolver.d.ts +13 -0
  248. package/types/utils/nativeResolver.js +91 -0
  249. package/types/utils/oxc/ast.d.ts +4 -0
  250. package/types/utils/oxc/ast.js +61 -0
  251. package/types/utils/oxc/parse.d.ts +3 -0
  252. package/types/utils/oxc/parse.js +2 -0
  253. package/types/utils/oxc/replacements.d.ts +12 -0
  254. package/types/utils/oxc/replacements.js +18 -0
  255. package/types/utils/oxc/sourceLocations.d.ts +5 -0
  256. package/types/utils/oxc/sourceLocations.js +63 -0
  257. package/types/utils/oxcPreevalStage/evalStrategy.d.ts +3 -0
  258. package/types/utils/oxcPreevalStage/evalStrategy.js +2 -0
  259. package/types/utils/oxcPreevalStage/prepareCode.d.ts +3 -0
  260. package/types/utils/oxcPreevalStage/prepareCode.js +20 -0
  261. package/types/utils/oxcPreevalStage/prevalExport.d.ts +1 -0
  262. package/types/utils/oxcPreevalStage/prevalExport.js +22 -0
  263. package/types/utils/oxcPreevalStage/processors.d.ts +10 -0
  264. package/types/utils/oxcPreevalStage/processors.js +16 -0
  265. package/types/utils/oxcPreevalStage/staticOverlay.d.ts +3 -0
  266. package/types/utils/oxcPreevalStage/staticOverlay.js +23 -0
  267. package/types/utils/oxcPreevalStage/types.d.ts +22 -0
  268. package/types/utils/oxcPreevalStage/types.js +1 -0
  269. package/types/utils/oxcPreevalStage.d.ts +2 -18
  270. package/types/utils/oxcPreevalStage.js +17 -79
  271. package/types/utils/oxcPreevalTransforms.js +111 -75
  272. package/types/utils/parseOxc.js +6 -1
  273. package/types/utils/processorStaticSemantics.d.ts +13 -0
  274. package/types/utils/processorStaticSemantics.js +191 -0
  275. package/types/utils/resolveWithConditions.js +3 -3
  276. package/esm/eval/resolverStrategy.js +0 -51
  277. package/esm/eval/resolverStrategy.js.map +0 -1
  278. package/types/eval/resolverStrategy.d.ts +0 -13
  279. package/types/eval/resolverStrategy.js +0 -46
@@ -1 +1 @@
1
- {"mappings":"AAYA,SAAS,mCAAmC;AAC5C,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B;AAiCtC,MAAM,iBAAiB,IAAI,IAAI;CAC7B;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,MAAM,mBAAmB,IAAI,IAAI;CAC/B,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,MAAM,6BAA6B,IAAI,IAAI,CAAC,gBAAgB,eAAe,CAAC;AAC5E,MAAM,yBAAyB,IAAI,IAAI;CAAC;CAAQ;CAAS;CAAU,CAAC;AACpE,MAAM,oBAAoB,IAAI,IAAI,CAChC,qBACA,wBACD,CAAC;AACF,MAAM,qBAAqB;AAC3B,MAAM,6BAA6B;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AACD,MAAM,iCAAiC;AACvC,MAAM,gBAAgB;AACtB,MAAM,gBAAgB;AACtB,MAAM,sBAAsB,IAAI,IAAI;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AACF,MAAM,kBAAkB;AAExB,MAAM,eAAe,QAAsB,SAAwB;CACjE,UAAU,IAAI,KAAK;CACnB;CACA,OAAO,IAAI,KAAK;CAChB;CACD;AAED,MAAM,gBA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../src/utils/oxcPreevalTransforms.ts"],"version":3,"sourcesContent":["/* eslint-disable no-restricted-syntax,no-continue */\n\nimport type {\n CallExpression,\n Expression,\n ImportExpression,\n Node,\n Program,\n} from 'oxc-parser';\n\nimport type { CodeRemoverOptions } from '@wyw-in-js/shared';\n\nimport { collectOxcExportsAndImports } from './collectOxcExportsAndImports';\nimport { EventEmitter } from './EventEmitter';\nimport { parseOxcProgramCached } from './parseOxc';\n\ntype AnyNode = Node & Record<string, unknown>;\n\ntype Replacement = {\n end: number;\n start: number;\n value: string;\n};\n\ntype Scope = {\n bindings: Map<string, Expression | null>;\n key: string;\n names: Set<string>;\n parent: Scope | null;\n};\n\ntype ImportBinding = {\n imported: string | 'default' | '*';\n local: string;\n source: string;\n};\n\ntype OxcFunctionLikeNode = Node & {\n async: boolean;\n body: Node;\n id?: { name: string } | null;\n type:\n | 'ArrowFunctionExpression'\n | 'FunctionDeclaration'\n | 'FunctionExpression';\n};\n\nconst ssrCheckFields = new Set([\n 'document',\n 'location',\n 'navigator',\n 'sessionStorage',\n 'localStorage',\n 'window',\n]);\n\nconst forbiddenGlobals = new Set([\n ...ssrCheckFields,\n '$RefreshReg$',\n '$RefreshSig$',\n 'XMLHttpRequest',\n 'clearImmediate',\n 'clearInterval',\n 'clearTimeout',\n 'fetch',\n 'navigator',\n 'setImmediate',\n 'setInterval',\n 'setTimeout',\n]);\n\nconst alwaysForbiddenIdentifiers = new Set(['$RefreshReg$', '$RefreshSig$']);\nconst promiseCallbackMethods = new Set(['then', 'catch', 'finally']);\nconst jsxRuntimeSources = new Set([\n 'react/jsx-runtime',\n 'react/jsx-dev-runtime',\n]);\nconst defaultPlaceholder = '...';\nconst defaultReactComponentTypes = [\n 'ExoticComponent',\n 'FC',\n 'ForwardRefExoticComponent',\n 'FunctionComponent',\n 'LazyExoticComponent',\n 'MemoExoticComponent',\n 'NamedExoticComponent',\n];\nconst generatedProcessorHelperNameRe = /^_exp\\d*$/;\nconst requireCallRe = /\\brequire\\s*\\(/;\nconst windowTokenRe = /\\bwindow\\b/;\nconst removableOwnerTypes = new Set([\n 'DoWhileStatement',\n 'ExpressionStatement',\n 'ForInStatement',\n 'ForOfStatement',\n 'ForStatement',\n 'FunctionDeclaration',\n 'IfStatement',\n 'PropertyDefinition',\n 'ReturnStatement',\n 'VariableDeclaration',\n 'WhileStatement',\n]);\nconst importMetaEnvRe = /\\bimport\\s*\\.\\s*meta\\s*\\.\\s*env\\b/;\n\nconst createScope = (parent: Scope | null, key: string): Scope => ({\n bindings: new Map(),\n key,\n names: new Set(),\n parent,\n});\n\nconst createsScope = (node: Node): boolean =>\n node.type === 'Program' ||\n node.type === 'BlockStatement' ||\n node.type === 'FunctionDeclaration' ||\n node.type === 'FunctionExpression' ||\n node.type === 'ArrowFunctionExpression';\n\nconst hasBinding = (scope: Scope, name: string): boolean => {\n let current: Scope | null = scope;\n while (current) {\n if (current.names.has(name)) {\n return true;\n }\n\n current = current.parent;\n }\n\n return false;\n};\n\nconst getBindingKey = (scope: Scope, name: string): string | null => {\n let current: Scope | null = scope;\n while (current) {\n if (current.names.has(name)) {\n return `${current.key}\\0${name}`;\n }\n\n current = current.parent;\n }\n\n return null;\n};\n\nconst getStaticBinding = (\n scope: Scope,\n name: string\n): Expression | null | undefined => {\n let current: Scope | null = scope;\n while (current) {\n if (current.bindings.has(name)) {\n return current.bindings.get(name);\n }\n\n current = current.parent;\n }\n\n return undefined;\n};\n\nconst isFileLikeRequireSpecifier = (value: string): boolean =>\n value.startsWith('.') || value.startsWith('/') || value.startsWith('file:');\n\nconst isNode = (value: unknown): value is Node =>\n !!value &&\n typeof value === 'object' &&\n 'type' in value &&\n typeof (value as { type?: unknown }).type === 'string';\n\nconst getChildren = (node: Node): Node[] => {\n const result: Node[] = [];\n const record = node as AnyNode;\n\n Object.keys(record).forEach((key) => {\n if (key === 'type' || key === 'start' || key === 'end' || key === 'range') {\n return;\n }\n\n const value = record[key];\n if (isNode(value)) {\n result.push(value);\n return;\n }\n\n if (Array.isArray(value)) {\n value.forEach((item) => {\n if (isNode(item)) {\n result.push(item);\n }\n });\n }\n });\n\n return result;\n};\n\nconst parseOxc = (code: string, filename: string): Program => {\n return parseOxcProgramCached(filename, code, 'unambiguous');\n};\n\nconst unwrapExpression = (node: Expression): Expression => {\n if (\n node.type === 'TSAsExpression' ||\n node.type === 'TSSatisfiesExpression' ||\n node.type === 'TSNonNullExpression' ||\n node.type === 'TSTypeAssertion' ||\n node.type === 'ParenthesizedExpression'\n ) {\n return unwrapExpression(node.expression);\n }\n\n return node;\n};\n\nconst getMemberPropertyName = (node: Node): string | null => {\n if (node.type !== 'MemberExpression') {\n return null;\n }\n\n if (node.computed) {\n return node.property.type === 'Literal' &&\n typeof node.property.value === 'string'\n ? node.property.value\n : null;\n }\n\n return node.property.type === 'Identifier' ? node.property.name : null;\n};\n\nconst isStringLikeExpression = (node: Expression): boolean => {\n const expression = unwrapExpression(node);\n\n if (expression.type === 'Literal' && typeof expression.value === 'string') {\n return true;\n }\n\n if (expression.type === 'TemplateLiteral') {\n return true;\n }\n\n if (expression.type === 'BinaryExpression' && expression.operator === '+') {\n return (\n isStringLikeExpression(expression.left) ||\n isStringLikeExpression(expression.right)\n );\n }\n\n if (\n expression.type === 'CallExpression' &&\n expression.callee.type === 'MemberExpression' &&\n getMemberPropertyName(expression.callee) === 'concat'\n ) {\n return isStringLikeExpression(expression.callee.object);\n }\n\n return false;\n};\n\nconst templateLiteralToConcat = (code: string, node: Expression): string => {\n if (node.type !== 'TemplateLiteral' || node.expressions.length === 0) {\n return code.slice(node.start, node.end);\n }\n\n const parts: string[] = [];\n node.quasis.forEach((quasi, index) => {\n const cooked = quasi.value.cooked ?? quasi.value.raw;\n if (cooked !== '') {\n parts.push(JSON.stringify(cooked));\n }\n\n const expression = node.expressions[index];\n if (expression) {\n parts.push(code.slice(expression.start, expression.end));\n }\n });\n\n return parts.length > 0 ? parts.join(' + ') : '\"\"';\n};\n\nconst dynamicImportArgumentCode = (code: string, node: Expression): string => {\n if (node.type === 'TemplateLiteral') {\n return templateLiteralToConcat(code, node);\n }\n\n return code.slice(node.start, node.end);\n};\n\nconst evaluateStaticValue = (\n node: Expression,\n scope: Scope,\n seen = new Set<string>()\n): unknown | undefined => {\n const expression = unwrapExpression(node);\n\n if (expression.type === 'Literal') {\n return expression.value;\n }\n\n if (expression.type === 'TemplateLiteral') {\n let result = '';\n\n for (let idx = 0; idx < expression.quasis.length; idx += 1) {\n result += expression.quasis[idx]?.value.cooked ?? '';\n\n const nextExpression = expression.expressions[idx];\n if (!nextExpression) {\n continue;\n }\n\n const value = evaluateStaticValue(nextExpression, scope, seen);\n if (\n value === undefined ||\n (typeof value !== 'string' && typeof value !== 'number')\n ) {\n return undefined;\n }\n\n result += String(value);\n }\n\n return result;\n }\n\n if (expression.type === 'Identifier') {\n if (seen.has(expression.name)) {\n return undefined;\n }\n\n const binding = getStaticBinding(scope, expression.name);\n if (!binding) {\n return undefined;\n }\n\n return evaluateStaticValue(\n binding,\n scope,\n new Set([...seen, expression.name])\n );\n }\n\n if (expression.type === 'BinaryExpression' && expression.operator === '+') {\n const left = evaluateStaticValue(expression.left, scope, seen);\n const right = evaluateStaticValue(expression.right, scope, seen);\n\n if (left === undefined || right === undefined) {\n return undefined;\n }\n\n if (typeof left === 'number' && typeof right === 'number') {\n return left + right;\n }\n\n if (\n (typeof left === 'string' || typeof left === 'number') &&\n (typeof right === 'string' || typeof right === 'number')\n ) {\n return `${left}${right}`;\n }\n }\n\n if (\n expression.type === 'CallExpression' &&\n expression.callee.type === 'MemberExpression'\n ) {\n const objectValue = evaluateStaticValue(\n expression.callee.object,\n scope,\n seen\n );\n const propertyName = getMemberPropertyName(expression.callee);\n if (!propertyName) {\n return undefined;\n }\n\n if (typeof objectValue === 'string') {\n if (propertyName === 'toLowerCase' && expression.arguments.length === 0) {\n return objectValue.toLowerCase();\n }\n\n if (propertyName === 'toUpperCase' && expression.arguments.length === 0) {\n return objectValue.toUpperCase();\n }\n\n if (propertyName === 'trim' && expression.arguments.length === 0) {\n return objectValue.trim();\n }\n\n if (propertyName === 'concat') {\n const args = expression.arguments.map((argument) =>\n argument.type === 'SpreadElement'\n ? undefined\n : evaluateStaticValue(argument, scope, seen)\n );\n if (\n args.some((value) => value === undefined) ||\n args.some(\n (value) => typeof value !== 'string' && typeof value !== 'number'\n )\n ) {\n return undefined;\n }\n\n return objectValue.concat(...args.map((value) => String(value)));\n }\n }\n }\n\n return undefined;\n};\n\nconst isLiteralRequireArg = (node: Expression): boolean => {\n const expression = unwrapExpression(node);\n\n if (expression.type === 'Literal' && typeof expression.value === 'string') {\n return true;\n }\n\n if (\n expression.type === 'TemplateLiteral' &&\n expression.expressions.length === 0\n ) {\n return true;\n }\n\n return false;\n};\n\nconst applyReplacements = (\n code: string,\n replacements: Replacement[]\n): string => {\n let result = code;\n replacements\n .sort((a, b) => b.start - a.start)\n .forEach((replacement) => {\n result =\n result.slice(0, replacement.start) +\n replacement.value +\n result.slice(replacement.end);\n });\n\n return result;\n};\n\nconst isIdentifierNamed = (value: unknown, name: string): boolean =>\n isNode(value) && value.type === 'Identifier' && value.name === name;\n\nconst isImportMeta = (node: unknown): boolean => {\n if (!isNode(node) || node.type !== 'MetaProperty') {\n return false;\n }\n\n const metaProperty = node as AnyNode;\n return (\n isIdentifierNamed(metaProperty.meta, 'import') &&\n isIdentifierNamed(metaProperty.property, 'meta')\n );\n};\n\nconst isImportMetaEnv = (node: Node): boolean => {\n if (node.type !== 'MemberExpression') {\n return false;\n }\n\n if (node.computed || !isIdentifierNamed(node.property, 'env')) {\n return false;\n }\n\n return isImportMeta(node.object);\n};\n\nconst collectBindingNames = (node: Node): string[] => {\n if (node.type === 'Identifier') {\n return [node.name];\n }\n\n if (node.type === 'RestElement') {\n return collectBindingNames(node.argument);\n }\n\n if (node.type === 'AssignmentPattern') {\n return collectBindingNames(node.left);\n }\n\n if (node.type === 'ObjectPattern') {\n return node.properties.flatMap((property) =>\n property.type === 'RestElement'\n ? collectBindingNames(property.argument)\n : collectBindingNames(property.value)\n );\n }\n\n if (node.type === 'ArrayPattern') {\n return node.elements.flatMap((element) =>\n element ? collectBindingNames(element) : []\n );\n }\n\n if (node.type === 'TSParameterProperty') {\n return collectBindingNames(node.parameter);\n }\n\n return [];\n};\n\nconst predeclareScopeNames = (node: Node, scope: Scope): void => {\n if (\n node.type === 'FunctionDeclaration' ||\n node.type === 'FunctionExpression' ||\n node.type === 'ArrowFunctionExpression'\n ) {\n if (node.type !== 'ArrowFunctionExpression' && node.id) {\n scope.names.add(node.id.name);\n }\n\n node.params.forEach((param) => {\n collectBindingNames(param).forEach((name) => {\n scope.names.add(name);\n });\n });\n }\n\n const visitScopeDescendants = (child: Node): void => {\n if (child.type === 'VariableDeclarator') {\n collectBindingNames(child.id).forEach((name) => {\n scope.names.add(name);\n });\n } else if (child.type === 'FunctionDeclaration' && child.id) {\n scope.names.add(child.id.name);\n } else if (child.type === 'ClassDeclaration' && child.id) {\n scope.names.add(child.id.name);\n } else if (\n child.type === 'ImportDefaultSpecifier' ||\n child.type === 'ImportNamespaceSpecifier' ||\n child.type === 'ImportSpecifier'\n ) {\n scope.names.add(child.local.name);\n }\n\n if (createsScope(child)) {\n return;\n }\n\n getChildren(child).forEach(visitScopeDescendants);\n };\n\n getChildren(node).forEach(visitScopeDescendants);\n};\n\nconst declareBindings = (node: Node, scope: Scope): void => {\n if (node.type === 'VariableDeclarator') {\n const names = collectBindingNames(node.id);\n names.forEach((name) => {\n scope.names.add(name);\n scope.bindings.set(name, null);\n });\n\n if (node.id.type === 'Identifier' && node.init) {\n scope.bindings.set(node.id.name, node.init);\n }\n return;\n }\n\n if (node.type === 'FunctionDeclaration' && node.id) {\n scope.names.add(node.id.name);\n scope.bindings.set(node.id.name, null);\n }\n\n if (node.type === 'ClassDeclaration' && node.id) {\n scope.names.add(node.id.name);\n scope.bindings.set(node.id.name, null);\n return;\n }\n\n if (\n node.type === 'ImportDefaultSpecifier' ||\n node.type === 'ImportNamespaceSpecifier' ||\n node.type === 'ImportSpecifier'\n ) {\n scope.names.add(node.local.name);\n scope.bindings.set(node.local.name, null);\n return;\n }\n\n if (\n node.type === 'FunctionDeclaration' ||\n node.type === 'FunctionExpression' ||\n node.type === 'ArrowFunctionExpression'\n ) {\n node.params.forEach((param) => {\n collectBindingNames(param).forEach((name) => {\n scope.names.add(name);\n scope.bindings.set(name, null);\n });\n });\n }\n};\n\nconst visit = (\n node: Node,\n scope: Scope,\n enter: (\n node: Node,\n scope: Scope,\n parent: Node | null,\n ancestors: Node[]\n ) => void,\n parent: Node | null = null,\n ancestors: Node[] = []\n): void => {\n let currentScope = scope;\n if (createsScope(node)) {\n currentScope = createScope(scope, `${node.type}:${node.start}:${node.end}`);\n predeclareScopeNames(node, currentScope);\n }\n\n declareBindings(node, currentScope);\n enter(node, currentScope, parent, ancestors);\n\n getChildren(node).forEach((child) =>\n visit(child, currentScope, enter, node, [...ancestors, node])\n );\n};\n\nexport const replaceImportMetaEnvWithOxc = (\n code: string,\n filename: string\n): string => {\n if (!importMetaEnvRe.test(code)) {\n return code;\n }\n\n const replacements: Replacement[] = [];\n\n visit(parseOxc(code, filename), createScope(null, 'root'), (node) => {\n if (!isImportMetaEnv(node)) {\n return;\n }\n\n replacements.push({\n end: node.end,\n start: node.start,\n value: '__wyw_import_meta_env',\n });\n });\n\n return applyReplacements(code, replacements);\n};\n\ntype CombinedSyntaxRewriteOptions = {\n addRequireFallback: boolean;\n eventEmitter?: EventEmitter;\n rewriteDynamicImports: boolean;\n};\n\ntype RequireFallbackCandidate = {\n call: CallExpression;\n scope: Scope;\n};\n\nfunction collectDynamicImportAndRequireFallbackReplacements(\n code: string,\n filename: string,\n options: CombinedSyntaxRewriteOptions\n): Replacement[] {\n const eventEmitter = options.eventEmitter ?? EventEmitter.dummy;\n const dynamicImportCandidates: ImportExpression[] = [];\n const requireFallbackCandidates: RequireFallbackCandidate[] = [];\n\n eventEmitter.perf(\n 'transform:preeval:dynamicImportRequireFallback:scan',\n () => {\n visit(\n parseOxc(code, filename),\n createScope(null, 'root'),\n (node, scope) => {\n if (\n options.rewriteDynamicImports &&\n node.type === 'ImportExpression'\n ) {\n dynamicImportCandidates.push(node as ImportExpression);\n }\n\n if (!options.addRequireFallback || node.type !== 'CallExpression') {\n return;\n }\n\n const call = node as CallExpression;\n if (\n call.callee.type !== 'Identifier' ||\n call.callee.name !== 'require' ||\n hasBinding(scope, 'require') ||\n call.arguments.length !== 1\n ) {\n return;\n }\n\n const [firstArg] = call.arguments;\n if (\n !firstArg ||\n firstArg.type === 'SpreadElement' ||\n isLiteralRequireArg(firstArg)\n ) {\n return;\n }\n\n requireFallbackCandidates.push({\n call,\n scope,\n });\n }\n );\n }\n );\n\n const replacements: Replacement[] = [];\n\n eventEmitter.perf('transform:preeval:dynamicImport', () => {\n dynamicImportCandidates.forEach((importExpression) => {\n const argument = importExpression.source;\n const nextArgument = isStringLikeExpression(argument)\n ? unwrapExpression(argument)\n : argument;\n\n replacements.push({\n end: importExpression.end,\n start: importExpression.start,\n value: `__wyw_dynamic_import(${dynamicImportArgumentCode(\n code,\n nextArgument\n )})`,\n });\n });\n });\n\n eventEmitter.perf('transform:preeval:requireFallback', () => {\n requireFallbackCandidates.forEach(({ call, scope }) => {\n const [firstArg] = call.arguments;\n if (!firstArg || firstArg.type === 'SpreadElement') {\n return;\n }\n\n const staticValue = evaluateStaticValue(firstArg, scope);\n if (\n typeof staticValue === 'string' &&\n isFileLikeRequireSpecifier(staticValue)\n ) {\n replacements.push({\n end: firstArg.end,\n start: firstArg.start,\n value: JSON.stringify(staticValue),\n });\n return;\n }\n\n replacements.push({\n end: firstArg.end,\n start: firstArg.end,\n value: ', true',\n });\n });\n });\n\n return replacements;\n}\n\nexport const rewriteDynamicImportsWithOxc = (\n code: string,\n filename: string\n): string => {\n const replacements = collectDynamicImportAndRequireFallbackReplacements(\n code,\n filename,\n {\n addRequireFallback: false,\n rewriteDynamicImports: true,\n }\n );\n\n return applyReplacements(code, replacements);\n};\n\nexport const addRequireFallbackWithOxc = (\n code: string,\n filename: string\n): string => {\n const replacements = collectDynamicImportAndRequireFallbackReplacements(\n code,\n filename,\n {\n addRequireFallback: true,\n rewriteDynamicImports: false,\n }\n );\n\n return applyReplacements(code, replacements);\n};\n\nexport const rewriteDynamicImportsAndAddRequireFallbackWithOxc = (\n code: string,\n filename: string,\n options: CombinedSyntaxRewriteOptions\n): string => {\n const replacements = collectDynamicImportAndRequireFallbackReplacements(\n code,\n filename,\n options\n );\n\n return applyReplacements(code, replacements);\n};\n\nconst isBindingPosition = (node: Node, parent: Node | null): boolean => {\n if (!parent) {\n return false;\n }\n\n if (parent.type === 'VariableDeclarator' && parent.id === node) {\n return true;\n }\n\n if (\n (parent.type === 'FunctionDeclaration' ||\n parent.type === 'FunctionExpression' ||\n parent.type === 'ClassDeclaration' ||\n parent.type === 'ClassExpression') &&\n parent.id === node\n ) {\n return true;\n }\n\n if (\n parent.type === 'ImportSpecifier' &&\n (parent.local === node || parent.imported === node)\n ) {\n return true;\n }\n\n if (\n (parent.type === 'ImportDefaultSpecifier' ||\n parent.type === 'ImportNamespaceSpecifier') &&\n parent.local === node\n ) {\n return true;\n }\n\n if (\n parent.type === 'ExportSpecifier' &&\n (parent.local === node || parent.exported === node)\n ) {\n return true;\n }\n\n return false;\n};\n\nconst isPropertyOnlyIdentifier = (node: Node, parent: Node | null): boolean => {\n if (!parent) {\n return false;\n }\n\n if (\n parent.type === 'MemberExpression' &&\n !parent.computed &&\n parent.property === node\n ) {\n return true;\n }\n\n if (\n (parent.type === 'Property' ||\n parent.type === 'MethodDefinition' ||\n parent.type === 'PropertyDefinition') &&\n !parent.computed &&\n parent.key === node\n ) {\n return true;\n }\n\n return false;\n};\n\nconst isTypeContext = (ancestors: Node[]): boolean =>\n ancestors.some(\n (ancestor) =>\n ancestor.type.startsWith('TS') || ancestor.type.startsWith('JSDoc')\n );\n\nconst isInsideTypeof = (ancestors: Node[]): boolean =>\n ancestors.some(\n (ancestor) =>\n ancestor.type === 'UnaryExpression' && ancestor.operator === 'typeof'\n );\n\nconst isInsideImportDeclaration = (ancestors: Node[]): boolean =>\n ancestors.some((ancestor) => ancestor.type === 'ImportDeclaration');\n\nfunction findLastAncestor<T extends Node>(\n ancestors: Node[],\n predicate: (ancestor: Node) => ancestor is T\n): T | null;\nfunction findLastAncestor(\n ancestors: Node[],\n predicate: (ancestor: Node) => boolean\n): Node | null;\nfunction findLastAncestor(\n ancestors: Node[],\n predicate: (ancestor: Node) => boolean\n): Node | null {\n for (let idx = ancestors.length - 1; idx >= 0; idx -= 1) {\n const ancestor = ancestors[idx];\n if (predicate(ancestor)) {\n return ancestor;\n }\n }\n\n return null;\n}\n\nconst findRemovableOwner = (node: Node, ancestors: Node[]): Node => {\n let owner: Node = node;\n let ownerAncestorIndex = -1;\n\n if (!removableOwnerTypes.has(node.type)) {\n for (let idx = ancestors.length - 1; idx >= 0; idx -= 1) {\n const ancestor = ancestors[idx];\n if (removableOwnerTypes.has(ancestor.type)) {\n owner = ancestor;\n ownerAncestorIndex = idx;\n break;\n }\n }\n }\n\n const parent =\n ownerAncestorIndex > 0 ? ancestors[ownerAncestorIndex - 1] : null;\n if (\n parent?.type === 'ExportNamedDeclaration' &&\n 'declaration' in parent &&\n parent.declaration === owner\n ) {\n return parent;\n }\n\n return owner;\n};\n\ntype ExportedBindingProtection = {\n start: number;\n end: number;\n value: string;\n};\n\nconst collectReExportedLocalNames = (program: Program): Set<string> => {\n const names = new Set<string>();\n for (const stmt of program.body) {\n if (\n stmt.type !== 'ExportNamedDeclaration' ||\n stmt.declaration ||\n stmt.source\n ) {\n continue;\n }\n for (const spec of stmt.specifiers) {\n if (spec.type === 'ExportSpecifier' && spec.local.type === 'Identifier') {\n names.add(spec.local.name);\n }\n }\n }\n return names;\n};\n\n// When an offending identifier sits inside the value of a top-level export,\n// removing the surrounding declaration would strip the export binding too.\n// ESM linker then fails on consumers' `import { name } from '...'` because the\n// named export no longer exists. To keep the binding alive, replace just the\n// value (declarator init or default-export expression) with `undefined`.\nconst findExportedBindingProtection = (\n node: Node,\n ancestors: Node[],\n reExportedLocalNames: Set<string>\n): ExportedBindingProtection | null => {\n for (let idx = ancestors.length - 1; idx >= 0; idx -= 1) {\n const ancestor = ancestors[idx];\n\n if (ancestor.type === 'ExportDefaultDeclaration') {\n const decl = ancestor.declaration;\n if (decl && decl !== node && 'start' in decl && 'end' in decl) {\n return { start: decl.start, end: decl.end, value: 'undefined' };\n }\n return null;\n }\n\n if (ancestor.type !== 'VariableDeclarator') {\n continue;\n }\n\n if (\n ancestor.id.type !== 'Identifier' ||\n !ancestor.init ||\n ancestor.init === node\n ) {\n return null;\n }\n\n const varDecl = ancestors[idx - 1];\n const wrapper = ancestors[idx - 2] ?? null;\n\n if (varDecl?.type !== 'VariableDeclaration') {\n return null;\n }\n\n const isDirectExport =\n wrapper?.type === 'ExportNamedDeclaration' &&\n wrapper.declaration === varDecl;\n const isTopLevelDeclaration =\n wrapper === null || wrapper?.type === 'Program';\n const isReExported =\n isTopLevelDeclaration && reExportedLocalNames.has(ancestor.id.name);\n\n if (!isDirectExport && !isReExported) {\n return null;\n }\n\n return {\n start: ancestor.init.start,\n end: ancestor.init.end,\n value: 'undefined',\n };\n }\n\n return null;\n};\n\nconst findPromiseCallbackOwner = (ancestors: Node[]): Node | null => {\n for (let idx = ancestors.length - 1; idx >= 0; idx -= 1) {\n const ancestor = ancestors[idx];\n if (\n ancestor.type === 'NewExpression' &&\n ancestor.callee.type === 'Identifier' &&\n ancestor.callee.name === 'Promise'\n ) {\n return ancestor;\n }\n\n if (\n ancestor.type === 'CallExpression' &&\n ancestor.callee.type === 'MemberExpression' &&\n promiseCallbackMethods.has(getMemberPropertyName(ancestor.callee) ?? '')\n ) {\n return ancestor;\n }\n }\n\n return null;\n};\n\nconst containsForbiddenIdentifier = (node: Node): boolean => {\n if (node.type === 'Identifier' && alwaysForbiddenIdentifiers.has(node.name)) {\n return true;\n }\n\n return getChildren(node).some(containsForbiddenIdentifier);\n};\n\nconst collectWindowScopedNames = (program: Program): Set<string> => {\n const windowScopedNames = new Set<string>();\n\n visit(program, createScope(null, 'root'), (node, scope) => {\n if (\n node.type !== 'MemberExpression' ||\n node.object.type !== 'Identifier' ||\n node.object.name !== 'window' ||\n hasBinding(scope, 'window')\n ) {\n return;\n }\n\n const propertyName = getMemberPropertyName(node);\n if (propertyName) {\n windowScopedNames.add(propertyName);\n }\n });\n\n return windowScopedNames;\n};\n\nconst containsForbiddenReference = (\n node: Node,\n scope: Scope,\n windowScopedNames: Set<string>,\n derivedForbiddenBindings: Set<string> = new Set()\n): boolean => {\n let found = false;\n\n visit(node, scope, (child, childScope, parent, ancestors) => {\n if (\n found ||\n child.type !== 'Identifier' ||\n isTypeContext(ancestors) ||\n isInsideTypeof(ancestors) ||\n isPropertyOnlyIdentifier(child, parent) ||\n isBindingPosition(child, parent)\n ) {\n return;\n }\n\n const bindingKey = getBindingKey(childScope, child.name);\n if (\n alwaysForbiddenIdentifiers.has(child.name) ||\n (forbiddenGlobals.has(child.name) &&\n !hasBinding(childScope, child.name)) ||\n (windowScopedNames.has(child.name) &&\n !hasBinding(childScope, child.name)) ||\n (bindingKey !== null && derivedForbiddenBindings.has(bindingKey))\n ) {\n found = true;\n }\n });\n\n return found;\n};\n\nconst nameFromModuleExport = (node: Node): string | null => {\n if (node.type === 'Identifier') {\n return node.name;\n }\n\n if (node.type === 'Literal' && typeof node.value === 'string') {\n return node.value;\n }\n\n return null;\n};\n\nconst collectImportBindings = (\n code: string,\n filename: string,\n program: Program\n): ImportBinding[] => {\n const bindings = new Map<string, ImportBinding>();\n const addBinding = (binding: ImportBinding): void => {\n bindings.set(\n `${binding.local}\\0${binding.source}\\0${binding.imported}`,\n binding\n );\n };\n\n program.body.forEach((statement) => {\n if (statement.type !== 'ImportDeclaration') {\n return;\n }\n\n const source = statement.source.value;\n statement.specifiers.forEach((specifier) => {\n if (specifier.type === 'ImportDefaultSpecifier') {\n addBinding({\n imported: 'default',\n local: specifier.local.name,\n source,\n });\n return;\n }\n\n if (specifier.type === 'ImportNamespaceSpecifier') {\n addBinding({\n imported: '*',\n local: specifier.local.name,\n source,\n });\n return;\n }\n\n const imported = nameFromModuleExport(specifier.imported);\n if (!imported) {\n return;\n }\n\n addBinding({\n imported,\n local: specifier.local.name,\n source,\n });\n });\n });\n\n if (!requireCallRe.test(code)) {\n return [...bindings.values()];\n }\n\n collectOxcExportsAndImports(code, filename).imports.forEach((item) => {\n if (item.imported === 'side-effect') {\n return;\n }\n\n addBinding({\n imported: item.imported,\n local: item.local.code,\n source: item.source,\n });\n\n if (item.local.name && item.local.name !== item.local.code) {\n addBinding({\n imported: item.imported,\n local: item.local.name,\n source: item.source,\n });\n }\n });\n\n return [...bindings.values()];\n};\n\nconst getImportBinding = (\n imports: ImportBinding[],\n local: string\n): ImportBinding | undefined => imports.find((item) => item.local === local);\n\nfunction unwrapSequenceCallee(node: Expression): Expression {\n if (\n node.type === 'SequenceExpression' &&\n node.expressions.length === 2 &&\n node.expressions[0]?.type === 'Literal' &&\n node.expressions[0].value === 0\n ) {\n return node.expressions[1] as Expression;\n }\n\n return node;\n}\n\nconst getExpressionImportKey = (node: Expression): string | null => {\n const expression = unwrapSequenceCallee(node);\n\n if (expression.type === 'Identifier') {\n return expression.name;\n }\n\n if (expression.type !== 'MemberExpression') {\n return null;\n }\n\n if (expression.object.type !== 'Identifier') {\n return null;\n }\n\n const propertyName = getMemberPropertyName(expression);\n return propertyName ? `${expression.object.name}.${propertyName}` : null;\n};\n\nconst isHookOrCreateElement = (name: string): boolean =>\n name === 'createElement' || /use[A-Z]/.test(name);\n\nconst getInnermostCallee = (call: CallExpression): Expression => {\n let callee = unwrapSequenceCallee(call.callee);\n while (callee.type === 'CallExpression') {\n callee = unwrapSequenceCallee(callee.callee);\n }\n\n return callee;\n};\n\nconst getImportForExpression = (\n node: Expression,\n imports: ImportBinding[]\n): [source: string, imported: string] | undefined => {\n const expression = unwrapSequenceCallee(node);\n const directMatchKey = getExpressionImportKey(expression);\n if (directMatchKey) {\n const directMatch = getImportBinding(imports, directMatchKey);\n if (directMatch) {\n return [directMatch.source, directMatch.imported];\n }\n }\n\n if (expression.type === 'Identifier') {\n const matched = getImportBinding(imports, expression.name);\n return matched ? [matched.source, matched.imported] : undefined;\n }\n\n if (expression.type !== 'MemberExpression') {\n return undefined;\n }\n\n if (expression.object.type !== 'Identifier') {\n return undefined;\n }\n\n const propertyName = getMemberPropertyName(expression);\n if (!propertyName) {\n return undefined;\n }\n\n const objectImport = getImportBinding(imports, expression.object.name);\n if (!objectImport) {\n return undefined;\n }\n\n if (\n objectImport.imported === 'default' ||\n objectImport.imported === '*' ||\n objectImport.source === 'react'\n ) {\n return [objectImport.source, propertyName];\n }\n\n return undefined;\n};\n\nconst isReactRuntimeCall = (\n call: CallExpression,\n imports: ImportBinding[]\n): boolean => {\n const callee = unwrapSequenceCallee(call.callee);\n const matched = getImportForExpression(callee, imports);\n if (!matched) {\n return false;\n }\n\n const [source, imported] = matched;\n if (jsxRuntimeSources.has(source)) {\n return true;\n }\n\n return source === 'react' && isHookOrCreateElement(imported);\n};\n\nconst isHocCall = (\n call: CallExpression,\n hocs: Record<string, string[]>,\n imports: ImportBinding[]\n): boolean => {\n const matched = getImportForExpression(getInnermostCallee(call), imports);\n return !!matched && hocs[matched[0]]?.includes(matched[1]);\n};\n\nconst getComponentTypes = (\n options?: CodeRemoverOptions\n): Record<string, string[]> => {\n const componentTypes = {\n ...(options?.componentTypes ?? { react: [defaultPlaceholder] }),\n };\n const reactTypes = componentTypes.react;\n\n if (Array.isArray(reactTypes) && reactTypes.includes(defaultPlaceholder)) {\n const idx = reactTypes.indexOf(defaultPlaceholder);\n componentTypes.react = [...reactTypes];\n componentTypes.react.splice(idx, 1, ...defaultReactComponentTypes);\n }\n\n return componentTypes;\n};\n\nconst getTypeImport = (\n node: Node,\n imports: ImportBinding[]\n): [source: string, imported: string] | undefined => {\n if (node.type === 'Identifier') {\n const matched = getImportBinding(imports, node.name);\n return matched ? [matched.source, matched.imported] : undefined;\n }\n\n if (node.type !== 'TSQualifiedName') {\n return undefined;\n }\n\n if (node.left.type !== 'Identifier') {\n return undefined;\n }\n\n const matched = getImportBinding(imports, node.left.name);\n return matched ? [matched.source, node.right.name] : undefined;\n};\n\nconst isComponentTypeMatch = (\n id: Node,\n componentTypes: Record<string, string[]>,\n imports: ImportBinding[]\n): boolean => {\n if (id.type !== 'Identifier') {\n return false;\n }\n\n const annotation = id.typeAnnotation;\n if (\n !annotation ||\n annotation.type !== 'TSTypeAnnotation' ||\n annotation.typeAnnotation.type !== 'TSTypeReference'\n ) {\n return false;\n }\n\n const matched = getTypeImport(annotation.typeAnnotation.typeName, imports);\n return !!matched && componentTypes[matched[0]]?.includes(matched[1]);\n};\n\nconst getClassName = (node: Node): string | null =>\n node.type === 'ClassDeclaration' && node.id ? node.id.name : null;\n\nconst isFunctionLikeNode = (node: Node): node is OxcFunctionLikeNode =>\n node.type === 'FunctionDeclaration' ||\n node.type === 'FunctionExpression' ||\n node.type === 'ArrowFunctionExpression';\n\nconst isImmediatelyInvokedFunction = (\n fnNode: Node,\n ancestors: Node[],\n fnIndex: number\n): boolean => {\n // Walk past any ParenthesizedExpression / SequenceExpression wrappers that\n // sit between the function and its enclosing CallExpression. oxc-parser\n // preserves ParenthesizedExpression nodes, so `(() => {...})()` shows up\n // as CallExpression -> ParenthesizedExpression -> ArrowFunctionExpression.\n let child: Node = fnNode;\n for (let idx = fnIndex - 1; idx >= 0; idx -= 1) {\n const ancestor = ancestors[idx];\n if (\n ancestor.type === 'ParenthesizedExpression' &&\n 'expression' in ancestor &&\n ancestor.expression === child\n ) {\n child = ancestor;\n continue;\n }\n if (\n ancestor.type === 'SequenceExpression' &&\n Array.isArray(ancestor.expressions) &&\n ancestor.expressions[ancestor.expressions.length - 1] === child\n ) {\n child = ancestor;\n continue;\n }\n return ancestor.type === 'CallExpression' && ancestor.callee === child;\n }\n return false;\n};\n\n// A reference is \"deferred\" when it lives inside a function body that is\n// not immediately invoked. Module preeval reads exports without calling\n// them, so deferred references never run and must not be sanitized — that\n// would silently drop the binding (or remove the entire export) and break\n// importers that expect the function to be callable.\nconst isInDeferredFunctionScope = (ancestors: Node[]): boolean => {\n for (let idx = ancestors.length - 1; idx >= 0; idx -= 1) {\n const ancestor = ancestors[idx];\n if (!isFunctionLikeNode(ancestor)) {\n continue;\n }\n if (!isImmediatelyInvokedFunction(ancestor, ancestors, idx)) {\n return true;\n }\n }\n return false;\n};\n\nconst findFunctionReplacement = (ancestors: Node[]): Replacement | null => {\n const renderMethod = findLastAncestor(\n ancestors,\n (ancestor) =>\n ancestor.type === 'MethodDefinition' &&\n ancestor.key.type === 'Identifier' &&\n ancestor.key.name === 'render'\n );\n\n if (renderMethod) {\n const classDecl = findLastAncestor(\n ancestors,\n (ancestor) => ancestor.type === 'ClassDeclaration'\n );\n const className = classDecl ? getClassName(classDecl) : null;\n if (classDecl && className) {\n return {\n start: classDecl.start,\n end: classDecl.end,\n value: `function ${className}() { return null; }`,\n };\n }\n }\n\n const functionNode = findLastAncestor(ancestors, isFunctionLikeNode);\n\n if (!functionNode) {\n return null;\n }\n\n if (functionNode.type === 'ArrowFunctionExpression') {\n return {\n start: functionNode.start,\n end: functionNode.end,\n value: `${functionNode.async ? 'async ' : ''}() => { return null; }`,\n };\n }\n\n if (functionNode.type === 'FunctionDeclaration') {\n return {\n start: functionNode.start,\n end: functionNode.end,\n value: `${functionNode.async ? 'async ' : ''}function ${\n functionNode.id?.name ?? ''\n }() { return null; }`,\n };\n }\n\n return {\n start: functionNode.body.start,\n end: functionNode.body.end,\n value: '{ return null; }',\n };\n};\n\nconst normalizeReplacements = (replacements: Replacement[]): Replacement[] => {\n const sorted = [...replacements].sort((a, b) =>\n a.start === b.start ? b.end - a.end : a.start - b.start\n );\n const result: Replacement[] = [];\n\n sorted.forEach((replacement) => {\n const last = result[result.length - 1];\n if (\n last &&\n replacement.start >= last.start &&\n replacement.end <= last.end\n ) {\n return;\n }\n\n result.push(replacement);\n });\n\n return result;\n};\n\nexport const removeDangerousCodeWithOxc = (\n code: string,\n filename: string,\n options?: CodeRemoverOptions\n): string => {\n const replacements: Replacement[] = [];\n const derivedForbiddenBindings = new Set<string>();\n const program = parseOxc(code, filename);\n const imports = collectImportBindings(code, filename, program);\n const componentTypes = getComponentTypes(options);\n const hocs = options?.hocs ?? {};\n const hasHocs = Object.keys(hocs).length > 0;\n const windowScopedNames = windowTokenRe.test(code)\n ? collectWindowScopedNames(program)\n : new Set<string>();\n const reExportedLocalNames = collectReExportedLocalNames(program);\n\n const derivedBindingDiscovery = { found: true };\n while (derivedBindingDiscovery.found) {\n derivedBindingDiscovery.found = false;\n\n visit(program, createScope(null, 'root'), (node, scope) => {\n if (\n node.type !== 'VariableDeclarator' ||\n node.id.type !== 'Identifier' ||\n !node.init\n ) {\n return;\n }\n\n const bindingKey = getBindingKey(scope, node.id.name);\n if (!bindingKey || derivedForbiddenBindings.has(bindingKey)) {\n return;\n }\n\n if (\n containsForbiddenIdentifier(node.init) ||\n containsForbiddenReference(\n node.init,\n scope,\n windowScopedNames,\n derivedForbiddenBindings\n )\n ) {\n derivedForbiddenBindings.add(bindingKey);\n derivedBindingDiscovery.found = true;\n }\n });\n }\n\n visit(\n program,\n createScope(null, 'root'),\n (node, scope, parent, ancestors) => {\n if (node.type === 'JSXElement' || node.type === 'JSXFragment') {\n replacements.push(\n findFunctionReplacement(ancestors) ?? {\n start: node.start,\n end: node.end,\n value: 'null',\n }\n );\n return;\n }\n\n if (node.type === 'CallExpression') {\n if (isReactRuntimeCall(node, imports)) {\n const replacement = findFunctionReplacement(ancestors);\n if (replacement) {\n replacements.push(replacement);\n }\n\n return;\n }\n\n if (hasHocs && isHocCall(node, hocs, imports)) {\n replacements.push({\n start: node.start,\n end: node.end,\n value: '() => null',\n });\n return;\n }\n }\n\n if (\n node.type === 'VariableDeclarator' &&\n node.id.type === 'Identifier' &&\n node.init &&\n isComponentTypeMatch(node.id, componentTypes, imports)\n ) {\n replacements.push({\n start: node.init.start,\n end: node.init.end,\n value: '() => null',\n });\n return;\n }\n\n if (\n node.type === 'UnaryExpression' &&\n node.operator === 'typeof' &&\n node.argument.type === 'Identifier' &&\n ssrCheckFields.has(node.argument.name) &&\n !hasBinding(scope, node.argument.name)\n ) {\n replacements.push({\n start: node.start,\n end: node.end,\n value: '\"undefined\"',\n });\n return;\n }\n\n if (node.type === 'MetaProperty') {\n const owner = findRemovableOwner(node, ancestors);\n replacements.push({ start: owner.start, end: owner.end, value: '' });\n return;\n }\n\n if (\n node.type !== 'Identifier' ||\n isTypeContext(ancestors) ||\n isInsideTypeof(ancestors) ||\n isInsideImportDeclaration(ancestors)\n ) {\n return;\n }\n\n if (isPropertyOnlyIdentifier(node, parent)) {\n return;\n }\n\n const isAlwaysForbidden = alwaysForbiddenIdentifiers.has(node.name);\n const bindingKey = getBindingKey(scope, node.name);\n const isDerivedForbidden =\n bindingKey !== null && derivedForbiddenBindings.has(bindingKey);\n const isWindowScoped =\n windowScopedNames.has(node.name) && !hasBinding(scope, node.name);\n const isForbiddenGlobal =\n forbiddenGlobals.has(node.name) && !hasBinding(scope, node.name);\n\n if (\n !isAlwaysForbidden &&\n !isDerivedForbidden &&\n !isWindowScoped &&\n !isForbiddenGlobal\n ) {\n return;\n }\n\n if (!isAlwaysForbidden && isInDeferredFunctionScope(ancestors)) {\n return;\n }\n\n if (isBindingPosition(node, parent) && !isAlwaysForbidden) {\n return;\n }\n\n if (\n parent?.type === 'ExportDefaultDeclaration' &&\n parent.declaration === node\n ) {\n return;\n }\n\n if (\n generatedProcessorHelperNameRe.test(node.name) &&\n hasBinding(scope, node.name)\n ) {\n return;\n }\n\n const generatedHelperDeclarator = findLastAncestor(\n ancestors,\n (ancestor) =>\n ancestor.type === 'VariableDeclarator' &&\n ancestor.id.type === 'Identifier' &&\n generatedProcessorHelperNameRe.test(ancestor.id.name)\n );\n if (generatedHelperDeclarator) {\n return;\n }\n\n if (\n parent?.type === 'Property' &&\n parent.value === node &&\n hasBinding(scope, node.name)\n ) {\n return;\n }\n\n if (parent?.type === 'Property' && parent.value === node) {\n replacements.push({\n start: node.start,\n end: node.end,\n value: parent.shorthand ? `${node.name}: undefined` : 'undefined',\n });\n return;\n }\n\n const grandparent = ancestors[ancestors.length - 2] ?? null;\n if (\n parent?.type === 'MemberExpression' &&\n parent.object === node &&\n grandparent?.type === 'SpreadElement' &&\n grandparent.argument === parent\n ) {\n replacements.push({\n start: grandparent.start,\n end: grandparent.end,\n value: '...{}',\n });\n return;\n }\n\n const exportProtection = findExportedBindingProtection(\n node,\n ancestors,\n reExportedLocalNames\n );\n if (exportProtection) {\n replacements.push(exportProtection);\n return;\n }\n\n const promiseOwner = findPromiseCallbackOwner(ancestors);\n const owner = promiseOwner\n ? findRemovableOwner(promiseOwner, ancestors)\n : findRemovableOwner(node, ancestors);\n replacements.push({ start: owner.start, end: owner.end, value: '' });\n }\n );\n\n return applyReplacements(code, normalizeReplacements(replacements));\n};\n"],"file":"oxcPreevalTransforms.js"}
1
+ {"mappings":"AAYA,SAAS,mCAAmC;AAC5C,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AAiCtC,MAAM,iBAAiB,IAAI,IAAI;CAC7B;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,MAAM,mBAAmB,IAAI,IAAI;CAC/B,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,MAAM,6BAA6B,IAAI,IAAI,CAAC,gBAAgB,eAAe,CAAC;AAC5E,MAAM,yBAAyB,IAAI,IAAI;CAAC;CAAQ;CAAS;CAAU,CAAC;AACpE,MAAM,oBAAoB,IAAI,IAAI,CAChC,qBACA,wBACD,CAAC;AACF,MAAM,qBAAqB;AAC3B,MAAM,6BAA6B;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AACD,MAAM,mBAAmB,CAAC,cAAc,OAAO;AAC/C,MAAM,iCAAiC;AACvC,M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,KAAK;IAChB,OAAO,KAAK;IACZ,KAAK,KAAK;IACV,OAAO,OAAO,YAAY,GAAG,KAAK,KAAK,eAAe;IACvD,CAAC;AACF;;EAGF,MAAM,cAAc,UAAU,UAAU,SAAS,MAAM;AACvD,MACE,QAAQ,SAAS,sBACjB,OAAO,WAAW,QAClB,aAAa,SAAS,mBACtB,YAAY,aAAa,QACzB;AACA,gBAAa,KAAK;IAChB,OAAO,YAAY;IACnB,KAAK,YAAY;IACjB,OAAO;IACR,CAAC;AACF;;EAGF,MAAM,mBAAmB,8BACvB,MACA,WACA,qBACD;AACD,MAAI,kBAAkB;AACpB,gBAAa,KAAK,iBAAiB;AACnC;;EAGF,MAAM,eAAe,yBAAyB,UAAU;EACxD,MAAM,QAAQ,eACV,mBAAmB,cAAc,UAAU,GAC3C,mBAAmB,MAAM,UAAU;AACvC,eAAa,KAAK;GAAE,OAAO,MAAM;GAAO,KAAK,MAAM;GAAK,OAAO;GAAI,CAAC;GAEvE;AAED,QAAO,kBAAkB,MAAM,sBAAsB,aAAa,CAAC","names":[],"sources":["../../src/utils/oxcPreevalTransforms.ts"],"version":3,"sourcesContent":["/* eslint-disable no-restricted-syntax,no-continue */\n\nimport type {\n CallExpression,\n Expression,\n ImportExpression,\n Node,\n Program,\n} from 'oxc-parser';\n\nimport type { CodeRemoverOptions } from '@wyw-in-js/shared';\n\nimport { collectOxcExportsAndImports } from './collectOxcExportsAndImports';\nimport { EventEmitter } from './EventEmitter';\nimport { getOxcNodeChildren } from './oxc/ast';\nimport { parseOxcProgramCached } from './parseOxc';\n\ntype AnyNode = Node & Record<string, unknown>;\n\ntype Replacement = {\n end: number;\n start: number;\n value: string;\n};\n\ntype Scope = {\n bindings: Map<string, Expression | null>;\n key: string;\n names: Set<string>;\n parent: Scope | null;\n};\n\ntype ImportBinding = {\n imported: string | 'default' | '*';\n local: string;\n source: string;\n};\n\ntype OxcFunctionLikeNode = Node & {\n async: boolean;\n body: Node;\n id?: { name: string } | null;\n type:\n | 'ArrowFunctionExpression'\n | 'FunctionDeclaration'\n | 'FunctionExpression';\n};\n\nconst ssrCheckFields = new Set([\n 'document',\n 'location',\n 'navigator',\n 'sessionStorage',\n 'localStorage',\n 'window',\n]);\n\nconst forbiddenGlobals = new Set([\n ...ssrCheckFields,\n '$RefreshReg$',\n '$RefreshSig$',\n 'XMLHttpRequest',\n 'clearImmediate',\n 'clearInterval',\n 'clearTimeout',\n 'fetch',\n 'navigator',\n 'setImmediate',\n 'setInterval',\n 'setTimeout',\n]);\n\nconst alwaysForbiddenIdentifiers = new Set(['$RefreshReg$', '$RefreshSig$']);\nconst promiseCallbackMethods = new Set(['then', 'catch', 'finally']);\nconst jsxRuntimeSources = new Set([\n 'react/jsx-runtime',\n 'react/jsx-dev-runtime',\n]);\nconst defaultPlaceholder = '...';\nconst defaultReactComponentTypes = [\n 'ExoticComponent',\n 'FC',\n 'ForwardRefExoticComponent',\n 'FunctionComponent',\n 'LazyExoticComponent',\n 'MemoExoticComponent',\n 'NamedExoticComponent',\n];\nconst defaultReactHocs = ['forwardRef', 'memo'];\nconst generatedProcessorHelperNameRe = /^_exp\\d*$/;\nconst requireCallRe = /\\brequire\\s*\\(/;\nconst windowTokenRe = /\\bwindow\\b/;\nconst removableOwnerTypes = new Set([\n 'DoWhileStatement',\n 'ExpressionStatement',\n 'ForInStatement',\n 'ForOfStatement',\n 'ForStatement',\n 'FunctionDeclaration',\n 'IfStatement',\n 'PropertyDefinition',\n 'ReturnStatement',\n 'VariableDeclaration',\n 'WhileStatement',\n]);\nconst importMetaEnvRe = /\\bimport\\s*\\.\\s*meta\\s*\\.\\s*env\\b/;\n\nconst createScope = (parent: Scope | null, key: string): Scope => ({\n bindings: new Map(),\n key,\n names: new Set(),\n parent,\n});\n\nconst createsScope = (node: Node): boolean =>\n node.type === 'Program' ||\n node.type === 'BlockStatement' ||\n node.type === 'FunctionDeclaration' ||\n node.type === 'FunctionExpression' ||\n node.type === 'ArrowFunctionExpression';\n\nconst hasBinding = (scope: Scope, name: string): boolean => {\n let current: Scope | null = scope;\n while (current) {\n if (current.names.has(name)) {\n return true;\n }\n\n current = current.parent;\n }\n\n return false;\n};\n\nconst getBindingKey = (scope: Scope, name: string): string | null => {\n let current: Scope | null = scope;\n while (current) {\n if (current.names.has(name)) {\n return `${current.key}\\0${name}`;\n }\n\n current = current.parent;\n }\n\n return null;\n};\n\nconst getStaticBinding = (\n scope: Scope,\n name: string\n): Expression | null | undefined => {\n let current: Scope | null = scope;\n while (current) {\n if (current.bindings.has(name)) {\n return current.bindings.get(name);\n }\n\n current = current.parent;\n }\n\n return undefined;\n};\n\nconst isFileLikeRequireSpecifier = (value: string): boolean =>\n value.startsWith('.') || value.startsWith('/') || value.startsWith('file:');\n\nconst isNode = (value: unknown): value is Node =>\n !!value &&\n typeof value === 'object' &&\n 'type' in value &&\n typeof (value as { type?: unknown }).type === 'string';\n\n// Reuses the per-node.type visitor-key cache in utils/oxc/ast.ts. This file's\n// getChildren shape historically diverged from the canonical one (a smaller\n// metadata-key skip set), but the produced children list is identical in\n// practice because oxc-parser nodes don't carry the extra metadata fields.\nconst getChildren = getOxcNodeChildren;\n\nconst parseOxc = (code: string, filename: string): Program => {\n return parseOxcProgramCached(filename, code, 'unambiguous');\n};\n\nconst unwrapExpression = (node: Expression): Expression => {\n if (\n node.type === 'TSAsExpression' ||\n node.type === 'TSSatisfiesExpression' ||\n node.type === 'TSNonNullExpression' ||\n node.type === 'TSTypeAssertion' ||\n node.type === 'ParenthesizedExpression'\n ) {\n return unwrapExpression(node.expression);\n }\n\n return node;\n};\n\nconst getMemberPropertyName = (node: Node): string | null => {\n if (node.type !== 'MemberExpression') {\n return null;\n }\n\n if (node.computed) {\n return node.property.type === 'Literal' &&\n typeof node.property.value === 'string'\n ? node.property.value\n : null;\n }\n\n return node.property.type === 'Identifier' ? node.property.name : null;\n};\n\nconst isStringLikeExpression = (node: Expression): boolean => {\n const expression = unwrapExpression(node);\n\n if (expression.type === 'Literal' && typeof expression.value === 'string') {\n return true;\n }\n\n if (expression.type === 'TemplateLiteral') {\n return true;\n }\n\n if (expression.type === 'BinaryExpression' && expression.operator === '+') {\n return (\n isStringLikeExpression(expression.left) ||\n isStringLikeExpression(expression.right)\n );\n }\n\n if (\n expression.type === 'CallExpression' &&\n expression.callee.type === 'MemberExpression' &&\n getMemberPropertyName(expression.callee) === 'concat'\n ) {\n return isStringLikeExpression(expression.callee.object);\n }\n\n return false;\n};\n\nconst templateLiteralToConcat = (code: string, node: Expression): string => {\n if (node.type !== 'TemplateLiteral' || node.expressions.length === 0) {\n return code.slice(node.start, node.end);\n }\n\n const parts: string[] = [];\n node.quasis.forEach((quasi, index) => {\n const cooked = quasi.value.cooked ?? quasi.value.raw;\n if (cooked !== '') {\n parts.push(JSON.stringify(cooked));\n }\n\n const expression = node.expressions[index];\n if (expression) {\n parts.push(code.slice(expression.start, expression.end));\n }\n });\n\n return parts.length > 0 ? parts.join(' + ') : '\"\"';\n};\n\nconst dynamicImportArgumentCode = (code: string, node: Expression): string => {\n if (node.type === 'TemplateLiteral') {\n return templateLiteralToConcat(code, node);\n }\n\n return code.slice(node.start, node.end);\n};\n\nconst evaluateStaticValue = (\n node: Expression,\n scope: Scope,\n seen = new Set<string>()\n): unknown | undefined => {\n const expression = unwrapExpression(node);\n\n if (expression.type === 'Literal') {\n return expression.value;\n }\n\n if (expression.type === 'TemplateLiteral') {\n let result = '';\n\n for (let idx = 0; idx < expression.quasis.length; idx += 1) {\n result += expression.quasis[idx]?.value.cooked ?? '';\n\n const nextExpression = expression.expressions[idx];\n if (!nextExpression) {\n continue;\n }\n\n const value = evaluateStaticValue(nextExpression, scope, seen);\n if (\n value === undefined ||\n (typeof value !== 'string' && typeof value !== 'number')\n ) {\n return undefined;\n }\n\n result += String(value);\n }\n\n return result;\n }\n\n if (expression.type === 'Identifier') {\n if (seen.has(expression.name)) {\n return undefined;\n }\n\n const binding = getStaticBinding(scope, expression.name);\n if (!binding) {\n return undefined;\n }\n\n return evaluateStaticValue(\n binding,\n scope,\n new Set([...seen, expression.name])\n );\n }\n\n if (expression.type === 'BinaryExpression' && expression.operator === '+') {\n const left = evaluateStaticValue(expression.left, scope, seen);\n const right = evaluateStaticValue(expression.right, scope, seen);\n\n if (left === undefined || right === undefined) {\n return undefined;\n }\n\n if (typeof left === 'number' && typeof right === 'number') {\n return left + right;\n }\n\n if (\n (typeof left === 'string' || typeof left === 'number') &&\n (typeof right === 'string' || typeof right === 'number')\n ) {\n return `${left}${right}`;\n }\n }\n\n if (\n expression.type === 'CallExpression' &&\n expression.callee.type === 'MemberExpression'\n ) {\n const objectValue = evaluateStaticValue(\n expression.callee.object,\n scope,\n seen\n );\n const propertyName = getMemberPropertyName(expression.callee);\n if (!propertyName) {\n return undefined;\n }\n\n if (typeof objectValue === 'string') {\n if (propertyName === 'toLowerCase' && expression.arguments.length === 0) {\n return objectValue.toLowerCase();\n }\n\n if (propertyName === 'toUpperCase' && expression.arguments.length === 0) {\n return objectValue.toUpperCase();\n }\n\n if (propertyName === 'trim' && expression.arguments.length === 0) {\n return objectValue.trim();\n }\n\n if (propertyName === 'concat') {\n const args = expression.arguments.map((argument) =>\n argument.type === 'SpreadElement'\n ? undefined\n : evaluateStaticValue(argument, scope, seen)\n );\n if (\n args.some((value) => value === undefined) ||\n args.some(\n (value) => typeof value !== 'string' && typeof value !== 'number'\n )\n ) {\n return undefined;\n }\n\n return objectValue.concat(...args.map((value) => String(value)));\n }\n }\n }\n\n return undefined;\n};\n\nconst isLiteralRequireArg = (node: Expression): boolean => {\n const expression = unwrapExpression(node);\n\n if (expression.type === 'Literal' && typeof expression.value === 'string') {\n return true;\n }\n\n if (\n expression.type === 'TemplateLiteral' &&\n expression.expressions.length === 0\n ) {\n return true;\n }\n\n return false;\n};\n\nconst applyReplacements = (\n code: string,\n replacements: Replacement[]\n): string => {\n let result = code;\n replacements\n .sort((a, b) => b.start - a.start)\n .forEach((replacement) => {\n result =\n result.slice(0, replacement.start) +\n replacement.value +\n result.slice(replacement.end);\n });\n\n return result;\n};\n\nconst isIdentifierNamed = (value: unknown, name: string): boolean =>\n isNode(value) && value.type === 'Identifier' && value.name === name;\n\nconst isImportMeta = (node: unknown): boolean => {\n if (!isNode(node) || node.type !== 'MetaProperty') {\n return false;\n }\n\n const metaProperty = node as AnyNode;\n return (\n isIdentifierNamed(metaProperty.meta, 'import') &&\n isIdentifierNamed(metaProperty.property, 'meta')\n );\n};\n\nconst isImportMetaEnv = (node: Node): boolean => {\n if (node.type !== 'MemberExpression') {\n return false;\n }\n\n if (node.computed || !isIdentifierNamed(node.property, 'env')) {\n return false;\n }\n\n return isImportMeta(node.object);\n};\n\nconst collectBindingNames = (node: Node): string[] => {\n if (node.type === 'Identifier') {\n return [node.name];\n }\n\n if (node.type === 'RestElement') {\n return collectBindingNames(node.argument);\n }\n\n if (node.type === 'AssignmentPattern') {\n return collectBindingNames(node.left);\n }\n\n if (node.type === 'ObjectPattern') {\n return node.properties.flatMap((property) =>\n property.type === 'RestElement'\n ? collectBindingNames(property.argument)\n : collectBindingNames(property.value)\n );\n }\n\n if (node.type === 'ArrayPattern') {\n return node.elements.flatMap((element) =>\n element ? collectBindingNames(element) : []\n );\n }\n\n if (node.type === 'TSParameterProperty') {\n return collectBindingNames(node.parameter);\n }\n\n return [];\n};\n\nconst predeclareScopeNames = (node: Node, scope: Scope): void => {\n if (\n node.type === 'FunctionDeclaration' ||\n node.type === 'FunctionExpression' ||\n node.type === 'ArrowFunctionExpression'\n ) {\n if (node.type !== 'ArrowFunctionExpression' && node.id) {\n scope.names.add(node.id.name);\n }\n\n node.params.forEach((param) => {\n collectBindingNames(param).forEach((name) => {\n scope.names.add(name);\n });\n });\n }\n\n const visitScopeDescendants = (child: Node): void => {\n switch (child.type) {\n case 'VariableDeclarator': {\n const names = collectBindingNames(child.id);\n for (let i = 0; i < names.length; i += 1) {\n scope.names.add(names[i]);\n }\n break;\n }\n case 'FunctionDeclaration':\n case 'ClassDeclaration':\n if (child.id) {\n scope.names.add(child.id.name);\n }\n break;\n case 'ImportDefaultSpecifier':\n case 'ImportNamespaceSpecifier':\n case 'ImportSpecifier':\n scope.names.add(child.local.name);\n break;\n default:\n break;\n }\n\n if (createsScope(child)) {\n return;\n }\n\n const children = getChildren(child);\n for (let i = 0; i < children.length; i += 1) {\n visitScopeDescendants(children[i]);\n }\n };\n\n const rootChildren = getChildren(node);\n for (let i = 0; i < rootChildren.length; i += 1) {\n visitScopeDescendants(rootChildren[i]);\n }\n};\n\nconst declareBindings = (node: Node, scope: Scope): void => {\n // Called for every visited AST node, so the dispatch is hot. A switch lets\n // V8 generate a jump table on node.type; the previous chained `if`s walked\n // each branch's string-compare for every non-matching node.\n switch (node.type) {\n case 'VariableDeclarator': {\n const names = collectBindingNames(node.id);\n for (let i = 0; i < names.length; i += 1) {\n const name = names[i];\n scope.names.add(name);\n scope.bindings.set(name, null);\n }\n if (node.id.type === 'Identifier' && node.init) {\n scope.bindings.set(node.id.name, node.init);\n }\n return;\n }\n case 'ClassDeclaration': {\n if (node.id) {\n scope.names.add(node.id.name);\n scope.bindings.set(node.id.name, null);\n }\n return;\n }\n case 'ImportDefaultSpecifier':\n case 'ImportNamespaceSpecifier':\n case 'ImportSpecifier': {\n scope.names.add(node.local.name);\n scope.bindings.set(node.local.name, null);\n return;\n }\n case 'FunctionDeclaration': {\n if (node.id) {\n scope.names.add(node.id.name);\n scope.bindings.set(node.id.name, null);\n }\n // Fall through to declare params.\n }\n // eslint-disable-next-line no-fallthrough\n case 'FunctionExpression':\n case 'ArrowFunctionExpression': {\n const { params } = node;\n for (let i = 0; i < params.length; i += 1) {\n const names = collectBindingNames(params[i]);\n for (let j = 0; j < names.length; j += 1) {\n const name = names[j];\n scope.names.add(name);\n scope.bindings.set(name, null);\n }\n }\n break;\n }\n default:\n break;\n }\n};\n\nconst visit = (\n node: Node,\n scope: Scope,\n enter: (\n node: Node,\n scope: Scope,\n parent: Node | null,\n ancestors: Node[]\n ) => void,\n parent: Node | null = null,\n ancestors: Node[] = []\n): void => {\n let currentScope = scope;\n if (createsScope(node)) {\n currentScope = createScope(scope, `${node.type}:${node.start}:${node.end}`);\n predeclareScopeNames(node, currentScope);\n }\n\n declareBindings(node, currentScope);\n enter(node, currentScope, parent, ancestors);\n\n // Push onto a shared ancestors stack instead of allocating `[...ancestors,\n // node]` per child step (O(n × depth) extra allocation on deep ASTs).\n // Every consumer of `ancestors` in this file reads it synchronously inside\n // the enter callback; future callers that need to retain the reference\n // must .slice() it themselves.\n ancestors.push(node);\n const children = getChildren(node);\n for (let i = 0; i < children.length; i += 1) {\n visit(children[i], currentScope, enter, node, ancestors);\n }\n ancestors.pop();\n};\n\nexport const replaceImportMetaEnvWithOxc = (\n code: string,\n filename: string\n): string => {\n if (!importMetaEnvRe.test(code)) {\n return code;\n }\n\n const replacements: Replacement[] = [];\n\n visit(parseOxc(code, filename), createScope(null, 'root'), (node) => {\n if (!isImportMetaEnv(node)) {\n return;\n }\n\n replacements.push({\n end: node.end,\n start: node.start,\n value: '__wyw_import_meta_env',\n });\n });\n\n return applyReplacements(code, replacements);\n};\n\ntype CombinedSyntaxRewriteOptions = {\n addRequireFallback: boolean;\n eventEmitter?: EventEmitter;\n rewriteDynamicImports: boolean;\n};\n\ntype RequireFallbackCandidate = {\n call: CallExpression;\n scope: Scope;\n};\n\nfunction collectDynamicImportAndRequireFallbackReplacements(\n code: string,\n filename: string,\n options: CombinedSyntaxRewriteOptions\n): Replacement[] {\n const eventEmitter = options.eventEmitter ?? EventEmitter.dummy;\n const dynamicImportCandidates: ImportExpression[] = [];\n const requireFallbackCandidates: RequireFallbackCandidate[] = [];\n\n eventEmitter.perf(\n 'transform:preeval:dynamicImportRequireFallback:scan',\n () => {\n visit(\n parseOxc(code, filename),\n createScope(null, 'root'),\n (node, scope) => {\n if (\n options.rewriteDynamicImports &&\n node.type === 'ImportExpression'\n ) {\n dynamicImportCandidates.push(node as ImportExpression);\n }\n\n if (!options.addRequireFallback || node.type !== 'CallExpression') {\n return;\n }\n\n const call = node as CallExpression;\n if (\n call.callee.type !== 'Identifier' ||\n call.callee.name !== 'require' ||\n hasBinding(scope, 'require') ||\n call.arguments.length !== 1\n ) {\n return;\n }\n\n const [firstArg] = call.arguments;\n if (\n !firstArg ||\n firstArg.type === 'SpreadElement' ||\n isLiteralRequireArg(firstArg)\n ) {\n return;\n }\n\n requireFallbackCandidates.push({\n call,\n scope,\n });\n }\n );\n }\n );\n\n const replacements: Replacement[] = [];\n\n eventEmitter.perf('transform:preeval:dynamicImport', () => {\n dynamicImportCandidates.forEach((importExpression) => {\n const argument = importExpression.source;\n const nextArgument = isStringLikeExpression(argument)\n ? unwrapExpression(argument)\n : argument;\n\n replacements.push({\n end: importExpression.end,\n start: importExpression.start,\n value: `__wyw_dynamic_import(${dynamicImportArgumentCode(\n code,\n nextArgument\n )})`,\n });\n });\n });\n\n eventEmitter.perf('transform:preeval:requireFallback', () => {\n requireFallbackCandidates.forEach(({ call, scope }) => {\n const [firstArg] = call.arguments;\n if (!firstArg || firstArg.type === 'SpreadElement') {\n return;\n }\n\n const staticValue = evaluateStaticValue(firstArg, scope);\n if (\n typeof staticValue === 'string' &&\n isFileLikeRequireSpecifier(staticValue)\n ) {\n replacements.push({\n end: firstArg.end,\n start: firstArg.start,\n value: JSON.stringify(staticValue),\n });\n return;\n }\n\n replacements.push({\n end: firstArg.end,\n start: firstArg.end,\n value: ', true',\n });\n });\n });\n\n return replacements;\n}\n\nexport const rewriteDynamicImportsWithOxc = (\n code: string,\n filename: string\n): string => {\n const replacements = collectDynamicImportAndRequireFallbackReplacements(\n code,\n filename,\n {\n addRequireFallback: false,\n rewriteDynamicImports: true,\n }\n );\n\n return applyReplacements(code, replacements);\n};\n\nexport const addRequireFallbackWithOxc = (\n code: string,\n filename: string\n): string => {\n const replacements = collectDynamicImportAndRequireFallbackReplacements(\n code,\n filename,\n {\n addRequireFallback: true,\n rewriteDynamicImports: false,\n }\n );\n\n return applyReplacements(code, replacements);\n};\n\nexport const rewriteDynamicImportsAndAddRequireFallbackWithOxc = (\n code: string,\n filename: string,\n options: CombinedSyntaxRewriteOptions\n): string => {\n const replacements = collectDynamicImportAndRequireFallbackReplacements(\n code,\n filename,\n options\n );\n\n return applyReplacements(code, replacements);\n};\n\nconst isBindingPosition = (node: Node, parent: Node | null): boolean => {\n if (!parent) {\n return false;\n }\n\n if (parent.type === 'VariableDeclarator' && parent.id === node) {\n return true;\n }\n\n if (\n (parent.type === 'FunctionDeclaration' ||\n parent.type === 'FunctionExpression' ||\n parent.type === 'ClassDeclaration' ||\n parent.type === 'ClassExpression') &&\n parent.id === node\n ) {\n return true;\n }\n\n if (\n parent.type === 'ImportSpecifier' &&\n (parent.local === node || parent.imported === node)\n ) {\n return true;\n }\n\n if (\n (parent.type === 'ImportDefaultSpecifier' ||\n parent.type === 'ImportNamespaceSpecifier') &&\n parent.local === node\n ) {\n return true;\n }\n\n if (\n parent.type === 'ExportSpecifier' &&\n (parent.local === node || parent.exported === node)\n ) {\n return true;\n }\n\n return false;\n};\n\nconst isPropertyOnlyIdentifier = (node: Node, parent: Node | null): boolean => {\n if (!parent) {\n return false;\n }\n\n if (\n parent.type === 'MemberExpression' &&\n !parent.computed &&\n parent.property === node\n ) {\n return true;\n }\n\n if (\n (parent.type === 'Property' ||\n parent.type === 'MethodDefinition' ||\n parent.type === 'PropertyDefinition') &&\n !parent.computed &&\n parent.key === node\n ) {\n return true;\n }\n\n return false;\n};\n\nconst isTypeContext = (ancestors: Node[]): boolean =>\n ancestors.some(\n (ancestor) =>\n ancestor.type.startsWith('TS') || ancestor.type.startsWith('JSDoc')\n );\n\nconst isInsideTypeof = (ancestors: Node[]): boolean =>\n ancestors.some(\n (ancestor) =>\n ancestor.type === 'UnaryExpression' && ancestor.operator === 'typeof'\n );\n\nconst isInsideImportDeclaration = (ancestors: Node[]): boolean =>\n ancestors.some((ancestor) => ancestor.type === 'ImportDeclaration');\n\nfunction findLastAncestor<T extends Node>(\n ancestors: Node[],\n predicate: (ancestor: Node) => ancestor is T\n): T | null;\nfunction findLastAncestor(\n ancestors: Node[],\n predicate: (ancestor: Node) => boolean\n): Node | null;\nfunction findLastAncestor(\n ancestors: Node[],\n predicate: (ancestor: Node) => boolean\n): Node | null {\n for (let idx = ancestors.length - 1; idx >= 0; idx -= 1) {\n const ancestor = ancestors[idx];\n if (predicate(ancestor)) {\n return ancestor;\n }\n }\n\n return null;\n}\n\nconst findRemovableOwner = (node: Node, ancestors: Node[]): Node => {\n let owner: Node = node;\n let ownerAncestorIndex = -1;\n\n if (!removableOwnerTypes.has(node.type)) {\n for (let idx = ancestors.length - 1; idx >= 0; idx -= 1) {\n const ancestor = ancestors[idx];\n if (removableOwnerTypes.has(ancestor.type)) {\n owner = ancestor;\n ownerAncestorIndex = idx;\n break;\n }\n }\n }\n\n const parent =\n ownerAncestorIndex > 0 ? ancestors[ownerAncestorIndex - 1] : null;\n if (\n parent?.type === 'ExportNamedDeclaration' &&\n 'declaration' in parent &&\n parent.declaration === owner\n ) {\n return parent;\n }\n\n return owner;\n};\n\ntype ExportedBindingProtection = {\n start: number;\n end: number;\n value: string;\n};\n\nconst collectReExportedLocalNames = (program: Program): Set<string> => {\n const names = new Set<string>();\n for (const stmt of program.body) {\n if (\n stmt.type !== 'ExportNamedDeclaration' ||\n stmt.declaration ||\n stmt.source\n ) {\n continue;\n }\n for (const spec of stmt.specifiers) {\n if (spec.type === 'ExportSpecifier' && spec.local.type === 'Identifier') {\n names.add(spec.local.name);\n }\n }\n }\n return names;\n};\n\n// When an offending identifier sits inside the value of a top-level export,\n// removing the surrounding declaration would strip the export binding too.\n// ESM linker then fails on consumers' `import { name } from '...'` because the\n// named export no longer exists. To keep the binding alive, replace just the\n// value (declarator init or default-export expression) with `undefined`.\nconst findExportedBindingProtection = (\n node: Node,\n ancestors: Node[],\n reExportedLocalNames: Set<string>\n): ExportedBindingProtection | null => {\n for (let idx = ancestors.length - 1; idx >= 0; idx -= 1) {\n const ancestor = ancestors[idx];\n\n if (ancestor.type === 'ExportDefaultDeclaration') {\n const decl = ancestor.declaration;\n if (decl && decl !== node && 'start' in decl && 'end' in decl) {\n return { start: decl.start, end: decl.end, value: 'undefined' };\n }\n return null;\n }\n\n if (ancestor.type !== 'VariableDeclarator') {\n continue;\n }\n\n if (\n ancestor.id.type !== 'Identifier' ||\n !ancestor.init ||\n ancestor.init === node\n ) {\n return null;\n }\n\n const varDecl = ancestors[idx - 1];\n const wrapper = ancestors[idx - 2] ?? null;\n\n if (varDecl?.type !== 'VariableDeclaration') {\n return null;\n }\n\n const isDirectExport =\n wrapper?.type === 'ExportNamedDeclaration' &&\n wrapper.declaration === varDecl;\n const isTopLevelDeclaration =\n wrapper === null || wrapper?.type === 'Program';\n const isReExported =\n isTopLevelDeclaration && reExportedLocalNames.has(ancestor.id.name);\n\n if (!isDirectExport && !isReExported) {\n return null;\n }\n\n return {\n start: ancestor.init.start,\n end: ancestor.init.end,\n value: 'undefined',\n };\n }\n\n return null;\n};\n\nconst findPromiseCallbackOwner = (ancestors: Node[]): Node | null => {\n for (let idx = ancestors.length - 1; idx >= 0; idx -= 1) {\n const ancestor = ancestors[idx];\n if (\n ancestor.type === 'NewExpression' &&\n ancestor.callee.type === 'Identifier' &&\n ancestor.callee.name === 'Promise'\n ) {\n return ancestor;\n }\n\n if (\n ancestor.type === 'CallExpression' &&\n ancestor.callee.type === 'MemberExpression' &&\n promiseCallbackMethods.has(getMemberPropertyName(ancestor.callee) ?? '')\n ) {\n return ancestor;\n }\n }\n\n return null;\n};\n\nconst containsForbiddenIdentifier = (node: Node): boolean => {\n if (node.type === 'Identifier' && alwaysForbiddenIdentifiers.has(node.name)) {\n return true;\n }\n\n return getChildren(node).some(containsForbiddenIdentifier);\n};\n\nconst collectWindowScopedNames = (program: Program): Set<string> => {\n const windowScopedNames = new Set<string>();\n\n visit(program, createScope(null, 'root'), (node, scope) => {\n if (\n node.type !== 'MemberExpression' ||\n node.object.type !== 'Identifier' ||\n node.object.name !== 'window' ||\n hasBinding(scope, 'window')\n ) {\n return;\n }\n\n const propertyName = getMemberPropertyName(node);\n if (propertyName) {\n windowScopedNames.add(propertyName);\n }\n });\n\n return windowScopedNames;\n};\n\nconst containsForbiddenReference = (\n node: Node,\n scope: Scope,\n windowScopedNames: Set<string>,\n derivedForbiddenBindings: Set<string> = new Set()\n): boolean => {\n let found = false;\n\n visit(node, scope, (child, childScope, parent, ancestors) => {\n if (\n found ||\n child.type !== 'Identifier' ||\n isTypeContext(ancestors) ||\n isInsideTypeof(ancestors) ||\n isPropertyOnlyIdentifier(child, parent) ||\n isBindingPosition(child, parent)\n ) {\n return;\n }\n\n const bindingKey = getBindingKey(childScope, child.name);\n if (\n alwaysForbiddenIdentifiers.has(child.name) ||\n (forbiddenGlobals.has(child.name) &&\n !hasBinding(childScope, child.name)) ||\n (windowScopedNames.has(child.name) &&\n !hasBinding(childScope, child.name)) ||\n (bindingKey !== null && derivedForbiddenBindings.has(bindingKey))\n ) {\n found = true;\n }\n });\n\n return found;\n};\n\nconst nameFromModuleExport = (node: Node): string | null => {\n if (node.type === 'Identifier') {\n return node.name;\n }\n\n if (node.type === 'Literal' && typeof node.value === 'string') {\n return node.value;\n }\n\n return null;\n};\n\nconst collectImportBindings = (\n code: string,\n filename: string,\n program: Program\n): ImportBinding[] => {\n const bindings = new Map<string, ImportBinding>();\n const addBinding = (binding: ImportBinding): void => {\n bindings.set(\n `${binding.local}\\0${binding.source}\\0${binding.imported}`,\n binding\n );\n };\n\n program.body.forEach((statement) => {\n if (statement.type !== 'ImportDeclaration') {\n return;\n }\n\n const source = statement.source.value;\n statement.specifiers.forEach((specifier) => {\n if (specifier.type === 'ImportDefaultSpecifier') {\n addBinding({\n imported: 'default',\n local: specifier.local.name,\n source,\n });\n return;\n }\n\n if (specifier.type === 'ImportNamespaceSpecifier') {\n addBinding({\n imported: '*',\n local: specifier.local.name,\n source,\n });\n return;\n }\n\n const imported = nameFromModuleExport(specifier.imported);\n if (!imported) {\n return;\n }\n\n addBinding({\n imported,\n local: specifier.local.name,\n source,\n });\n });\n });\n\n if (!requireCallRe.test(code)) {\n return [...bindings.values()];\n }\n\n collectOxcExportsAndImports(code, filename).imports.forEach((item) => {\n if (item.imported === 'side-effect') {\n return;\n }\n\n addBinding({\n imported: item.imported,\n local: item.local.code,\n source: item.source,\n });\n\n if (item.local.name && item.local.name !== item.local.code) {\n addBinding({\n imported: item.imported,\n local: item.local.name,\n source: item.source,\n });\n }\n });\n\n return [...bindings.values()];\n};\n\nconst getImportBinding = (\n imports: ImportBinding[],\n local: string\n): ImportBinding | undefined => imports.find((item) => item.local === local);\n\nfunction unwrapSequenceCallee(node: Expression): Expression {\n if (\n node.type === 'SequenceExpression' &&\n node.expressions.length === 2 &&\n node.expressions[0]?.type === 'Literal' &&\n node.expressions[0].value === 0\n ) {\n return node.expressions[1] as Expression;\n }\n\n return node;\n}\n\nconst getExpressionImportKey = (node: Expression): string | null => {\n const expression = unwrapSequenceCallee(node);\n\n if (expression.type === 'Identifier') {\n return expression.name;\n }\n\n if (expression.type !== 'MemberExpression') {\n return null;\n }\n\n if (expression.object.type !== 'Identifier') {\n return null;\n }\n\n const propertyName = getMemberPropertyName(expression);\n return propertyName ? `${expression.object.name}.${propertyName}` : null;\n};\n\nconst isHookOrCreateElement = (name: string): boolean =>\n name === 'createElement' || /use[A-Z]/.test(name);\n\nconst getInnermostCallee = (call: CallExpression): Expression => {\n let callee = unwrapSequenceCallee(call.callee);\n while (callee.type === 'CallExpression') {\n callee = unwrapSequenceCallee(callee.callee);\n }\n\n return callee;\n};\n\nconst getImportForExpression = (\n node: Expression,\n imports: ImportBinding[]\n): [source: string, imported: string] | undefined => {\n const expression = unwrapSequenceCallee(node);\n const directMatchKey = getExpressionImportKey(expression);\n if (directMatchKey) {\n const directMatch = getImportBinding(imports, directMatchKey);\n if (directMatch) {\n return [directMatch.source, directMatch.imported];\n }\n }\n\n if (expression.type === 'Identifier') {\n const matched = getImportBinding(imports, expression.name);\n return matched ? [matched.source, matched.imported] : undefined;\n }\n\n if (expression.type !== 'MemberExpression') {\n return undefined;\n }\n\n if (expression.object.type !== 'Identifier') {\n return undefined;\n }\n\n const propertyName = getMemberPropertyName(expression);\n if (!propertyName) {\n return undefined;\n }\n\n const objectImport = getImportBinding(imports, expression.object.name);\n if (!objectImport) {\n return undefined;\n }\n\n if (\n objectImport.imported === 'default' ||\n objectImport.imported === '*' ||\n objectImport.source === 'react'\n ) {\n return [objectImport.source, propertyName];\n }\n\n return undefined;\n};\n\nconst isReactRuntimeCall = (\n call: CallExpression,\n imports: ImportBinding[]\n): boolean => {\n const callee = unwrapSequenceCallee(call.callee);\n const matched = getImportForExpression(callee, imports);\n if (!matched) {\n return false;\n }\n\n const [source, imported] = matched;\n if (jsxRuntimeSources.has(source)) {\n return true;\n }\n\n return source === 'react' && isHookOrCreateElement(imported);\n};\n\nconst isHocCall = (\n call: CallExpression,\n hocs: Record<string, string[]>,\n imports: ImportBinding[]\n): boolean => {\n const matched = getImportForExpression(getInnermostCallee(call), imports);\n return !!matched && hocs[matched[0]]?.includes(matched[1]);\n};\n\nconst isInsideHocCall = (\n ancestors: Node[],\n hocs: Record<string, string[]>,\n imports: ImportBinding[]\n): boolean =>\n ancestors.some(\n (ancestor): ancestor is CallExpression =>\n ancestor.type === 'CallExpression' && isHocCall(ancestor, hocs, imports)\n );\n\nconst getComponentTypes = (\n options?: CodeRemoverOptions\n): Record<string, string[]> => {\n const componentTypes = {\n ...(options?.componentTypes ?? { react: [defaultPlaceholder] }),\n };\n const reactTypes = componentTypes.react;\n\n if (Array.isArray(reactTypes) && reactTypes.includes(defaultPlaceholder)) {\n const idx = reactTypes.indexOf(defaultPlaceholder);\n componentTypes.react = [...reactTypes];\n componentTypes.react.splice(idx, 1, ...defaultReactComponentTypes);\n }\n\n return componentTypes;\n};\n\nconst getHocs = (options?: CodeRemoverOptions): Record<string, string[]> => {\n const hocs = {\n ...(options?.hocs ?? {}),\n };\n const reactHocs = new Set([...defaultReactHocs, ...(hocs.react ?? [])]);\n\n hocs.react = [...reactHocs];\n return hocs;\n};\n\nconst getTypeImport = (\n node: Node,\n imports: ImportBinding[]\n): [source: string, imported: string] | undefined => {\n if (node.type === 'Identifier') {\n const matched = getImportBinding(imports, node.name);\n return matched ? [matched.source, matched.imported] : undefined;\n }\n\n if (node.type !== 'TSQualifiedName') {\n return undefined;\n }\n\n if (node.left.type !== 'Identifier') {\n return undefined;\n }\n\n const matched = getImportBinding(imports, node.left.name);\n return matched ? [matched.source, node.right.name] : undefined;\n};\n\nconst isComponentTypeMatch = (\n id: Node,\n componentTypes: Record<string, string[]>,\n imports: ImportBinding[]\n): boolean => {\n if (id.type !== 'Identifier') {\n return false;\n }\n\n const annotation = id.typeAnnotation;\n if (\n !annotation ||\n annotation.type !== 'TSTypeAnnotation' ||\n annotation.typeAnnotation.type !== 'TSTypeReference'\n ) {\n return false;\n }\n\n const matched = getTypeImport(annotation.typeAnnotation.typeName, imports);\n return !!matched && componentTypes[matched[0]]?.includes(matched[1]);\n};\n\nconst getClassName = (node: Node): string | null =>\n node.type === 'ClassDeclaration' && node.id ? node.id.name : null;\n\nconst isFunctionLikeNode = (node: Node): node is OxcFunctionLikeNode =>\n node.type === 'FunctionDeclaration' ||\n node.type === 'FunctionExpression' ||\n node.type === 'ArrowFunctionExpression';\n\nconst isImmediatelyInvokedFunction = (\n fnNode: Node,\n ancestors: Node[],\n fnIndex: number\n): boolean => {\n // Walk past any ParenthesizedExpression / SequenceExpression wrappers that\n // sit between the function and its enclosing CallExpression. oxc-parser\n // preserves ParenthesizedExpression nodes, so `(() => {...})()` shows up\n // as CallExpression -> ParenthesizedExpression -> ArrowFunctionExpression.\n let child: Node = fnNode;\n for (let idx = fnIndex - 1; idx >= 0; idx -= 1) {\n const ancestor = ancestors[idx];\n if (\n ancestor.type === 'ParenthesizedExpression' &&\n 'expression' in ancestor &&\n ancestor.expression === child\n ) {\n child = ancestor;\n continue;\n }\n if (\n ancestor.type === 'SequenceExpression' &&\n Array.isArray(ancestor.expressions) &&\n ancestor.expressions[ancestor.expressions.length - 1] === child\n ) {\n child = ancestor;\n continue;\n }\n return ancestor.type === 'CallExpression' && ancestor.callee === child;\n }\n return false;\n};\n\n// A reference is \"deferred\" when it lives inside a function body that is\n// not immediately invoked. Module preeval reads exports without calling\n// them, so deferred references never run and must not be sanitized — that\n// would silently drop the binding (or remove the entire export) and break\n// importers that expect the function to be callable.\nconst isInDeferredFunctionScope = (ancestors: Node[]): boolean => {\n for (let idx = ancestors.length - 1; idx >= 0; idx -= 1) {\n const ancestor = ancestors[idx];\n if (!isFunctionLikeNode(ancestor)) {\n continue;\n }\n if (!isImmediatelyInvokedFunction(ancestor, ancestors, idx)) {\n return true;\n }\n }\n return false;\n};\n\nconst findFunctionReplacement = (ancestors: Node[]): Replacement | null => {\n const renderMethod = findLastAncestor(\n ancestors,\n (ancestor) =>\n ancestor.type === 'MethodDefinition' &&\n ancestor.key.type === 'Identifier' &&\n ancestor.key.name === 'render'\n );\n\n if (renderMethod) {\n const classDecl = findLastAncestor(\n ancestors,\n (ancestor) => ancestor.type === 'ClassDeclaration'\n );\n const className = classDecl ? getClassName(classDecl) : null;\n if (classDecl && className) {\n return {\n start: classDecl.start,\n end: classDecl.end,\n value: `function ${className}() { return null; }`,\n };\n }\n }\n\n const functionNode = findLastAncestor(ancestors, isFunctionLikeNode);\n\n if (!functionNode) {\n return null;\n }\n\n if (functionNode.type === 'ArrowFunctionExpression') {\n return {\n start: functionNode.start,\n end: functionNode.end,\n value: `${functionNode.async ? 'async ' : ''}() => { return null; }`,\n };\n }\n\n if (functionNode.type === 'FunctionDeclaration') {\n return {\n start: functionNode.start,\n end: functionNode.end,\n value: `${functionNode.async ? 'async ' : ''}function ${\n functionNode.id?.name ?? ''\n }() { return null; }`,\n };\n }\n\n return {\n start: functionNode.body.start,\n end: functionNode.body.end,\n value: '{ return null; }',\n };\n};\n\nconst normalizeReplacements = (replacements: Replacement[]): Replacement[] => {\n const sorted = [...replacements].sort((a, b) =>\n a.start === b.start ? b.end - a.end : a.start - b.start\n );\n const result: Replacement[] = [];\n\n sorted.forEach((replacement) => {\n const last = result[result.length - 1];\n if (\n last &&\n replacement.start >= last.start &&\n replacement.end <= last.end\n ) {\n return;\n }\n\n result.push(replacement);\n });\n\n return result;\n};\n\nexport const removeDangerousCodeWithOxc = (\n code: string,\n filename: string,\n options?: CodeRemoverOptions\n): string => {\n const replacements: Replacement[] = [];\n const derivedForbiddenBindings = new Set<string>();\n const program = parseOxc(code, filename);\n const imports = collectImportBindings(code, filename, program);\n const componentTypes = getComponentTypes(options);\n const hocs = getHocs(options);\n const hasHocs = Object.keys(hocs).length > 0;\n const windowScopedNames = windowTokenRe.test(code)\n ? collectWindowScopedNames(program)\n : new Set<string>();\n const reExportedLocalNames = collectReExportedLocalNames(program);\n\n const derivedBindingDiscovery = { found: true };\n while (derivedBindingDiscovery.found) {\n derivedBindingDiscovery.found = false;\n\n visit(program, createScope(null, 'root'), (node, scope) => {\n if (\n node.type !== 'VariableDeclarator' ||\n node.id.type !== 'Identifier' ||\n !node.init\n ) {\n return;\n }\n\n const bindingKey = getBindingKey(scope, node.id.name);\n if (!bindingKey || derivedForbiddenBindings.has(bindingKey)) {\n return;\n }\n\n if (\n containsForbiddenIdentifier(node.init) ||\n containsForbiddenReference(\n node.init,\n scope,\n windowScopedNames,\n derivedForbiddenBindings\n )\n ) {\n derivedForbiddenBindings.add(bindingKey);\n derivedBindingDiscovery.found = true;\n }\n });\n }\n\n visit(\n program,\n createScope(null, 'root'),\n (node, scope, parent, ancestors) => {\n if (node.type === 'JSXElement' || node.type === 'JSXFragment') {\n replacements.push(\n findFunctionReplacement(ancestors) ?? {\n start: node.start,\n end: node.end,\n value: 'null',\n }\n );\n return;\n }\n\n if (node.type === 'CallExpression') {\n if (isReactRuntimeCall(node, imports)) {\n const replacement = findFunctionReplacement(ancestors);\n if (replacement) {\n replacements.push(replacement);\n }\n\n return;\n }\n\n if (hasHocs && isHocCall(node, hocs, imports)) {\n replacements.push({\n start: node.start,\n end: node.end,\n value: '() => null',\n });\n return;\n }\n }\n\n if (\n node.type === 'VariableDeclarator' &&\n node.id.type === 'Identifier' &&\n node.init &&\n isComponentTypeMatch(node.id, componentTypes, imports)\n ) {\n replacements.push({\n start: node.init.start,\n end: node.init.end,\n value: '() => null',\n });\n return;\n }\n\n if (\n node.type === 'UnaryExpression' &&\n node.operator === 'typeof' &&\n node.argument.type === 'Identifier' &&\n ssrCheckFields.has(node.argument.name) &&\n !hasBinding(scope, node.argument.name)\n ) {\n replacements.push({\n start: node.start,\n end: node.end,\n value: '\"undefined\"',\n });\n return;\n }\n\n if (node.type === 'MetaProperty') {\n const owner = findRemovableOwner(node, ancestors);\n replacements.push({ start: owner.start, end: owner.end, value: '' });\n return;\n }\n\n if (\n node.type !== 'Identifier' ||\n isTypeContext(ancestors) ||\n isInsideTypeof(ancestors) ||\n isInsideImportDeclaration(ancestors)\n ) {\n return;\n }\n\n if (isPropertyOnlyIdentifier(node, parent)) {\n return;\n }\n\n const isAlwaysForbidden = alwaysForbiddenIdentifiers.has(node.name);\n const bindingKey = getBindingKey(scope, node.name);\n const isDerivedForbidden =\n bindingKey !== null && derivedForbiddenBindings.has(bindingKey);\n const isWindowScoped =\n windowScopedNames.has(node.name) && !hasBinding(scope, node.name);\n const isForbiddenGlobal =\n forbiddenGlobals.has(node.name) && !hasBinding(scope, node.name);\n\n if (\n !isAlwaysForbidden &&\n !isDerivedForbidden &&\n !isWindowScoped &&\n !isForbiddenGlobal\n ) {\n return;\n }\n\n if (!isAlwaysForbidden && isInDeferredFunctionScope(ancestors)) {\n return;\n }\n\n if (hasHocs && isInsideHocCall(ancestors, hocs, imports)) {\n return;\n }\n\n if (isBindingPosition(node, parent) && !isAlwaysForbidden) {\n return;\n }\n\n if (\n parent?.type === 'ExportDefaultDeclaration' &&\n parent.declaration === node\n ) {\n return;\n }\n\n if (\n generatedProcessorHelperNameRe.test(node.name) &&\n hasBinding(scope, node.name)\n ) {\n return;\n }\n\n const generatedHelperDeclarator = findLastAncestor(\n ancestors,\n (ancestor) =>\n ancestor.type === 'VariableDeclarator' &&\n ancestor.id.type === 'Identifier' &&\n generatedProcessorHelperNameRe.test(ancestor.id.name)\n );\n if (generatedHelperDeclarator) {\n return;\n }\n\n if (\n parent?.type === 'Property' &&\n parent.value === node &&\n hasBinding(scope, node.name)\n ) {\n return;\n }\n\n if (parent?.type === 'Property' && parent.value === node) {\n replacements.push({\n start: node.start,\n end: node.end,\n value: parent.shorthand ? `${node.name}: undefined` : 'undefined',\n });\n return;\n }\n\n const grandparent = ancestors[ancestors.length - 2] ?? null;\n if (\n parent?.type === 'MemberExpression' &&\n parent.object === node &&\n grandparent?.type === 'SpreadElement' &&\n grandparent.argument === parent\n ) {\n replacements.push({\n start: grandparent.start,\n end: grandparent.end,\n value: '...{}',\n });\n return;\n }\n\n const exportProtection = findExportedBindingProtection(\n node,\n ancestors,\n reExportedLocalNames\n );\n if (exportProtection) {\n replacements.push(exportProtection);\n return;\n }\n\n const promiseOwner = findPromiseCallbackOwner(ancestors);\n const owner = promiseOwner\n ? findRemovableOwner(promiseOwner, ancestors)\n : findRemovableOwner(node, ancestors);\n replacements.push({ start: owner.start, end: owner.end, value: '' });\n }\n );\n\n return applyReplacements(code, normalizeReplacements(replacements));\n};\n"],"file":"oxcPreevalTransforms.js"}
@@ -1,5 +1,10 @@
1
1
  import { parseSync } from "oxc-parser";
2
- const MAX_PARSE_CACHE_ENTRIES = 200;
2
+ // 200 evicts under sustained pressure on large monorepos — the
3
+ // removeUnusedAfterReplacement cleanup loop reparses on every iteration
4
+ // (new content -> new key) and applyOxcProcessors reparses after extraction.
5
+ // 1000 is still bounded (~50-100 MB worst case for an enormous build) and
6
+ // keeps every entry hot across the actions for a single file.
7
+ const MAX_PARSE_CACHE_ENTRIES = 1e3;
3
8
  const parseCache = new Map();
4
9
  const getAstType = (filename) => filename.endsWith(".ts") || filename.endsWith(".tsx") ? "ts" : "js";
5
10
  const makeCacheKey = (filename, code, sourceType) => `${sourceType}\0${filename}\0${code}`;
@@ -1 +1 @@
1
- {"mappings":"AAAA,SAAS,iBAAiB;AAY1B,MAAM,0BAA0B;AAChC,MAAM,aAAa,IAAI,KAAwB;AAE/C,MAAM,cAAc,aAClB,SAAS,SAAS,MAAM,IAAI,SAAS,SAAS,OAAO,GAAG,OAAO;AAEjE,MAAM,gBACJ,UACA,MACA,eACW,GAAG,WAAW,IAAI,SAAS,IAAI;AAE5C,MAAM,kBAAkB,KAAa,UAAgC;AACnE,YAAW,IAAI,KAAK,MAAM;AAC1B,KAAI,WAAW,OAAO,yBAAyB;EAC7C,MAAM,YAAY,WAAW,MAAM,CAAC,MAAM,CAAC;AAC3C,MAAI,WAAW;AACb,cAAW,OAAO,UAAU;;;AAIhC,QAAO;;AAGT,OAAO,MAAM,kBACX,UACA,MACA,eACc;CACd,MAAM,WAAW,aAAa,UAAU,MAAM,WAAW;CACzD,MAAM,SAAS,WAAW,IAAI,SAAS;AACvC,KAAI,QAAQ;AACV,SAAO;;CAGT,MAAM,SAAS,UAAU,UAAU,MAAM;EACvC,SAAS,WAAW,SAAS;EAC7B,OAAO;EACP;EACD,CAAC;CACF,MAAM,aAAa,OAAO,OAAO,MAAM,UAAU,MAAM,aAAa,QAAQ;AAC5E,KAAI,YAAY;AACd,QAAM,IAAI,MAAM,WAAW,QAAQ;;AAGrC,QAAO,eAAe,UAAU;EAC9B,QAAQ,EACN,iBAAiB,OAAO,OAAO,iBAChC;EACD,SAAS,OAAO;EACjB,CAAC;;AAGJ,OAAO,MAAM,yBACX,UACA,MACA,eACY,eAAe,UAAU,MAAM,WAAW,CAAC","names":[],"sources":["../../src/utils/parseOxc.ts"],"version":3,"sourcesContent":["import { parseSync } from 'oxc-parser';\nimport type { Program } from 'oxc-parser';\n\ntype OxcSourceType = 'module' | 'unambiguous';\n\ntype ParsedOxc = {\n module: {\n hasModuleSyntax: boolean;\n };\n program: Program;\n};\n\nconst MAX_PARSE_CACHE_ENTRIES = 200;\nconst parseCache = new Map<string, ParsedOxc>();\n\nconst getAstType = (filename: string): 'js' | 'ts' =>\n filename.endsWith('.ts') || filename.endsWith('.tsx') ? 'ts' : 'js';\n\nconst makeCacheKey = (\n filename: string,\n code: string,\n sourceType: OxcSourceType\n): string => `${sourceType}\\0${filename}\\0${code}`;\n\nconst setCachedParse = (key: string, value: ParsedOxc): ParsedOxc => {\n parseCache.set(key, value);\n if (parseCache.size > MAX_PARSE_CACHE_ENTRIES) {\n const oldestKey = parseCache.keys().next().value;\n if (oldestKey) {\n parseCache.delete(oldestKey);\n }\n }\n\n return value;\n};\n\nexport const parseOxcCached = (\n filename: string,\n code: string,\n sourceType: OxcSourceType\n): ParsedOxc => {\n const cacheKey = makeCacheKey(filename, code, sourceType);\n const cached = parseCache.get(cacheKey);\n if (cached) {\n return cached;\n }\n\n const parsed = parseSync(filename, code, {\n astType: getAstType(filename),\n range: true,\n sourceType,\n });\n const fatalError = parsed.errors.find((error) => error.severity === 'Error');\n if (fatalError) {\n throw new Error(fatalError.message);\n }\n\n return setCachedParse(cacheKey, {\n module: {\n hasModuleSyntax: parsed.module.hasModuleSyntax,\n },\n program: parsed.program as Program,\n });\n};\n\nexport const parseOxcProgramCached = (\n filename: string,\n code: string,\n sourceType: OxcSourceType\n): Program => parseOxcCached(filename, code, sourceType).program;\n"],"file":"parseOxc.js"}
1
+ {"mappings":"AAAA,SAAS,iBAAiB;;;;;;AAiB1B,MAAM,0BAA0B;AAChC,MAAM,aAAa,IAAI,KAAwB;AAE/C,MAAM,cAAc,aAClB,SAAS,SAAS,MAAM,IAAI,SAAS,SAAS,OAAO,GAAG,OAAO;AAEjE,MAAM,gBACJ,UACA,MACA,eACW,GAAG,WAAW,IAAI,SAAS,IAAI;AAE5C,MAAM,kBAAkB,KAAa,UAAgC;AACnE,YAAW,IAAI,KAAK,MAAM;AAC1B,KAAI,WAAW,OAAO,yBAAyB;EAC7C,MAAM,YAAY,WAAW,MAAM,CAAC,MAAM,CAAC;AAC3C,MAAI,WAAW;AACb,cAAW,OAAO,UAAU;;;AAIhC,QAAO;;AAGT,OAAO,MAAM,kBACX,UACA,MACA,eACc;CACd,MAAM,WAAW,aAAa,UAAU,MAAM,WAAW;CACzD,MAAM,SAAS,WAAW,IAAI,SAAS;AACvC,KAAI,QAAQ;AACV,SAAO;;CAGT,MAAM,SAAS,UAAU,UAAU,MAAM;EACvC,SAAS,WAAW,SAAS;EAC7B,OAAO;EACP;EACD,CAAC;CACF,MAAM,aAAa,OAAO,OAAO,MAAM,UAAU,MAAM,aAAa,QAAQ;AAC5E,KAAI,YAAY;AACd,QAAM,IAAI,MAAM,WAAW,QAAQ;;AAGrC,QAAO,eAAe,UAAU;EAC9B,QAAQ,EACN,iBAAiB,OAAO,OAAO,iBAChC;EACD,SAAS,OAAO;EACjB,CAAC;;AAGJ,OAAO,MAAM,yBACX,UACA,MACA,eACY,eAAe,UAAU,MAAM,WAAW,CAAC","names":[],"sources":["../../src/utils/parseOxc.ts"],"version":3,"sourcesContent":["import { parseSync } from 'oxc-parser';\nimport type { Program } from 'oxc-parser';\n\ntype OxcSourceType = 'module' | 'unambiguous';\n\ntype ParsedOxc = {\n module: {\n hasModuleSyntax: boolean;\n };\n program: Program;\n};\n\n// 200 evicts under sustained pressure on large monorepos — the\n// removeUnusedAfterReplacement cleanup loop reparses on every iteration\n// (new content -> new key) and applyOxcProcessors reparses after extraction.\n// 1000 is still bounded (~50-100 MB worst case for an enormous build) and\n// keeps every entry hot across the actions for a single file.\nconst MAX_PARSE_CACHE_ENTRIES = 1000;\nconst parseCache = new Map<string, ParsedOxc>();\n\nconst getAstType = (filename: string): 'js' | 'ts' =>\n filename.endsWith('.ts') || filename.endsWith('.tsx') ? 'ts' : 'js';\n\nconst makeCacheKey = (\n filename: string,\n code: string,\n sourceType: OxcSourceType\n): string => `${sourceType}\\0${filename}\\0${code}`;\n\nconst setCachedParse = (key: string, value: ParsedOxc): ParsedOxc => {\n parseCache.set(key, value);\n if (parseCache.size > MAX_PARSE_CACHE_ENTRIES) {\n const oldestKey = parseCache.keys().next().value;\n if (oldestKey) {\n parseCache.delete(oldestKey);\n }\n }\n\n return value;\n};\n\nexport const parseOxcCached = (\n filename: string,\n code: string,\n sourceType: OxcSourceType\n): ParsedOxc => {\n const cacheKey = makeCacheKey(filename, code, sourceType);\n const cached = parseCache.get(cacheKey);\n if (cached) {\n return cached;\n }\n\n const parsed = parseSync(filename, code, {\n astType: getAstType(filename),\n range: true,\n sourceType,\n });\n const fatalError = parsed.errors.find((error) => error.severity === 'Error');\n if (fatalError) {\n throw new Error(fatalError.message);\n }\n\n return setCachedParse(cacheKey, {\n module: {\n hasModuleSyntax: parsed.module.hasModuleSyntax,\n },\n program: parsed.program as Program,\n });\n};\n\nexport const parseOxcProgramCached = (\n filename: string,\n code: string,\n sourceType: OxcSourceType\n): Program => parseOxcCached(filename, code, sourceType).program;\n"],"file":"parseOxc.js"}
@@ -0,0 +1,157 @@
1
+ export const unknownProcessorStaticValue = Symbol("unknownProcessorStaticValue");
2
+ export const createProcessorStaticContext = (processor) => {
3
+ const processorWithInternals = processor;
4
+ return {
5
+ addDependency: () => {},
6
+ debug: () => {},
7
+ fileContext: processorWithInternals.context ?? {},
8
+ metadata: {
9
+ className: processor.className,
10
+ displayName: processor.displayName,
11
+ isReferenced: processor.isReferenced,
12
+ location: processor.location,
13
+ slug: processor.slug,
14
+ tagSource: processor.tagSource
15
+ },
16
+ options: processorWithInternals.options ?? {},
17
+ unresolved: (reason, details) => ({
18
+ ...details ? { details } : {},
19
+ kind: "unresolved",
20
+ reason
21
+ })
22
+ };
23
+ };
24
+ export const isProcessorStaticValue = (value) => {
25
+ if (typeof value !== "object" || value === null || !("kind" in value)) {
26
+ return false;
27
+ }
28
+ const candidate = value;
29
+ switch (candidate.kind) {
30
+ case "class-name": return typeof candidate.className === "string";
31
+ case "opaque-component": return candidate.className === undefined || typeof candidate.className === "string";
32
+ case "runtime-callback":
33
+ case "serializable": return true;
34
+ case "selector-chain": return typeof candidate.className === "string" && Array.isArray(candidate.selectors) && candidate.selectors.every((selector) => typeof selector === "string");
35
+ case "unresolved": return typeof candidate.reason === "string";
36
+ default: return false;
37
+ }
38
+ };
39
+ export const getProcessorStaticValue = (processor) => {
40
+ if (!processor.getStaticValue) {
41
+ return null;
42
+ }
43
+ try {
44
+ const value = processor.getStaticValue(createProcessorStaticContext(processor));
45
+ return isProcessorStaticValue(value) ? value : null;
46
+ } catch {
47
+ return null;
48
+ }
49
+ };
50
+ export const processorStaticValueToRuntimeValue = (value) => {
51
+ switch (value.kind) {
52
+ case "class-name": return value.value === undefined ? value.className : value.value;
53
+ case "opaque-component":
54
+ case "runtime-callback": return value.value === undefined ? unknownProcessorStaticValue : value.value;
55
+ case "selector-chain":
56
+ case "serializable": return value.value;
57
+ case "unresolved": return unknownProcessorStaticValue;
58
+ default: return unknownProcessorStaticValue;
59
+ }
60
+ };
61
+ export const resolveProcessorStaticRuntimeValue = (processor) => {
62
+ const staticValue = getProcessorStaticValue(processor);
63
+ return staticValue ? processorStaticValueToRuntimeValue(staticValue) : unknownProcessorStaticValue;
64
+ };
65
+ export const resolveProcessorStaticClassName = (processor) => {
66
+ const staticValue = getProcessorStaticValue(processor);
67
+ if (staticValue?.kind !== "class-name") {
68
+ return null;
69
+ }
70
+ const runtimeValue = processorStaticValueToRuntimeValue(staticValue);
71
+ return typeof runtimeValue === "string" ? runtimeValue : staticValue.className;
72
+ };
73
+ export const processorLiteralValue = (expression) => {
74
+ const expressionWithValue = expression;
75
+ if (expression.type === "StringLiteral" || expression.type === "NumericLiteral" || expression.type === "BooleanLiteral" || expression.type === "Literal") {
76
+ return expressionWithValue.value;
77
+ }
78
+ if (expression.type === "NullLiteral") {
79
+ return null;
80
+ }
81
+ return unknownProcessorStaticValue;
82
+ };
83
+ export const processorPropertyKeyName = (key) => {
84
+ if (key.type === "Identifier") {
85
+ return key.name;
86
+ }
87
+ const value = processorLiteralValue(key);
88
+ return typeof value === "string" ? value : null;
89
+ };
90
+ export const processorObjectPropertyValue = (expression, name) => {
91
+ if (expression.type !== "ObjectExpression") {
92
+ return null;
93
+ }
94
+ const { properties } = expression;
95
+ if (!properties) {
96
+ return null;
97
+ }
98
+ for (const property of properties) {
99
+ if ((property.type === "ObjectProperty" || property.type === "Property") && property.key && processorPropertyKeyName(property.key) === name) {
100
+ return property.value ?? null;
101
+ }
102
+ }
103
+ return null;
104
+ };
105
+ export const processorExpressionToStaticValue = (expression, resolveHelperCall) => {
106
+ const literal = processorLiteralValue(expression);
107
+ if (literal !== unknownProcessorStaticValue) {
108
+ return literal;
109
+ }
110
+ if (expression.type === "ArrayExpression") {
111
+ const { elements } = expression;
112
+ if (!elements) {
113
+ return unknownProcessorStaticValue;
114
+ }
115
+ const result = [];
116
+ for (const element of elements) {
117
+ if (element === null) {
118
+ result.push(null);
119
+ } else {
120
+ const value = processorExpressionToStaticValue(element, resolveHelperCall);
121
+ if (value === unknownProcessorStaticValue) {
122
+ return unknownProcessorStaticValue;
123
+ }
124
+ result.push(value);
125
+ }
126
+ }
127
+ return result;
128
+ }
129
+ if (expression.type === "ObjectExpression") {
130
+ const metaExpression = processorObjectPropertyValue(expression, "__wyw_meta");
131
+ if (!metaExpression || metaExpression.type !== "ObjectExpression") {
132
+ return unknownProcessorStaticValue;
133
+ }
134
+ const classNameExpression = processorObjectPropertyValue(metaExpression, "className");
135
+ const className = classNameExpression ? processorLiteralValue(classNameExpression) : unknownProcessorStaticValue;
136
+ if (typeof className !== "string") {
137
+ return unknownProcessorStaticValue;
138
+ }
139
+ const extendsExpression = processorObjectPropertyValue(metaExpression, "extends");
140
+ const extended = extendsExpression ? processorExpressionToStaticValue(extendsExpression, resolveHelperCall) : null;
141
+ if (extended === unknownProcessorStaticValue) {
142
+ return unknownProcessorStaticValue;
143
+ }
144
+ return { __wyw_meta: {
145
+ className,
146
+ extends: extended
147
+ } };
148
+ }
149
+ if (expression.type === "CallExpression") {
150
+ const call = expression;
151
+ if (call.arguments?.length === 0 && call.callee?.type === "Identifier") {
152
+ return resolveHelperCall(call.callee.name);
153
+ }
154
+ }
155
+ return unknownProcessorStaticValue;
156
+ };
157
+ //# sourceMappingURL=processorStaticSemantics.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAOA,OAAO,MAAM,8BAA8B,OACzC,8BACD;AASD,OAAO,MAAM,gCACX,cAC2B;CAC3B,MAAM,yBAAyB;AAE/B,QAAO;EACL,qBAAqB;EACrB,aAAa;EACb,aACE,uBAAuB,WACtB,EAAE;EACL,UAAU;GACR,WAAW,UAAU;GACrB,aAAa,UAAU;GACvB,cAAc,UAAU;GACxB,UAAU,UAAU;GACpB,MAAM,UAAU;GAChB,WAAW,UAAU;GACtB;EACD,SACE,uBAAuB,WACtB,EAAE;EACL,aAAa,QAAQ,aAAa;GAChC,GAAI,UAAU,EAAE,SAAS,GAAG,EAAE;GAC9B,MAAM;GACN;GACD;EACF;;AAGH,OAAO,MAAM,0BACX,UACkC;AAClC,KAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,EAAE,UAAU,QAAQ;AACrE,SAAO;;CAGT,MAAM,YAAY;AAClB,SAAQ,UAAU,MAAlB;EACE,KAAK,aACH,QAAO,OAAO,UAAU,cAAc;EACxC,KAAK,mBACH,QACE,UAAU,cAAc,aACxB,OAAO,UAAU,cAAc;EAEnC,KAAK;EACL,KAAK,eACH,QAAO;EACT,KAAK,iBACH,QACE,OAAO,UAAU,cAAc,YAC/B,MAAM,QAAQ,UAAU,UAAU,IAClC,UAAU,UAAU,OAAO,aAAa,OAAO,aAAa,SAAS;EAEzE,KAAK,aACH,QAAO,OAAO,UAAU,WAAW;EACrC,QACE,QAAO;;;AAIb,OAAO,MAAM,2BACX,cACgC;AAChC,KAAI,CAAC,UAAU,gBAAgB;AAC7B,SAAO;;AAGT,KAAI;EACF,MAAM,QAAQ,UAAU,eACtB,6BAA6B,UAAU,CACxC;AACD,SAAO,uBAAuB,MAAM,GAAG,QAAQ;SACzC;AACN,SAAO;;;AAIX,OAAO,MAAM,sCACX,UAC0C;AAC1C,S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;CAC1C,MAAM,UAAU,sBAAsB,WAAW;AACjD,KAAI,YAAY,6BAA6B;AAC3C,SAAO;;AAGT,KAAI,WAAW,SAAS,mBAAmB;EACzC,MAAM,EAAE,aAAa;AAGrB,MAAI,CAAC,UAAU;AACb,UAAO;;EAGT,MAAM,SAAoB,EAAE;AAC5B,OAAK,MAAM,WAAW,UAAU;AAC9B,OAAI,YAAY,MAAM;AACpB,WAAO,KAAK,KAAK;UACZ;IACL,MAAM,QAAQ,iCACZ,SACA,kBACD;AACD,QAAI,UAAU,6BAA6B;AACzC,YAAO;;AAGT,WAAO,KAAK,MAAM;;;AAItB,SAAO;;AAGT,KAAI,WAAW,SAAS,oBAAoB;EAC1C,MAAM,iBAAiB,6BACrB,YACA,aACD;AACD,MAAI,CAAC,kBAAkB,eAAe,SAAS,oBAAoB;AACjE,UAAO;;EAGT,MAAM,sBAAsB,6BAC1B,gBACA,YACD;EACD,MAAM,YAAY,sBACd,sBAAsB,oBAAoB,GAC1C;AACJ,MAAI,OAAO,cAAc,UAAU;AACjC,UAAO;;EAGT,MAAM,oBAAoB,6BACxB,gBACA,UACD;EACD,MAAM,WAAW,oBACb,iCAAiC,mBAAmB,kBAAkB,GACtE;AACJ,MAAI,aAAa,6BAA6B;AAC5C,UAAO;;AAGT,SAAO,EACL,YAAY;GACV;GACA,SAAS;GACV,EACF;;AAGH,KAAI,WAAW,SAAS,kBAAkB;EACxC,MAAM,OAAO;AAIb,MAAI,KAAK,WAAW,WAAW,KAAK,KAAK,QAAQ,SAAS,cAAc;AACtE,UAAO,kBACJ,KAAK,OAAkD,KACzD;;;AAIL,QAAO","names":[],"sources":["../../src/utils/processorStaticSemantics.ts"],"version":3,"sourcesContent":["import type {\n BaseProcessor,\n Expression as ProcessorExpression,\n ProcessorStaticContext,\n ProcessorStaticValue,\n} from '@wyw-in-js/processor-utils';\n\nexport const unknownProcessorStaticValue = Symbol(\n 'unknownProcessorStaticValue'\n);\n\nexport type UnknownProcessorStaticValue = typeof unknownProcessorStaticValue;\n\ntype ProcessorWithStaticInternals = BaseProcessor & {\n context?: ProcessorStaticContext['fileContext'];\n options?: ProcessorStaticContext['options'];\n};\n\nexport const createProcessorStaticContext = (\n processor: BaseProcessor\n): ProcessorStaticContext => {\n const processorWithInternals = processor as ProcessorWithStaticInternals;\n\n return {\n addDependency: () => {},\n debug: () => {},\n fileContext:\n processorWithInternals.context ??\n ({} as ProcessorStaticContext['fileContext']),\n metadata: {\n className: processor.className,\n displayName: processor.displayName,\n isReferenced: processor.isReferenced,\n location: processor.location,\n slug: processor.slug,\n tagSource: processor.tagSource,\n },\n options:\n processorWithInternals.options ??\n ({} as ProcessorStaticContext['options']),\n unresolved: (reason, details) => ({\n ...(details ? { details } : {}),\n kind: 'unresolved',\n reason,\n }),\n };\n};\n\nexport const isProcessorStaticValue = (\n value: unknown\n): value is ProcessorStaticValue => {\n if (typeof value !== 'object' || value === null || !('kind' in value)) {\n return false;\n }\n\n const candidate = value as ProcessorStaticValue;\n switch (candidate.kind) {\n case 'class-name':\n return typeof candidate.className === 'string';\n case 'opaque-component':\n return (\n candidate.className === undefined ||\n typeof candidate.className === 'string'\n );\n case 'runtime-callback':\n case 'serializable':\n return true;\n case 'selector-chain':\n return (\n typeof candidate.className === 'string' &&\n Array.isArray(candidate.selectors) &&\n candidate.selectors.every((selector) => typeof selector === 'string')\n );\n case 'unresolved':\n return typeof candidate.reason === 'string';\n default:\n return false;\n }\n};\n\nexport const getProcessorStaticValue = (\n processor: BaseProcessor\n): ProcessorStaticValue | null => {\n if (!processor.getStaticValue) {\n return null;\n }\n\n try {\n const value = processor.getStaticValue(\n createProcessorStaticContext(processor)\n );\n return isProcessorStaticValue(value) ? value : null;\n } catch {\n return null;\n }\n};\n\nexport const processorStaticValueToRuntimeValue = (\n value: ProcessorStaticValue\n): unknown | UnknownProcessorStaticValue => {\n switch (value.kind) {\n case 'class-name':\n return value.value === undefined ? value.className : value.value;\n case 'opaque-component':\n case 'runtime-callback':\n return value.value === undefined\n ? unknownProcessorStaticValue\n : value.value;\n case 'selector-chain':\n case 'serializable':\n return value.value;\n case 'unresolved':\n return unknownProcessorStaticValue;\n default:\n return unknownProcessorStaticValue;\n }\n};\n\nexport const resolveProcessorStaticRuntimeValue = (\n processor: BaseProcessor\n): unknown | UnknownProcessorStaticValue => {\n const staticValue = getProcessorStaticValue(processor);\n return staticValue\n ? processorStaticValueToRuntimeValue(staticValue)\n : unknownProcessorStaticValue;\n};\n\nexport const resolveProcessorStaticClassName = (\n processor: BaseProcessor\n): string | null => {\n const staticValue = getProcessorStaticValue(processor);\n if (staticValue?.kind !== 'class-name') {\n return null;\n }\n\n const runtimeValue = processorStaticValueToRuntimeValue(staticValue);\n return typeof runtimeValue === 'string'\n ? runtimeValue\n : staticValue.className;\n};\n\nexport const processorLiteralValue = (\n expression: ProcessorExpression\n): unknown | UnknownProcessorStaticValue => {\n const expressionWithValue = expression as ProcessorExpression & {\n value?: unknown;\n };\n\n if (\n expression.type === 'StringLiteral' ||\n expression.type === 'NumericLiteral' ||\n expression.type === 'BooleanLiteral' ||\n expression.type === 'Literal'\n ) {\n return expressionWithValue.value;\n }\n\n if (expression.type === 'NullLiteral') {\n return null;\n }\n\n return unknownProcessorStaticValue;\n};\n\nexport const processorPropertyKeyName = (\n key: ProcessorExpression\n): string | null => {\n if (key.type === 'Identifier') {\n return (key as ProcessorExpression & { name: string }).name;\n }\n\n const value = processorLiteralValue(key);\n return typeof value === 'string' ? value : null;\n};\n\nexport const processorObjectPropertyValue = (\n expression: ProcessorExpression,\n name: string\n): ProcessorExpression | null => {\n if (expression.type !== 'ObjectExpression') {\n return null;\n }\n\n const { properties } = expression as ProcessorExpression & {\n properties?: Array<\n ProcessorExpression & {\n key?: ProcessorExpression;\n type: string;\n value?: ProcessorExpression;\n }\n >;\n };\n if (!properties) {\n return null;\n }\n\n for (const property of properties) {\n if (\n (property.type === 'ObjectProperty' || property.type === 'Property') &&\n property.key &&\n processorPropertyKeyName(property.key) === name\n ) {\n return property.value ?? null;\n }\n }\n\n return null;\n};\n\nexport const processorExpressionToStaticValue = (\n expression: ProcessorExpression,\n resolveHelperCall: (name: string) => unknown | UnknownProcessorStaticValue\n): unknown | UnknownProcessorStaticValue => {\n const literal = processorLiteralValue(expression);\n if (literal !== unknownProcessorStaticValue) {\n return literal;\n }\n\n if (expression.type === 'ArrayExpression') {\n const { elements } = expression as ProcessorExpression & {\n elements?: Array<ProcessorExpression | null>;\n };\n if (!elements) {\n return unknownProcessorStaticValue;\n }\n\n const result: unknown[] = [];\n for (const element of elements) {\n if (element === null) {\n result.push(null);\n } else {\n const value = processorExpressionToStaticValue(\n element,\n resolveHelperCall\n );\n if (value === unknownProcessorStaticValue) {\n return unknownProcessorStaticValue;\n }\n\n result.push(value);\n }\n }\n\n return result;\n }\n\n if (expression.type === 'ObjectExpression') {\n const metaExpression = processorObjectPropertyValue(\n expression,\n '__wyw_meta'\n );\n if (!metaExpression || metaExpression.type !== 'ObjectExpression') {\n return unknownProcessorStaticValue;\n }\n\n const classNameExpression = processorObjectPropertyValue(\n metaExpression,\n 'className'\n );\n const className = classNameExpression\n ? processorLiteralValue(classNameExpression)\n : unknownProcessorStaticValue;\n if (typeof className !== 'string') {\n return unknownProcessorStaticValue;\n }\n\n const extendsExpression = processorObjectPropertyValue(\n metaExpression,\n 'extends'\n );\n const extended = extendsExpression\n ? processorExpressionToStaticValue(extendsExpression, resolveHelperCall)\n : null;\n if (extended === unknownProcessorStaticValue) {\n return unknownProcessorStaticValue;\n }\n\n return {\n __wyw_meta: {\n className,\n extends: extended,\n },\n };\n }\n\n if (expression.type === 'CallExpression') {\n const call = expression as ProcessorExpression & {\n arguments?: ProcessorExpression[];\n callee?: ProcessorExpression;\n };\n if (call.arguments?.length === 0 && call.callee?.type === 'Identifier') {\n return resolveHelperCall(\n (call.callee as ProcessorExpression & { name: string }).name\n );\n }\n }\n\n return unknownProcessorStaticValue;\n};\n"],"file":"processorStaticSemantics.js"}
@@ -53,7 +53,7 @@ const resolveWithNodeProcess = (id, parent, conditions) => {
53
53
  parsed = JSON.parse(stdout);
54
54
  } catch {
55
55
  throw new Error([
56
- "[wyw-in-js] Failed to parse Node resolver fallback output.",
56
+ "[wyw-in-js] Failed to parse custom module resolver output.",
57
57
  `stdout: ${stdout}`,
58
58
  result.stderr ? `stderr: ${result.stderr.trim()}` : ""
59
59
  ].filter(Boolean).join("\n"));
@@ -66,7 +66,7 @@ const resolveWithNodeProcess = (id, parent, conditions) => {
66
66
  }
67
67
  if (result.status !== 0 || !parsed?.resolved) {
68
68
  throw new Error([
69
- "[wyw-in-js] Node resolver fallback failed.",
69
+ "[wyw-in-js] Custom module resolver fallback failed.",
70
70
  `status: ${result.status ?? "null"}`,
71
71
  result.stderr ? `stderr: ${result.stderr.trim()}` : ""
72
72
  ].filter(Boolean).join("\n"));
@@ -82,7 +82,7 @@ export const resolveFilenameWithConditions = (moduleImpl, id, parent, conditions
82
82
  // Bun crashes on macOS/Silicon in this exact path:
83
83
  // Module._resolveFilename(specifier, parent, false, { conditions })
84
84
  // We reproduced it both with a tiny standalone script and through the
85
- // `EvalBroker > passes conditionNames to node fallback resolution` test,
85
+ // `EvalBroker > passes conditionNames to native fallback resolution` test,
86
86
  // including on Bun 1.3.13. Keep this fallback narrow: only conditioned
87
87
  // resolution under Bun goes through a short-lived Node subprocess.
88
88
  //
@@ -1 +1 @@
1
- {"mappings":"AAAA,SAAS,iBAAiB;AAC1B,OAAO,kBAAkB;AAsBzB,MAAM,kCAAkC,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BlD,MAAM,qBAAqB,QAAQ,SAAS,SAAS,MAAM;AAE3D,MAAM,wBACJ,aACA;AAEF,MAAM,0BACJ,IACA,QACA,eACW;CACX,MAAM,aAAa,QAAQ,IAAI,mBAAmB;CAClD,MAAM,SAAS,UACb,YACA,CAAC,MAAM,gCAAgC,EACvC;EACE,UAAU;EACV,OAAO,KAAK,UAAU;GACpB,YAAY,CAAC,GAAG,WAAW;GAC3B;GACA;GACD,CAAC;EACF,WAAW,OAAO;EACnB,CACF;AAED,KAAI,OAAO,OAAO;AAChB,QAAM,OAAO;;CAGf,IAAI,SAA8C;CAClD,MAAM,SAAS,OAAO,OAAO,MAAM;AACnC,KAAI,QAAQ;AACV,MAAI;AACF,YAAS,KAAK,MAAM,OAAO;UACrB;AACN,SAAM,IAAI,MACR;IACE;IACA,WAAW;IACX,OAAO,SAAS,WAAW,OAAO,OAAO,MAAM,KAAK;IACrD,CACE,OAAO,QAAQ,CACf,KAAK,KAAK,CACd;;;AAIL,KAAI,QAAQ,OAAO;EACjB,MAAM,QAAQ,IAAI,MAAM,OAAO,MAAM,QAAQ;AAC7C,QAAM,OAAO,OAAO,MAAM;AAC1B,QAAM;;AAGR,KAAI,OAAO,WAAW,KAAK,CAAC,QAAQ,UAAU;AAC5C,QAAM,IAAI,MACR;GACE;GACA,WAAW,OAAO,UAAU;GAC5B,OAAO,SAAS,WAAW,OAAO,OAAO,MAAM,KAAK;GACrD,CACE,OAAO,QAAQ,CACf,KAAK,KAAK,CACd;;AAGH,QAAO,OAAO;;AAGhB,OAAO,MAAM,iCACX,YACA,IACA,QACA,eACW;CACX,MAAM,iBAAiB,aAAa,EAAE,YAAY,GAAG;CACrD,MAAM,qBACJ,WAAW,qBAAqB;AAElC,KAAI,CAAC,cAAc,CAAC,cAAc,IAAI,CAAC,oBAAoB;AACzD,SAAO,WAAW,iBAAiB,IAAI,QAAQ,OAAO,eAAe;;;;;;;;;;;;;;;;;AAkBvE,QAAO,uBAAuB,IAAI,QAAQ,WAAW","names":[],"sources":["../../src/utils/resolveWithConditions.ts"],"version":3,"sourcesContent":["import { spawnSync } from 'child_process';\nimport NativeModule from 'module';\n\ntype ResolveFilenameParent = {\n filename: string;\n id: string;\n paths: string[];\n};\n\ntype ResolveFilenameModuleImplementation = {\n _resolveFilename: (\n id: string,\n options: ResolveFilenameParent,\n isMain?: boolean,\n resolveOptions?: { conditions?: Set<string> }\n ) => string;\n};\n\ntype NodeConditionalResolveResult = {\n error?: { code?: string; message: string };\n resolved?: string;\n};\n\nconst NODE_CONDITIONAL_RESOLVE_SCRIPT = String.raw`\nconst fs = require('node:fs');\nconst Module = require('node:module');\n\nconst input = JSON.parse(fs.readFileSync(0, 'utf8'));\n\ntry {\n const resolved = Module._resolveFilename(\n input.id,\n input.parent,\n false,\n input.conditions ? { conditions: new Set(input.conditions) } : undefined\n );\n fs.writeFileSync(1, JSON.stringify({ resolved }));\n} catch (error) {\n fs.writeFileSync(\n 1,\n JSON.stringify({\n error: {\n code:\n error && typeof error === 'object' && 'code' in error\n ? error.code\n : undefined,\n message: error instanceof Error ? error.message : String(error),\n },\n })\n );\n process.exitCode = 1;\n}\n`;\n\nconst isBunRuntime = () => process.execPath.includes('bun');\n\nconst nativeResolveFilename = (\n NativeModule as unknown as ResolveFilenameModuleImplementation\n)._resolveFilename;\n\nconst resolveWithNodeProcess = (\n id: string,\n parent: ResolveFilenameParent,\n conditions: Set<string>\n): string => {\n const nodeBinary = process.env.WYW_NODE_BINARY || 'node';\n const result = spawnSync(\n nodeBinary,\n ['-e', NODE_CONDITIONAL_RESOLVE_SCRIPT],\n {\n encoding: 'utf8',\n input: JSON.stringify({\n conditions: [...conditions],\n id,\n parent,\n }),\n maxBuffer: 1024 * 1024,\n }\n );\n\n if (result.error) {\n throw result.error;\n }\n\n let parsed: NodeConditionalResolveResult | null = null;\n const stdout = result.stdout.trim();\n if (stdout) {\n try {\n parsed = JSON.parse(stdout) as NodeConditionalResolveResult;\n } catch {\n throw new Error(\n [\n '[wyw-in-js] Failed to parse Node resolver fallback output.',\n `stdout: ${stdout}`,\n result.stderr ? `stderr: ${result.stderr.trim()}` : '',\n ]\n .filter(Boolean)\n .join('\\n')\n );\n }\n }\n\n if (parsed?.error) {\n const error = new Error(parsed.error.message) as NodeJS.ErrnoException;\n error.code = parsed.error.code;\n throw error;\n }\n\n if (result.status !== 0 || !parsed?.resolved) {\n throw new Error(\n [\n '[wyw-in-js] Node resolver fallback failed.',\n `status: ${result.status ?? 'null'}`,\n result.stderr ? `stderr: ${result.stderr.trim()}` : '',\n ]\n .filter(Boolean)\n .join('\\n')\n );\n }\n\n return parsed.resolved;\n};\n\nexport const resolveFilenameWithConditions = (\n moduleImpl: ResolveFilenameModuleImplementation,\n id: string,\n parent: ResolveFilenameParent,\n conditions?: Set<string>\n): string => {\n const resolveOptions = conditions ? { conditions } : undefined;\n const usesNativeResolver =\n moduleImpl._resolveFilename === nativeResolveFilename;\n\n if (!conditions || !isBunRuntime() || !usesNativeResolver) {\n return moduleImpl._resolveFilename(id, parent, false, resolveOptions);\n }\n\n // Bun crashes on macOS/Silicon in this exact path:\n // Module._resolveFilename(specifier, parent, false, { conditions })\n // We reproduced it both with a tiny standalone script and through the\n // `EvalBroker > passes conditionNames to node fallback resolution` test,\n // including on Bun 1.3.13. Keep this fallback narrow: only conditioned\n // resolution under Bun goes through a short-lived Node subprocess.\n //\n // Cleanup criteria:\n // 1. Bun passes the minimal local `_resolveFilename(..., { conditions })`\n // repro on macOS without segfaulting.\n // 2. The conditionNames runner path passes without this fallback.\n //\n // As of 2026-04-20 we did not find an exact open upstream Bun issue for this\n // `_resolveFilename(..., { conditions })` crash, so keep the comment factual\n // and the workaround self-contained.\n return resolveWithNodeProcess(id, parent, conditions);\n};\n"],"file":"resolveWithConditions.js"}
1
+ {"mappings":"AAAA,SAAS,iBAAiB;AAC1B,OAAO,kBAAkB;AAsBzB,MAAM,kCAAkC,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BlD,MAAM,qBAAqB,QAAQ,SAAS,SAAS,MAAM;AAE3D,MAAM,wBACJ,aACA;AAEF,MAAM,0BACJ,IACA,QACA,eACW;CACX,MAAM,aAAa,QAAQ,IAAI,mBAAmB;CAClD,MAAM,SAAS,UACb,YACA,CAAC,MAAM,gCAAgC,EACvC;EACE,UAAU;EACV,OAAO,KAAK,UAAU;GACpB,YAAY,CAAC,GAAG,WAAW;GAC3B;GACA;GACD,CAAC;EACF,WAAW,OAAO;EACnB,CACF;AAED,KAAI,OAAO,OAAO;AAChB,QAAM,OAAO;;CAGf,IAAI,SAA8C;CAClD,MAAM,SAAS,OAAO,OAAO,MAAM;AACnC,KAAI,QAAQ;AACV,MAAI;AACF,YAAS,KAAK,MAAM,OAAO;UACrB;AACN,SAAM,IAAI,MACR;IACE;IACA,WAAW;IACX,OAAO,SAAS,WAAW,OAAO,OAAO,MAAM,KAAK;IACrD,CACE,OAAO,QAAQ,CACf,KAAK,KAAK,CACd;;;AAIL,KAAI,QAAQ,OAAO;EACjB,MAAM,QAAQ,IAAI,MAAM,OAAO,MAAM,QAAQ;AAC7C,QAAM,OAAO,OAAO,MAAM;AAC1B,QAAM;;AAGR,KAAI,OAAO,WAAW,KAAK,CAAC,QAAQ,UAAU;AAC5C,QAAM,IAAI,MACR;GACE;GACA,WAAW,OAAO,UAAU;GAC5B,OAAO,SAAS,WAAW,OAAO,OAAO,MAAM,KAAK;GACrD,CACE,OAAO,QAAQ,CACf,KAAK,KAAK,CACd;;AAGH,QAAO,OAAO;;AAGhB,OAAO,MAAM,iCACX,YACA,IACA,QACA,eACW;CACX,MAAM,iBAAiB,aAAa,EAAE,YAAY,GAAG;CACrD,MAAM,qBACJ,WAAW,qBAAqB;AAElC,KAAI,CAAC,cAAc,CAAC,cAAc,IAAI,CAAC,oBAAoB;AACzD,SAAO,WAAW,iBAAiB,IAAI,QAAQ,OAAO,eAAe;;;;;;;;;;;;;;;;;AAkBvE,QAAO,uBAAuB,IAAI,QAAQ,WAAW","names":[],"sources":["../../src/utils/resolveWithConditions.ts"],"version":3,"sourcesContent":["import { spawnSync } from 'child_process';\nimport NativeModule from 'module';\n\ntype ResolveFilenameParent = {\n filename: string;\n id: string;\n paths: string[];\n};\n\ntype ResolveFilenameModuleImplementation = {\n _resolveFilename: (\n id: string,\n options: ResolveFilenameParent,\n isMain?: boolean,\n resolveOptions?: { conditions?: Set<string> }\n ) => string;\n};\n\ntype NodeConditionalResolveResult = {\n error?: { code?: string; message: string };\n resolved?: string;\n};\n\nconst NODE_CONDITIONAL_RESOLVE_SCRIPT = String.raw`\nconst fs = require('node:fs');\nconst Module = require('node:module');\n\nconst input = JSON.parse(fs.readFileSync(0, 'utf8'));\n\ntry {\n const resolved = Module._resolveFilename(\n input.id,\n input.parent,\n false,\n input.conditions ? { conditions: new Set(input.conditions) } : undefined\n );\n fs.writeFileSync(1, JSON.stringify({ resolved }));\n} catch (error) {\n fs.writeFileSync(\n 1,\n JSON.stringify({\n error: {\n code:\n error && typeof error === 'object' && 'code' in error\n ? error.code\n : undefined,\n message: error instanceof Error ? error.message : String(error),\n },\n })\n );\n process.exitCode = 1;\n}\n`;\n\nconst isBunRuntime = () => process.execPath.includes('bun');\n\nconst nativeResolveFilename = (\n NativeModule as unknown as ResolveFilenameModuleImplementation\n)._resolveFilename;\n\nconst resolveWithNodeProcess = (\n id: string,\n parent: ResolveFilenameParent,\n conditions: Set<string>\n): string => {\n const nodeBinary = process.env.WYW_NODE_BINARY || 'node';\n const result = spawnSync(\n nodeBinary,\n ['-e', NODE_CONDITIONAL_RESOLVE_SCRIPT],\n {\n encoding: 'utf8',\n input: JSON.stringify({\n conditions: [...conditions],\n id,\n parent,\n }),\n maxBuffer: 1024 * 1024,\n }\n );\n\n if (result.error) {\n throw result.error;\n }\n\n let parsed: NodeConditionalResolveResult | null = null;\n const stdout = result.stdout.trim();\n if (stdout) {\n try {\n parsed = JSON.parse(stdout) as NodeConditionalResolveResult;\n } catch {\n throw new Error(\n [\n '[wyw-in-js] Failed to parse custom module resolver output.',\n `stdout: ${stdout}`,\n result.stderr ? `stderr: ${result.stderr.trim()}` : '',\n ]\n .filter(Boolean)\n .join('\\n')\n );\n }\n }\n\n if (parsed?.error) {\n const error = new Error(parsed.error.message) as NodeJS.ErrnoException;\n error.code = parsed.error.code;\n throw error;\n }\n\n if (result.status !== 0 || !parsed?.resolved) {\n throw new Error(\n [\n '[wyw-in-js] Custom module resolver fallback failed.',\n `status: ${result.status ?? 'null'}`,\n result.stderr ? `stderr: ${result.stderr.trim()}` : '',\n ]\n .filter(Boolean)\n .join('\\n')\n );\n }\n\n return parsed.resolved;\n};\n\nexport const resolveFilenameWithConditions = (\n moduleImpl: ResolveFilenameModuleImplementation,\n id: string,\n parent: ResolveFilenameParent,\n conditions?: Set<string>\n): string => {\n const resolveOptions = conditions ? { conditions } : undefined;\n const usesNativeResolver =\n moduleImpl._resolveFilename === nativeResolveFilename;\n\n if (!conditions || !isBunRuntime() || !usesNativeResolver) {\n return moduleImpl._resolveFilename(id, parent, false, resolveOptions);\n }\n\n // Bun crashes on macOS/Silicon in this exact path:\n // Module._resolveFilename(specifier, parent, false, { conditions })\n // We reproduced it both with a tiny standalone script and through the\n // `EvalBroker > passes conditionNames to native fallback resolution` test,\n // including on Bun 1.3.13. Keep this fallback narrow: only conditioned\n // resolution under Bun goes through a short-lived Node subprocess.\n //\n // Cleanup criteria:\n // 1. Bun passes the minimal local `_resolveFilename(..., { conditions })`\n // repro on macOS without segfaulting.\n // 2. The conditionNames runner path passes without this fallback.\n //\n // As of 2026-04-20 we did not find an exact open upstream Bun issue for this\n // `_resolveFilename(..., { conditions })` crash, so keep the comment factual\n // and the workaround self-contained.\n return resolveWithNodeProcess(id, parent, conditions);\n};\n"],"file":"resolveWithConditions.js"}