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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. package/esm/cache.js +7 -0
  2. package/esm/cache.js.map +1 -1
  3. package/esm/debug/fileReporter.js +35 -1
  4. package/esm/debug/fileReporter.js.map +1 -1
  5. package/esm/eval/broker.js +230 -89
  6. package/esm/eval/broker.js.map +1 -1
  7. package/esm/eval/protocol.js.map +1 -1
  8. package/esm/eval/runner.js +143 -24
  9. package/esm/eval/runner.js.map +1 -1
  10. package/esm/module.js +70 -43
  11. package/esm/module.js.map +1 -1
  12. package/esm/transform/Entrypoint.types.js.map +1 -1
  13. package/esm/transform/generators/processEntrypoint.js +35 -20
  14. package/esm/transform/generators/processEntrypoint.js.map +1 -1
  15. package/esm/transform/generators/resolveImports.js +48 -2
  16. package/esm/transform/generators/resolveImports.js.map +1 -1
  17. package/esm/transform/generators/resolveStaticOxcValues/cache.js +182 -0
  18. package/esm/transform/generators/resolveStaticOxcValues/cache.js.map +1 -0
  19. package/esm/transform/generators/resolveStaticOxcValues/candidateResolver.js +146 -0
  20. package/esm/transform/generators/resolveStaticOxcValues/candidateResolver.js.map +1 -0
  21. package/esm/transform/generators/resolveStaticOxcValues/dependencies.js +33 -0
  22. package/esm/transform/generators/resolveStaticOxcValues/dependencies.js.map +1 -0
  23. package/esm/transform/generators/resolveStaticOxcValues/environment.js +29 -0
  24. package/esm/transform/generators/resolveStaticOxcValues/environment.js.map +1 -0
  25. package/esm/transform/generators/resolveStaticOxcValues/exportResolver.js +351 -0
  26. package/esm/transform/generators/resolveStaticOxcValues/exportResolver.js.map +1 -0
  27. package/esm/transform/generators/resolveStaticOxcValues/exportTargets.js +253 -0
  28. package/esm/transform/generators/resolveStaticOxcValues/exportTargets.js.map +1 -0
  29. package/esm/transform/generators/resolveStaticOxcValues/objectAssign.js +310 -0
  30. package/esm/transform/generators/resolveStaticOxcValues/objectAssign.js.map +1 -0
  31. package/esm/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.js +74 -0
  32. package/esm/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.js.map +1 -0
  33. package/esm/transform/generators/resolveStaticOxcValues/opaqueRuntime.js +229 -0
  34. package/esm/transform/generators/resolveStaticOxcValues/opaqueRuntime.js.map +1 -0
  35. package/esm/transform/generators/resolveStaticOxcValues/processorStaticExport.js +172 -0
  36. package/esm/transform/generators/resolveStaticOxcValues/processorStaticExport.js.map +1 -0
  37. package/esm/transform/generators/resolveStaticOxcValues/processorStaticModel.js +476 -0
  38. package/esm/transform/generators/resolveStaticOxcValues/processorStaticModel.js.map +1 -0
  39. package/esm/transform/generators/resolveStaticOxcValues/processorTarget.js +55 -0
  40. package/esm/transform/generators/resolveStaticOxcValues/processorTarget.js.map +1 -0
  41. package/esm/transform/generators/resolveStaticOxcValues/programAnalysis.js +123 -0
  42. package/esm/transform/generators/resolveStaticOxcValues/programAnalysis.js.map +1 -0
  43. package/esm/transform/generators/resolveStaticOxcValues/prune.js +186 -0
  44. package/esm/transform/generators/resolveStaticOxcValues/prune.js.map +1 -0
  45. package/esm/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.js +183 -0
  46. package/esm/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.js.map +1 -0
  47. package/esm/transform/generators/resolveStaticOxcValues/staticExpression.js +298 -0
  48. package/esm/transform/generators/resolveStaticOxcValues/staticExpression.js.map +1 -0
  49. package/esm/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.js +298 -0
  50. package/esm/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.js.map +1 -0
  51. package/esm/transform/generators/resolveStaticOxcValues/types.js +3 -0
  52. package/esm/transform/generators/resolveStaticOxcValues/types.js.map +1 -0
  53. package/esm/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.js +59 -0
  54. package/esm/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.js.map +1 -0
  55. package/esm/transform/generators/resolveStaticOxcValues.js +1 -2910
  56. package/esm/transform/generators/resolveStaticOxcValues.js.map +1 -1
  57. package/esm/transform/generators/transform.js +57 -45
  58. package/esm/transform/generators/transform.js.map +1 -1
  59. package/esm/transform/helpers/loadWywOptions.js +33 -4
  60. package/esm/transform/helpers/loadWywOptions.js.map +1 -1
  61. package/esm/transform.js +3 -1
  62. package/esm/transform.js.map +1 -1
  63. package/esm/utils/EventEmitter.js +42 -9
  64. package/esm/utils/EventEmitter.js.map +1 -1
  65. package/esm/utils/applyOxcProcessors/applyOxcProcessors.js +160 -0
  66. package/esm/utils/applyOxcProcessors/applyOxcProcessors.js.map +1 -0
  67. package/esm/utils/applyOxcProcessors/cleanupBindings.js +157 -0
  68. package/esm/utils/applyOxcProcessors/cleanupBindings.js.map +1 -0
  69. package/esm/utils/applyOxcProcessors/cleanupRemovals.js +431 -0
  70. package/esm/utils/applyOxcProcessors/cleanupRemovals.js.map +1 -0
  71. package/esm/utils/applyOxcProcessors/displayName.js +93 -0
  72. package/esm/utils/applyOxcProcessors/displayName.js.map +1 -0
  73. package/esm/utils/applyOxcProcessors/expressionValues.js +152 -0
  74. package/esm/utils/applyOxcProcessors/expressionValues.js.map +1 -0
  75. package/esm/utils/applyOxcProcessors/processorFactory.js +62 -0
  76. package/esm/utils/applyOxcProcessors/processorFactory.js.map +1 -0
  77. package/esm/utils/applyOxcProcessors/processorUsages.js +143 -0
  78. package/esm/utils/applyOxcProcessors/processorUsages.js.map +1 -0
  79. package/esm/utils/applyOxcProcessors/sameFileStaticValues.js +207 -0
  80. package/esm/utils/applyOxcProcessors/sameFileStaticValues.js.map +1 -0
  81. package/esm/utils/applyOxcProcessors/shared.js +29 -0
  82. package/esm/utils/applyOxcProcessors/shared.js.map +1 -0
  83. package/esm/utils/applyOxcProcessors/types.js +2 -0
  84. package/esm/utils/applyOxcProcessors/types.js.map +1 -0
  85. package/esm/utils/applyOxcProcessors.js +1 -1216
  86. package/esm/utils/applyOxcProcessors.js.map +1 -1
  87. package/esm/utils/collectOxcRuntime/normalizeRuntimeCode.js +157 -0
  88. package/esm/utils/collectOxcRuntime/normalizeRuntimeCode.js.map +1 -0
  89. package/esm/utils/collectOxcRuntime/sourceMap.js +36 -0
  90. package/esm/utils/collectOxcRuntime/sourceMap.js.map +1 -0
  91. package/esm/utils/collectOxcRuntime/types.js +2 -0
  92. package/esm/utils/collectOxcRuntime/types.js.map +1 -0
  93. package/esm/utils/collectOxcRuntime.js +5 -193
  94. package/esm/utils/collectOxcRuntime.js.map +1 -1
  95. package/esm/utils/collectOxcTemplateDependencies/expressionExtraction.js +496 -0
  96. package/esm/utils/collectOxcTemplateDependencies/expressionExtraction.js.map +1 -0
  97. package/esm/utils/collectOxcTemplateDependencies/expressionReplacements.js +113 -0
  98. package/esm/utils/collectOxcTemplateDependencies/expressionReplacements.js.map +1 -0
  99. package/esm/utils/collectOxcTemplateDependencies/scopeAnalysis.js +387 -0
  100. package/esm/utils/collectOxcTemplateDependencies/scopeAnalysis.js.map +1 -0
  101. package/esm/utils/collectOxcTemplateDependencies/staticBindings.js +17 -0
  102. package/esm/utils/collectOxcTemplateDependencies/staticBindings.js.map +1 -0
  103. package/esm/utils/collectOxcTemplateDependencies/staticEvaluator.js +540 -0
  104. package/esm/utils/collectOxcTemplateDependencies/staticEvaluator.js.map +1 -0
  105. package/esm/utils/collectOxcTemplateDependencies/types.js +2 -0
  106. package/esm/utils/collectOxcTemplateDependencies/types.js.map +1 -0
  107. package/esm/utils/collectOxcTemplateDependencies.js +3 -1397
  108. package/esm/utils/collectOxcTemplateDependencies.js.map +1 -1
  109. package/esm/utils/nativeResolver.js +93 -0
  110. package/esm/utils/nativeResolver.js.map +1 -0
  111. package/esm/utils/oxc/ast.js +28 -0
  112. package/esm/utils/oxc/ast.js.map +1 -0
  113. package/esm/utils/oxc/parse.js +3 -0
  114. package/esm/utils/oxc/parse.js.map +1 -0
  115. package/esm/utils/oxc/replacements.js +14 -0
  116. package/esm/utils/oxc/replacements.js.map +1 -0
  117. package/esm/utils/oxc/sourceLocations.js +59 -0
  118. package/esm/utils/oxc/sourceLocations.js.map +1 -0
  119. package/esm/utils/oxcPreevalStage/evalStrategy.js +3 -0
  120. package/esm/utils/oxcPreevalStage/evalStrategy.js.map +1 -0
  121. package/esm/utils/oxcPreevalStage/prepareCode.js +21 -0
  122. package/esm/utils/oxcPreevalStage/prepareCode.js.map +1 -0
  123. package/esm/utils/oxcPreevalStage/prevalExport.js +23 -0
  124. package/esm/utils/oxcPreevalStage/prevalExport.js.map +1 -0
  125. package/esm/utils/oxcPreevalStage/processors.js +17 -0
  126. package/esm/utils/oxcPreevalStage/processors.js.map +1 -0
  127. package/esm/utils/oxcPreevalStage/staticOverlay.js +18 -0
  128. package/esm/utils/oxcPreevalStage/staticOverlay.js.map +1 -0
  129. package/esm/utils/oxcPreevalStage/types.js +2 -0
  130. package/esm/utils/oxcPreevalStage/types.js.map +1 -0
  131. package/esm/utils/oxcPreevalStage.js +17 -73
  132. package/esm/utils/oxcPreevalStage.js.map +1 -1
  133. package/esm/utils/oxcPreevalTransforms.js +12 -1
  134. package/esm/utils/oxcPreevalTransforms.js.map +1 -1
  135. package/esm/utils/processorStaticSemantics.js +157 -0
  136. package/esm/utils/processorStaticSemantics.js.map +1 -0
  137. package/esm/utils/resolveWithConditions.js +3 -3
  138. package/esm/utils/resolveWithConditions.js.map +1 -1
  139. package/package.json +4 -3
  140. package/types/cache.js +8 -0
  141. package/types/debug/fileReporter.js +46 -1
  142. package/types/eval/broker.d.ts +6 -2
  143. package/types/eval/broker.js +244 -95
  144. package/types/eval/protocol.d.ts +15 -1
  145. package/types/module.d.ts +4 -1
  146. package/types/module.js +97 -48
  147. package/types/transform/Entrypoint.types.d.ts +3 -0
  148. package/types/transform/generators/resolveImports.d.ts +3 -1
  149. package/types/transform/generators/resolveImports.js +49 -2
  150. package/types/transform/generators/resolveStaticOxcValues/cache.d.ts +25 -0
  151. package/types/transform/generators/resolveStaticOxcValues/cache.js +182 -0
  152. package/types/transform/generators/resolveStaticOxcValues/candidateResolver.d.ts +5 -0
  153. package/types/transform/generators/resolveStaticOxcValues/candidateResolver.js +149 -0
  154. package/types/transform/generators/resolveStaticOxcValues/dependencies.d.ts +6 -0
  155. package/types/transform/generators/resolveStaticOxcValues/dependencies.js +37 -0
  156. package/types/transform/generators/resolveStaticOxcValues/environment.d.ts +12 -0
  157. package/types/transform/generators/resolveStaticOxcValues/environment.js +32 -0
  158. package/types/transform/generators/resolveStaticOxcValues/exportResolver.d.ts +4 -0
  159. package/types/transform/generators/resolveStaticOxcValues/exportResolver.js +358 -0
  160. package/types/transform/generators/resolveStaticOxcValues/exportTargets.d.ts +20 -0
  161. package/types/transform/generators/resolveStaticOxcValues/exportTargets.js +285 -0
  162. package/types/transform/generators/resolveStaticOxcValues/objectAssign.d.ts +41 -0
  163. package/types/transform/generators/resolveStaticOxcValues/objectAssign.js +352 -0
  164. package/types/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.d.ts +6 -0
  165. package/types/transform/generators/resolveStaticOxcValues/objectAssignStaticExport.js +88 -0
  166. package/types/transform/generators/resolveStaticOxcValues/opaqueRuntime.d.ts +13 -0
  167. package/types/transform/generators/resolveStaticOxcValues/opaqueRuntime.js +263 -0
  168. package/types/transform/generators/resolveStaticOxcValues/processorStaticExport.d.ts +4 -0
  169. package/types/transform/generators/resolveStaticOxcValues/processorStaticExport.js +191 -0
  170. package/types/transform/generators/resolveStaticOxcValues/processorStaticModel.d.ts +40 -0
  171. package/types/transform/generators/resolveStaticOxcValues/processorStaticModel.js +516 -0
  172. package/types/transform/generators/resolveStaticOxcValues/processorTarget.d.ts +5 -0
  173. package/types/transform/generators/resolveStaticOxcValues/processorTarget.js +62 -0
  174. package/types/transform/generators/resolveStaticOxcValues/programAnalysis.d.ts +11 -0
  175. package/types/transform/generators/resolveStaticOxcValues/programAnalysis.js +133 -0
  176. package/types/transform/generators/resolveStaticOxcValues/prune.d.ts +15 -0
  177. package/types/transform/generators/resolveStaticOxcValues/prune.js +220 -0
  178. package/types/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.d.ts +2 -0
  179. package/types/transform/generators/resolveStaticOxcValues/resolveStaticOxcPreevalValues.js +197 -0
  180. package/types/transform/generators/resolveStaticOxcValues/staticExpression.d.ts +25 -0
  181. package/types/transform/generators/resolveStaticOxcValues/staticExpression.js +391 -0
  182. package/types/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.d.ts +14 -0
  183. package/types/transform/generators/resolveStaticOxcValues/staticExpressionDependencies.js +304 -0
  184. package/types/transform/generators/resolveStaticOxcValues/types.d.ts +99 -0
  185. package/types/transform/generators/resolveStaticOxcValues/types.js +2 -0
  186. package/types/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.d.ts +7 -0
  187. package/types/transform/generators/resolveStaticOxcValues/zeroArgFunctionStaticExport.js +64 -0
  188. package/types/transform/generators/resolveStaticOxcValues.d.ts +1 -2
  189. package/types/transform/generators/resolveStaticOxcValues.js +1 -3235
  190. package/types/transform/generators/transform.js +63 -49
  191. package/types/transform/helpers/loadWywOptions.js +23 -3
  192. package/types/transform.js +3 -1
  193. package/types/utils/EventEmitter.d.ts +16 -1
  194. package/types/utils/EventEmitter.js +44 -9
  195. package/types/utils/applyOxcProcessors/applyOxcProcessors.d.ts +8 -0
  196. package/types/utils/applyOxcProcessors/applyOxcProcessors.js +167 -0
  197. package/types/utils/applyOxcProcessors/cleanupBindings.d.ts +12 -0
  198. package/types/utils/applyOxcProcessors/cleanupBindings.js +189 -0
  199. package/types/utils/applyOxcProcessors/cleanupRemovals.d.ts +16 -0
  200. package/types/utils/applyOxcProcessors/cleanupRemovals.js +482 -0
  201. package/types/utils/applyOxcProcessors/displayName.d.ts +9 -0
  202. package/types/utils/applyOxcProcessors/displayName.js +113 -0
  203. package/types/utils/applyOxcProcessors/expressionValues.d.ts +11 -0
  204. package/types/utils/applyOxcProcessors/expressionValues.js +170 -0
  205. package/types/utils/applyOxcProcessors/processorFactory.d.ts +7 -0
  206. package/types/utils/applyOxcProcessors/processorFactory.js +70 -0
  207. package/types/utils/applyOxcProcessors/processorUsages.d.ts +16 -0
  208. package/types/utils/applyOxcProcessors/processorUsages.js +163 -0
  209. package/types/utils/applyOxcProcessors/sameFileStaticValues.d.ts +23 -0
  210. package/types/utils/applyOxcProcessors/sameFileStaticValues.js +211 -0
  211. package/types/utils/applyOxcProcessors/shared.d.ts +10 -0
  212. package/types/utils/applyOxcProcessors/shared.js +37 -0
  213. package/types/utils/applyOxcProcessors/types.d.ts +88 -0
  214. package/types/utils/applyOxcProcessors/types.js +1 -0
  215. package/types/utils/applyOxcProcessors.d.ts +1 -16
  216. package/types/utils/applyOxcProcessors.js +1 -1391
  217. package/types/utils/collectOxcRuntime/normalizeRuntimeCode.d.ts +1 -0
  218. package/types/utils/collectOxcRuntime/normalizeRuntimeCode.js +185 -0
  219. package/types/utils/collectOxcRuntime/sourceMap.d.ts +2 -0
  220. package/types/utils/collectOxcRuntime/sourceMap.js +37 -0
  221. package/types/utils/collectOxcRuntime/types.d.ts +16 -0
  222. package/types/utils/collectOxcRuntime/types.js +1 -0
  223. package/types/utils/collectOxcRuntime.d.ts +2 -12
  224. package/types/utils/collectOxcRuntime.js +5 -224
  225. package/types/utils/collectOxcTemplateDependencies/expressionExtraction.d.ts +6 -0
  226. package/types/utils/collectOxcTemplateDependencies/expressionExtraction.js +550 -0
  227. package/types/utils/collectOxcTemplateDependencies/expressionReplacements.d.ts +11 -0
  228. package/types/utils/collectOxcTemplateDependencies/expressionReplacements.js +131 -0
  229. package/types/utils/collectOxcTemplateDependencies/scopeAnalysis.d.ts +20 -0
  230. package/types/utils/collectOxcTemplateDependencies/scopeAnalysis.js +434 -0
  231. package/types/utils/collectOxcTemplateDependencies/staticBindings.d.ts +7 -0
  232. package/types/utils/collectOxcTemplateDependencies/staticBindings.js +13 -0
  233. package/types/utils/collectOxcTemplateDependencies/staticEvaluator.d.ts +13 -0
  234. package/types/utils/collectOxcTemplateDependencies/staticEvaluator.js +626 -0
  235. package/types/utils/collectOxcTemplateDependencies/types.d.ts +116 -0
  236. package/types/utils/collectOxcTemplateDependencies/types.js +1 -0
  237. package/types/utils/collectOxcTemplateDependencies.d.ts +4 -38
  238. package/types/utils/collectOxcTemplateDependencies.js +3 -1580
  239. package/types/utils/nativeResolver.d.ts +13 -0
  240. package/types/utils/nativeResolver.js +91 -0
  241. package/types/utils/oxc/ast.d.ts +4 -0
  242. package/types/utils/oxc/ast.js +37 -0
  243. package/types/utils/oxc/parse.d.ts +3 -0
  244. package/types/utils/oxc/parse.js +2 -0
  245. package/types/utils/oxc/replacements.d.ts +12 -0
  246. package/types/utils/oxc/replacements.js +18 -0
  247. package/types/utils/oxc/sourceLocations.d.ts +5 -0
  248. package/types/utils/oxc/sourceLocations.js +63 -0
  249. package/types/utils/oxcPreevalStage/evalStrategy.d.ts +3 -0
  250. package/types/utils/oxcPreevalStage/evalStrategy.js +2 -0
  251. package/types/utils/oxcPreevalStage/prepareCode.d.ts +3 -0
  252. package/types/utils/oxcPreevalStage/prepareCode.js +20 -0
  253. package/types/utils/oxcPreevalStage/prevalExport.d.ts +1 -0
  254. package/types/utils/oxcPreevalStage/prevalExport.js +22 -0
  255. package/types/utils/oxcPreevalStage/processors.d.ts +10 -0
  256. package/types/utils/oxcPreevalStage/processors.js +16 -0
  257. package/types/utils/oxcPreevalStage/staticOverlay.d.ts +3 -0
  258. package/types/utils/oxcPreevalStage/staticOverlay.js +23 -0
  259. package/types/utils/oxcPreevalStage/types.d.ts +22 -0
  260. package/types/utils/oxcPreevalStage/types.js +1 -0
  261. package/types/utils/oxcPreevalStage.d.ts +2 -18
  262. package/types/utils/oxcPreevalStage.js +17 -79
  263. package/types/utils/oxcPreevalTransforms.js +14 -1
  264. package/types/utils/processorStaticSemantics.d.ts +13 -0
  265. package/types/utils/processorStaticSemantics.js +191 -0
  266. package/types/utils/resolveWithConditions.js +3 -3
  267. package/esm/eval/resolverStrategy.js +0 -51
  268. package/esm/eval/resolverStrategy.js.map +0 -1
  269. package/types/eval/resolverStrategy.d.ts +0 -13
  270. package/types/eval/resolverStrategy.js +0 -46
