@nubjs/nub-darwin-x64 0.2.2 → 0.2.4

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 (348) hide show
  1. package/bin/nub +0 -0
  2. package/bin/nubx +0 -0
  3. package/package.json +2 -3
  4. package/runtime/addons/nub-native.node +0 -0
  5. package/runtime/cache-evict.mjs +0 -69
  6. package/runtime/compile-cache-restore.mjs +0 -21
  7. package/runtime/floor-builtin.mjs +0 -57
  8. package/runtime/navigator-locks.mjs +0 -242
  9. package/runtime/navigator-shim.mjs +0 -144
  10. package/runtime/node_modules/@js-temporal/polyfill/CHANGELOG.md +0 -453
  11. package/runtime/node_modules/@js-temporal/polyfill/LICENSE +0 -13
  12. package/runtime/node_modules/@js-temporal/polyfill/README.md +0 -90
  13. package/runtime/node_modules/@js-temporal/polyfill/dist/index.cjs +0 -2
  14. package/runtime/node_modules/@js-temporal/polyfill/dist/index.cjs.map +0 -1
  15. package/runtime/node_modules/@js-temporal/polyfill/dist/index.esm.js +0 -2
  16. package/runtime/node_modules/@js-temporal/polyfill/dist/index.esm.js.map +0 -1
  17. package/runtime/node_modules/@js-temporal/polyfill/dist/index.umd.js +0 -2
  18. package/runtime/node_modules/@js-temporal/polyfill/dist/index.umd.js.map +0 -1
  19. package/runtime/node_modules/@js-temporal/polyfill/index.d.cts +0 -1215
  20. package/runtime/node_modules/@js-temporal/polyfill/index.d.ts +0 -1215
  21. package/runtime/node_modules/@js-temporal/polyfill/lib/assert.ts +0 -8
  22. package/runtime/node_modules/@js-temporal/polyfill/lib/bigintmath.ts +0 -39
  23. package/runtime/node_modules/@js-temporal/polyfill/lib/calendar.ts +0 -2424
  24. package/runtime/node_modules/@js-temporal/polyfill/lib/debug.ts +0 -7
  25. package/runtime/node_modules/@js-temporal/polyfill/lib/duration.ts +0 -438
  26. package/runtime/node_modules/@js-temporal/polyfill/lib/durationformat.d.ts +0 -93
  27. package/runtime/node_modules/@js-temporal/polyfill/lib/ecmascript.ts +0 -4973
  28. package/runtime/node_modules/@js-temporal/polyfill/lib/index.ts +0 -34
  29. package/runtime/node_modules/@js-temporal/polyfill/lib/init.ts +0 -43
  30. package/runtime/node_modules/@js-temporal/polyfill/lib/instant.ts +0 -138
  31. package/runtime/node_modules/@js-temporal/polyfill/lib/internaltypes.d.ts +0 -242
  32. package/runtime/node_modules/@js-temporal/polyfill/lib/intl.ts +0 -758
  33. package/runtime/node_modules/@js-temporal/polyfill/lib/intrinsicclass.ts +0 -162
  34. package/runtime/node_modules/@js-temporal/polyfill/lib/legacydate.ts +0 -17
  35. package/runtime/node_modules/@js-temporal/polyfill/lib/math.ts +0 -96
  36. package/runtime/node_modules/@js-temporal/polyfill/lib/now.ts +0 -48
  37. package/runtime/node_modules/@js-temporal/polyfill/lib/plaindate.ts +0 -212
  38. package/runtime/node_modules/@js-temporal/polyfill/lib/plaindatetime.ts +0 -274
  39. package/runtime/node_modules/@js-temporal/polyfill/lib/plainmonthday.ts +0 -110
  40. package/runtime/node_modules/@js-temporal/polyfill/lib/plaintime.ts +0 -154
  41. package/runtime/node_modules/@js-temporal/polyfill/lib/plainyearmonth.ts +0 -157
  42. package/runtime/node_modules/@js-temporal/polyfill/lib/regex.ts +0 -59
  43. package/runtime/node_modules/@js-temporal/polyfill/lib/slots.ts +0 -341
  44. package/runtime/node_modules/@js-temporal/polyfill/lib/temporal.ts +0 -10
  45. package/runtime/node_modules/@js-temporal/polyfill/lib/timeduration.ts +0 -149
  46. package/runtime/node_modules/@js-temporal/polyfill/lib/zoneddatetime.ts +0 -492
  47. package/runtime/node_modules/@js-temporal/polyfill/package.json +0 -143
  48. package/runtime/node_modules/@oxc-project/runtime/CHANGELOG.md +0 -88
  49. package/runtime/node_modules/@oxc-project/runtime/LICENSE +0 -22
  50. package/runtime/node_modules/@oxc-project/runtime/README.md +0 -5
  51. package/runtime/node_modules/@oxc-project/runtime/package.json +0 -1066
  52. package/runtime/node_modules/@oxc-project/runtime/src/helpers/AwaitValue.js +0 -4
  53. package/runtime/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js +0 -4
  54. package/runtime/node_modules/@oxc-project/runtime/src/helpers/applyDecoratedDescriptor.js +0 -9
  55. package/runtime/node_modules/@oxc-project/runtime/src/helpers/applyDecs.js +0 -236
  56. package/runtime/node_modules/@oxc-project/runtime/src/helpers/applyDecs2203.js +0 -184
  57. package/runtime/node_modules/@oxc-project/runtime/src/helpers/applyDecs2203R.js +0 -191
  58. package/runtime/node_modules/@oxc-project/runtime/src/helpers/applyDecs2301.js +0 -222
  59. package/runtime/node_modules/@oxc-project/runtime/src/helpers/applyDecs2305.js +0 -133
  60. package/runtime/node_modules/@oxc-project/runtime/src/helpers/applyDecs2311.js +0 -124
  61. package/runtime/node_modules/@oxc-project/runtime/src/helpers/arrayLikeToArray.js +0 -6
  62. package/runtime/node_modules/@oxc-project/runtime/src/helpers/arrayWithHoles.js +0 -4
  63. package/runtime/node_modules/@oxc-project/runtime/src/helpers/arrayWithoutHoles.js +0 -5
  64. package/runtime/node_modules/@oxc-project/runtime/src/helpers/assertClassBrand.js +0 -5
  65. package/runtime/node_modules/@oxc-project/runtime/src/helpers/assertThisInitialized.js +0 -5
  66. package/runtime/node_modules/@oxc-project/runtime/src/helpers/asyncGeneratorDelegate.js +0 -24
  67. package/runtime/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js +0 -45
  68. package/runtime/node_modules/@oxc-project/runtime/src/helpers/asyncToGenerator.js +0 -26
  69. package/runtime/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js +0 -5
  70. package/runtime/node_modules/@oxc-project/runtime/src/helpers/callSuper.js +0 -7
  71. package/runtime/node_modules/@oxc-project/runtime/src/helpers/checkInRHS.js +0 -6
  72. package/runtime/node_modules/@oxc-project/runtime/src/helpers/checkPrivateRedeclaration.js +0 -4
  73. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classApplyDescriptorDestructureSet.js +0 -10
  74. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classApplyDescriptorGet.js +0 -4
  75. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classApplyDescriptorSet.js +0 -7
  76. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classCallCheck.js +0 -4
  77. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classCheckPrivateStaticAccess.js +0 -5
  78. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classCheckPrivateStaticFieldDescriptor.js +0 -4
  79. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classExtractFieldDescriptor.js +0 -5
  80. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classNameTDZError.js +0 -4
  81. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateFieldDestructureSet.js +0 -7
  82. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateFieldGet.js +0 -7
  83. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateFieldGet2.js +0 -5
  84. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateFieldInitSpec.js +0 -5
  85. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateFieldLooseBase.js +0 -5
  86. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateFieldLooseKey.js +0 -5
  87. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateFieldSet.js +0 -7
  88. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateFieldSet2.js +0 -5
  89. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateGetter.js +0 -5
  90. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateMethodGet.js +0 -5
  91. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateMethodInitSpec.js +0 -5
  92. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateMethodSet.js +0 -4
  93. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classPrivateSetter.js +0 -5
  94. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classStaticPrivateFieldDestructureSet.js +0 -7
  95. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classStaticPrivateFieldSpecGet.js +0 -7
  96. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classStaticPrivateFieldSpecSet.js +0 -7
  97. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classStaticPrivateMethodGet.js +0 -5
  98. package/runtime/node_modules/@oxc-project/runtime/src/helpers/classStaticPrivateMethodSet.js +0 -4
  99. package/runtime/node_modules/@oxc-project/runtime/src/helpers/construct.js +0 -10
  100. package/runtime/node_modules/@oxc-project/runtime/src/helpers/createClass.js +0 -13
  101. package/runtime/node_modules/@oxc-project/runtime/src/helpers/createForOfIteratorHelper.js +0 -50
  102. package/runtime/node_modules/@oxc-project/runtime/src/helpers/createForOfIteratorHelperLoose.js +0 -19
  103. package/runtime/node_modules/@oxc-project/runtime/src/helpers/createSuper.js +0 -16
  104. package/runtime/node_modules/@oxc-project/runtime/src/helpers/decorate.js +0 -23
  105. package/runtime/node_modules/@oxc-project/runtime/src/helpers/decorateMetadata.js +0 -9
  106. package/runtime/node_modules/@oxc-project/runtime/src/helpers/decorateParam.js +0 -11
  107. package/runtime/node_modules/@oxc-project/runtime/src/helpers/defaults.js +0 -9
  108. package/runtime/node_modules/@oxc-project/runtime/src/helpers/defineAccessor.js +0 -8
  109. package/runtime/node_modules/@oxc-project/runtime/src/helpers/defineEnumerableProperties.js +0 -12
  110. package/runtime/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js +0 -10
  111. package/runtime/node_modules/@oxc-project/runtime/src/helpers/dispose.js +0 -28
  112. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/AwaitValue.js +0 -4
  113. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/OverloadYield.js +0 -4
  114. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/applyDecoratedDescriptor.js +0 -9
  115. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/applyDecs.js +0 -236
  116. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/applyDecs2203.js +0 -184
  117. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/applyDecs2203R.js +0 -191
  118. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/applyDecs2301.js +0 -222
  119. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/applyDecs2305.js +0 -133
  120. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/applyDecs2311.js +0 -124
  121. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/arrayLikeToArray.js +0 -6
  122. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/arrayWithHoles.js +0 -4
  123. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/arrayWithoutHoles.js +0 -5
  124. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/assertClassBrand.js +0 -5
  125. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/assertThisInitialized.js +0 -5
  126. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/asyncGeneratorDelegate.js +0 -24
  127. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/asyncIterator.js +0 -45
  128. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/asyncToGenerator.js +0 -26
  129. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/awaitAsyncGenerator.js +0 -5
  130. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/callSuper.js +0 -7
  131. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/checkInRHS.js +0 -6
  132. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/checkPrivateRedeclaration.js +0 -4
  133. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classApplyDescriptorDestructureSet.js +0 -10
  134. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classApplyDescriptorGet.js +0 -4
  135. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classApplyDescriptorSet.js +0 -7
  136. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classCallCheck.js +0 -4
  137. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classCheckPrivateStaticAccess.js +0 -5
  138. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classCheckPrivateStaticFieldDescriptor.js +0 -4
  139. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classExtractFieldDescriptor.js +0 -5
  140. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classNameTDZError.js +0 -4
  141. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateFieldDestructureSet.js +0 -7
  142. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateFieldGet.js +0 -7
  143. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateFieldGet2.js +0 -5
  144. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateFieldInitSpec.js +0 -5
  145. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateFieldLooseBase.js +0 -5
  146. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateFieldLooseKey.js +0 -5
  147. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateFieldSet.js +0 -7
  148. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateFieldSet2.js +0 -5
  149. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateGetter.js +0 -5
  150. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateMethodGet.js +0 -5
  151. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateMethodInitSpec.js +0 -5
  152. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateMethodSet.js +0 -4
  153. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classPrivateSetter.js +0 -5
  154. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classStaticPrivateFieldDestructureSet.js +0 -7
  155. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classStaticPrivateFieldSpecGet.js +0 -7
  156. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classStaticPrivateFieldSpecSet.js +0 -7
  157. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classStaticPrivateMethodGet.js +0 -5
  158. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/classStaticPrivateMethodSet.js +0 -4
  159. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/construct.js +0 -10
  160. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/createClass.js +0 -13
  161. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/createForOfIteratorHelper.js +0 -50
  162. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/createForOfIteratorHelperLoose.js +0 -19
  163. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/createSuper.js +0 -16
  164. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/decorate.js +0 -21
  165. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/decorateMetadata.js +0 -7
  166. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/decorateParam.js +0 -9
  167. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/defaults.js +0 -9
  168. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/defineAccessor.js +0 -8
  169. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/defineEnumerableProperties.js +0 -12
  170. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/defineProperty.js +0 -10
  171. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/dispose.js +0 -28
  172. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/extends.js +0 -10
  173. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/get.js +0 -11
  174. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/getPrototypeOf.js +0 -6
  175. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/identity.js +0 -4
  176. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/importDeferProxy.js +0 -27
  177. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/inherits.js +0 -14
  178. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/inheritsLoose.js +0 -5
  179. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/initializerDefineProperty.js +0 -9
  180. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/initializerWarningHelper.js +0 -4
  181. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/instanceof.js +0 -4
  182. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/interopRequireDefault.js +0 -6
  183. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/interopRequireWildcard.js +0 -27
  184. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/isNativeFunction.js +0 -8
  185. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/isNativeReflectConstruct.js +0 -9
  186. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/iterableToArray.js +0 -4
  187. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/iterableToArrayLimit.js +0 -28
  188. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/jsx.js +0 -22
  189. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/maybeArrayLike.js +0 -9
  190. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/newArrowCheck.js +0 -4
  191. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/nonIterableRest.js +0 -4
  192. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/nonIterableSpread.js +0 -4
  193. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/nullishReceiverError.js +0 -4
  194. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/objectDestructuringEmpty.js +0 -4
  195. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/objectSpread.js +0 -14
  196. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/objectSpread2.js +0 -23
  197. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/objectWithoutProperties.js +0 -13
  198. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/objectWithoutPropertiesLoose.js +0 -10
  199. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/package.json +0 -3
  200. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/possibleConstructorReturn.js +0 -8
  201. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/readOnlyError.js +0 -4
  202. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/regeneratorRuntime.js +0 -304
  203. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/set.js +0 -22
  204. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/setFunctionName.js +0 -12
  205. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/setPrototypeOf.js +0 -6
  206. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/skipFirstGeneratorNext.js +0 -7
  207. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/slicedToArray.js +0 -8
  208. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/superPropBase.js +0 -6
  209. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/superPropGet.js +0 -9
  210. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/superPropSet.js +0 -6
  211. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/taggedTemplateLiteral.js +0 -8
  212. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/taggedTemplateLiteralLoose.js +0 -4
  213. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/tdz.js +0 -4
  214. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/temporalRef.js +0 -6
  215. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/temporalUndefined.js +0 -2
  216. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/toArray.js +0 -8
  217. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/toConsumableArray.js +0 -8
  218. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/toPrimitive.js +0 -12
  219. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/toPropertyKey.js +0 -7
  220. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/toSetter.js +0 -10
  221. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/typeof.js +0 -10
  222. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/unsupportedIterableToArray.js +0 -9
  223. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/using.js +0 -12
  224. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/usingCtx.js +0 -59
  225. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/wrapAsyncGenerator.js +0 -69
  226. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/wrapNativeSuper.js +0 -27
  227. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/wrapRegExp.js +0 -51
  228. package/runtime/node_modules/@oxc-project/runtime/src/helpers/esm/writeOnlyError.js +0 -4
  229. package/runtime/node_modules/@oxc-project/runtime/src/helpers/extends.js +0 -10
  230. package/runtime/node_modules/@oxc-project/runtime/src/helpers/get.js +0 -11
  231. package/runtime/node_modules/@oxc-project/runtime/src/helpers/getPrototypeOf.js +0 -6
  232. package/runtime/node_modules/@oxc-project/runtime/src/helpers/identity.js +0 -4
  233. package/runtime/node_modules/@oxc-project/runtime/src/helpers/importDeferProxy.js +0 -27
  234. package/runtime/node_modules/@oxc-project/runtime/src/helpers/inherits.js +0 -14
  235. package/runtime/node_modules/@oxc-project/runtime/src/helpers/inheritsLoose.js +0 -5
  236. package/runtime/node_modules/@oxc-project/runtime/src/helpers/initializerDefineProperty.js +0 -9
  237. package/runtime/node_modules/@oxc-project/runtime/src/helpers/initializerWarningHelper.js +0 -4
  238. package/runtime/node_modules/@oxc-project/runtime/src/helpers/instanceof.js +0 -4
  239. package/runtime/node_modules/@oxc-project/runtime/src/helpers/interopRequireDefault.js +0 -6
  240. package/runtime/node_modules/@oxc-project/runtime/src/helpers/interopRequireWildcard.js +0 -27
  241. package/runtime/node_modules/@oxc-project/runtime/src/helpers/isNativeFunction.js +0 -8
  242. package/runtime/node_modules/@oxc-project/runtime/src/helpers/isNativeReflectConstruct.js +0 -9
  243. package/runtime/node_modules/@oxc-project/runtime/src/helpers/iterableToArray.js +0 -4
  244. package/runtime/node_modules/@oxc-project/runtime/src/helpers/iterableToArrayLimit.js +0 -28
  245. package/runtime/node_modules/@oxc-project/runtime/src/helpers/jsx.js +0 -22
  246. package/runtime/node_modules/@oxc-project/runtime/src/helpers/maybeArrayLike.js +0 -9
  247. package/runtime/node_modules/@oxc-project/runtime/src/helpers/newArrowCheck.js +0 -4
  248. package/runtime/node_modules/@oxc-project/runtime/src/helpers/nonIterableRest.js +0 -4
  249. package/runtime/node_modules/@oxc-project/runtime/src/helpers/nonIterableSpread.js +0 -4
  250. package/runtime/node_modules/@oxc-project/runtime/src/helpers/nullishReceiverError.js +0 -4
  251. package/runtime/node_modules/@oxc-project/runtime/src/helpers/objectDestructuringEmpty.js +0 -4
  252. package/runtime/node_modules/@oxc-project/runtime/src/helpers/objectSpread.js +0 -14
  253. package/runtime/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js +0 -23
  254. package/runtime/node_modules/@oxc-project/runtime/src/helpers/objectWithoutProperties.js +0 -13
  255. package/runtime/node_modules/@oxc-project/runtime/src/helpers/objectWithoutPropertiesLoose.js +0 -10
  256. package/runtime/node_modules/@oxc-project/runtime/src/helpers/possibleConstructorReturn.js +0 -8
  257. package/runtime/node_modules/@oxc-project/runtime/src/helpers/readOnlyError.js +0 -4
  258. package/runtime/node_modules/@oxc-project/runtime/src/helpers/regeneratorRuntime.js +0 -304
  259. package/runtime/node_modules/@oxc-project/runtime/src/helpers/set.js +0 -22
  260. package/runtime/node_modules/@oxc-project/runtime/src/helpers/setFunctionName.js +0 -12
  261. package/runtime/node_modules/@oxc-project/runtime/src/helpers/setPrototypeOf.js +0 -6
  262. package/runtime/node_modules/@oxc-project/runtime/src/helpers/skipFirstGeneratorNext.js +0 -7
  263. package/runtime/node_modules/@oxc-project/runtime/src/helpers/slicedToArray.js +0 -8
  264. package/runtime/node_modules/@oxc-project/runtime/src/helpers/superPropBase.js +0 -6
  265. package/runtime/node_modules/@oxc-project/runtime/src/helpers/superPropGet.js +0 -9
  266. package/runtime/node_modules/@oxc-project/runtime/src/helpers/superPropSet.js +0 -6
  267. package/runtime/node_modules/@oxc-project/runtime/src/helpers/taggedTemplateLiteral.js +0 -8
  268. package/runtime/node_modules/@oxc-project/runtime/src/helpers/taggedTemplateLiteralLoose.js +0 -4
  269. package/runtime/node_modules/@oxc-project/runtime/src/helpers/tdz.js +0 -4
  270. package/runtime/node_modules/@oxc-project/runtime/src/helpers/temporalRef.js +0 -6
  271. package/runtime/node_modules/@oxc-project/runtime/src/helpers/temporalUndefined.js +0 -2
  272. package/runtime/node_modules/@oxc-project/runtime/src/helpers/toArray.js +0 -8
  273. package/runtime/node_modules/@oxc-project/runtime/src/helpers/toConsumableArray.js +0 -8
  274. package/runtime/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js +0 -12
  275. package/runtime/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js +0 -7
  276. package/runtime/node_modules/@oxc-project/runtime/src/helpers/toSetter.js +0 -10
  277. package/runtime/node_modules/@oxc-project/runtime/src/helpers/typeof.js +0 -10
  278. package/runtime/node_modules/@oxc-project/runtime/src/helpers/unsupportedIterableToArray.js +0 -9
  279. package/runtime/node_modules/@oxc-project/runtime/src/helpers/using.js +0 -12
  280. package/runtime/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js +0 -59
  281. package/runtime/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js +0 -69
  282. package/runtime/node_modules/@oxc-project/runtime/src/helpers/wrapNativeSuper.js +0 -27
  283. package/runtime/node_modules/@oxc-project/runtime/src/helpers/wrapRegExp.js +0 -51
  284. package/runtime/node_modules/@oxc-project/runtime/src/helpers/writeOnlyError.js +0 -4
  285. package/runtime/node_modules/@petamoriken/float16/LICENSE +0 -21
  286. package/runtime/node_modules/@petamoriken/float16/README.md +0 -413
  287. package/runtime/node_modules/@petamoriken/float16/browser/float16.js +0 -1340
  288. package/runtime/node_modules/@petamoriken/float16/browser/float16.mjs +0 -1325
  289. package/runtime/node_modules/@petamoriken/float16/index.d.ts +0 -546
  290. package/runtime/node_modules/@petamoriken/float16/index.v5.6.d.ts +0 -546
  291. package/runtime/node_modules/@petamoriken/float16/index.v5.7.d.ts +0 -555
  292. package/runtime/node_modules/@petamoriken/float16/inspect/node.cjs +0 -25
  293. package/runtime/node_modules/@petamoriken/float16/inspect/node.mjs +0 -23
  294. package/runtime/node_modules/@petamoriken/float16/lib/DataView.cjs +0 -16
  295. package/runtime/node_modules/@petamoriken/float16/lib/Float16Array.cjs +0 -690
  296. package/runtime/node_modules/@petamoriken/float16/lib/_util/arrayIterator.cjs +0 -52
  297. package/runtime/node_modules/@petamoriken/float16/lib/_util/brand.cjs +0 -27
  298. package/runtime/node_modules/@petamoriken/float16/lib/_util/converter.cjs +0 -111
  299. package/runtime/node_modules/@petamoriken/float16/lib/_util/is.cjs +0 -78
  300. package/runtime/node_modules/@petamoriken/float16/lib/_util/messages.cjs +0 -18
  301. package/runtime/node_modules/@petamoriken/float16/lib/_util/primordials.cjs +0 -150
  302. package/runtime/node_modules/@petamoriken/float16/lib/_util/spec.cjs +0 -84
  303. package/runtime/node_modules/@petamoriken/float16/lib/f16round.cjs +0 -10
  304. package/runtime/node_modules/@petamoriken/float16/lib/index.cjs +0 -16
  305. package/runtime/node_modules/@petamoriken/float16/lib/isTypedArray.cjs +0 -11
  306. package/runtime/node_modules/@petamoriken/float16/package.json +0 -115
  307. package/runtime/node_modules/@petamoriken/float16/src/DataView.mjs +0 -35
  308. package/runtime/node_modules/@petamoriken/float16/src/Float16Array.mjs +0 -1194
  309. package/runtime/node_modules/@petamoriken/float16/src/_util/arrayIterator.mjs +0 -86
  310. package/runtime/node_modules/@petamoriken/float16/src/_util/brand.mjs +0 -31
  311. package/runtime/node_modules/@petamoriken/float16/src/_util/converter.mjs +0 -173
  312. package/runtime/node_modules/@petamoriken/float16/src/_util/is.mjs +0 -151
  313. package/runtime/node_modules/@petamoriken/float16/src/_util/messages.mjs +0 -22
  314. package/runtime/node_modules/@petamoriken/float16/src/_util/primordials.mjs +0 -254
  315. package/runtime/node_modules/@petamoriken/float16/src/_util/spec.mjs +0 -137
  316. package/runtime/node_modules/@petamoriken/float16/src/f16round.mjs +0 -10
  317. package/runtime/node_modules/@petamoriken/float16/src/index.mjs +0 -7
  318. package/runtime/node_modules/@petamoriken/float16/src/isTypedArray.mjs +0 -10
  319. package/runtime/node_modules/jsbi/LICENSE +0 -176
  320. package/runtime/node_modules/jsbi/README.md +0 -173
  321. package/runtime/node_modules/jsbi/dist/jsbi-cjs.js +0 -2
  322. package/runtime/node_modules/jsbi/dist/jsbi-cjs.js.map +0 -1
  323. package/runtime/node_modules/jsbi/dist/jsbi-umd.js +0 -2
  324. package/runtime/node_modules/jsbi/dist/jsbi-umd.js.map +0 -1
  325. package/runtime/node_modules/jsbi/dist/jsbi.mjs +0 -2
  326. package/runtime/node_modules/jsbi/dist/jsbi.mjs.map +0 -1
  327. package/runtime/node_modules/jsbi/jsbi.d.ts +0 -43
  328. package/runtime/node_modules/jsbi/package.json +0 -35
  329. package/runtime/node_modules/urlpattern-polyfill/LICENSE +0 -19
  330. package/runtime/node_modules/urlpattern-polyfill/README.md +0 -242
  331. package/runtime/node_modules/urlpattern-polyfill/dist/index.d.ts +0 -9
  332. package/runtime/node_modules/urlpattern-polyfill/dist/types.d.ts +0 -49
  333. package/runtime/node_modules/urlpattern-polyfill/dist/urlpattern.cjs +0 -1
  334. package/runtime/node_modules/urlpattern-polyfill/dist/urlpattern.js +0 -1
  335. package/runtime/node_modules/urlpattern-polyfill/index.cjs +0 -7
  336. package/runtime/node_modules/urlpattern-polyfill/index.js +0 -7
  337. package/runtime/node_modules/urlpattern-polyfill/package.json +0 -149
  338. package/runtime/pnp-bin-run.cjs +0 -91
  339. package/runtime/pnp-util.cjs +0 -62
  340. package/runtime/polyfills.cjs +0 -278
  341. package/runtime/preload-async-hooks.mjs +0 -110
  342. package/runtime/preload-common.cjs +0 -1096
  343. package/runtime/preload.cjs +0 -313
  344. package/runtime/preload.mjs +0 -149
  345. package/runtime/transform-core.mjs +0 -756
  346. package/runtime/version.mjs +0 -12
  347. package/runtime/worker-blob-url.cjs +0 -116
  348. package/runtime/worker-polyfill.mjs +0 -541
@@ -1,1096 +0,0 @@
1
- // Shared preload machinery for BOTH tiers — CommonJS, zero top-level await.
2
- //
3
- // The fast tier (Node 22.15+) loads this from a `--require` CJS preload
4
- // (preload.cjs) so Node keeps its synchronous `Module.runMain` CJS entry path
5
- // (top-level `executionAsyncId()===1`, sync exception origin, `require.main.id`
6
- // `'.'`, `module.parent` `null`) — all of which the old `--import` ESM preload
7
- // broke by forcing eager ESM-loader init that routed even a CJS entry through the
8
- // async ESM module-job (R1). The compat tier (18.19–22.14) loads this from its
9
- // async `--import` preload.mjs and reuses the same hook/require/watch/Temporal
10
- // logic; only hook REGISTRATION differs (sync `module.registerHooks` on the fast
11
- // tier vs async `module.register` loader worker on compat), which each entry owns.
12
- //
13
- // EVERYTHING here is synchronous and import-of-transform-core is a plain
14
- // `require()` — transform-core.mjs has no top-level await and is require(esm)-able
15
- // on the fast tier; the compat entry passes its already-imported core bindings in
16
- // (it imported them as ESM), so this module never require()s the core there.
17
-
18
- const module_ = require("node:module");
19
- const { readdirSync } = require("node:fs");
20
- const { fileURLToPath, pathToFileURL } = require("node:url");
21
- const { join, dirname, extname: pathExtname } = require("node:path");
22
-
23
- // ── data: URL unknown-format fidelity helpers ───────────────────────
24
- // Mirror Node's internal/modules/esm/get_format.js so nub's sync registerHooks load
25
- // hook surfaces ERR_UNKNOWN_MODULE_FORMAT for an unsupported `data:` MIME exactly as
26
- // plain Node does (see the load hook for why the sync tier needs this pre-check).
27
- // `mimeToFormat`: text/application javascript -> module, application/json -> json,
28
- // application/wasm -> wasm, anything else -> null (unknown).
29
- function dataUrlMimeToFormat(mime) {
30
- if (mime == null) return null;
31
- if (/^\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?$/i.test(mime)) return "module";
32
- if (mime === "application/json") return "json";
33
- if (mime === "application/wasm") return "wasm";
34
- return null;
35
- }
36
-
37
- // Returns true when `url` is a `data:` URL whose MIME maps to no module format —
38
- // i.e. the case where Node would ultimately throw ERR_UNKNOWN_MODULE_FORMAT.
39
- function unknownDataUrlFormat(url) {
40
- // Strip the `data:` scheme; Node parses the pathname (everything after `data:`).
41
- const m = /^([^/]+\/[^;,]+)(?:[^,]*?)(;base64)?,/.exec(url.slice(5));
42
- const mime = m ? m[1] : null;
43
- return dataUrlMimeToFormat(mime) === null;
44
- }
45
-
46
- // Yarn PnP API handle, fetched lazily via Node's `module.findPnpApi`. `.pnp.cjs`
47
- // (injected by the Rust spawn layer via --require, ahead of nub's preload) sets
48
- // `process.versions.pnp` and installs `findPnpApi`, which returns the pnpapi object
49
- // governing a given path. Unlike a bare `require("pnpapi")` — which throws here,
50
- // since this preload lives in nub's install dir, OUTSIDE the user's PnP tree —
51
- // `findPnpApi` resolves by the queried path, so an out-of-tree issuer works. Being
52
- // a plain query it never re-enters nub's resolve hooks, so there is no ordering
53
- // constraint with `module.registerHooks` (the reason the previous abs-path require
54
- // was load-bearing-fragile). nub resolves PnP specifiers through
55
- // `pnpapi.resolveRequest` (its public, conditions-free resolver) in both the
56
- // registerHooks resolve hook and the `_resolveFilename` override below. No env var
57
- // (brand boundary); `null` when this is not a PnP run.
58
- let __pnpApi;
59
- function pnpApi() {
60
- if (__pnpApi) return __pnpApi; // cache only a SUCCESSFUL lookup (see below)
61
- if (!process.versions.pnp) return null;
62
- // `findPnpApi` matches by the queried path. A single synthesized `cwd + sep` anchor
63
- // can miss on Windows (drive-letter casing, 8.3 short paths, trailing separator),
64
- // and a transient early miss must NOT be cached sticky — otherwise every later
65
- // resolution falls through to PnP's `_resolveFilename`, which rejects the
66
- // `conditions` option Node injects under a registered hook (the intermittent
67
- // Windows `conditions` crash). So try several real in-tree anchors and cache only
68
- // on success: `argv[1]` is the user's entry file (in-tree for `nub <file>`); cwd
69
- // covers `nub run` / `nub exec`.
70
- for (const anchor of [process.argv[1], cwdIssuer(), process.cwd()]) {
71
- if (!anchor) continue;
72
- try {
73
- const api = module_.findPnpApi(anchor);
74
- if (api) return (__pnpApi = api);
75
- } catch {}
76
- }
77
- return null;
78
- }
79
-
80
- // Shared PnP ESM resolution (resolveRequest + format) + the directory-issuer
81
- // helper, identical to the compat worker's — see runtime/pnp-util.cjs.
82
- const { pnpResolveEsm, cwdIssuer } = require("./pnp-util.cjs");
83
-
84
- // ── Watch-mode dependency reporting (main thread only) ──────────────
85
- // Under `nub watch`, Node's FilesWatcher only watches files in the import graph;
86
- // config files (tsconfig.json, package.json) and `.env*` are NOT in any graph, so
87
- // an edit to them otherwise goes stale. Node accepts incremental
88
- // `process.send({'watch:require': [...]})` over its WATCH_REPORT_DEPENDENCIES IPC
89
- // at ANY point in the child's life (it adds each path to the watch set), so we
90
- // report config paths AS the core loader discovers them. The reporters are
91
- // injected into the core via setWatchHooks so getTsconfigForDir / getPackageType
92
- // self-report. The flush is coalesced via setImmediate.
93
- function installWatchReporting(core) {
94
- const WATCH_REPORTING =
95
- process.env.WATCH_REPORT_DEPENDENCIES === "1" && typeof process.send === "function";
96
- const watchReported = new Set();
97
- const watchPending = [];
98
- let watchFlushScheduled = false;
99
- function flushWatchDeps() {
100
- watchFlushScheduled = false;
101
- if (watchPending.length === 0) return;
102
- const batch = watchPending.splice(0, watchPending.length);
103
- try { process.send({ "watch:require": batch }); } catch {}
104
- }
105
- function reportWatchDep(path) {
106
- if (!WATCH_REPORTING || !path || watchReported.has(path)) return;
107
- watchReported.add(path);
108
- watchPending.push(path);
109
- if (!watchFlushScheduled) {
110
- watchFlushScheduled = true;
111
- // A scheduled immediate is drained before the loop would exit, so even a
112
- // script that finishes synchronously flushes its deps. (Don't unref: an
113
- // unref'd immediate is skipped on a synchronous exit, dropping the report.)
114
- setImmediate(flushWatchDeps);
115
- }
116
- }
117
- // Report a directory's `.env*` files (the natural watch targets). Scanned once
118
- // per directory, lazily.
119
- const watchEnvScannedDirs = new Set();
120
- function reportEnvFilesIn(dir) {
121
- if (!WATCH_REPORTING || watchEnvScannedDirs.has(dir)) return;
122
- watchEnvScannedDirs.add(dir);
123
- let entries;
124
- try { entries = readdirSync(dir); } catch { return; }
125
- for (const name of entries) {
126
- if (name === ".env" || name.startsWith(".env.")) reportWatchDep(join(dir, name));
127
- }
128
- }
129
- core.setWatchHooks({ reportDep: reportWatchDep, reportEnvDir: reportEnvFilesIn });
130
- return WATCH_REPORTING;
131
- }
132
-
133
- // ── Resolve / load hooks (sync `module.registerHooks` shape) ────────
134
- // Returns `{ resolve, load }` closing over `core` + the watch flag. The compat
135
- // tier does NOT use these (its hooks run async in the loader worker via
136
- // preload-async-hooks.mjs); only the fast tier's `module.registerHooks` does.
137
-
138
- // True once USER code registers its own `module.registerHooks` (a ts-node/tsx-style
139
- // transpiler). nub registers exactly one hook set from the preload (the FIRST call
140
- // after the wrap below); every later call is the user's. This lets the load hook
141
- // tell apart a bare `'typescript'` format that a USER resolve hook set (defer — the
142
- // user's own load hook will transpile) from the bare `'typescript'` that Node's
143
- // NATIVE CJS loader assigns to a `.ts` entry/require in a package with no explicit
144
- // `type` (transpile — there is no user hook to do it, and Node's strip-only mode
145
- // can't handle enums/namespaces). See makeHooks().load.
146
- let __userHooksRegistered = false;
147
- function installUserHookDetector() {
148
- if (typeof module_.registerHooks !== "function") return;
149
- const orig = module_.registerHooks;
150
- if (orig.__nubWrapped) return;
151
- let seen = 0;
152
- const wrapped = function (...args) {
153
- // Call #1 is nub's own preload registration; #2+ are user hooks.
154
- if (seen >= 1) __userHooksRegistered = true;
155
- seen += 1;
156
- return orig.apply(this, args);
157
- };
158
- wrapped.__nubWrapped = true;
159
- try { module_.registerHooks = wrapped; } catch {}
160
- }
161
-
162
- // True once a USER async ESM loader is active — registered via `module.register()`
163
- // at runtime (the tsx / ts-node/esm pattern, incl. via `--import`). On the FAST tier
164
- // nub itself NEVER calls `module.register()` (it uses sync `module.registerHooks`),
165
- // so on that tier any `module.register()` call is the user's. We wrap it to observe
166
- // runtime registrations; the static CLI-flag forms (`--experimental-loader`/`--loader`
167
- // /`--import`) are read separately from `process.execArgv` (see userAsyncLoaderActive).
168
- let __userAsyncLoaderRegistered = false;
169
- function installUserAsyncLoaderDetector() {
170
- if (typeof module_.register !== "function") return;
171
- const orig = module_.register;
172
- if (orig.__nubAsyncWrapped) return;
173
- const wrapped = function (...args) {
174
- // On the fast tier nub never calls module.register, so every call here is the
175
- // user's. (registerLoaderWorker — nub's only register caller — is the compat /
176
- // require(esm)-off path, which does not run the fast-tier sync load hook that
177
- // performs the commonjs-sync relabel, so a false positive there is harmless.)
178
- __userAsyncLoaderRegistered = true;
179
- return orig.apply(this, args);
180
- };
181
- wrapped.__nubAsyncWrapped = true;
182
- try { module_.register = wrapped; } catch {}
183
- }
184
-
185
- // Did the process start with a CLI flag that registers a user async ESM loader?
186
- // `--experimental-loader` / `--loader` register a loader directly; `--import` runs a
187
- // module that commonly calls `module.register()` (tsx, ts-node/esm). Read once from
188
- // `process.execArgv` — these flags appear before any user code runs, so this is a
189
- // reliable preload-time signal. Conservative on `--import`: a `--import` that does NOT
190
- // register a loader is harmless to relabel, but presence of the flag declines the
191
- // optimization rather than risk interop breakage (correctness over coverage).
192
- let __cliAsyncLoaderCache;
193
- function cliAsyncLoaderPresent() {
194
- if (__cliAsyncLoaderCache !== undefined) return __cliAsyncLoaderCache;
195
- let present = false;
196
- try {
197
- const argv = process.execArgv;
198
- if (Array.isArray(argv)) {
199
- for (const a of argv) {
200
- if (typeof a !== "string") continue;
201
- if (
202
- a === "--loader" || a.startsWith("--loader=") ||
203
- a === "--experimental-loader" || a.startsWith("--experimental-loader=") ||
204
- a === "--import" || a.startsWith("--import=")
205
- ) { present = true; break; }
206
- }
207
- }
208
- } catch { /* execArgv unavailable — treat as no loader */ }
209
- __cliAsyncLoaderCache = present;
210
- return present;
211
- }
212
-
213
- // The guard for the `commonjs-sync` relabel: is a USER async ESM loader active on the
214
- // import-of-CJS path? Relabel ONLY when nub is the sole loader (the common case —
215
- // next build/dev) so we never route a user loader's inner require()s through its own
216
- // ESM resolve hook (the interop break documented at the load hook below). Either a CLI
217
- // loader flag OR a runtime module.register() disqualifies the optimization.
218
- function userAsyncLoaderActive() {
219
- return __userAsyncLoaderRegistered || cliAsyncLoaderPresent();
220
- }
221
-
222
- // ── Internal `module.register()` without the DEP0205 leak ────────────
223
- // `module.register()` is the loader-WORKER registration surface (async ESM hooks in
224
- // a dedicated thread). nub uses it for the compat tier (18.19–22.14, where the sync
225
- // `module.registerHooks` doesn't exist) and for the fast tier's
226
- // `--no-experimental-require-module` fallback (where `require(esm)` is off, so the
227
- // in-thread sync hooks can't load transform-core.mjs synchronously). On Node 26+,
228
- // `module.register()` emits a one-shot `[DEP0205]` DeprecationWarning steering callers
229
- // to `module.registerHooks()` — but nub CANNOT use `registerHooks` on these paths
230
- // (no sync surface on compat; no sync core load when require(esm) is disabled), and
231
- // the deprecation is for nub's OWN internal call, not anything the user wrote: the
232
- // user has no action to take, so the warning is pure noise on their stderr. Suppress
233
- // exactly that DEP0205 emission for the duration of nub's own register() call, then
234
- // restore `process.emitWarning` untouched, so a user's later `module.register()` (or
235
- // any other deprecation) still warns normally. Default-preserving: only nub's
236
- // internal call is silenced, only for DEP0205, only on the versions that emit it.
237
- function registerLoaderWorker(specifier, parentURL, options) {
238
- const realEmitWarning = process.emitWarning;
239
- let restored = false;
240
- const restore = () => {
241
- if (restored) return;
242
- restored = true;
243
- try { process.emitWarning = realEmitWarning; } catch {}
244
- };
245
- try {
246
- process.emitWarning = function (warning, ...rest) {
247
- // Node calls emitWarning(msg, 'DeprecationWarning', 'DEP0205', ...) for the
248
- // module.register() deprecation. Swallow only that exact code; pass everything
249
- // else (including any non-DEP0205 deprecation) straight through.
250
- const code = typeof rest[0] === "object" && rest[0] !== null ? rest[0].code : rest[1];
251
- if (code === "DEP0205") return;
252
- return realEmitWarning.call(this, warning, ...rest);
253
- };
254
- return module_.register(specifier, parentURL, options);
255
- } finally {
256
- restore();
257
- }
258
- }
259
-
260
- // Is this error Node's "an async `module.register` loader cannot service a SYNCHRONOUS
261
- // resolve/load" stub? On Node 22.15–~24.11 the async-hooks proxy's `resolveSync`/
262
- // `loadSync` are stubs that unconditionally `throw new ERR_METHOD_NOT_IMPLEMENTED(...)`.
263
- // nub's fast-tier SYNC `module.registerHooks` hooks force EVERY resolve/load onto the
264
- // synchronous chain; when a USER async loader (e.g. @tailwindcss/node's
265
- // esm-cache.loader.mjs under Turbopack) is ALSO registered, the chain's default step
266
- // reaches that stub and throws — killing the build. We must detect this WITHOUT the
267
- // `userAsyncLoaderActive()` flag: the very FIRST throwing resolution is the loader
268
- // module's own specifier, resolved DURING `module.register` before the detector flag is
269
- // observable, so the flag is false exactly when recovery is needed. The error code +
270
- // message is the reliable signal. (Node 24.12+/25.2+/26 implement these methods, so the
271
- // stub never throws there and this never fires.)
272
- function isAsyncLoaderSyncStub(err) {
273
- if (!err || typeof err.message !== "string") return false;
274
- // Two shapes across the affected Node band: (a) the method exists but is a stub that
275
- // throws ERR_METHOD_NOT_IMPLEMENTED('resolveSync()'/'loadSync()') (e.g. 24.3); (b) the
276
- // method is ENTIRELY ABSENT, so Node's `this[#customizations].resolveSync/loadSync(...)`
277
- // throws a TypeError "... is not a function" (e.g. 22.16/24.11). Match both.
278
- if (err.code === "ERR_METHOD_NOT_IMPLEMENTED" &&
279
- (err.message.includes("resolveSync") || err.message.includes("loadSync"))) {
280
- return true;
281
- }
282
- return err instanceof TypeError &&
283
- (err.message.includes("resolveSync is not a function") ||
284
- err.message.includes("loadSync is not a function"));
285
- }
286
-
287
- // Resolve a specifier to a URL the registerHooks resolve chain can return, as the
288
- // recovery path when Node's default resolve step throws the async-loader stub (see
289
- // isAsyncLoaderSyncStub). Returns `{ url, shortCircuit }`, or null if it cannot resolve
290
- // (caller re-throws the original error so behavior is unchanged).
291
- //
292
- // Uses the parent's CommonJS resolver (`createRequire().resolve`) — the only fully-sync,
293
- // conditions-capable resolver available in this `--require` CJS preload. It honors
294
- // `node_modules`, package `exports`, relative + absolute paths, and bare/scoped
295
- // specifiers, but under the REQUIRE condition; a DUAL package whose `exports` differ by
296
- // `import`/`require` gets its `require` build where Node's default ESM resolve would
297
- // return the `import` build (latent — the in-the-wild trigger resolves non-dual internal
298
- // modules). Builtins MUST be mapped back to `node:`: `require.resolve("fs")` returns the
299
- // bare name `"fs"`, which must not become a bogus `file://<cwd>/fs` URL.
300
- function resolveViaParentRequire(specifier, parentURL) {
301
- try {
302
- // An ALREADY-RESOLVED specifier needs no resolution — return it verbatim. This is the
303
- // common Turbopack/Tailwind trigger: Node resolves the loader module's OWN absolute
304
- // `file://` URL (`@tailwindcss/node/dist/esm-cache.loader.mjs`) synchronously during
305
- // `module.register`, with `parentURL` = `data:` (no useful base). `require.resolve`
306
- // cannot take a `file://` URL string, so pass these through directly. Builtins and
307
- // `data:` specifiers are likewise already-resolved.
308
- if (specifier.startsWith("file:") || specifier.startsWith("data:")) {
309
- return { url: specifier, shortCircuit: true };
310
- }
311
- if (specifier.startsWith("node:") || module_.isBuiltin(specifier)) {
312
- return { url: specifier.startsWith("node:") ? specifier : `node:${specifier}`, shortCircuit: true };
313
- }
314
- const base = parentURL && String(parentURL).startsWith("file:")
315
- ? String(parentURL)
316
- : pathToFileURL(join(process.cwd(), "noop.js")).href;
317
- const resolved = module_.createRequire(base).resolve(specifier);
318
- if (module_.isBuiltin(resolved)) {
319
- return { url: resolved.startsWith("node:") ? resolved : `node:${resolved}`, shortCircuit: true };
320
- }
321
- const url = resolved.startsWith("node:") || resolved.startsWith("data:")
322
- ? resolved
323
- : pathToFileURL(resolved).href;
324
- return { url, shortCircuit: true };
325
- } catch {
326
- return null;
327
- }
328
- }
329
-
330
- function makeHooks(core, watchReporting) {
331
- installUserHookDetector();
332
- installUserAsyncLoaderDetector();
333
-
334
- function resolve(specifier, context, nextResolve) {
335
- const r = core.resolveSpec(specifier, context.parentURL);
336
- if (r) return r;
337
- // Yarn PnP (ESM): PnP doesn't patch the ESM loader, so `import` of a PnP dep must
338
- // be resolved explicitly — through `pnpapi.resolveRequest`, passing Node's
339
- // `context.conditions` (the import-side set) so a DUAL package resolves to its
340
- // `import` build, not its `require` build. Returns a virtual `.zip` path Node
341
- // reads via the zipfs patch. If the api is momentarily unavailable we fall through
342
- // to `nextResolve`, which reaches nub's `_resolveFilename` override (delegating to
343
- // PnP) — so a plain dep still resolves; only a dual package's condition is lost.
344
- const pnp = pnpApi();
345
- if (pnp && !module_.isBuiltin(specifier) && !specifier.startsWith("node:")) {
346
- try {
347
- const res = pnpResolveEsm(pnp, specifier, context);
348
- if (res) return res;
349
- } catch { /* fall through to Node's resolver */ }
350
- }
351
- try {
352
- return nextResolve(specifier, context);
353
- } catch (err) {
354
- if (isAsyncLoaderSyncStub(err)) {
355
- const fallback = resolveViaParentRequire(specifier, context.parentURL);
356
- if (fallback) return fallback;
357
- }
358
- throw err;
359
- }
360
- }
361
-
362
- // Recovery for the async-loader `loadSync` stub: load a `file:` module ourselves when
363
- // Node's default load step throws ERR_METHOD_NOT_IMPLEMENTED (see isAsyncLoaderSyncStub).
364
- // Reads source from disk and derives the format from extension + nearest package `type`
365
- // (nub's own moduleFormatFor — the same source-of-truth as the transpile path). For a
366
- // transpilable TS/JSX file outside node_modules, route through nub's transpiler; for a
367
- // data-extension, through loadData; otherwise hand back raw source with the derived
368
- // format. Returns null if it cannot (caller re-throws). A CJS result keeps source:null
369
- // and hands off to the native CommonJS loader, matching the default-load contract.
370
- function loadViaDisk(url, ext) {
371
- try {
372
- const path = fileURLToPath(url);
373
- if (core.TRANSPILE_EXTS.has(ext) && !core.isNodeModules(url)) {
374
- return core.loadTranspile(url, ext);
375
- }
376
- // Plain JS: transpile only when transformable; else fall through to the raw-
377
- // source path below (which hands CJS back as `source:null` → Node's native
378
- // CJS loader), byte-identical to a non-intercepted file.
379
- if (core.PLAIN_JS_EXTS.has(ext) && !core.isNodeModules(url)) {
380
- const r = core.maybeTranspilePlainJs(url, ext);
381
- if (r) return r;
382
- }
383
- if (ext in core.DATA_EXTS) return core.loadData(url, ext);
384
- const { readFileSync } = require("node:fs");
385
- const source = readFileSync(path);
386
- const pkgType = core.getPackageType(dirname(path));
387
- const format = core.moduleFormatFor(ext, pkgType, path, source.toString("utf8"));
388
- if (format === "commonjs") return { format: "commonjs", source: null, shortCircuit: true };
389
- return { format, source, shortCircuit: true };
390
- } catch {
391
- return null;
392
- }
393
- }
394
-
395
- function load(url, context, nextLoad) {
396
- const ext = core.extname(url);
397
-
398
- // Watch mode: surface this file's nearest config files (tsconfig.json,
399
- // package.json) + sibling `.env*` so edits to them restart the run. Done for
400
- // every user file (not just transpiled ones) — getTsconfigForDir/
401
- // getPackageType self-report via the injected watch hooks.
402
- if (watchReporting && url.startsWith("file:") && !core.isNodeModules(url)) {
403
- try {
404
- const dir = dirname(fileURLToPath(url));
405
- core.getTsconfigForDir(dir);
406
- core.getPackageType(dir);
407
- } catch {}
408
- }
409
-
410
- // A USER resolve hook (a ts-node/tsx-style transpiler registered AFTER nub's
411
- // own preload hook) claimed this file with the bare 'typescript' format: defer
412
- // to the user's own load chain. The discriminator is `__userHooksRegistered`,
413
- // NOT the bare format alone — Node's NATIVE CJS loader ALSO emits the bare
414
- // string 'typescript' for a `.ts` entry/require whose nearest package.json has
415
- // no explicit `type` (cjs/loader.js getFormatOfExtensionlessFile, lines ~1986),
416
- // and in that native case nub MUST transpile (Node's strip-only mode can't
417
- // handle enums/namespaces). So we only step aside when a user hook is present:
418
- // nub registers exactly one hook set from the preload, the user registers theirs
419
- // later, and registering theirs OUTERMOST (LIFO) means their load hook wraps
420
- // nub's — it sets format='typescript', calls nextLoad into nub, and (without this
421
- // guard) nub would transpile with oxc — a type-stripper, not a module-format
422
- // transformer — leaving `export {}` verbatim and, for a `type:commonjs` package,
423
- // handing Node format='commonjs' + ESM source = invalid CJS. Stepping aside lets
424
- // nub fall through to Node's native load, returning raw TS source back up to the
425
- // user's outer hook, which does the real ESM->CJS conversion, matching Node.
426
- // Native 'module-typescript'/'commonjs-typescript' formats still fall through to
427
- // nub's transpile below, so normal augmentation is unchanged.
428
- if (__userHooksRegistered && context && context.format === "typescript") {
429
- return nextLoad(url, context);
430
- }
431
-
432
- // R12: never transpile `.ts`/`.tsx`/… inside node_modules. Node itself throws
433
- // ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING for TS under node_modules; if
434
- // nub transpiled it instead, that native error would never surface and nub
435
- // would be MORE permissive than Node. Fall through to `nextLoad` so Node's own
436
- // handling (and its error) applies. (The TS-parent extensionless resolution in
437
- // the resolve hook is intended and stays — only this load-time transpile is
438
- // gated.)
439
- if (core.TRANSPILE_EXTS.has(ext) && !core.isNodeModules(url)) {
440
- return core.loadTranspile(url, ext);
441
- }
442
- // Project-source plain JS (`.js`/`.mjs`/`.cjs`): transpile ONLY when it carries
443
- // transformable syntax. A no-op plain-JS file returns null here and falls through
444
- // to Node's native loader (the `nextLoad`/relabel path below) BYTE-FOR-BYTE — it
445
- // is never intercepted, so native CJS/ESM behavior (the relabel, require.cache,
446
- // the require-of-ESM-syntax-`.cjs` error) is preserved. node_modules excluded.
447
- if (core.PLAIN_JS_EXTS.has(ext) && !core.isNodeModules(url)) {
448
- const r = core.maybeTranspilePlainJs(url, ext);
449
- if (r) return r;
450
- }
451
- if (ext in core.DATA_EXTS) return core.loadData(url, ext);
452
-
453
- // Fidelity: a `data:` URL whose MIME maps to no module format (e.g.
454
- // `data:application/x-unknown,…`) must surface Node's ERR_UNKNOWN_MODULE_FORMAT.
455
- // Node's default load returns `format: null` for this, which its ASYNC loader path
456
- // later converts to ERR_UNKNOWN_MODULE_FORMAT in validateLoadResult. But nub's SYNC
457
- // `module.registerHooks` load hook routes the default step's result through
458
- // customization_hooks' validateLoadSloppy -> validateFormat, which accepts only a
459
- // string or `undefined` and throws ERR_INVALID_RETURN_PROPERTY_VALUE on `null` —
460
- // and it does so INSIDE the `nextLoad` call below (the validator wraps each step),
461
- // so nub never gets the result back to normalize it, and nub's own load-hook frame
462
- // leaks into the user-visible stack. Vanilla Node, having registered no hook on this
463
- // path, never hits that validator and throws the correct ERR_UNKNOWN_MODULE_FORMAT.
464
- // Return `format: undefined` (not the default step's `null`) WITHOUT calling the
465
- // default load: undefined passes validateFormat, then Node's own
466
- // #translate -> validateLoadResult sees format == null and throws the NATIVE
467
- // ERR_UNKNOWN_MODULE_FORMAT — byte-identical to plain Node (the `[code]` name
468
- // decoration, the exact message, and a stack with zero nub frames). Short-circuit
469
- // so the chain stops here; the empty source is never read (the throw precedes any
470
- // translation).
471
- if (typeof url === "string" && url.startsWith("data:") &&
472
- (!context || context.format == null) &&
473
- unknownDataUrlFormat(url)) {
474
- return { format: undefined, source: "", shortCircuit: true };
475
- }
476
-
477
- let r;
478
- try {
479
- r = nextLoad(url, context);
480
- } catch (err) {
481
- // Async-loader `loadSync` stub (the load-hook twin of the resolve recovery): with a
482
- // USER async `module.register` loader present, nub's sync load hook forces the default
483
- // step onto the synchronous chain, which calls the async-hooks `loadSync` stub →
484
- // ERR_METHOD_NOT_IMPLEMENTED. Recover by loading the module ourselves: read source
485
- // from disk and derive the format from the URL/extension (the same source-of-truth
486
- // nub's own transpile path uses), so the synchronous module-job gets real source
487
- // instead of crashing. node:/data:/non-file URLs and the no-format case fall through
488
- // to a re-throw (we can't synthesize those here). Re-throw anything that isn't the stub.
489
- if (isAsyncLoaderSyncStub(err) && typeof url === "string") {
490
- // Builtins: hand back the `builtin` format with no source — Node loads them
491
- // natively (a `node:`-scheme module the default load would have returned builtin for).
492
- if (url.startsWith("node:") || module_.isBuiltin(url)) {
493
- return { format: "builtin", source: null, shortCircuit: true };
494
- }
495
- if (url.startsWith("file:")) {
496
- const recovered = loadViaDisk(url, ext);
497
- if (recovered) return recovered;
498
- }
499
- }
500
- throw err;
501
- }
502
-
503
- // #18 — relabel a `commonjs` result as `commonjs-sync` for `file:` URLs ON THE
504
- // `import()`-OF-CJS PATH so the module (and its inner require()s) routes through
505
- // Node's SOUND synchronous CJS translator (loadCJSModuleWithModuleLoad), which
506
- // builds a real CJS `require` with `.cache`/`.extensions`. Without this, nub's
507
- // sync load hook makes Node pick loadCJSModuleWithSpecialRequire — a hand-rolled
508
- // `require` missing `.cache`/`.extensions` — so CJS that does `require.cache[...]`
509
- // (next's bundled `conf`) crashes with "Cannot convert undefined or null to
510
- // object". Version-banded in Node: broken 22.15–~25, fixed in 26 via the
511
- // special-require repair (#60380); the relabel is a no-op on 26.
512
- //
513
- // Two narrowing guards make this surgical — relabel ONLY the path that actually
514
- // hits the broken translator, so nothing else moves:
515
- //
516
- // (1) IMPORT PATH ONLY. The bad special-require is chosen only when CJS is
517
- // reached via dynamic `import()`. On the broken band Node passes that load
518
- // step `context.conditions` as an ARRAY containing "import"; a plain
519
- // `require()` of the same file passes an empty-object `conditions` (no
520
- // "import"). Gating on the "import" condition leaves `require()` loads
521
- // untouched — without this, relabeling a `require()`-loaded `.cjs` that
522
- // contains ESM syntax makes Node's sync translator accept it instead of
523
- // throwing "Unexpected token 'export'" (a real regression: it swallows the
524
- // syntax error vanilla Node raises). On Node 26 the require path also carries
525
- // an array but without "import", and the relabel is a no-op there regardless.
526
- //
527
- // (2) NO USER LOADER/HOOK. Skip whenever a USER async ESM loader OR a USER sync
528
- // `module.registerHooks` hook is active. Relabeling makes Node treat the
529
- // module as ESM-translatable, re-routing inner resolution through the user's
530
- // hook chain — which changes resolve-hook call shape/count (the
531
- // module-hooks resolve-import-cjs contract) and breaks async-loader interop
532
- // (the source-backfill EXCEPTION block below documents the same hazard). When
533
- // nub is the SOLE loader (the next-build/dev common case) the path is nub's
534
- // own, so the relabel is safe; otherwise leave the native-CJS handoff intact.
535
- if (
536
- r && r.format === "commonjs" &&
537
- typeof url === "string" && url.startsWith("file:") &&
538
- Array.isArray(context && context.conditions) &&
539
- context.conditions.includes("import") &&
540
- !__userHooksRegistered && !userAsyncLoaderActive()
541
- ) {
542
- return { ...r, format: "commonjs-sync" };
543
- }
544
-
545
- // nub's sync `module.registerHooks` load hook forces the synchronous
546
- // module-job (ModuleJobSync.syncLink -> loadAndTranslateForImportInRequiredESM),
547
- // which cannot async-fetch source. When a user `--experimental-loader` resolve
548
- // hook sets `format` without a `source` (a pattern vanilla Node tolerates on its
549
- // async load path by fetching the source itself), the default load returns
550
- // source:null and Node's assertBufferSource throws ERR_INVALID_RETURN_PROPERTY_VALUE.
551
- // Backfill the source from disk so the sync path matches Node — without touching
552
- // nub's own resolve/transpile hooks.
553
- //
554
- // EXCEPTION — format 'commonjs' (and 'builtin') MUST keep source:null. For those
555
- // formats Node's ESM loader deliberately returns no source and hands the module
556
- // off to the NATIVE CommonJS loader (Module._load), where `require()` uses CJS
557
- // resolution. A CJS `.js` ENTRY, when a user `--experimental-loader` is active, is
558
- // routed through the ESM loader for format detection but still loads as CJS this
559
- // way. If we backfilled its source, the ESM loader would instead translate it via
560
- // its CommonJS-to-ESM wrapper, routing every inner `require()` through the ESM
561
- // resolve hook — so `require('assert')` would hand the bare 'assert' specifier to
562
- // the user's resolve hook and crash with ERR_INVALID_RETURN_PROPERTY_VALUE (the
563
- // shadow-realm/custom-loaders corpus failure). Only ESM-shaped formats ('module',
564
- // 'json', 'wasm', …) genuinely need the source on the sync path.
565
- // ('commonjs-sync' is excluded for the same reason as 'commonjs' — it's the
566
- // sync CJS handoff the #18 relabel above produces; backfilling its source would
567
- // re-route inner require()s through the ESM wrapper. The relabel block early-
568
- // returns, so this is defense-in-depth against a future refactor.)
569
- if (
570
- r && r.source == null && r.format &&
571
- r.format !== "commonjs" && r.format !== "commonjs-sync" && r.format !== "builtin" &&
572
- typeof url === "string" && url.startsWith("file:")
573
- ) {
574
- try {
575
- const { readFileSync } = require("node:fs");
576
- return { ...r, source: readFileSync(fileURLToPath(url)) };
577
- } catch { /* fall through with the original result */ }
578
- }
579
- return r;
580
- }
581
-
582
- return { resolve, load };
583
- }
584
-
585
- // ── CommonJS require() augmentation (BOTH tiers) ────────────────────
586
- // `module.registerHooks`' CJS-`require()` coverage is INCOMPLETE before ~Node 24:
587
- // on Node 22.15 a `require()` from a `.cts` parent (which Node loads via the ESM
588
- // translator's special-require) hits native Module._resolveFilename with no
589
- // tsconfig/extensionless handling — a `require('@alias')` or `require('./x')` of a
590
- // `.ts` target throws MODULE_NOT_FOUND, while the same code works on Node 26 (where
591
- // registerHooks does cover it) and on the fast `import` path. On the compat tier
592
- // (18.19–22.14) the only hook surface is `module.register`, which intercepts the
593
- // ESM loader ONLY — so `require()` is entirely unaugmented there. Both gaps have
594
- // the same closure: install this main-thread CJS shim, reusing the core's canonical
595
- // resolveCjsPath / loadTranspile (no drift). It tries nub's resolution first and
596
- // FALLS THROUGH to native on a miss, so it is a safe no-op on the versions where
597
- // registerHooks already covers require (Node 24+/26). Mechanism stays within the
598
- // augmenter rules: exactly what `--require`-installing the ts-node / tsx CJS shim
599
- // has always done.
600
- //
601
- // This error is surfaced ONLY on Node versions without native require(esm)
602
- // (< 20.19 / 22.0–22.11), where require() of an ES module genuinely cannot work.
603
- // On every require(esm)-capable Node, Node loads the ES module itself and this is
604
- // never reached. The message is user-facing: no internal mechanism names.
605
- function requireEsmError(filename) {
606
- const err = new Error(
607
- `Cannot require() this file — it is an ES module.\n` +
608
- ` ${filename}\n` +
609
- `It uses \`import\`/\`export\`, so it loads as an ES module, and this version of ` +
610
- `Node can't require() an ES module. Load it with \`import(...)\` instead, rename ` +
611
- `it to .cts for a CommonJS module, or upgrade Node.`,
612
- );
613
- err.code = "ERR_REQUIRE_ESM";
614
- return err;
615
- }
616
-
617
- // `withClassicTranspile` — also install the `require.extensions` (classic CommonJS
618
- // loader) transpile hook. Needed ONLY on Node WITHOUT native require(esm)
619
- // (< 20.19 / 22.0–22.11): there, `module.register`'s ESM-loader hooks can't reach a
620
- // `require()`, AND an ES module simply can't be require()d, so we transpile CJS
621
- // content classically and surface a clean error for ESM content. On require(esm)-
622
- // capable Node we DON'T install it — registering `require.extensions['.ts']` would
623
- // shadow Node's own native require(esm) of ES-module `.ts` files (breaking
624
- // `require("./esm.ts")`), and the resolve shim below plus the tier's load hook
625
- // already cover resolution + transpile.
626
- function installCjsRequireHooks(core, withClassicTranspile) {
627
- const origResolveFilename = module_._resolveFilename;
628
- module_._resolveFilename = function (request, parent, isMain, options) {
629
- let resolved = null;
630
- try {
631
- const parentPath = parent && typeof parent.filename === "string" ? parent.filename : null;
632
- resolved = core.resolveCjsPath(request, parentPath);
633
- } catch { /* fall through to Node */ }
634
- if (resolved) {
635
- if (withClassicTranspile && core.requireTargetIsEsm(resolved, pathExtname(resolved))) {
636
- throw requireEsmError(resolved);
637
- }
638
- return resolved;
639
- }
640
- // Yarn PnP (CJS): `.pnp.cjs` already patched THIS function (origResolveFilename)
641
- // to resolve from PnP's manifest, including zip-stored deps — so we just delegate
642
- // to it. The one snag is that a registered customization hook makes Node thread a
643
- // `conditions` option that PnP rejects ("aren't supported by PnP yet
644
- // (conditions)"), so strip it first. The require/default condition PnP then
645
- // applies is exactly right for `require()`. This replaces the former
646
- // `pnpapi.resolveRequest` reimplementation: simpler, and with no `findPnpApi` in
647
- // the hot path there is no lookup-miss to leak a `conditions` crash on Windows.
648
- //
649
- // GATED ON PnP (`process.versions.pnp`). Off PnP the strip is NOT a harmless
650
- // no-op: a user who passes custom `conditions` to require-side resolution via
651
- // `module.registerHooks` (Node's module-hooks custom-conditions tests) relies on
652
- // Node's own `_resolveFilename` honoring them, and unconditionally deleting the
653
- // key silently dropped their conditions — breaking module-hooks/test-module-hooks-
654
- // custom-conditions{,-cjs}. PnP is the only resolver that rejects `conditions`, so
655
- // only strip when PnP is actually active; everywhere else conditions pass through.
656
- if (process.versions.pnp && options && "conditions" in options) {
657
- options = { ...options };
658
- delete options.conditions;
659
- }
660
- try {
661
- return origResolveFilename.call(this, request, parent, isMain, options);
662
- } catch (e) {
663
- // Under PnP, an in-tree issuer requiring a dep NOT in its manifest makes PnP
664
- // throw. That is nub's OWN transpile helpers (e.g. `@oxc-project/runtime`),
665
- // injected into transpiled user code and resolved via NODE_PATH globalPaths
666
- // (A30). Fall back to Node's native path resolver, which PnP does NOT patch.
667
- // Gated to PnP so off-PnP a genuine miss surfaces Node's own error unchanged.
668
- if (process.versions.pnp && e && e.code === "MODULE_NOT_FOUND") {
669
- const lookupPaths = module_._resolveLookupPaths(request, parent) || [];
670
- const found = module_._findPath(request, lookupPaths, isMain);
671
- if (found) return found;
672
- }
673
- throw e;
674
- }
675
- };
676
-
677
- if (!withClassicTranspile) return;
678
-
679
- // require.extensions: transpile via the SAME loadTranspile the load hook uses —
680
- // target:'es2022' lowering (`using`), tsconfig, source maps, the Stage-3
681
- // decorator guard, and module-format detection are all identical to the fast
682
- // tier. The path is already a real TS file (Module._resolveFilename ran first).
683
- // A module-format source can't be _compile'd as CJS — same clean error as above.
684
- const transpileExtension = (mod, filename) => {
685
- const { source, format } = core.loadTranspile(pathToFileURL(filename).href, pathExtname(filename));
686
- if (format === "module") throw requireEsmError(filename);
687
- mod._compile(source, filename);
688
- };
689
- for (const ext of [".ts", ".cts", ".mts", ".tsx", ".jsx"]) {
690
- module_._extensions[ext] = transpileExtension;
691
- }
692
-
693
- // Project-source plain JS (`.js`/`.cjs`) routes through the SAME pipeline so
694
- // `using`/`v`-flag-RegExp/decorators lower uniformly on the classic require tier —
695
- // but ONLY when the file carries transformable syntax. THREE cases, each preserving
696
- // Node's native behavior where it must:
697
- // (1) node_modules dep → native handler (deps are NEVER transpiled). Node has no
698
- // own `_extensions['.cjs']` (only `.js`/`.json`/`.node`), and compiles `.cjs`
699
- // through the same CJS path as `.js`, so the `.cjs` bail falls back to the
700
- // `.js` handler (`|| nativeJs`) — without it a node_modules `.cjs` require
701
- // would call `undefined` and crash.
702
- // (2) project file with transformable syntax → transpile (lower it).
703
- // (3) project file with NOTHING to lower → the ORIGINAL native handler, raw bytes
704
- // compiled exactly as Node would. We never serve our own source for a no-op
705
- // file, so require.cache / the require-of-ESM-syntax-`.cjs` SyntaxError / every
706
- // native CJS behavior is byte-identical.
707
- // `.mjs` is ESM-only; Node registers no require.extensions handler for it, so a
708
- // `require()` of `.mjs` throws ERR_REQUIRE_ESM as before — we don't override it.
709
- const nativeJs = module_._extensions[".js"];
710
- for (const ext of [".js", ".cjs"]) {
711
- const origExtension = module_._extensions[ext] || nativeJs;
712
- module_._extensions[ext] = (mod, filename) => {
713
- if (core.isNodeModules(pathToFileURL(filename).href)) {
714
- return origExtension.call(module_._extensions, mod, filename); // (1)
715
- }
716
- const r = core.maybeTranspilePlainJs(pathToFileURL(filename).href, pathExtname(filename));
717
- if (r) {
718
- if (r.format === "module") throw requireEsmError(filename); // (2)
719
- mod._compile(r.source, filename);
720
- return;
721
- }
722
- return origExtension.call(module_._extensions, mod, filename); // (3)
723
- };
724
- }
725
- }
726
-
727
- // ── Clobbered-polyfill preloading + Temporal lazy global ────────────
728
- // Packages in the core's CLOBBER_MAP can't be imported after hooks register
729
- // because the resolve hook returns a synthetic module instead of the real package.
730
- // Load them here via CJS require (not yet hooked) and return them so the polyfill
731
- // installer can stash them. Temporal is the exception (A37): the polyfill is ~18ms
732
- // to load and most scripts never touch it, so we only RESOLVE its path now (cheap)
733
- // and defer the load to a lazy global getter. Requiring it later by absolute path
734
- // bypasses the CLOBBER_MAP resolve-hook entry, which keys on the specifier.
735
- function preloadPolyfillPackages(reqFromRuntime) {
736
- const preloaded = {};
737
- // Feature-detect before requiring (A39): URLPattern is native on Node 24+, so
738
- // skip loading the polyfill there. On 22.x it's absent → load it.
739
- if (typeof globalThis.URLPattern === "undefined") {
740
- try { preloaded.urlpattern = reqFromRuntime("urlpattern-polyfill"); } catch {}
741
- }
742
- // Float16Array: native on Node 24+, absent on the 22.x floor.
743
- if (typeof globalThis.Float16Array === "undefined") {
744
- try { preloaded.float16 = reqFromRuntime("@petamoriken/float16"); } catch {}
745
- }
746
- return preloaded;
747
- }
748
-
749
- // Install the lazy `globalThis.Temporal` getter. The polyfill is loaded — and even
750
- // RESOLVED — only on first access. CRITICAL ordering note (regexp one-off): the
751
- // `require.resolve("@js-temporal/polyfill")` is deferred INTO the getter, NOT run at
752
- // preload top level. An unconditional resolve at startup mutates the legacy
753
- // `RegExp.$_` static (the resolved node_modules path matches an internal regex), so
754
- // a program inspecting `RegExp.$_` on its first line would otherwise see a leaked
755
- // path (test-startup-empty-regexp-statics). Deferring the resolve keeps `RegExp.$_`
756
- // empty at user-code start; the cost is paid only by a program that touches Temporal.
757
- function installTemporalLazyGlobal(reqFromRuntime) {
758
- if (typeof globalThis.Temporal !== "undefined") return;
759
-
760
- const defineTemporal = (value) =>
761
- Object.defineProperty(globalThis, "Temporal", {
762
- value,
763
- configurable: true,
764
- writable: true,
765
- enumerable: false,
766
- });
767
- Object.defineProperty(globalThis, "Temporal", {
768
- configurable: true,
769
- enumerable: false,
770
- get() {
771
- let temporalPath;
772
- try { temporalPath = reqFromRuntime.resolve("@js-temporal/polyfill"); } catch {}
773
- if (!temporalPath) return undefined;
774
- const polyfill = reqFromRuntime(temporalPath);
775
- // @js-temporal/polyfill exports `toTemporalInstant` as a function but does
776
- // NOT auto-install it on Date.prototype (you assign it yourself). Install it
777
- // here so that on the floor (no native Temporal) `date.toTemporalInstant()`
778
- // AND the package clobber's re-export of `Date.prototype.toTemporalInstant`
779
- // both work — matching native Node. Guarded so we never replace a native
780
- // implementation on a runtime that ships Temporal.
781
- if (
782
- typeof Date.prototype.toTemporalInstant !== "function" &&
783
- typeof polyfill.toTemporalInstant === "function"
784
- ) {
785
- Object.defineProperty(Date.prototype, "toTemporalInstant", {
786
- value: polyfill.toTemporalInstant,
787
- configurable: true,
788
- writable: true,
789
- enumerable: false,
790
- });
791
- }
792
- const T = polyfill.Temporal;
793
- defineTemporal(T);
794
- return T;
795
- },
796
- set: defineTemporal,
797
- });
798
- }
799
-
800
- // ── Compile-cache handling (R8) ─────────────────────────────────────
801
- // nub injects its preload chain via `--require`, which Node loads at bootstrap.
802
- // If the user set NODE_COMPILE_CACHE, Node would enable the V8 code cache BEFORE
803
- // this preload runs and cache every module the chain pulls in (preload.cjs,
804
- // transform-core.mjs, this file, polyfills.cjs, …) into the USER's dir — so a
805
- // program reading `fs.readdirSync(NODE_COMPILE_CACHE)` would see ~9 nub entries,
806
- // not its own 1 (program-observable; R8). spawn.rs prevents that by STRIPPING
807
- // NODE_COMPILE_CACHE from the child env (bootstrap caches nothing) and stashing
808
- // the original value in a sentinel file keyed on nub's PID — which is THIS child's
809
- // `process.ppid` (nub is our direct parent). The dir travels via a sentinel file,
810
- // never a NUB_* env var (brand boundary).
811
- //
812
- // Two preload steps consume it:
813
- // 1. restoreCompileCacheEnv() runs EARLY, before transform-core.mjs is required,
814
- // to put the original value BACK into process.env.NODE_COMPILE_CACHE. That
815
- // matters because (a) transform-core reads `NODE_COMPILE_CACHE === "0"` as
816
- // nub's transpile-cache disable signal, and (b) user code may read the env.
817
- // Restoring it in JS does NOT re-trigger Node's V8 compile cache (Node
818
- // configures that once at bootstrap from the now-stripped env), so the
819
- // preload chain stays uncached. It also DELETES the sentinel (consume-once,
820
- // so a recycled PID can't read stale state and the file never leaks).
821
- // 2. reenableUserCompileCache() runs LAST, after all nub modules are loaded
822
- // uncached and right before user code, and calls
823
- // `module.enableCompileCache(dir)` for a real dir so the user's OWN modules
824
- // cache as they always did. A value of "0" is nub's disable sentinel (Node
825
- // treats "0" as a literal dir named 0, but nub honors it as "no caching"),
826
- // so we skip enabling there.
827
- // Best-effort throughout: a missing/unreadable sentinel or an enableCompileCache
828
- // failure just means no user compile cache — strictly safer than the old pollution.
829
- // `os.tmpdir()` without requiring `node:os`. Requiring os at preload pulls
830
- // `Internal Binding os` + `NativeModule os` into process.moduleLoadList on EVERY
831
- // startup (test-bootstrap-modules observes this) even though almost no run touches
832
- // the compile-cache sentinel. This replica mirrors Node's libuv/os.tmpdir() env
833
- // resolution (POSIX: TMPDIR→TMP→TEMP→/tmp; Win32: TEMP→TMP→SystemRoot/windir+\temp),
834
- // trailing-separator-stripped, which is also what Rust's env::temp_dir() (the side
835
- // that WRITES the sentinel in spawn.rs) resolves to — so both ends agree.
836
- function tmpdirNoOs() {
837
- const env = process.env;
838
- if (process.platform === "win32") {
839
- let dir = env.TEMP || env.TMP || ((env.SystemRoot || env.windir || "") + "\\temp");
840
- if (dir.length > 1 && dir.endsWith("\\") && !dir.endsWith(":\\")) dir = dir.slice(0, -1);
841
- return dir;
842
- }
843
- let dir = env.TMPDIR || env.TMP || env.TEMP || "/tmp";
844
- if (dir.length > 1 && dir.endsWith("/")) dir = dir.slice(0, -1);
845
- return dir;
846
- }
847
-
848
- function compileCacheSentinelPath() {
849
- return join(tmpdirNoOs(), `nub-ccache-${process.ppid}`);
850
- }
851
-
852
- function restoreCompileCacheEnv() {
853
- try {
854
- const { readFileSync, rmSync } = require("node:fs");
855
- const value = readFileSync(compileCacheSentinelPath(), "utf8");
856
- try { rmSync(compileCacheSentinelPath()); } catch {}
857
- if (value) process.env.NODE_COMPILE_CACHE = value;
858
- } catch { /* no sentinel: env was never set, or already consumed */ }
859
- // Propagate the R8 strip to node grandchildren the user spawns directly (plain
860
- // node inheriting nub's --require preload + a live NODE_COMPILE_CACHE → it would
861
- // cache nub's preload chain into the user's dir). The wrap MUST preserve each
862
- // function's own symbols (esp. [util.promisify.custom]) — dropping them broke
863
- // util.promisify(child_process.*) + abort/sync-io behavior. See wrapSpawnLike.
864
- try { armChildProcessCompileCacheWrap(); } catch {}
865
- }
866
-
867
- // Arm the child_process compile-cache wrap WITHOUT eagerly requiring child_process.
868
- //
869
- // Eagerly `require("node:child_process")` at preload time pulls ~40 builtins into
870
- // process.moduleLoadList on EVERY startup — net, dgram, the entire streams tree,
871
- // spawn_sync/tty_wrap/pipe_wrap/tcp_wrap, os, vm, etc. (test-bootstrap-modules
872
- // observes the exact list; child_process is the dominant extra-builtin source).
873
- // A program that never spawns a child shouldn't pay that cost — and Node's own
874
- // startup never loads child_process.
875
- //
876
- // So we intercept `Module._load` and apply the wrap to the child_process module the
877
- // FIRST time USER code requires it (`require('child_process')` /
878
- // `require('node:child_process')`), patching the returned singleton before handing
879
- // it back. After patching once we restore the original `_load`, so steady-state
880
- // require() has zero added overhead. If the user never requires child_process, the
881
- // module is never loaded and the builtins stay out of the load list — matching Node.
882
- let __cpWrapArmed = false;
883
- function armChildProcessCompileCacheWrap() {
884
- if (__cpWrapArmed || __cpWrapped) return;
885
- __cpWrapArmed = true;
886
- if (typeof module_._load !== "function") return;
887
- const origLoad = module_._load;
888
- module_._load = function (request, parent, isMain) {
889
- const exports = origLoad.call(this, request, parent, isMain);
890
- if (request === "child_process" || request === "node:child_process") {
891
- module_._load = origLoad; // restore: one-shot, no steady-state overhead
892
- try { wrapChildProcessCompileCache(exports); } catch {}
893
- }
894
- return exports;
895
- };
896
- }
897
-
898
- // Monkey-patch child_process so node-targeted children the USER spawns with an
899
- // explicit live NODE_COMPILE_CACHE get the SAME R8 treatment spawn.rs gives nub's
900
- // own children: strip NODE_COMPILE_CACHE from the child env (so Node's bootstrap
901
- // caches nothing of nub's inherited preload chain) and stash the original dir in a
902
- // PID-keyed sentinel file the grandchild's restoreCompileCacheEnv() reads back via
903
- // `process.ppid` to re-enable caching for the USER's own modules post-bootstrap.
904
- // Brand rule: the dir travels via a sentinel file, never a NUB_* env var.
905
- // `cp` is the already-loaded child_process exports object, passed in by the lazy
906
- // `_load` interceptor so we never require it ourselves (which would defeat the
907
- // deferral).
908
- let __cpWrapped = false;
909
- function wrapChildProcessCompileCache(cp) {
910
- if (__cpWrapped || !cp) return;
911
- __cpWrapped = true;
912
- const { writeFileSync } = require("node:fs");
913
- const { basename } = require("node:path");
914
-
915
- const isNodeTarget = (command) => {
916
- if (typeof command !== "string" || command.length === 0) return false;
917
- if (command === process.execPath) return true;
918
- const base = basename(command).toLowerCase();
919
- return base === "node" || base === "node.exe";
920
- };
921
-
922
- // Returns a possibly-rewritten options object with NODE_COMPILE_CACHE stripped
923
- // from the child's env, after writing the sentinel keyed on THIS process's pid
924
- // (= the grandchild's process.ppid). Two source cases, both stripped:
925
- // • EXPLICIT env (options.env carries NODE_COMPILE_CACHE) — strip from it.
926
- // • INHERITED env (no options.env, child inherits this process's env) — when
927
- // OUR process.env carries a live NODE_COMPILE_CACHE, materialize an explicit
928
- // env from process.env with it removed. This case matters now that the
929
- // DEFAULT (nub-owned) cache also travels via the sentinel and gets restored
930
- // into process.env: a node child the user spawns with NO explicit env would
931
- // otherwise inherit it and enable the cache AT BOOTSTRAP — before any preload
932
- // gate — collapsing that child's V8 coverage if it runs under
933
- // --experimental-test-coverage (the test-runner coverage-width fixtures, which
934
- // are spawned with inherited env). Stripping here makes every node-target
935
- // child boot cache-off; its own preload re-enables the cache post-bootstrap
936
- // via reenableUserCompileCache UNLESS it's collecting coverage.
937
- const stripFromOptions = (options) => {
938
- const inheritedDir = process.env.NODE_COMPILE_CACHE;
939
- const opts = options && typeof options === "object" ? options : {};
940
- const env = opts.env;
941
- if (env && typeof env === "object") {
942
- const dir = env.NODE_COMPILE_CACHE;
943
- if (!dir || dir === "0") return options;
944
- try {
945
- writeFileSync(join(tmpdirNoOs(), `nub-ccache-${process.pid}`), String(dir));
946
- } catch { return options; }
947
- const newEnv = { ...env };
948
- delete newEnv.NODE_COMPILE_CACHE;
949
- return { ...opts, env: newEnv };
950
- }
951
- // Inherited env path: only act when this process actually carries a live cache
952
- // dir (otherwise there is nothing for the child to inherit and we leave the
953
- // spawn's env untouched — `undefined` keeps Node's default inheritance).
954
- if (!inheritedDir || inheritedDir === "0") return options;
955
- try {
956
- writeFileSync(join(tmpdirNoOs(), `nub-ccache-${process.pid}`), String(inheritedDir));
957
- } catch { return options; }
958
- const newEnv = { ...process.env };
959
- delete newEnv.NODE_COMPILE_CACHE;
960
- return { ...opts, env: newEnv };
961
- };
962
-
963
- // For (command, args?, options?) signatures the options object is the last arg
964
- // that is a non-array object; args is an optional array in between. Rewrites the
965
- // call in place and dispatches to the original.
966
- // Copy `orig`'s OWN symbols onto `wrapped` — crucially [util.promisify.custom],
967
- // which Node sets on execFile/exec so `util.promisify(execFile)` returns a
968
- // {stdout,stderr} promise. A bare wrapper without it silently changes promisify's
969
- // result shape (broke test-child-process-promisified / -abortController /
970
- // util-promisify-custom-names / sync-io-option / test-output-abort).
971
- const preserveSymbols = (wrapped, orig) => {
972
- for (const s of Object.getOwnPropertySymbols(orig)) {
973
- try { wrapped[s] = orig[s]; } catch { /* read-only symbol: skip */ }
974
- }
975
- return wrapped;
976
- };
977
- const wrapSpawnLike = (orig) => preserveSymbols(function (command, ...rest) {
978
- if (isNodeTarget(command)) {
979
- let optIdx = -1;
980
- for (let i = rest.length - 1; i >= 0; i--) {
981
- const a = rest[i];
982
- if (a && typeof a === "object" && !Array.isArray(a)) { optIdx = i; break; }
983
- if (typeof a === "function") continue; // execFile callback
984
- if (Array.isArray(a)) break; // args array — no options object present
985
- }
986
- if (optIdx >= 0) rest[optIdx] = stripFromOptions(rest[optIdx]);
987
- }
988
- return orig.call(this, command, ...rest);
989
- }, orig);
990
-
991
- cp.spawn = wrapSpawnLike(cp.spawn);
992
- cp.spawnSync = wrapSpawnLike(cp.spawnSync);
993
- cp.execFile = wrapSpawnLike(cp.execFile);
994
- cp.execFileSync = wrapSpawnLike(cp.execFileSync);
995
-
996
- // fork() always runs `process.execPath`, so it is always a node target. Its
997
- // signature is (modulePath, args?, options?); reuse the same options rewrite.
998
- const origFork = cp.fork;
999
- cp.fork = function (modulePath, ...rest) {
1000
- let optIdx = -1;
1001
- for (let i = rest.length - 1; i >= 0; i--) {
1002
- const a = rest[i];
1003
- if (a && typeof a === "object" && !Array.isArray(a)) { optIdx = i; break; }
1004
- if (Array.isArray(a)) break;
1005
- }
1006
- if (optIdx >= 0) rest[optIdx] = stripFromOptions(rest[optIdx]);
1007
- return origFork.call(this, modulePath, ...rest);
1008
- };
1009
- }
1010
-
1011
- // True when V8 code coverage is active for THIS process — `--experimental-test-
1012
- // coverage` / a bare `--test-coverage*` flag in our own argv or execArgv, or a
1013
- // non-empty NODE_V8_COVERAGE env. A WARM compile cache makes V8 coverage imprecise
1014
- // (cached bytecode collapses/omits per-branch ranges, so a fixture's coverage
1015
- // JSON loses `functions[].ranges[1]` and the line/branch percentages drift from
1016
- // plain node). nub must therefore NOT (re)enable its compile cache for any process
1017
- // that is collecting coverage. This mirrors spawn.rs's coverage gate, but catches
1018
- // the case spawn.rs cannot see: a grandchild the USER's test code spawns directly
1019
- // (e.g. `spawnSync(execPath, [fixture], { env: { NODE_V8_COVERAGE } })`), which
1020
- // inherits nub's preload via NODE_OPTIONS but never goes through nub's Rust spawn
1021
- // path — so the gate has to live here too. (Observed against parallel/test-v8-
1022
- // coverage, test-runner-coverage-thresholds, and the test-runner coverage-width
1023
- // snapshot tests, all of which warm-cache then collect coverage in a child.)
1024
- function coverageActiveInProcess() {
1025
- if (process.env.NODE_V8_COVERAGE) return true;
1026
- const hasCovFlag = (a) =>
1027
- typeof a === "string" &&
1028
- (a === "--experimental-test-coverage" || a.startsWith("--test-coverage"));
1029
- return (process.execArgv || []).some(hasCovFlag) || (process.argv || []).some(hasCovFlag);
1030
- }
1031
-
1032
- function reenableUserCompileCache() {
1033
- // Coverage active: leave the compile cache OFF so V8 collects precise per-branch
1034
- // ranges (a warm cache collapses them — see coverageActiveInProcess). Two things
1035
- // matter, because Node's test runner spawns a SEPARATE isolated child to run the
1036
- // covered fixture and that child enables its cache at BOOTSTRAP from an inherited
1037
- // NODE_COMPILE_CACHE — too early for any preload gate to catch:
1038
- // (a) don't enableCompileCache in THIS process, and
1039
- // (b) set NODE_DISABLE_COMPILE_CACHE=1 in our env so EVERY descendant (incl. the
1040
- // test runner's isolated coverage child) boots with the cache off. Node
1041
- // honors NODE_DISABLE_COMPILE_CACHE at bootstrap and it travels via the env,
1042
- // reaching children nub never spawns itself. We do NOT clear NODE_COMPILE_CACHE
1043
- // (user code may read it); the disable var takes precedence at bootstrap.
1044
- // This is the JS half of the compile-cache/coverage fix; spawn.rs is the Rust half
1045
- // (it never sets the DEFAULT cache when it can see coverage in nub's own
1046
- // argv/NODE_OPTIONS/NODE_V8_COVERAGE).
1047
- //
1048
- // INTENTIONAL COVERAGE JUDGMENT CALL (b): NODE_DISABLE_COMPILE_CACHE=1 is set in
1049
- // process.env, so it propagates SUBTREE-WIDE for the rest of this coverage session —
1050
- // it is inherited by EVERY descendant, including non-coverage grandchildren the
1051
- // user's test code spawns mid-run (e.g. a build step a covered test shells out to).
1052
- // Those grandchildren therefore ALSO lose compile caching for the duration, even
1053
- // though they aren't themselves collecting coverage. We accept this: the disable var
1054
- // is the only mechanism that reaches the test runner's isolated coverage child
1055
- // (which boots its cache before any preload gate can fire), and scoping it more
1056
- // tightly than "the whole coverage subtree" isn't possible via an inherited env var.
1057
- // The cost is bounded (no caching during one coverage session) and self-healing (a
1058
- // grandchild spawned outside a coverage run is unaffected); surprising only to a
1059
- // user who expects an unrelated grandchild to keep caching while a parent collects
1060
- // coverage. Documented here and at the spawn.rs coverage branch (judgment call (a)).
1061
- if (coverageActiveInProcess()) {
1062
- const dir = process.env.NODE_COMPILE_CACHE;
1063
- if (!dir || dir === "0") {
1064
- // No explicit cache: keep coverage precise by disabling nub's default
1065
- // subtree-wide (the only mechanism that reaches the test runner's isolated
1066
- // coverage child, which boots its cache before any preload gate can fire).
1067
- process.env.NODE_DISABLE_COMPILE_CACHE = "1";
1068
- return;
1069
- }
1070
- // Explicit NODE_COMPILE_CACHE present: the user's choice wins over coverage
1071
- // precision (the maintainer, 2026-06-11) — same tradeoff they'd have on plain node.
1072
- // Narrow accepted caveat: a nub-DEFAULT dir restored from the sentinel is
1073
- // indistinguishable from a user dir here; that combination is reachable only
1074
- // when coverage is invisible to nub's own spawn (e.g. a c8-style grandchild
1075
- // setting NODE_V8_COVERAGE itself). Simple + documented beats provenance
1076
- // plumbing through the sentinel.
1077
- try { module_.enableCompileCache(dir); } catch {}
1078
- return;
1079
- }
1080
- const dir = process.env.NODE_COMPILE_CACHE;
1081
- // "0" is nub's disable signal (see transform-core); anything else is the user's
1082
- // real cache dir, which we re-point Node's compile cache at for THEIR modules.
1083
- if (!dir || dir === "0") return;
1084
- try { module_.enableCompileCache(dir); } catch {}
1085
- }
1086
-
1087
- module.exports = {
1088
- installWatchReporting,
1089
- registerLoaderWorker,
1090
- makeHooks,
1091
- installCjsRequireHooks,
1092
- preloadPolyfillPackages,
1093
- installTemporalLazyGlobal,
1094
- restoreCompileCacheEnv,
1095
- reenableUserCompileCache,
1096
- };