package/types/module.d.ts CHANGED
@@ -34,6 +34,9 @@ type ResolvedImport = {
34
34
  only: string[];
35
35
  external?: boolean;
36
36
  };
37
+ type NativeFallbackOptions = {
38
+ warnOnFallback: boolean;
39
+ };
37
40
  export declare class Module {
38
41
  #private;
39
42
  private services;
@@ -84,7 +87,7 @@ export declare class Module {
84
87
  private applyImportOverrides;
85
88
  private getModuleForResolved;
86
89
  private resolveWithConditions;
87
- resolveWithNodeFallback: (id: string, importer: Entrypoint | IEvaluatedEntrypoint, kind: EvalResolverKind) => ResolvedImport;
90
+ resolveWithNativeFallback: (id: string, importer: Entrypoint | IEvaluatedEntrypoint, kind: EvalResolverKind, { warnOnFallback }?: NativeFallbackOptions) => ResolvedImport;
88
91
  private requireWithFallback;
89
92
  protected createChild(entrypoint: Entrypoint): Module;
90
93
  private loadByImportLoaders;
package/types/module.js CHANGED
@@ -22,6 +22,7 @@ import { Entrypoint } from './transform/Entrypoint';
22
22
  import { getStack, isSuperSet, mergeOnly, } from './transform/Entrypoint.helpers';
23
23
  import { isUnprocessedEntrypointError } from './transform/actions/UnprocessedEntrypointError';
24
24
  import { applyImportOverrideToOnly, getImportOverride, resolveMockSpecifier, toImportKey, } from './utils/importOverrides';
25
+ import { resolveWithNativeResolver } from './utils/nativeResolver';
25
26
  import { parseRequest, stripQueryAndHash } from './utils/parseRequest';
26
27
  import { resolveFilenameWithConditions } from './utils/resolveWithConditions';
27
28
  import { createVmContext } from './vm/createVmContext';
@@ -93,7 +94,7 @@ const nodeRequire = createRequire(import.meta.url);
93
94
  const NOOP = () => { };
94
95
  const TROUBLESHOOTING_URL = 'https://wyw-in-js.dev/troubleshooting';
95
96
  const defaultEvalOptions = {
96
- mode: 'strict',
97
+ errors: 'strict',
97
98
  require: 'warn-and-run',
98
99
  resolver: 'bundler',
99
100
  };
@@ -551,7 +552,7 @@ export class Module {
551
552
  const resolved = await this.resolveImport(specifier, importer, kind);
552
553
  const evalOptions = getEvalOptions(this.services);
553
554
  if (!resolved) {
554
- if (evalOptions.mode === 'loose') {
555
+ if (evalOptions.errors === 'loose') {
555
556
  return this.createSyntheticModule(specifier, { default: undefined });
556
557
  }
557
558
  throw new Error([
@@ -585,7 +586,7 @@ export class Module {
585
586
  return null;
586
587
  }
587
588
  }
588
- if (evalOptions.resolver !== 'node') {
589
+ const resolveBundlerDependency = () => {
589
590
  const dependency = getImporterDependency(importer, specifier);
590
591
  if (dependency?.resolved) {
591
592
  return {
@@ -594,9 +595,34 @@ export class Module {
594
595
  only: dependency.only,
595
596
  };
596
597
  }
598
+ return null;
599
+ };
600
+ if (evalOptions.resolver === 'hybrid') {
601
+ try {
602
+ return this.resolveWithNativeFallback(specifier, importer, kind, {
603
+ warnOnFallback: false,
604
+ });
605
+ }
606
+ catch {
607
+ // Hybrid mode lets the bundler resolver handle aliases, virtual IDs,
608
+ // and other specifiers that the native resolver cannot resolve.
609
+ }
610
+ }
611
+ if (evalOptions.resolver === 'native') {
612
+ return this.resolveWithNativeFallback(specifier, importer, kind, {
613
+ warnOnFallback: false,
614
+ });
597
615
  }
598
- if (evalOptions.resolver === 'node' || evalOptions.require !== 'off') {
599
- return this.resolveWithNodeFallback(specifier, importer, kind);
616
+ if (evalOptions.resolver === 'bundler' ||
617
+ evalOptions.resolver === 'hybrid') {
618
+ const dependency = resolveBundlerDependency();
619
+ if (dependency)
620
+ return dependency;
621
+ }
622
+ if (evalOptions.resolver === 'bundler' && evalOptions.require !== 'off') {
623
+ return this.resolveWithNativeFallback(specifier, importer, kind, {
624
+ warnOnFallback: true,
625
+ });
600
626
  }
601
627
  return null;
602
628
  }
@@ -609,7 +635,9 @@ export class Module {
609
635
  only: dependency.only,
610
636
  }, importer);
611
637
  }
612
- return this.resolveWithNodeFallback(specifier, importer, 'require');
638
+ return this.resolveWithNativeFallback(specifier, importer, 'require', {
639
+ warnOnFallback: true,
640
+ });
613
641
  }
614
642
  applyImportOverrides(resolved, importer) {
615
643
  const { root } = this.services.options;
@@ -706,48 +734,65 @@ export class Module {
706
734
  throw error;
707
735
  }
708
736
  }
709
- resolveWithNodeFallback = (id, importer, kind) => {
710
- if (!this.ignored) {
711
- this.debug('❌ import has not been resolved during prepare stage. Fallback to Node.js resolver');
737
+ resolveWithNativeFallback = (id, importer, kind, { warnOnFallback } = { warnOnFallback: true }) => {
738
+ if (!this.ignored && warnOnFallback) {
739
+ this.debug('❌ import has not been resolved during prepare stage. Fallback to native resolver');
712
740
  }
713
741
  const extensions = this.moduleImpl._extensions;
714
742
  const added = [];
715
743
  try {
716
- // Check for supported extensions
717
- this.extensions.forEach((ext) => {
718
- if (ext === '.cjs' || ext === '.mjs') {
719
- return;
720
- }
721
- if (ext in extensions) {
722
- return;
723
- }
724
- // When an extension is not supported, add it
725
- // And keep track of it to clean it up after resolving
726
- // Use noop for the transform function since we handle it
727
- extensions[ext] = NOOP;
728
- added.push(ext);
729
- });
730
744
  const filename = importer.name;
731
745
  const strippedId = stripQueryAndHash(id);
732
- const parent = {
733
- id: filename,
734
- filename,
735
- paths: this.moduleImpl._nodeModulePaths(path.dirname(filename)),
736
- };
737
- const { conditionNames } = this.services.options.pluginOptions;
738
- const conditions = conditionNames?.length
739
- ? expandConditions(conditionNames)
740
- : undefined;
741
- let resolved = this.resolveWithConditions(strippedId, parent, conditions);
742
- const isFileSpecifier = strippedId.startsWith('.') || path.isAbsolute(strippedId);
743
- if (isFileSpecifier &&
744
- path.extname(strippedId) === '' &&
745
- resolved.endsWith('.cjs') &&
746
- fs.existsSync(`${resolved.slice(0, -4)}.js`)) {
747
- // When both `.cjs` and `.js` exist for an extensionless specifier, the
748
- // resolver may pick `.cjs` depending on the environment/extensions.
749
- // Prefer `.js` to keep resolved paths stable (e.g. importOverrides keys).
750
- resolved = `${resolved.slice(0, -4)}.js`;
746
+ const { conditionNames, oxcOptions } = this.services.options.pluginOptions;
747
+ let resolved;
748
+ try {
749
+ if (this.moduleImpl === DefaultModuleImplementation) {
750
+ resolved = resolveWithNativeResolver({
751
+ conditionNames,
752
+ extensions: this.extensions,
753
+ importer: filename,
754
+ kind,
755
+ oxcOptions,
756
+ specifier: id,
757
+ });
758
+ }
759
+ else {
760
+ // Preserve the test-only custom module implementation hook.
761
+ this.extensions.forEach((ext) => {
762
+ if (ext === '.cjs' || ext === '.mjs')
763
+ return;
764
+ if (ext in extensions)
765
+ return;
766
+ extensions[ext] = NOOP;
767
+ added.push(ext);
768
+ });
769
+ const parent = {
770
+ id: filename,
771
+ filename,
772
+ paths: this.moduleImpl._nodeModulePaths(path.dirname(filename)),
773
+ };
774
+ const conditions = conditionNames?.length
775
+ ? expandConditions(conditionNames)
776
+ : undefined;
777
+ resolved = this.resolveWithConditions(strippedId, parent, conditions);
778
+ const isFileSpecifier = strippedId.startsWith('.') || path.isAbsolute(strippedId);
779
+ if (isFileSpecifier &&
780
+ path.extname(strippedId) === '' &&
781
+ resolved.endsWith('.cjs') &&
782
+ fs.existsSync(`${resolved.slice(0, -4)}.js`)) {
783
+ resolved = `${resolved.slice(0, -4)}.js`;
784
+ }
785
+ }
786
+ }
787
+ catch (error) {
788
+ throw new Error([
789
+ `[wyw-in-js] Native resolver failed during eval.`,
790
+ ``,
791
+ `importer: ${filename}`,
792
+ `source: ${id}`,
793
+ ``,
794
+ `error: ${error instanceof Error ? error.message : String(error)}`,
795
+ ].join('\n'));
751
796
  }
752
797
  const { root } = this.services.options;
753
798
  const keyInfo = toImportKey({
@@ -758,8 +803,12 @@ export class Module {
758
803
  const override = getImportOverride(this.services.options.pluginOptions.importOverrides, keyInfo.key);
759
804
  const evalOptions = getEvalOptions(this.services);
760
805
  const basePolicy = evalOptions.require === 'warn-and-run' ? 'warn' : 'error';
761
- let policy = override?.unknown ?? (override?.mock ? 'allow' : basePolicy);
762
- if (evalOptions.require === 'off' && policy !== 'error') {
806
+ let policy = warnOnFallback
807
+ ? override?.unknown ?? (override?.mock ? 'allow' : basePolicy)
808
+ : 'allow';
809
+ if (warnOnFallback &&
810
+ evalOptions.require === 'off' &&
811
+ policy !== 'error') {
763
812
  policy = 'error';
764
813
  }
765
814
  const shouldWarn = !this.ignored && policy === 'warn';
@@ -780,7 +829,7 @@ export class Module {
780
829
  }
781
830
  if (policy === 'error') {
782
831
  throw new Error([
783
- `[wyw-in-js] Unknown import reached during eval (Node resolver fallback)`,
832
+ `[wyw-in-js] Unknown import reached during eval (native resolver fallback)`,
784
833
  ``,
785
834
  `importer: ${filename}`,
786
835
  `source: ${id}`,
@@ -802,7 +851,7 @@ export class Module {
802
851
  if (shouldWarn && !warnedUnknownImports.has(keyInfo.key)) {
803
852
  warnedUnknownImports.add(keyInfo.key);
804
853
  const warningMessage = [
805
- `[wyw-in-js] Unknown import reached during eval (Node resolver fallback)`,
854
+ `[wyw-in-js] Unknown import reached during eval (native resolver fallback)`,
806
855
  ``,
807
856
  `importer: ${filename}`,
808
857
  `source: ${id}`,
@@ -844,14 +893,14 @@ export class Module {
844
893
  requireWithFallback(id, importer, nonLiteral = false) {
845
894
  const evalOptions = getEvalOptions(this.services);
846
895
  if (nonLiteral || typeof id !== 'string') {
847
- if (evalOptions.mode === 'strict') {
896
+ if (evalOptions.errors === 'strict') {
848
897
  throw new Error(`[wyw-in-js] Non-literal require() is not supported during eval.\n` +
849
898
  `importer: ${importer.name}\n` +
850
899
  `hint: make it a string literal or mock the import via importOverrides.`);
851
900
  }
852
901
  emitEvalWarning(this.services, {
853
902
  code: 'require-error',
854
- message: '[wyw-in-js] Non-literal require() reached during eval (loose mode).',
903
+ message: '[wyw-in-js] Non-literal require() reached during eval (eval.errors: "loose").',
855
904
  importer: importer.name,
856
905
  });
857
906
  return {};
@@ -26,10 +26,13 @@ export interface IPreevalResult {
26
26
  dependencyNames?: string[];
27
27
  evalCode?: string;
28
28
  metadata: WYWTransformMetadata | null;
29
+ processorClassNames?: Record<string, string>;
29
30
  staticSideEffectImportLocals?: string[];
30
31
  staticDependencies?: string[];
31
32
  staticNullWYWMetaExtendsHelpers?: string[];
33
+ staticValuesApplied?: boolean;
32
34
  staticValueCache?: Map<string, unknown>;
35
+ runtimeOnlyStaticValueNames?: string[];
33
36
  staticValueCandidates?: Array<{
34
37
  imports: Array<{
35
38
  imported: 'default' | string;
@@ -1,4 +1,5 @@
1
1
  import type { AsyncScenarioForAction, IResolveImportsAction, SyncScenarioForAction } from '../types';
2
+ type AsyncResolve = (what: string, importer: string, stack: string[]) => Promise<string | null>;
2
3
  /**
3
4
  * Synchronously resolves specified imports with a provided resolver.
4
5
  */
@@ -6,4 +7,5 @@ export declare function syncResolveImports(this: IResolveImportsAction, resolve:
6
7
  /**
7
8
  * Asynchronously resolves specified imports with a provided resolver.
8
9
  */
9
- export declare function asyncResolveImports(this: IResolveImportsAction, resolve: (what: string, importer: string, stack: string[]) => Promise<string | null>): AsyncScenarioForAction<IResolveImportsAction>;
10
+ export declare function asyncResolveImports(this: IResolveImportsAction, resolve: AsyncResolve): AsyncScenarioForAction<IResolveImportsAction>;
11
+ export {};
@@ -1,7 +1,54 @@
1
- /* eslint-disable no-continue,no-await-in-loop,require-yield */
2
1
  import { getFileIdx } from '../../utils/getFileIdx';
3
2
  import { getStack, isSuperSet, mergeOnly } from '../Entrypoint.helpers';
4
3
  import { applyImportOverrideToOnly, getImportOverride, resolveMockSpecifier, toImportKey, } from '../../utils/importOverrides';
4
+ import { resolveWithNativeResolver } from '../../utils/nativeResolver';
5
+ const DEFAULT_EVAL_OPTIONS = {
6
+ errors: 'strict',
7
+ require: 'warn-and-run',
8
+ resolver: 'bundler',
9
+ };
10
+ const getEvalOptions = (services) => ({
11
+ ...DEFAULT_EVAL_OPTIONS,
12
+ ...(services.options.pluginOptions.eval ?? {}),
13
+ });
14
+ const resolveWithConfiguredEvalResolver = async (services, source, importer, stack, resolve) => {
15
+ const evalOptions = getEvalOptions(services);
16
+ if (evalOptions.customResolver) {
17
+ const customResolved = await evalOptions.customResolver(source, importer, 'import');
18
+ if (customResolved) {
19
+ return customResolved.external ? null : customResolved.id;
20
+ }
21
+ if (evalOptions.resolver === 'custom') {
22
+ return null;
23
+ }
24
+ }
25
+ if (evalOptions.resolver === 'hybrid') {
26
+ try {
27
+ return resolveWithNativeResolver({
28
+ conditionNames: services.options.pluginOptions.conditionNames,
29
+ extensions: services.options.pluginOptions.extensions,
30
+ importer,
31
+ kind: 'import',
32
+ oxcOptions: services.options.pluginOptions.oxcOptions,
33
+ specifier: source,
34
+ });
35
+ }
36
+ catch {
37
+ return resolve(source, importer, stack);
38
+ }
39
+ }
40
+ if (evalOptions.resolver === 'native') {
41
+ return resolveWithNativeResolver({
42
+ conditionNames: services.options.pluginOptions.conditionNames,
43
+ extensions: services.options.pluginOptions.extensions,
44
+ importer,
45
+ kind: 'import',
46
+ oxcOptions: services.options.pluginOptions.oxcOptions,
47
+ specifier: source,
48
+ });
49
+ }
50
+ return resolve(source, importer, stack);
51
+ };
5
52
  function applyImportOverrides(services, entrypoint, resolvedImports) {
6
53
  const overrides = services.options.pluginOptions.importOverrides;
7
54
  if (!overrides || Object.keys(overrides).length === 0) {
@@ -120,7 +167,7 @@ export async function* asyncResolveImports(resolve) {
120
167
  const getResolveTask = async (source, only) => {
121
168
  let resolved = null;
122
169
  try {
123
- resolved = await resolve(source, entrypoint.name, getStack(entrypoint));
170
+ resolved = await resolveWithConfiguredEvalResolver(this.services, source, entrypoint.name, getStack(entrypoint), resolve);
124
171
  }
125
172
  catch (err) {
126
173
  log('[async-resolve] ❌ cannot resolve %s in %s: %O', source, entrypoint.name, err);
@@ -0,0 +1,25 @@
1
+ import { runOxcPreevalStage } from '../../../utils/oxcPreevalStage';
2
+ import type { ITransformAction } from '../../types';
3
+ import type { StaticExportCacheEntry, StaticExportResult, StaticFileAnalysis, StaticFileHashCacheEntry, StaticMetadataPreevalCacheEntry } from './types';
4
+ export declare const staticFileAnalysisCaches: WeakMap<object, Map<string, StaticFileAnalysis>>;
5
+ export declare const staticFileHashCaches: WeakMap<object, Map<string, StaticFileHashCacheEntry>>;
6
+ export declare const staticExportResultCaches: WeakMap<object, Map<string, StaticExportCacheEntry>>;
7
+ export declare const staticMetadataPreevalCaches: WeakMap<object, Map<string, StaticMetadataPreevalCacheEntry>>;
8
+ export declare const hashStaticContent: (content: string | Buffer) => string;
9
+ export declare const getWeakCacheMap: <TValue>(caches: WeakMap<object, Map<string, TValue>>, key: object) => Map<string, TValue>;
10
+ export declare const isStaticResolveCacheEnabled: () => boolean;
11
+ export declare const staticCachePrefix: (action: ITransformAction) => string;
12
+ export declare const staticFileAnalysisCache: (action: ITransformAction) => Map<string, StaticFileAnalysis>;
13
+ export declare const staticFileHashCache: (action: ITransformAction) => Map<string, StaticFileHashCacheEntry>;
14
+ export declare const staticExportResultCache: (action: ITransformAction) => Map<string, StaticExportCacheEntry>;
15
+ export declare const staticMetadataPreevalCache: (action: ITransformAction) => Map<string, StaticMetadataPreevalCacheEntry>;
16
+ export declare const staticFileAnalysisCacheKey: (action: ITransformAction, filename: string, codeHash: string) => string;
17
+ export declare const staticExportCacheKey: (action: ITransformAction, filename: string, exportedName: string, codeHash: string) => string;
18
+ export declare const staticMetadataPreevalCacheKey: (action: ITransformAction, filename: string, codeHash: string) => string;
19
+ export declare const getStaticFileContentHash: (action: ITransformAction, dependency: string) => string | null;
20
+ export declare const collectStaticDependencyHashes: (action: ITransformAction, dependencies: string[]) => Map<string, string> | null;
21
+ export declare const areStaticDependencyHashesCurrent: (action: ITransformAction, dependencyHashes: Map<string, string>) => boolean;
22
+ export declare const getStaticExportCachedResult: (action: ITransformAction, filename: string, exportedName: string, codeHash: string) => StaticExportResult | null | undefined;
23
+ export declare const setStaticExportCachedResult: (action: ITransformAction, filename: string, exportedName: string, codeHash: string, result: StaticExportResult | null) => void;
24
+ export declare const getStaticFileAnalysis: (action: ITransformAction, filename: string) => StaticFileAnalysis | null;
25
+ export declare const getStaticMetadataPreevalResult: (action: ITransformAction, filename: string, code: string, codeHash: string) => ReturnType<typeof runOxcPreevalStage> | null;
@@ -0,0 +1,182 @@
1
+ /* eslint-disable no-restricted-syntax,no-continue,@typescript-eslint/no-use-before-define */
2
+ import { createHash } from 'crypto';
3
+ import { readFileSync, statSync } from 'fs';
4
+ import { isAbsolute } from 'path';
5
+ import { oxcShaker } from '../../../shaker';
6
+ import { runOxcPreevalStage } from '../../../utils/oxcPreevalStage';
7
+ import { stripQueryAndHash } from '../../../utils/parseRequest';
8
+ import { isEnvDisabled, parseProgram } from './environment';
9
+ import { STATIC_EXPORT_MAX_NULL_ATTEMPTS } from './types';
10
+ export const staticFileAnalysisCaches = new WeakMap();
11
+ export const staticFileHashCaches = new WeakMap();
12
+ export const staticExportResultCaches = new WeakMap();
13
+ export const staticMetadataPreevalCaches = new WeakMap();
14
+ export const hashStaticContent = (content) => createHash('sha256').update(content).digest('hex');
15
+ export const getWeakCacheMap = (caches, key) => {
16
+ let cache = caches.get(key);
17
+ if (!cache) {
18
+ cache = new Map();
19
+ caches.set(key, cache);
20
+ }
21
+ return cache;
22
+ };
23
+ export const isStaticResolveCacheEnabled = () => {
24
+ const envValue = process.env.WYW_STATIC_RESOLVE_CACHE?.trim().toLowerCase();
25
+ if (envValue) {
26
+ return !isEnvDisabled(envValue);
27
+ }
28
+ return true;
29
+ };
30
+ export const staticCachePrefix = (action) => `${action.services.cache.getKeySalt() ?? ''}\0${action.services.options.root ?? ''}`;
31
+ export const staticFileAnalysisCache = (action) => getWeakCacheMap(staticFileAnalysisCaches, action.services.cache);
32
+ export const staticFileHashCache = (action) => getWeakCacheMap(staticFileHashCaches, action.services.cache);
33
+ export const staticExportResultCache = (action) => getWeakCacheMap(staticExportResultCaches, action.services.cache);
34
+ export const staticMetadataPreevalCache = (action) => getWeakCacheMap(staticMetadataPreevalCaches, action.services.cache);
35
+ export const staticFileAnalysisCacheKey = (action, filename, codeHash) => `${staticCachePrefix(action)}\0${filename}\0${codeHash}`;
36
+ export const staticExportCacheKey = (action, filename, exportedName, codeHash) => `${staticCachePrefix(action)}\0${filename}\0${exportedName}\0${codeHash}`;
37
+ export const staticMetadataPreevalCacheKey = (action, filename, codeHash) => `${staticCachePrefix(action)}\0${filename}\0${codeHash}`;
38
+ export const getStaticFileContentHash = (action, dependency) => {
39
+ const filename = stripQueryAndHash(dependency);
40
+ if (!isAbsolute(filename)) {
41
+ return null;
42
+ }
43
+ let stat;
44
+ try {
45
+ stat = statSync(filename);
46
+ }
47
+ catch {
48
+ return null;
49
+ }
50
+ if (!stat.isFile()) {
51
+ return null;
52
+ }
53
+ const cache = staticFileHashCache(action);
54
+ const cached = cache.get(filename);
55
+ if (cached && cached.mtimeMs === stat.mtimeMs && cached.size === stat.size) {
56
+ return cached.hash;
57
+ }
58
+ let hash;
59
+ try {
60
+ hash = hashStaticContent(readFileSync(filename));
61
+ }
62
+ catch {
63
+ return null;
64
+ }
65
+ cache.set(filename, {
66
+ hash,
67
+ mtimeMs: stat.mtimeMs,
68
+ size: stat.size,
69
+ });
70
+ return hash;
71
+ };
72
+ export const collectStaticDependencyHashes = (action, dependencies) => {
73
+ const hashes = new Map();
74
+ for (const dependency of dependencies) {
75
+ const hash = getStaticFileContentHash(action, dependency);
76
+ if (!hash) {
77
+ return null;
78
+ }
79
+ hashes.set(stripQueryAndHash(dependency), hash);
80
+ }
81
+ return hashes;
82
+ };
83
+ export const areStaticDependencyHashesCurrent = (action, dependencyHashes) => {
84
+ for (const [dependency, expectedHash] of dependencyHashes) {
85
+ if (getStaticFileContentHash(action, dependency) !== expectedHash) {
86
+ return false;
87
+ }
88
+ }
89
+ return true;
90
+ };
91
+ export const getStaticExportCachedResult = (action, filename, exportedName, codeHash) => {
92
+ if (!isStaticResolveCacheEnabled()) {
93
+ return undefined;
94
+ }
95
+ const cache = staticExportResultCache(action);
96
+ const cacheKey = staticExportCacheKey(action, filename, exportedName, codeHash);
97
+ const cached = cache.get(cacheKey);
98
+ if (!cached) {
99
+ return undefined;
100
+ }
101
+ if (cached.result === null) {
102
+ // Bounded retry: until the attempt counter has been bumped enough times
103
+ // that we accept the null as stable, treat it as a cache miss so the
104
+ // caller re-walks. The counter is updated in setStaticExportCachedResult.
105
+ if (cached.attempts < STATIC_EXPORT_MAX_NULL_ATTEMPTS) {
106
+ return undefined;
107
+ }
108
+ return null;
109
+ }
110
+ if (areStaticDependencyHashesCurrent(action, cached.dependencyHashes)) {
111
+ return cached.result;
112
+ }
113
+ cache.delete(cacheKey);
114
+ return undefined;
115
+ };
116
+ export const setStaticExportCachedResult = (action, filename, exportedName, codeHash, result) => {
117
+ if (!isStaticResolveCacheEnabled()) {
118
+ return;
119
+ }
120
+ const cache = staticExportResultCache(action);
121
+ const cacheKey = staticExportCacheKey(action, filename, exportedName, codeHash);
122
+ if (!result) {
123
+ const existing = cache.get(cacheKey);
124
+ const attempts = existing && existing.result === null ? existing.attempts + 1 : 1;
125
+ cache.set(cacheKey, { attempts, result: null });
126
+ return;
127
+ }
128
+ const dependencyHashes = collectStaticDependencyHashes(action, result.dependencies);
129
+ if (!dependencyHashes) {
130
+ return;
131
+ }
132
+ cache.set(cacheKey, {
133
+ dependencyHashes,
134
+ result,
135
+ });
136
+ };
137
+ export const getStaticFileAnalysis = (action, filename) => {
138
+ const loadedAndParsed = action.services.loadAndParseFn(action.services, filename, undefined, action.services.log);
139
+ if (loadedAndParsed.evaluator === 'ignored' ||
140
+ loadedAndParsed.evaluator !== oxcShaker) {
141
+ return null;
142
+ }
143
+ const { code } = loadedAndParsed;
144
+ const codeHash = hashStaticContent(code);
145
+ const cache = staticFileAnalysisCache(action);
146
+ const cacheKey = staticFileAnalysisCacheKey(action, filename, codeHash);
147
+ const cached = cache.get(cacheKey);
148
+ if (cached) {
149
+ return cached;
150
+ }
151
+ const analysis = {
152
+ code,
153
+ codeHash,
154
+ program: parseProgram(code, filename),
155
+ };
156
+ cache.set(cacheKey, analysis);
157
+ return analysis;
158
+ };
159
+ export const getStaticMetadataPreevalResult = (action, filename, code, codeHash) => {
160
+ const cache = staticMetadataPreevalCache(action);
161
+ const cacheKey = staticMetadataPreevalCacheKey(action, filename, codeHash);
162
+ const cached = cache.get(cacheKey);
163
+ if (cached) {
164
+ return cached.result;
165
+ }
166
+ const root = action.services.options.root ?? process.cwd();
167
+ try {
168
+ const result = action.services.eventEmitter.perf('transform:preeval:staticMetadata', () => runOxcPreevalStage(code, {
169
+ filename,
170
+ root,
171
+ }, {
172
+ ...action.services.options.pluginOptions,
173
+ eventEmitter: action.services.eventEmitter,
174
+ }));
175
+ cache.set(cacheKey, { result });
176
+ return result;
177
+ }
178
+ catch {
179
+ cache.set(cacheKey, { result: null });
180
+ return null;
181
+ }
182
+ };
@@ -0,0 +1,5 @@
1
+ import { type OxcStaticValueCandidate } from '../../../utils/collectOxcTemplateDependencies';
2
+ import type { ITransformAction, SyncScenarioFor } from '../../types';
3
+ import type { StaticExportResult } from './types';
4
+ export declare function resolveCandidateValue(action: ITransformAction, candidate: OxcStaticValueCandidate, filename: string, memo: Map<string, StaticExportResult | null>): SyncScenarioFor<StaticExportResult | null>;
5
+ export declare function resolveOpaqueRuntimeCandidateValue(action: ITransformAction, candidate: OxcStaticValueCandidate, filename: string): SyncScenarioFor<StaticExportResult | null>;