@depup/nitro 3.0.260311-beta-depup.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (370) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +32 -0
  3. package/changes.json +14 -0
  4. package/dist/THIRD-PARTY-LICENSES.md +1646 -0
  5. package/dist/_build/common.mjs +29361 -0
  6. package/dist/_build/rolldown.mjs +173 -0
  7. package/dist/_build/rollup.mjs +194 -0
  8. package/dist/_build/vite.build.mjs +18 -0
  9. package/dist/_chunks/nitro.mjs +1159 -0
  10. package/dist/_chunks/nitro2.mjs +102 -0
  11. package/dist/_chunks/nitro3.mjs +129 -0
  12. package/dist/_chunks/utils.mjs +272 -0
  13. package/dist/_common.mjs +35 -0
  14. package/dist/_dev.d.mts +12 -0
  15. package/dist/_dev.mjs +519 -0
  16. package/dist/_libs/_.mjs +3 -0
  17. package/dist/_libs/_2.mjs +2 -0
  18. package/dist/_libs/_3.mjs +3 -0
  19. package/dist/_libs/_4.mjs +2 -0
  20. package/dist/_libs/_5.mjs +3 -0
  21. package/dist/_libs/_6.mjs +4 -0
  22. package/dist/_libs/_7.mjs +5 -0
  23. package/dist/_libs/c12+rc9.mjs +812 -0
  24. package/dist/_libs/c12+readdirp+chokidar.d.mts +230 -0
  25. package/dist/_libs/citty.mjs +361 -0
  26. package/dist/_libs/commondir+is-reference.mjs +1311 -0
  27. package/dist/_libs/compatx.d.mts +47 -0
  28. package/dist/_libs/compatx.mjs +45 -0
  29. package/dist/_libs/esbuild.d.mts +20 -0
  30. package/dist/_libs/escape-string-regexp.mjs +7 -0
  31. package/dist/_libs/estree+pluginutils.d.mts +241 -0
  32. package/dist/_libs/estree-walker.mjs +184 -0
  33. package/dist/_libs/exsolve.d.mts +1 -0
  34. package/dist/_libs/hasown+resolve+deepmerge.mjs +1949 -0
  35. package/dist/_libs/httpxy.d.mts +82 -0
  36. package/dist/_libs/httpxy.mjs +671 -0
  37. package/dist/_libs/js-tokens.d.mts +1 -0
  38. package/dist/_libs/klona.mjs +37 -0
  39. package/dist/_libs/magic-string.d.mts +220 -0
  40. package/dist/_libs/mlly.d.mts +57 -0
  41. package/dist/_libs/nypm+tinyexec.mjs +845 -0
  42. package/dist/_libs/perfect-debounce.mjs +88 -0
  43. package/dist/_libs/pkg-types.d.mts +23 -0
  44. package/dist/_libs/plugin-alias.mjs +64 -0
  45. package/dist/_libs/plugin-inject.mjs +131 -0
  46. package/dist/_libs/plugin-json.mjs +34 -0
  47. package/dist/_libs/pluginutils.mjs +646 -0
  48. package/dist/_libs/readdirp+chokidar.mjs +1606 -0
  49. package/dist/_libs/remapping.mjs +115 -0
  50. package/dist/_libs/resolve-uri+gen-mapping.mjs +442 -0
  51. package/dist/_libs/rou3.d.mts +44 -0
  52. package/dist/_libs/rou3.mjs +496 -0
  53. package/dist/_libs/std-env.d.mts +12 -0
  54. package/dist/_libs/strip-literal.d.mts +1 -0
  55. package/dist/_libs/tsconfck.mjs +813 -0
  56. package/dist/_libs/ultrahtml.mjs +127 -0
  57. package/dist/_libs/unimport+unplugin.mjs +1684 -0
  58. package/dist/_libs/unplugin+unimport.d.mts +423 -0
  59. package/dist/_libs/unwasm.d.mts +29 -0
  60. package/dist/_presets.mjs +1759 -0
  61. package/dist/builder.d.mts +64 -0
  62. package/dist/builder.mjs +15 -0
  63. package/dist/cli/_chunks/build.mjs +47 -0
  64. package/dist/cli/_chunks/common.mjs +14 -0
  65. package/dist/cli/_chunks/deploy.mjs +40 -0
  66. package/dist/cli/_chunks/dev.mjs +62 -0
  67. package/dist/cli/_chunks/docs.mjs +30 -0
  68. package/dist/cli/_chunks/list.mjs +25 -0
  69. package/dist/cli/_chunks/prepare.mjs +17 -0
  70. package/dist/cli/_chunks/preview.mjs +51 -0
  71. package/dist/cli/_chunks/run.mjs +53 -0
  72. package/dist/cli/_chunks/task.mjs +14 -0
  73. package/dist/cli/index.d.mts +1 -0
  74. package/dist/cli/index.mjs +22 -0
  75. package/dist/node_modules/@poppinss/colors/build/index.js +139 -0
  76. package/dist/node_modules/@poppinss/colors/package.json +118 -0
  77. package/dist/node_modules/@poppinss/dumper/build/chunk-26HALFTP.js +602 -0
  78. package/dist/node_modules/@poppinss/dumper/build/formatters/console/main.js +441 -0
  79. package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +725 -0
  80. package/dist/node_modules/@poppinss/dumper/package.json +122 -0
  81. package/dist/node_modules/@poppinss/exception/build/index.js +44 -0
  82. package/dist/node_modules/@poppinss/exception/package.json +109 -0
  83. package/dist/node_modules/@sindresorhus/is/distribution/index.js +1354 -0
  84. package/dist/node_modules/@sindresorhus/is/distribution/utilities.js +3 -0
  85. package/dist/node_modules/@sindresorhus/is/package.json +81 -0
  86. package/dist/node_modules/@speed-highlight/core/dist/index.js +4 -0
  87. package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -0
  88. package/dist/node_modules/@speed-highlight/core/package.json +94 -0
  89. package/dist/node_modules/cookie-es/dist/index.mjs +262 -0
  90. package/dist/node_modules/cookie-es/package.json +37 -0
  91. package/dist/node_modules/croner/dist/croner.js +1 -0
  92. package/dist/node_modules/croner/package.json +73 -0
  93. package/dist/node_modules/defu/dist/defu.mjs +69 -0
  94. package/dist/node_modules/defu/package.json +43 -0
  95. package/dist/node_modules/destr/dist/index.mjs +72 -0
  96. package/dist/node_modules/destr/package.json +47 -0
  97. package/dist/node_modules/error-stack-parser-es/dist/index.mjs +38 -0
  98. package/dist/node_modules/error-stack-parser-es/dist/lite.mjs +167 -0
  99. package/dist/node_modules/error-stack-parser-es/package.json +83 -0
  100. package/dist/node_modules/get-port-please/dist/index.mjs +430 -0
  101. package/dist/node_modules/get-port-please/package.json +39 -0
  102. package/dist/node_modules/kleur/index.mjs +110 -0
  103. package/dist/node_modules/kleur/package.json +51 -0
  104. package/dist/node_modules/rendu/dist/index.mjs +380 -0
  105. package/dist/node_modules/rendu/package.json +47 -0
  106. package/dist/node_modules/scule/dist/index.mjs +80 -0
  107. package/dist/node_modules/scule/package.json +43 -0
  108. package/dist/node_modules/source-map/lib/array-set.js +100 -0
  109. package/dist/node_modules/source-map/lib/base64-vlq.js +94 -0
  110. package/dist/node_modules/source-map/lib/base64.js +19 -0
  111. package/dist/node_modules/source-map/lib/binary-search.js +113 -0
  112. package/dist/node_modules/source-map/lib/mapping-list.js +83 -0
  113. package/dist/node_modules/source-map/lib/mappings.wasm +0 -0
  114. package/dist/node_modules/source-map/lib/read-wasm.js +27 -0
  115. package/dist/node_modules/source-map/lib/source-map-consumer.js +1081 -0
  116. package/dist/node_modules/source-map/lib/source-map-generator.js +439 -0
  117. package/dist/node_modules/source-map/lib/source-node.js +430 -0
  118. package/dist/node_modules/source-map/lib/url.js +13 -0
  119. package/dist/node_modules/source-map/lib/util.js +444 -0
  120. package/dist/node_modules/source-map/lib/wasm.js +138 -0
  121. package/dist/node_modules/source-map/package.json +79 -0
  122. package/dist/node_modules/source-map/source-map.js +10 -0
  123. package/dist/node_modules/supports-color/index.js +202 -0
  124. package/dist/node_modules/supports-color/package.json +64 -0
  125. package/dist/node_modules/ufo/dist/index.mjs +645 -0
  126. package/dist/node_modules/ufo/package.json +48 -0
  127. package/dist/node_modules/unctx/dist/index.mjs +131 -0
  128. package/dist/node_modules/unctx/package.json +67 -0
  129. package/dist/node_modules/youch/build/helpers-B9BQYaS6.js +23 -0
  130. package/dist/node_modules/youch/build/index.js +212 -0
  131. package/dist/node_modules/youch/build/public/error_cause/style.css +5 -0
  132. package/dist/node_modules/youch/build/public/error_info/script.js +13 -0
  133. package/dist/node_modules/youch/build/public/error_info/style.css +145 -0
  134. package/dist/node_modules/youch/build/public/error_metadata/style.css +3 -0
  135. package/dist/node_modules/youch/build/public/error_stack/script.js +72 -0
  136. package/dist/node_modules/youch/build/public/error_stack/style.css +219 -0
  137. package/dist/node_modules/youch/build/public/error_stack_source/style.css +123 -0
  138. package/dist/node_modules/youch/build/public/header/script.js +14 -0
  139. package/dist/node_modules/youch/build/public/header/style.css +56 -0
  140. package/dist/node_modules/youch/build/public/layout/script.js +12 -0
  141. package/dist/node_modules/youch/build/public/layout/style.css +435 -0
  142. package/dist/node_modules/youch/build/public_dir-C5bujZKB.js +25 -0
  143. package/dist/node_modules/youch/build/src/templates/error_cause/main.js +44 -0
  144. package/dist/node_modules/youch/build/src/templates/error_info/main.js +72 -0
  145. package/dist/node_modules/youch/build/src/templates/error_metadata/main.js +65 -0
  146. package/dist/node_modules/youch/build/src/templates/error_stack/main.js +152 -0
  147. package/dist/node_modules/youch/build/src/templates/error_stack_source/main.js +46 -0
  148. package/dist/node_modules/youch/build/src/templates/header/main.js +24 -0
  149. package/dist/node_modules/youch/build/src/templates/layout/main.js +27 -0
  150. package/dist/node_modules/youch/package.json +135 -0
  151. package/dist/node_modules/youch-core/build/index.js +316 -0
  152. package/dist/node_modules/youch-core/package.json +124 -0
  153. package/dist/presets/_nitro/runtime/nitro-dev.mjs +20 -0
  154. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +15 -0
  155. package/dist/presets/_nitro/runtime/service-worker.mjs +23 -0
  156. package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +14 -0
  157. package/dist/presets/aws-lambda/runtime/_utils.mjs +116 -0
  158. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +31 -0
  159. package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +13 -0
  160. package/dist/presets/azure/runtime/_utils.mjs +50 -0
  161. package/dist/presets/azure/runtime/azure-swa.mjs +30 -0
  162. package/dist/presets/bun/runtime/bun.mjs +40 -0
  163. package/dist/presets/cloudflare/runtime/_module-handler.mjs +87 -0
  164. package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +72 -0
  165. package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +17 -0
  166. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +39 -0
  167. package/dist/presets/cloudflare/runtime/plugin.dev.mjs +96 -0
  168. package/dist/presets/cloudflare/runtime/shims/workers.dev.mjs +27 -0
  169. package/dist/presets/deno/runtime/deno-deploy.mjs +19 -0
  170. package/dist/presets/deno/runtime/deno-server.mjs +39 -0
  171. package/dist/presets/netlify/runtime/netlify-edge.mjs +20 -0
  172. package/dist/presets/netlify/runtime/netlify.mjs +20 -0
  173. package/dist/presets/node/runtime/node-cluster.mjs +54 -0
  174. package/dist/presets/node/runtime/node-middleware.mjs +14 -0
  175. package/dist/presets/node/runtime/node-server.mjs +47 -0
  176. package/dist/presets/standard/runtime/server.mjs +4 -0
  177. package/dist/presets/stormkit/runtime/stormkit.mjs +27 -0
  178. package/dist/presets/vercel/runtime/cron-handler.mjs +25 -0
  179. package/dist/presets/vercel/runtime/isr.mjs +19 -0
  180. package/dist/presets/vercel/runtime/vercel.node.mjs +24 -0
  181. package/dist/presets/vercel/runtime/vercel.web.mjs +23 -0
  182. package/dist/presets/winterjs/runtime/winterjs.mjs +91 -0
  183. package/dist/presets/zeabur/runtime/zeabur.mjs +4 -0
  184. package/dist/presets/zephyr/runtime/server.mjs +3 -0
  185. package/dist/runtime/app.d.mts +1 -0
  186. package/dist/runtime/app.mjs +1 -0
  187. package/dist/runtime/cache.d.mts +1 -0
  188. package/dist/runtime/cache.mjs +1 -0
  189. package/dist/runtime/config.d.mts +3 -0
  190. package/dist/runtime/config.mjs +4 -0
  191. package/dist/runtime/context.d.mts +1 -0
  192. package/dist/runtime/context.mjs +1 -0
  193. package/dist/runtime/database.d.mts +1 -0
  194. package/dist/runtime/database.mjs +1 -0
  195. package/dist/runtime/internal/app.d.mts +16 -0
  196. package/dist/runtime/internal/app.mjs +208 -0
  197. package/dist/runtime/internal/cache.d.mts +7 -0
  198. package/dist/runtime/internal/cache.mjs +41 -0
  199. package/dist/runtime/internal/context.d.mts +14 -0
  200. package/dist/runtime/internal/context.mjs +24 -0
  201. package/dist/runtime/internal/database.d.mts +2 -0
  202. package/dist/runtime/internal/database.mjs +12 -0
  203. package/dist/runtime/internal/empty.mjs +0 -0
  204. package/dist/runtime/internal/error/dev.d.mts +10 -0
  205. package/dist/runtime/internal/error/dev.mjs +121 -0
  206. package/dist/runtime/internal/error/hooks.d.mts +1 -0
  207. package/dist/runtime/internal/error/hooks.mjs +9 -0
  208. package/dist/runtime/internal/error/prod.d.mts +6 -0
  209. package/dist/runtime/internal/error/prod.mjs +40 -0
  210. package/dist/runtime/internal/error/utils.d.mts +8 -0
  211. package/dist/runtime/internal/error/utils.mjs +3 -0
  212. package/dist/runtime/internal/meta.d.mts +2 -0
  213. package/dist/runtime/internal/meta.mjs +3 -0
  214. package/dist/runtime/internal/plugin.d.mts +3 -0
  215. package/dist/runtime/internal/plugin.mjs +4 -0
  216. package/dist/runtime/internal/route-rules.d.mts +9 -0
  217. package/dist/runtime/internal/route-rules.mjs +72 -0
  218. package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -0
  219. package/dist/runtime/internal/routes/dev-tasks.mjs +25 -0
  220. package/dist/runtime/internal/routes/openapi.d.mts +3 -0
  221. package/dist/runtime/internal/routes/openapi.mjs +94 -0
  222. package/dist/runtime/internal/routes/renderer-template.d.mts +2 -0
  223. package/dist/runtime/internal/routes/renderer-template.dev.d.mts +3 -0
  224. package/dist/runtime/internal/routes/renderer-template.dev.mjs +19 -0
  225. package/dist/runtime/internal/routes/renderer-template.mjs +4 -0
  226. package/dist/runtime/internal/routes/scalar.d.mts +3 -0
  227. package/dist/runtime/internal/routes/scalar.mjs +193 -0
  228. package/dist/runtime/internal/routes/swagger.d.mts +3 -0
  229. package/dist/runtime/internal/routes/swagger.mjs +42 -0
  230. package/dist/runtime/internal/runtime-config.d.mts +9 -0
  231. package/dist/runtime/internal/runtime-config.mjs +54 -0
  232. package/dist/runtime/internal/static.d.mts +3 -0
  233. package/dist/runtime/internal/static.mjs +67 -0
  234. package/dist/runtime/internal/storage.d.mts +2 -0
  235. package/dist/runtime/internal/storage.mjs +6 -0
  236. package/dist/runtime/internal/task.d.mts +19 -0
  237. package/dist/runtime/internal/task.mjs +69 -0
  238. package/dist/runtime/internal/vite/dev-entry.mjs +18 -0
  239. package/dist/runtime/internal/vite/dev-worker.mjs +264 -0
  240. package/dist/runtime/internal/vite/ssr-renderer.mjs +6 -0
  241. package/dist/runtime/meta.d.mts +5 -0
  242. package/dist/runtime/meta.mjs +27 -0
  243. package/dist/runtime/nitro.d.mts +11 -0
  244. package/dist/runtime/nitro.mjs +34 -0
  245. package/dist/runtime/runtime-config.d.mts +1 -0
  246. package/dist/runtime/runtime-config.mjs +1 -0
  247. package/dist/runtime/storage.d.mts +1 -0
  248. package/dist/runtime/storage.mjs +1 -0
  249. package/dist/runtime/task.d.mts +1 -0
  250. package/dist/runtime/task.mjs +1 -0
  251. package/dist/runtime/virtual/_runtime_warn.d.mts +1 -0
  252. package/dist/runtime/virtual/_runtime_warn.mjs +5 -0
  253. package/dist/runtime/virtual/database.d.mts +8 -0
  254. package/dist/runtime/virtual/database.mjs +2 -0
  255. package/dist/runtime/virtual/error-handler.d.mts +6 -0
  256. package/dist/runtime/virtual/error-handler.mjs +9 -0
  257. package/dist/runtime/virtual/feature-flags.d.mts +7 -0
  258. package/dist/runtime/virtual/feature-flags.mjs +7 -0
  259. package/dist/runtime/virtual/plugins.d.mts +3 -0
  260. package/dist/runtime/virtual/plugins.mjs +2 -0
  261. package/dist/runtime/virtual/polyfills.d.mts +3 -0
  262. package/dist/runtime/virtual/polyfills.mjs +2 -0
  263. package/dist/runtime/virtual/public-assets.d.mts +9 -0
  264. package/dist/runtime/virtual/public-assets.mjs +8 -0
  265. package/dist/runtime/virtual/renderer-template.d.mts +4 -0
  266. package/dist/runtime/virtual/renderer-template.mjs +7 -0
  267. package/dist/runtime/virtual/routing-meta.d.mts +7 -0
  268. package/dist/runtime/virtual/routing-meta.mjs +2 -0
  269. package/dist/runtime/virtual/routing.d.mts +8 -0
  270. package/dist/runtime/virtual/routing.mjs +11 -0
  271. package/dist/runtime/virtual/runtime-config.d.mts +3 -0
  272. package/dist/runtime/virtual/runtime-config.mjs +5 -0
  273. package/dist/runtime/virtual/server-assets.d.mts +7 -0
  274. package/dist/runtime/virtual/server-assets.mjs +12 -0
  275. package/dist/runtime/virtual/storage.d.mts +3 -0
  276. package/dist/runtime/virtual/storage.mjs +5 -0
  277. package/dist/runtime/virtual/tasks.d.mts +10 -0
  278. package/dist/runtime/virtual/tasks.mjs +3 -0
  279. package/dist/runtime/vite.d.mts +8 -0
  280. package/dist/runtime/vite.mjs +9 -0
  281. package/dist/types/index.d.mts +3010 -0
  282. package/dist/types/index.mjs +1 -0
  283. package/dist/vite.d.mts +52 -0
  284. package/dist/vite.mjs +740 -0
  285. package/lib/h3.d.mts +1 -0
  286. package/lib/h3.mjs +1 -0
  287. package/lib/tsconfig.json +27 -0
  288. package/lib/vite.types.d.mts +26 -0
  289. package/lib/vite.types.mjs +2 -0
  290. package/package.json +256 -0
  291. package/skills/nitro/SKILL.md +10 -0
  292. package/skills/nitro/docs/TOC.md +83 -0
  293. package/skills/nitro/docs/_navigation.json +679 -0
  294. package/skills/nitro/docs/config/index.md +1147 -0
  295. package/skills/nitro/docs/deploy/index.md +64 -0
  296. package/skills/nitro/docs/deploy/providers/alwaysdata.md +50 -0
  297. package/skills/nitro/docs/deploy/providers/aws-amplify.md +81 -0
  298. package/skills/nitro/docs/deploy/providers/aws.md +47 -0
  299. package/skills/nitro/docs/deploy/providers/azure.md +72 -0
  300. package/skills/nitro/docs/deploy/providers/cleavr.md +33 -0
  301. package/skills/nitro/docs/deploy/providers/cloudflare.md +375 -0
  302. package/skills/nitro/docs/deploy/providers/deno-deploy.md +66 -0
  303. package/skills/nitro/docs/deploy/providers/digitalocean.md +46 -0
  304. package/skills/nitro/docs/deploy/providers/firebase.md +32 -0
  305. package/skills/nitro/docs/deploy/providers/flightcontrol.md +67 -0
  306. package/skills/nitro/docs/deploy/providers/genezio.md +67 -0
  307. package/skills/nitro/docs/deploy/providers/github-pages.md +68 -0
  308. package/skills/nitro/docs/deploy/providers/gitlab-pages.md +37 -0
  309. package/skills/nitro/docs/deploy/providers/heroku.md +84 -0
  310. package/skills/nitro/docs/deploy/providers/iis.md +38 -0
  311. package/skills/nitro/docs/deploy/providers/koyeb.md +109 -0
  312. package/skills/nitro/docs/deploy/providers/netlify.md +47 -0
  313. package/skills/nitro/docs/deploy/providers/platform-sh.md +37 -0
  314. package/skills/nitro/docs/deploy/providers/render.md +37 -0
  315. package/skills/nitro/docs/deploy/providers/stormkit.md +24 -0
  316. package/skills/nitro/docs/deploy/providers/vercel.md +179 -0
  317. package/skills/nitro/docs/deploy/providers/zeabur.md +19 -0
  318. package/skills/nitro/docs/deploy/providers/zephyr.md +99 -0
  319. package/skills/nitro/docs/deploy/providers/zerops.md +102 -0
  320. package/skills/nitro/docs/deploy/runtimes/bun.md +15 -0
  321. package/skills/nitro/docs/deploy/runtimes/deno.md +19 -0
  322. package/skills/nitro/docs/deploy/runtimes/node.md +63 -0
  323. package/skills/nitro/docs/docs/assets.md +166 -0
  324. package/skills/nitro/docs/docs/cache.md +408 -0
  325. package/skills/nitro/docs/docs/configuration.md +256 -0
  326. package/skills/nitro/docs/docs/database.md +185 -0
  327. package/skills/nitro/docs/docs/index.md +56 -0
  328. package/skills/nitro/docs/docs/lifecycle.md +204 -0
  329. package/skills/nitro/docs/docs/migration.md +215 -0
  330. package/skills/nitro/docs/docs/nightly.md +31 -0
  331. package/skills/nitro/docs/docs/plugins.md +164 -0
  332. package/skills/nitro/docs/docs/quick-start.md +110 -0
  333. package/skills/nitro/docs/docs/renderer.md +322 -0
  334. package/skills/nitro/docs/docs/routing.md +711 -0
  335. package/skills/nitro/docs/docs/server-entry.md +239 -0
  336. package/skills/nitro/docs/docs/storage.md +261 -0
  337. package/skills/nitro/docs/docs/tasks.md +277 -0
  338. package/skills/nitro/docs/examples/api-routes.md +145 -0
  339. package/skills/nitro/docs/examples/auto-imports.md +93 -0
  340. package/skills/nitro/docs/examples/cached-handler.md +81 -0
  341. package/skills/nitro/docs/examples/custom-error-handler.md +98 -0
  342. package/skills/nitro/docs/examples/database.md +157 -0
  343. package/skills/nitro/docs/examples/elysia.md +70 -0
  344. package/skills/nitro/docs/examples/express.md +78 -0
  345. package/skills/nitro/docs/examples/fastify.md +79 -0
  346. package/skills/nitro/docs/examples/hello-world.md +68 -0
  347. package/skills/nitro/docs/examples/hono.md +74 -0
  348. package/skills/nitro/docs/examples/import-alias.md +100 -0
  349. package/skills/nitro/docs/examples/index.md +3 -0
  350. package/skills/nitro/docs/examples/middleware.md +91 -0
  351. package/skills/nitro/docs/examples/mono-jsx.md +68 -0
  352. package/skills/nitro/docs/examples/nano-jsx.md +70 -0
  353. package/skills/nitro/docs/examples/plugins.md +91 -0
  354. package/skills/nitro/docs/examples/renderer.md +113 -0
  355. package/skills/nitro/docs/examples/runtime-config.md +97 -0
  356. package/skills/nitro/docs/examples/server-fetch.md +87 -0
  357. package/skills/nitro/docs/examples/shiki.md +198 -0
  358. package/skills/nitro/docs/examples/virtual-routes.md +74 -0
  359. package/skills/nitro/docs/examples/vite-nitro-plugin.md +79 -0
  360. package/skills/nitro/docs/examples/vite-rsc.md +1041 -0
  361. package/skills/nitro/docs/examples/vite-ssr-html.md +217 -0
  362. package/skills/nitro/docs/examples/vite-ssr-preact.md +247 -0
  363. package/skills/nitro/docs/examples/vite-ssr-react.md +226 -0
  364. package/skills/nitro/docs/examples/vite-ssr-solid.md +256 -0
  365. package/skills/nitro/docs/examples/vite-ssr-tsr-react.md +442 -0
  366. package/skills/nitro/docs/examples/vite-ssr-tss-react.md +444 -0
  367. package/skills/nitro/docs/examples/vite-ssr-vue-router.md +616 -0
  368. package/skills/nitro/docs/examples/vite-trpc.md +335 -0
  369. package/skills/nitro/docs/examples/websocket.md +282 -0
  370. package/skills/nitro/docs/index.md +121 -0
@@ -0,0 +1,1311 @@
1
+ import { i as __toESM, r as __require, t as __commonJSMin } from "../_common.mjs";
2
+ import { P as Builder, S as MagicString, c as walk, i as createFilter, o as extractAssignedNames, r as attachScopes, s as makeLegalIdentifier } from "../_build/common.mjs";
3
+ import { existsSync, readFileSync, statSync } from "fs";
4
+ import { basename, dirname, extname, join, relative, resolve, sep } from "path";
5
+ //#region node_modules/.pnpm/commondir@1.0.1/node_modules/commondir/index.js
6
+ var require_commondir = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7
+ var path$1 = __require("path");
8
+ module.exports = function(basedir, relfiles) {
9
+ if (relfiles) var files = relfiles.map(function(r) {
10
+ return path$1.resolve(basedir, r);
11
+ });
12
+ else var files = basedir;
13
+ var res = files.slice(1).reduce(function(ps, file) {
14
+ if (!file.match(/^([A-Za-z]:)?\/|\\/)) throw new Error("relative path without a basedir");
15
+ var xs = file.split(/\/+|\\+/);
16
+ for (var i = 0; ps[i] === xs[i] && i < Math.min(ps.length, xs.length); i++);
17
+ return ps.slice(0, i);
18
+ }, files[0].split(/\/+|\\+/));
19
+ return res.length > 1 ? res.join("/") : "/";
20
+ };
21
+ }));
22
+ //#endregion
23
+ //#region node_modules/.pnpm/is-reference@1.2.1/node_modules/is-reference/dist/is-reference.es.js
24
+ function isReference(node, parent) {
25
+ if (node.type === "MemberExpression") return !node.computed && isReference(node.object, node);
26
+ if (node.type === "Identifier") {
27
+ if (!parent) return true;
28
+ switch (parent.type) {
29
+ case "MemberExpression": return parent.computed || node === parent.object;
30
+ case "MethodDefinition": return parent.computed;
31
+ case "FieldDefinition": return parent.computed || node === parent.value;
32
+ case "Property": return parent.computed || node === parent.value;
33
+ case "ExportSpecifier":
34
+ case "ImportSpecifier": return node === parent.local;
35
+ case "LabeledStatement":
36
+ case "BreakStatement":
37
+ case "ContinueStatement": return false;
38
+ default: return true;
39
+ }
40
+ }
41
+ return false;
42
+ }
43
+ //#endregion
44
+ //#region node_modules/.pnpm/@rollup+plugin-commonjs@29.0.2_rollup@4.59.0/node_modules/@rollup/plugin-commonjs/dist/es/index.js
45
+ var import_commondir = /* @__PURE__ */ __toESM(require_commondir(), 1);
46
+ var version = "29.0.1";
47
+ var peerDependencies = { rollup: "^2.68.0||^3.0.0||^4.0.0" };
48
+ function tryParse(parse, code, id) {
49
+ try {
50
+ return parse(code, { allowReturnOutsideFunction: true });
51
+ } catch (err) {
52
+ err.message += ` in ${id}`;
53
+ throw err;
54
+ }
55
+ }
56
+ const firstpassGlobal = /\b(?:require|module|exports|global)\b/;
57
+ const firstpassNoGlobal = /\b(?:require|module|exports)\b/;
58
+ function hasCjsKeywords(code, ignoreGlobal) {
59
+ return (ignoreGlobal ? firstpassNoGlobal : firstpassGlobal).test(code);
60
+ }
61
+ function analyzeTopLevelStatements(parse, code, id) {
62
+ const ast = tryParse(parse, code, id);
63
+ let isEsModule = false;
64
+ let hasDefaultExport = false;
65
+ let hasNamedExports = false;
66
+ for (const node of ast.body) switch (node.type) {
67
+ case "ExportDefaultDeclaration":
68
+ isEsModule = true;
69
+ hasDefaultExport = true;
70
+ break;
71
+ case "ExportNamedDeclaration":
72
+ isEsModule = true;
73
+ if (node.declaration) hasNamedExports = true;
74
+ else for (const specifier of node.specifiers) if (specifier.exported.name === "default") hasDefaultExport = true;
75
+ else hasNamedExports = true;
76
+ break;
77
+ case "ExportAllDeclaration":
78
+ isEsModule = true;
79
+ if (node.exported && node.exported.name === "default") hasDefaultExport = true;
80
+ else hasNamedExports = true;
81
+ break;
82
+ case "ImportDeclaration":
83
+ isEsModule = true;
84
+ break;
85
+ }
86
+ return {
87
+ isEsModule,
88
+ hasDefaultExport,
89
+ hasNamedExports,
90
+ ast
91
+ };
92
+ }
93
+ function deconflict(scopes, globals, identifier) {
94
+ let i = 1;
95
+ let deconflicted = makeLegalIdentifier(identifier);
96
+ const hasConflicts = () => scopes.some((scope) => scope.contains(deconflicted)) || globals.has(deconflicted);
97
+ while (hasConflicts()) {
98
+ deconflicted = makeLegalIdentifier(`${identifier}_${i}`);
99
+ i += 1;
100
+ }
101
+ for (const scope of scopes) scope.declarations[deconflicted] = true;
102
+ return deconflicted;
103
+ }
104
+ function getName(id) {
105
+ const name = makeLegalIdentifier(basename(id, extname(id)));
106
+ if (name !== "index") return name;
107
+ return makeLegalIdentifier(basename(dirname(id)));
108
+ }
109
+ function normalizePathSlashes(path) {
110
+ return path.replace(/\\/g, "/");
111
+ }
112
+ const getVirtualPathForDynamicRequirePath = (path, commonDir) => `/${normalizePathSlashes(relative(commonDir, path))}`;
113
+ function capitalize(name) {
114
+ return name[0].toUpperCase() + name.slice(1);
115
+ }
116
+ function getStrictRequiresFilter({ strictRequires }) {
117
+ switch (strictRequires) {
118
+ case void 0:
119
+ case true: return {
120
+ strictRequiresFilter: () => true,
121
+ detectCyclesAndConditional: false
122
+ };
123
+ case "auto":
124
+ case "debug":
125
+ case null: return {
126
+ strictRequiresFilter: () => false,
127
+ detectCyclesAndConditional: true
128
+ };
129
+ case false: return {
130
+ strictRequiresFilter: () => false,
131
+ detectCyclesAndConditional: false
132
+ };
133
+ default:
134
+ if (typeof strictRequires === "string" || Array.isArray(strictRequires)) return {
135
+ strictRequiresFilter: createFilter(strictRequires),
136
+ detectCyclesAndConditional: false
137
+ };
138
+ throw new Error("Unexpected value for \"strictRequires\" option.");
139
+ }
140
+ }
141
+ function getPackageEntryPoint(dirPath) {
142
+ let entryPoint = "index.js";
143
+ try {
144
+ if (existsSync(join(dirPath, "package.json"))) entryPoint = JSON.parse(readFileSync(join(dirPath, "package.json"), { encoding: "utf8" })).main || entryPoint;
145
+ } catch (ignored) {}
146
+ return entryPoint;
147
+ }
148
+ function isDirectory(path) {
149
+ try {
150
+ if (statSync(path).isDirectory()) return true;
151
+ } catch (ignored) {}
152
+ return false;
153
+ }
154
+ function getDynamicRequireModules(patterns, dynamicRequireRoot) {
155
+ const dynamicRequireModules = /* @__PURE__ */ new Map();
156
+ const dirNames = /* @__PURE__ */ new Set();
157
+ for (const pattern of !patterns || Array.isArray(patterns) ? patterns || [] : [patterns]) {
158
+ const isNegated = pattern.startsWith("!");
159
+ const modifyMap = (targetPath, resolvedPath) => isNegated ? dynamicRequireModules.delete(targetPath) : dynamicRequireModules.set(targetPath, resolvedPath);
160
+ for (const path of new Builder().withBasePath().withDirs().glob(isNegated ? pattern.substr(1) : pattern).crawl(relative(".", dynamicRequireRoot)).sync().sort((a, b) => a.localeCompare(b, "en"))) {
161
+ const resolvedPath = resolve(path);
162
+ const requirePath = normalizePathSlashes(resolvedPath);
163
+ if (isDirectory(resolvedPath)) {
164
+ dirNames.add(resolvedPath);
165
+ const modulePath = resolve(join(resolvedPath, getPackageEntryPoint(path)));
166
+ modifyMap(requirePath, modulePath);
167
+ modifyMap(normalizePathSlashes(modulePath), modulePath);
168
+ } else {
169
+ dirNames.add(dirname(resolvedPath));
170
+ modifyMap(requirePath, resolvedPath);
171
+ }
172
+ }
173
+ }
174
+ return {
175
+ commonDir: dirNames.size ? (0, import_commondir.default)([...dirNames, dynamicRequireRoot]) : null,
176
+ dynamicRequireModules
177
+ };
178
+ }
179
+ const FAILED_REQUIRE_ERROR = `throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');`;
180
+ const COMMONJS_REQUIRE_EXPORT = "commonjsRequire";
181
+ const CREATE_COMMONJS_REQUIRE_EXPORT = "createCommonjsRequire";
182
+ function getDynamicModuleRegistry(isDynamicRequireModulesEnabled, dynamicRequireModules, commonDir, ignoreDynamicRequires) {
183
+ if (!isDynamicRequireModulesEnabled) return `export function ${COMMONJS_REQUIRE_EXPORT}(path) {
184
+ ${FAILED_REQUIRE_ERROR}
185
+ }`;
186
+ return `${[...dynamicRequireModules.values()].map((id, index) => `import ${id.endsWith(".json") ? `json${index}` : `{ __require as require${index} }`} from ${JSON.stringify(id)};`).join("\n")}
187
+
188
+ var dynamicModules;
189
+
190
+ function getDynamicModules() {
191
+ return dynamicModules || (dynamicModules = {
192
+ ${[...dynamicRequireModules.keys()].map((id, index) => `\t\t${JSON.stringify(getVirtualPathForDynamicRequirePath(id, commonDir))}: ${id.endsWith(".json") ? `function () { return json${index}; }` : `require${index}`}`).join(",\n")}
193
+ });
194
+ }
195
+
196
+ export function ${CREATE_COMMONJS_REQUIRE_EXPORT}(originalModuleDir) {
197
+ function handleRequire(path) {
198
+ var resolvedPath = commonjsResolve(path, originalModuleDir);
199
+ if (resolvedPath !== null) {
200
+ return getDynamicModules()[resolvedPath]();
201
+ }
202
+ ${ignoreDynamicRequires ? "return require(path);" : FAILED_REQUIRE_ERROR}
203
+ }
204
+ handleRequire.resolve = function (path) {
205
+ var resolvedPath = commonjsResolve(path, originalModuleDir);
206
+ if (resolvedPath !== null) {
207
+ return resolvedPath;
208
+ }
209
+ return require.resolve(path);
210
+ }
211
+ return handleRequire;
212
+ }
213
+
214
+ function commonjsResolve (path, originalModuleDir) {
215
+ var shouldTryNodeModules = isPossibleNodeModulesPath(path);
216
+ path = normalize(path);
217
+ var relPath;
218
+ if (path[0] === '/') {
219
+ originalModuleDir = '';
220
+ }
221
+ var modules = getDynamicModules();
222
+ var checkedExtensions = ['', '.js', '.json'];
223
+ while (true) {
224
+ if (!shouldTryNodeModules) {
225
+ relPath = normalize(originalModuleDir + '/' + path);
226
+ } else {
227
+ relPath = normalize(originalModuleDir + '/node_modules/' + path);
228
+ }
229
+
230
+ if (relPath.endsWith('/..')) {
231
+ break; // Travelled too far up, avoid infinite loop
232
+ }
233
+
234
+ for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) {
235
+ var resolvedPath = relPath + checkedExtensions[extensionIndex];
236
+ if (modules[resolvedPath]) {
237
+ return resolvedPath;
238
+ }
239
+ }
240
+ if (!shouldTryNodeModules) break;
241
+ var nextDir = normalize(originalModuleDir + '/..');
242
+ if (nextDir === originalModuleDir) break;
243
+ originalModuleDir = nextDir;
244
+ }
245
+ return null;
246
+ }
247
+
248
+ function isPossibleNodeModulesPath (modulePath) {
249
+ var c0 = modulePath[0];
250
+ if (c0 === '/' || c0 === '\\\\') return false;
251
+ var c1 = modulePath[1], c2 = modulePath[2];
252
+ if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||
253
+ (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;
254
+ if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false;
255
+ return true;
256
+ }
257
+
258
+ function normalize (path) {
259
+ path = path.replace(/\\\\/g, '/');
260
+ var parts = path.split('/');
261
+ var slashed = parts[0] === '';
262
+ for (var i = 1; i < parts.length; i++) {
263
+ if (parts[i] === '.' || parts[i] === '') {
264
+ parts.splice(i--, 1);
265
+ }
266
+ }
267
+ for (var i = 1; i < parts.length; i++) {
268
+ if (parts[i] !== '..') continue;
269
+ if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {
270
+ parts.splice(--i, 2);
271
+ i--;
272
+ }
273
+ }
274
+ path = parts.join('/');
275
+ if (slashed && path[0] !== '/') path = '/' + path;
276
+ else if (path.length === 0) path = '.';
277
+ return path;
278
+ }`;
279
+ }
280
+ const isWrappedId = (id, suffix) => id.endsWith(suffix);
281
+ const wrapId = (id, suffix) => `\0${id}${suffix}`;
282
+ const unwrapId = (wrappedId, suffix) => wrappedId.slice(1, -suffix.length);
283
+ const PROXY_SUFFIX = "?commonjs-proxy";
284
+ const WRAPPED_SUFFIX = "?commonjs-wrapped";
285
+ const EXTERNAL_SUFFIX = "?commonjs-external";
286
+ const EXPORTS_SUFFIX = "?commonjs-exports";
287
+ const MODULE_SUFFIX = "?commonjs-module";
288
+ const ENTRY_SUFFIX = "?commonjs-entry";
289
+ const ES_IMPORT_SUFFIX = "?commonjs-es-import";
290
+ const DYNAMIC_MODULES_ID = "\0commonjs-dynamic-modules";
291
+ const HELPERS_ID = "\0commonjsHelpers.js";
292
+ const IS_WRAPPED_COMMONJS = "withRequireFunction";
293
+ const HELPERS = `
294
+ export var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
295
+
296
+ export function getDefaultExportFromCjs (x) {
297
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
298
+ }
299
+
300
+ export function getDefaultExportFromNamespaceIfPresent (n) {
301
+ return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n['default'] : n;
302
+ }
303
+
304
+ export function getDefaultExportFromNamespaceIfNotNamed (n) {
305
+ return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n;
306
+ }
307
+
308
+ export function getAugmentedNamespace(n) {
309
+ if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n;
310
+ var f = n.default;
311
+ if (typeof f == "function") {
312
+ var a = function a () {
313
+ var isInstance = false;
314
+ try {
315
+ isInstance = this instanceof a;
316
+ } catch {}
317
+ if (isInstance) {
318
+ return Reflect.construct(f, arguments, this.constructor);
319
+ }
320
+ return f.apply(this, arguments);
321
+ };
322
+ a.prototype = f.prototype;
323
+ } else a = {};
324
+ Object.defineProperty(a, '__esModule', {value: true});
325
+ Object.keys(n).forEach(function (k) {
326
+ var d = Object.getOwnPropertyDescriptor(n, k);
327
+ Object.defineProperty(a, k, d.get ? d : {
328
+ enumerable: true,
329
+ get: function () {
330
+ return n[k];
331
+ }
332
+ });
333
+ });
334
+ return a;
335
+ }
336
+ `;
337
+ function getHelpersModule() {
338
+ return HELPERS;
339
+ }
340
+ function getUnknownRequireProxy(id, requireReturnsDefault) {
341
+ if (requireReturnsDefault === true || id.endsWith(".json")) return `export { default } from ${JSON.stringify(id)};`;
342
+ const name = getName(id);
343
+ const exported = requireReturnsDefault === "auto" ? `import { getDefaultExportFromNamespaceIfNotNamed } from "${HELPERS_ID}"; export default /*@__PURE__*/getDefaultExportFromNamespaceIfNotNamed(${name});` : requireReturnsDefault === "preferred" ? `import { getDefaultExportFromNamespaceIfPresent } from "${HELPERS_ID}"; export default /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(${name});` : !requireReturnsDefault ? `import { getAugmentedNamespace } from "${HELPERS_ID}"; export default /*@__PURE__*/getAugmentedNamespace(${name});` : `export default ${name};`;
344
+ return `import * as ${name} from ${JSON.stringify(id)}; ${exported}`;
345
+ }
346
+ async function getStaticRequireProxy(id, requireReturnsDefault, loadModule) {
347
+ const name = getName(id);
348
+ const { meta: { commonjs: commonjsMeta } } = await loadModule({ id });
349
+ if (!commonjsMeta) return getUnknownRequireProxy(id, requireReturnsDefault);
350
+ if (commonjsMeta.isCommonJS) return `export { __moduleExports as default } from ${JSON.stringify(id)};`;
351
+ if (!requireReturnsDefault) return `import { getAugmentedNamespace } from "${HELPERS_ID}"; import * as ${name} from ${JSON.stringify(id)}; export default /*@__PURE__*/getAugmentedNamespace(${name});`;
352
+ if (requireReturnsDefault !== true && (requireReturnsDefault === "namespace" || !commonjsMeta.hasDefaultExport || requireReturnsDefault === "auto" && commonjsMeta.hasNamedExports)) return `import * as ${name} from ${JSON.stringify(id)}; export default ${name};`;
353
+ return `export { default } from ${JSON.stringify(id)};`;
354
+ }
355
+ function getEntryProxy(id, defaultIsModuleExports, getModuleInfo, shebang) {
356
+ const { meta: { commonjs: commonjsMeta }, hasDefaultExport } = getModuleInfo(id);
357
+ if (!commonjsMeta || commonjsMeta.isCommonJS !== IS_WRAPPED_COMMONJS) {
358
+ const stringifiedId = JSON.stringify(id);
359
+ let code = `export * from ${stringifiedId};`;
360
+ if (hasDefaultExport) code += `export { default } from ${stringifiedId};`;
361
+ return shebang + code;
362
+ }
363
+ const result = getEsImportProxy(id, defaultIsModuleExports, true);
364
+ return {
365
+ ...result,
366
+ code: shebang + result.code
367
+ };
368
+ }
369
+ function getEsImportProxy(id, defaultIsModuleExports, moduleSideEffects) {
370
+ const name = getName(id);
371
+ const exportsName = `${name}Exports`;
372
+ const requireModule = `require${capitalize(name)}`;
373
+ let code = `import { getDefaultExportFromCjs } from "${HELPERS_ID}";\nimport { __require as ${requireModule} } from ${JSON.stringify(id)};\nvar ${exportsName} = ${moduleSideEffects ? "" : "/*@__PURE__*/ "}${requireModule}();\nexport { ${exportsName} as __moduleExports };`;
374
+ if (defaultIsModuleExports === true) code += `\nexport { ${exportsName} as default };`;
375
+ else if (defaultIsModuleExports === false) code += `\nexport default ${exportsName}.default;`;
376
+ else code += `\nexport default /*@__PURE__*/getDefaultExportFromCjs(${exportsName});`;
377
+ return {
378
+ code,
379
+ syntheticNamedExports: "__moduleExports"
380
+ };
381
+ }
382
+ function getExternalBuiltinRequireProxy(id) {
383
+ return `import { createRequire } from 'node:module';
384
+ const require = createRequire(import.meta.url);
385
+ export function __require() { return require(${JSON.stringify(id)}); }`;
386
+ }
387
+ function getCandidatesForExtension(resolved, extension) {
388
+ return [resolved + extension, `${resolved}${sep}index${extension}`];
389
+ }
390
+ function getCandidates(resolved, extensions) {
391
+ return extensions.reduce((paths, extension) => paths.concat(getCandidatesForExtension(resolved, extension)), [resolved]);
392
+ }
393
+ function resolveExtensions(importee, importer, extensions) {
394
+ if (importee[0] !== "." || !importer) return void 0;
395
+ const candidates = getCandidates(resolve(dirname(importer), importee), extensions);
396
+ for (let i = 0; i < candidates.length; i += 1) try {
397
+ if (statSync(candidates[i]).isFile()) return { id: candidates[i] };
398
+ } catch (err) {}
399
+ }
400
+ function getResolveId(extensions, isPossibleCjsId) {
401
+ const currentlyResolving = /* @__PURE__ */ new Map();
402
+ return {
403
+ currentlyResolving,
404
+ async resolveId(importee, importer, resolveOptions) {
405
+ if (resolveOptions.custom?.["node-resolve"]?.isRequire) return null;
406
+ const currentlyResolvingForParent = currentlyResolving.get(importer);
407
+ if (currentlyResolvingForParent && currentlyResolvingForParent.has(importee)) {
408
+ this.warn({
409
+ code: "THIS_RESOLVE_WITHOUT_OPTIONS",
410
+ message: "It appears a plugin has implemented a \"resolveId\" hook that uses \"this.resolve\" without forwarding the third \"options\" parameter of \"resolveId\". This is problematic as it can lead to wrong module resolutions especially for the node-resolve plugin and in certain cases cause early exit errors for the commonjs plugin.\nIn rare cases, this warning can appear if the same file is both imported and required from the same mixed ES/CommonJS module, in which case it can be ignored.",
411
+ url: "https://rollupjs.org/guide/en/#resolveid"
412
+ });
413
+ return null;
414
+ }
415
+ if (isWrappedId(importee, WRAPPED_SUFFIX)) return unwrapId(importee, WRAPPED_SUFFIX);
416
+ if (importee.endsWith(ENTRY_SUFFIX) || isWrappedId(importee, MODULE_SUFFIX) || isWrappedId(importee, EXPORTS_SUFFIX) || isWrappedId(importee, PROXY_SUFFIX) || isWrappedId(importee, ES_IMPORT_SUFFIX) || isWrappedId(importee, EXTERNAL_SUFFIX) || importee.startsWith(HELPERS_ID) || importee === DYNAMIC_MODULES_ID) return importee;
417
+ if (importer) {
418
+ if (importer === DYNAMIC_MODULES_ID || isWrappedId(importer, PROXY_SUFFIX) || isWrappedId(importer, ES_IMPORT_SUFFIX) || importer.endsWith(ENTRY_SUFFIX)) return importee;
419
+ if (isWrappedId(importer, EXTERNAL_SUFFIX)) {
420
+ if (!await this.resolve(importee, importer, Object.assign({ skipSelf: true }, resolveOptions))) return null;
421
+ return {
422
+ id: importee,
423
+ external: true
424
+ };
425
+ }
426
+ }
427
+ if (importee.startsWith("\0")) return null;
428
+ const resolved = await this.resolve(importee, importer, Object.assign({ skipSelf: true }, resolveOptions)) || resolveExtensions(importee, importer, extensions);
429
+ if (!resolved || resolved.external || resolved.id.endsWith(ENTRY_SUFFIX) || isWrappedId(resolved.id, ES_IMPORT_SUFFIX) || !isPossibleCjsId(resolved.id)) return resolved;
430
+ const moduleInfo = await this.load(resolved);
431
+ const { meta: { commonjs: commonjsMeta } } = moduleInfo;
432
+ if (commonjsMeta) {
433
+ const { isCommonJS } = commonjsMeta;
434
+ if (isCommonJS) {
435
+ if (resolveOptions.isEntry) {
436
+ moduleInfo.moduleSideEffects = true;
437
+ return resolved.id + ENTRY_SUFFIX;
438
+ }
439
+ if (isCommonJS === IS_WRAPPED_COMMONJS) return {
440
+ id: wrapId(resolved.id, ES_IMPORT_SUFFIX),
441
+ meta: { commonjs: { resolved } }
442
+ };
443
+ }
444
+ }
445
+ return resolved;
446
+ }
447
+ };
448
+ }
449
+ function getRequireResolver(extensions, detectCyclesAndConditional, currentlyResolving, requireNodeBuiltins) {
450
+ const knownCjsModuleTypes = Object.create(null);
451
+ const requiredIds = Object.create(null);
452
+ const unconditionallyRequiredIds = Object.create(null);
453
+ const dependencies = Object.create(null);
454
+ const getDependencies = (id) => dependencies[id] || (dependencies[id] = /* @__PURE__ */ new Set());
455
+ const isCyclic = (id) => {
456
+ const dependenciesToCheck = new Set(getDependencies(id));
457
+ for (const dependency of dependenciesToCheck) {
458
+ if (dependency === id) return true;
459
+ for (const childDependency of getDependencies(dependency)) dependenciesToCheck.add(childDependency);
460
+ }
461
+ return false;
462
+ };
463
+ const fullyAnalyzedModules = Object.create(null);
464
+ const getTypeForFullyAnalyzedModule = (id) => {
465
+ const knownType = knownCjsModuleTypes[id];
466
+ if (knownType !== true || !detectCyclesAndConditional || fullyAnalyzedModules[id]) return knownType;
467
+ if (isCyclic(id)) return knownCjsModuleTypes[id] = IS_WRAPPED_COMMONJS;
468
+ return knownType;
469
+ };
470
+ const setInitialParentType = (id, initialCommonJSType) => {
471
+ if (fullyAnalyzedModules[id]) return;
472
+ knownCjsModuleTypes[id] = initialCommonJSType;
473
+ if (detectCyclesAndConditional && knownCjsModuleTypes[id] === true && requiredIds[id] && !unconditionallyRequiredIds[id]) knownCjsModuleTypes[id] = IS_WRAPPED_COMMONJS;
474
+ };
475
+ const analyzeRequiredModule = async (parentId, resolved, isConditional, loadModule) => {
476
+ const childId = resolved.id;
477
+ requiredIds[childId] = true;
478
+ if (!(isConditional || knownCjsModuleTypes[parentId] === IS_WRAPPED_COMMONJS)) unconditionallyRequiredIds[childId] = true;
479
+ getDependencies(parentId).add(childId);
480
+ if (!isCyclic(childId)) await loadModule(resolved);
481
+ };
482
+ const getTypeForImportedModule = async (resolved, loadModule) => {
483
+ if (resolved.id in knownCjsModuleTypes) return knownCjsModuleTypes[resolved.id];
484
+ const { meta: { commonjs } } = await loadModule(resolved);
485
+ return commonjs && commonjs.isCommonJS || false;
486
+ };
487
+ return {
488
+ getWrappedIds: () => Object.keys(knownCjsModuleTypes).filter((id) => knownCjsModuleTypes[id] === IS_WRAPPED_COMMONJS),
489
+ isRequiredId: (id) => requiredIds[id],
490
+ async shouldTransformCachedModule({ id: parentId, resolvedSources, meta: { commonjs: parentMeta } }) {
491
+ if (!(parentMeta && parentMeta.isCommonJS)) knownCjsModuleTypes[parentId] = false;
492
+ if (isWrappedId(parentId, ES_IMPORT_SUFFIX)) return false;
493
+ const parentRequires = parentMeta && parentMeta.requires;
494
+ if (parentRequires) {
495
+ setInitialParentType(parentId, parentMeta.initialCommonJSType);
496
+ await Promise.all(parentRequires.map(({ resolved, isConditional }) => analyzeRequiredModule(parentId, resolved, isConditional, this.load)));
497
+ if (getTypeForFullyAnalyzedModule(parentId) !== parentMeta.isCommonJS) return true;
498
+ for (const { resolved: { id } } of parentRequires) if (getTypeForFullyAnalyzedModule(id) !== parentMeta.isRequiredCommonJS[id]) return true;
499
+ fullyAnalyzedModules[parentId] = true;
500
+ for (const { resolved: { id } } of parentRequires) fullyAnalyzedModules[id] = true;
501
+ }
502
+ const parentRequireSet = new Set((parentRequires || []).map(({ resolved: { id } }) => id));
503
+ return (await Promise.all(Object.keys(resolvedSources).map((source) => resolvedSources[source]).filter(({ id, external }) => !(external || parentRequireSet.has(id))).map(async (resolved) => {
504
+ if (isWrappedId(resolved.id, ES_IMPORT_SUFFIX)) return await getTypeForImportedModule((await this.load(resolved)).meta.commonjs.resolved, this.load) !== IS_WRAPPED_COMMONJS;
505
+ return await getTypeForImportedModule(resolved, this.load) === IS_WRAPPED_COMMONJS;
506
+ }))).some((shouldTransform) => shouldTransform);
507
+ },
508
+ resolveRequireSourcesAndUpdateMeta: (rollupContext) => async (parentId, isParentCommonJS, parentMeta, sources) => {
509
+ parentMeta.initialCommonJSType = isParentCommonJS;
510
+ parentMeta.requires = [];
511
+ parentMeta.isRequiredCommonJS = Object.create(null);
512
+ setInitialParentType(parentId, isParentCommonJS);
513
+ const currentlyResolvingForParent = currentlyResolving.get(parentId) || /* @__PURE__ */ new Set();
514
+ currentlyResolving.set(parentId, currentlyResolvingForParent);
515
+ const requireTargets = await Promise.all(sources.map(async ({ source, isConditional }) => {
516
+ if (source.startsWith("\0")) return {
517
+ id: source,
518
+ allowProxy: false
519
+ };
520
+ currentlyResolvingForParent.add(source);
521
+ const resolved = await rollupContext.resolve(source, parentId, {
522
+ skipSelf: false,
523
+ custom: { "node-resolve": { isRequire: true } }
524
+ }) || resolveExtensions(source, parentId, extensions);
525
+ currentlyResolvingForParent.delete(source);
526
+ if (!resolved) return {
527
+ id: wrapId(source, EXTERNAL_SUFFIX),
528
+ allowProxy: false
529
+ };
530
+ const childId = resolved.id;
531
+ if (resolved.external) return {
532
+ id: wrapId(childId, EXTERNAL_SUFFIX),
533
+ allowProxy: false
534
+ };
535
+ parentMeta.requires.push({
536
+ resolved,
537
+ isConditional
538
+ });
539
+ await analyzeRequiredModule(parentId, resolved, isConditional, rollupContext.load);
540
+ return {
541
+ id: childId,
542
+ allowProxy: true
543
+ };
544
+ }));
545
+ parentMeta.isCommonJS = getTypeForFullyAnalyzedModule(parentId);
546
+ fullyAnalyzedModules[parentId] = true;
547
+ return requireTargets.map(({ id: dependencyId, allowProxy }, index) => {
548
+ let isCommonJS = parentMeta.isRequiredCommonJS[dependencyId] = getTypeForFullyAnalyzedModule(dependencyId);
549
+ const isExternalWrapped = isWrappedId(dependencyId, EXTERNAL_SUFFIX);
550
+ let resolvedDependencyId = dependencyId;
551
+ if (requireNodeBuiltins === true) {
552
+ if (parentMeta.isCommonJS === IS_WRAPPED_COMMONJS && !allowProxy && isExternalWrapped) {
553
+ if (unwrapId(dependencyId, EXTERNAL_SUFFIX).startsWith("node:")) {
554
+ isCommonJS = IS_WRAPPED_COMMONJS;
555
+ parentMeta.isRequiredCommonJS[dependencyId] = isCommonJS;
556
+ }
557
+ } else if (isExternalWrapped && !allowProxy) {
558
+ const actualExternalId = unwrapId(dependencyId, EXTERNAL_SUFFIX);
559
+ if (actualExternalId.startsWith("node:")) resolvedDependencyId = actualExternalId;
560
+ }
561
+ }
562
+ const isWrappedCommonJS = isCommonJS === IS_WRAPPED_COMMONJS;
563
+ fullyAnalyzedModules[dependencyId] = true;
564
+ const moduleInfo = isWrappedCommonJS && !isExternalWrapped ? rollupContext.getModuleInfo(dependencyId) : null;
565
+ return {
566
+ wrappedModuleSideEffects: !isWrappedCommonJS ? false : moduleInfo?.moduleSideEffects ?? true,
567
+ source: sources[index].source,
568
+ id: allowProxy ? wrapId(resolvedDependencyId, isWrappedCommonJS ? WRAPPED_SUFFIX : PROXY_SUFFIX) : resolvedDependencyId,
569
+ isCommonJS
570
+ };
571
+ });
572
+ },
573
+ isCurrentlyResolving(source, parentId) {
574
+ const currentlyResolvingForParent = currentlyResolving.get(parentId);
575
+ return currentlyResolvingForParent && currentlyResolvingForParent.has(source);
576
+ }
577
+ };
578
+ }
579
+ function validateVersion(actualVersion, peerDependencyVersion, name) {
580
+ const versionRegexp = /\^(\d+\.\d+\.\d+)/g;
581
+ let minMajor = Infinity;
582
+ let minMinor = Infinity;
583
+ let minPatch = Infinity;
584
+ let foundVersion;
585
+ while (foundVersion = versionRegexp.exec(peerDependencyVersion)) {
586
+ const [foundMajor, foundMinor, foundPatch] = foundVersion[1].split(".").map(Number);
587
+ if (foundMajor < minMajor) {
588
+ minMajor = foundMajor;
589
+ minMinor = foundMinor;
590
+ minPatch = foundPatch;
591
+ }
592
+ }
593
+ if (!actualVersion) throw new Error(`Insufficient ${name} version: "@rollup/plugin-commonjs" requires at least ${name}@${minMajor}.${minMinor}.${minPatch}.`);
594
+ const [major, minor, patch] = actualVersion.split(".").map(Number);
595
+ if (major < minMajor || major === minMajor && (minor < minMinor || minor === minMinor && patch < minPatch)) throw new Error(`Insufficient ${name} version: "@rollup/plugin-commonjs" requires at least ${name}@${minMajor}.${minMinor}.${minPatch} but found ${name}@${actualVersion}.`);
596
+ }
597
+ function triStateAnd(a, b) {
598
+ if (a === false) return false;
599
+ if (b === false) return false;
600
+ if (a === true && b === true) return true;
601
+ return null;
602
+ }
603
+ function triStateOr(a, b) {
604
+ if (a === true) return true;
605
+ if (b === true) return true;
606
+ if (a === false && b === false) return false;
607
+ return null;
608
+ }
609
+ const operators = {
610
+ "==": (x) => equals(x.left, x.right, false),
611
+ "!=": (x) => not(operators["=="](x)),
612
+ "===": (x) => equals(x.left, x.right, true),
613
+ "!==": (x) => not(operators["==="](x)),
614
+ "!": (x) => isFalsy(x.argument),
615
+ "&&": (x) => triStateAnd(isTruthy(x.left), isTruthy(x.right)),
616
+ "||": (x) => triStateOr(isTruthy(x.left), isTruthy(x.right))
617
+ };
618
+ function not(value) {
619
+ return value === null ? value : !value;
620
+ }
621
+ function equals(a, b, strict) {
622
+ if (a.type !== b.type) return null;
623
+ if (a.type === "Literal") return strict ? a.value === b.value : a.value == b.value;
624
+ return null;
625
+ }
626
+ function isTruthy(node) {
627
+ if (!node) return false;
628
+ if (node.type === "Literal") return !!node.value;
629
+ if (node.type === "ParenthesizedExpression") return isTruthy(node.expression);
630
+ if (node.operator in operators) return operators[node.operator](node);
631
+ return null;
632
+ }
633
+ function isFalsy(node) {
634
+ return not(isTruthy(node));
635
+ }
636
+ function getKeypath(node) {
637
+ const parts = [];
638
+ while (node.type === "MemberExpression") {
639
+ if (node.computed) return null;
640
+ parts.unshift(node.property.name);
641
+ node = node.object;
642
+ }
643
+ if (node.type !== "Identifier") return null;
644
+ const { name } = node;
645
+ parts.unshift(name);
646
+ return {
647
+ name,
648
+ keypath: parts.join(".")
649
+ };
650
+ }
651
+ const KEY_COMPILED_ESM = "__esModule";
652
+ function getDefineCompiledEsmType(node) {
653
+ const definedPropertyWithExports = getDefinePropertyCallName(node, "exports");
654
+ const definedProperty = definedPropertyWithExports || getDefinePropertyCallName(node, "module.exports");
655
+ if (definedProperty && definedProperty.key === KEY_COMPILED_ESM) return isTruthy(definedProperty.value) ? definedPropertyWithExports ? "exports" : "module" : false;
656
+ return false;
657
+ }
658
+ function getDefinePropertyCallName(node, targetName) {
659
+ const { callee: { object, property } } = node;
660
+ if (!object || object.type !== "Identifier" || object.name !== "Object") return;
661
+ if (!property || property.type !== "Identifier" || property.name !== "defineProperty") return;
662
+ if (node.arguments.length !== 3) return;
663
+ const targetNames = targetName.split(".");
664
+ const [target, key, value] = node.arguments;
665
+ if (targetNames.length === 1) {
666
+ if (target.type !== "Identifier" || target.name !== targetNames[0]) return;
667
+ }
668
+ if (targetNames.length === 2) {
669
+ if (target.type !== "MemberExpression" || target.object.name !== targetNames[0] || target.property.name !== targetNames[1]) return;
670
+ }
671
+ if (value.type !== "ObjectExpression" || !value.properties) return;
672
+ const valueProperty = value.properties.find((p) => p.key && p.key.name === "value");
673
+ if (!valueProperty || !valueProperty.value) return;
674
+ return {
675
+ key: key.value,
676
+ value: valueProperty.value
677
+ };
678
+ }
679
+ function isShorthandProperty(parent) {
680
+ return parent && parent.type === "Property" && parent.shorthand;
681
+ }
682
+ function isPropertyDefinitionKey(parent, node) {
683
+ return parent && parent.type === "PropertyDefinition" && parent.key === node;
684
+ }
685
+ function wrapCode(magicString, uses, moduleName, exportsName, indentExclusionRanges) {
686
+ const args = [];
687
+ const passedArgs = [];
688
+ if (uses.module) {
689
+ args.push("module");
690
+ passedArgs.push(moduleName);
691
+ }
692
+ if (uses.exports) {
693
+ args.push("exports");
694
+ passedArgs.push(uses.module ? `${moduleName}.exports` : exportsName);
695
+ }
696
+ magicString.trim().indent(" ", { exclude: indentExclusionRanges }).prepend(`(function (${args.join(", ")}) {\n`).append(` \n} (${passedArgs.join(", ")}));`);
697
+ }
698
+ function rewriteExportsAndGetExportsBlock(magicString, moduleName, exportsName, exportedExportsName, wrapped, moduleExportsAssignments, firstTopLevelModuleExportsAssignment, exportsAssignmentsByName, topLevelAssignments, defineCompiledEsmExpressions, deconflictedExportNames, code, HELPERS_NAME, exportMode, defaultIsModuleExports, usesRequireWrapper, requireName) {
699
+ const exports = [];
700
+ const exportDeclarations = [];
701
+ if (usesRequireWrapper) getExportsWhenUsingRequireWrapper(magicString, wrapped, exportMode, exports, moduleExportsAssignments, exportsAssignmentsByName, moduleName, exportsName, requireName, defineCompiledEsmExpressions);
702
+ else if (exportMode === "replace") getExportsForReplacedModuleExports(magicString, exports, exportDeclarations, moduleExportsAssignments, firstTopLevelModuleExportsAssignment, exportsName, defaultIsModuleExports, HELPERS_NAME);
703
+ else {
704
+ if (exportMode === "module") {
705
+ exportDeclarations.push(`var ${exportedExportsName} = ${moduleName}.exports`);
706
+ exports.push(`${exportedExportsName} as __moduleExports`);
707
+ } else exports.push(`${exportsName} as __moduleExports`);
708
+ if (wrapped) exportDeclarations.push(getDefaultExportDeclaration(exportedExportsName, defaultIsModuleExports, HELPERS_NAME));
709
+ else getExports(magicString, exports, exportDeclarations, moduleExportsAssignments, exportsAssignmentsByName, deconflictedExportNames, topLevelAssignments, moduleName, exportsName, exportedExportsName, defineCompiledEsmExpressions, HELPERS_NAME, defaultIsModuleExports, exportMode);
710
+ }
711
+ if (exports.length) exportDeclarations.push(`export { ${exports.join(", ")} }`);
712
+ return `\n\n${exportDeclarations.join(";\n")};`;
713
+ }
714
+ function getExportsWhenUsingRequireWrapper(magicString, wrapped, exportMode, exports, moduleExportsAssignments, exportsAssignmentsByName, moduleName, exportsName, requireName, defineCompiledEsmExpressions) {
715
+ exports.push(`${requireName} as __require`);
716
+ if (wrapped) return;
717
+ if (exportMode === "replace") rewriteModuleExportsAssignments(magicString, moduleExportsAssignments, exportsName);
718
+ else {
719
+ rewriteModuleExportsAssignments(magicString, moduleExportsAssignments, `${moduleName}.exports`);
720
+ for (const [exportName, { nodes }] of exportsAssignmentsByName) for (const { node, type } of nodes) magicString.overwrite(node.start, node.left.end, `${exportMode === "module" && type === "module" ? `${moduleName}.exports` : exportsName}.${exportName}`);
721
+ replaceDefineCompiledEsmExpressionsAndGetIfRestorable(defineCompiledEsmExpressions, magicString, exportMode, moduleName, exportsName);
722
+ }
723
+ }
724
+ function getExportsForReplacedModuleExports(magicString, exports, exportDeclarations, moduleExportsAssignments, firstTopLevelModuleExportsAssignment, exportsName, defaultIsModuleExports, HELPERS_NAME) {
725
+ for (const { left } of moduleExportsAssignments) magicString.overwrite(left.start, left.end, exportsName);
726
+ magicString.prependRight(firstTopLevelModuleExportsAssignment.left.start, "var ");
727
+ exports.push(`${exportsName} as __moduleExports`);
728
+ exportDeclarations.push(getDefaultExportDeclaration(exportsName, defaultIsModuleExports, HELPERS_NAME));
729
+ }
730
+ function getDefaultExportDeclaration(exportedExportsName, defaultIsModuleExports, HELPERS_NAME) {
731
+ return `export default ${defaultIsModuleExports === true ? exportedExportsName : defaultIsModuleExports === false ? `${exportedExportsName}.default` : `/*@__PURE__*/${HELPERS_NAME}.getDefaultExportFromCjs(${exportedExportsName})`}`;
732
+ }
733
+ function getExports(magicString, exports, exportDeclarations, moduleExportsAssignments, exportsAssignmentsByName, deconflictedExportNames, topLevelAssignments, moduleName, exportsName, exportedExportsName, defineCompiledEsmExpressions, HELPERS_NAME, defaultIsModuleExports, exportMode) {
734
+ let deconflictedDefaultExportName;
735
+ for (const { left } of moduleExportsAssignments) magicString.overwrite(left.start, left.end, `${moduleName}.exports`);
736
+ for (const [exportName, { nodes }] of exportsAssignmentsByName) {
737
+ const deconflicted = deconflictedExportNames[exportName];
738
+ let needsDeclaration = true;
739
+ for (const { node, type } of nodes) {
740
+ let replacement = `${deconflicted} = ${exportMode === "module" && type === "module" ? `${moduleName}.exports` : exportsName}.${exportName}`;
741
+ if (needsDeclaration && topLevelAssignments.has(node)) {
742
+ replacement = `var ${replacement}`;
743
+ needsDeclaration = false;
744
+ }
745
+ magicString.overwrite(node.start, node.left.end, replacement);
746
+ }
747
+ if (needsDeclaration) magicString.prepend(`var ${deconflicted};\n`);
748
+ if (exportName === "default") deconflictedDefaultExportName = deconflicted;
749
+ else exports.push(exportName === deconflicted ? exportName : `${deconflicted} as ${exportName}`);
750
+ }
751
+ const isRestorableCompiledEsm = replaceDefineCompiledEsmExpressionsAndGetIfRestorable(defineCompiledEsmExpressions, magicString, exportMode, moduleName, exportsName);
752
+ if (defaultIsModuleExports === false || defaultIsModuleExports === "auto" && isRestorableCompiledEsm && moduleExportsAssignments.length === 0) exports.push(`${deconflictedDefaultExportName || exportedExportsName} as default`);
753
+ else if (defaultIsModuleExports === true || !isRestorableCompiledEsm && moduleExportsAssignments.length === 0) exports.push(`${exportedExportsName} as default`);
754
+ else exportDeclarations.push(getDefaultExportDeclaration(exportedExportsName, defaultIsModuleExports, HELPERS_NAME));
755
+ }
756
+ function rewriteModuleExportsAssignments(magicString, moduleExportsAssignments, exportsName) {
757
+ for (const { left } of moduleExportsAssignments) magicString.overwrite(left.start, left.end, exportsName);
758
+ }
759
+ function replaceDefineCompiledEsmExpressionsAndGetIfRestorable(defineCompiledEsmExpressions, magicString, exportMode, moduleName, exportsName) {
760
+ let isRestorableCompiledEsm = false;
761
+ for (const { node, type } of defineCompiledEsmExpressions) {
762
+ isRestorableCompiledEsm = true;
763
+ const moduleExportsExpression = node.type === "CallExpression" ? node.arguments[0] : node.left.object;
764
+ magicString.overwrite(moduleExportsExpression.start, moduleExportsExpression.end, exportMode === "module" && type === "module" ? `${moduleName}.exports` : exportsName);
765
+ }
766
+ return isRestorableCompiledEsm;
767
+ }
768
+ function isRequireExpression(node, scope) {
769
+ if (!node) return false;
770
+ if (node.type !== "CallExpression") return false;
771
+ if (node.arguments.length === 0) return false;
772
+ return isRequire(node.callee, scope);
773
+ }
774
+ function isRequire(node, scope) {
775
+ return node.type === "Identifier" && node.name === "require" && !scope.contains("require") || node.type === "MemberExpression" && isModuleRequire(node, scope);
776
+ }
777
+ function isModuleRequire({ object, property }, scope) {
778
+ return object.type === "Identifier" && object.name === "module" && property.type === "Identifier" && property.name === "require" && !scope.contains("module");
779
+ }
780
+ function hasDynamicArguments(node) {
781
+ return node.arguments.length > 1 || node.arguments[0].type !== "Literal" && (node.arguments[0].type !== "TemplateLiteral" || node.arguments[0].expressions.length > 0);
782
+ }
783
+ const reservedMethod = {
784
+ resolve: true,
785
+ cache: true,
786
+ main: true
787
+ };
788
+ function isNodeRequirePropertyAccess(parent) {
789
+ return parent && parent.property && reservedMethod[parent.property.name];
790
+ }
791
+ function getRequireStringArg(node) {
792
+ return node.arguments[0].type === "Literal" ? node.arguments[0].value : node.arguments[0].quasis[0].value.cooked;
793
+ }
794
+ function getRequireHandlers() {
795
+ const requireExpressions = [];
796
+ function addRequireExpression(sourceId, node, scope, usesReturnValue, isInsideTryBlock, isInsideConditional, toBeRemoved) {
797
+ requireExpressions.push({
798
+ sourceId,
799
+ node,
800
+ scope,
801
+ usesReturnValue,
802
+ isInsideTryBlock,
803
+ isInsideConditional,
804
+ toBeRemoved
805
+ });
806
+ }
807
+ async function rewriteRequireExpressionsAndGetImportBlock(magicString, topLevelDeclarations, reassignedNames, helpersName, dynamicRequireName, moduleName, exportsName, id, exportMode, resolveRequireSourcesAndUpdateMeta, needsRequireWrapper, isEsModule, isDynamicRequireModulesEnabled, getIgnoreTryCatchRequireStatementMode, commonjsMeta) {
808
+ const imports = [];
809
+ imports.push(`import * as ${helpersName} from "${HELPERS_ID}"`);
810
+ if (dynamicRequireName) imports.push(`import { ${isDynamicRequireModulesEnabled ? CREATE_COMMONJS_REQUIRE_EXPORT : COMMONJS_REQUIRE_EXPORT} as ${dynamicRequireName} } from "${DYNAMIC_MODULES_ID}"`);
811
+ if (exportMode === "module") imports.push(`import { __module as ${moduleName} } from ${JSON.stringify(wrapId(id, MODULE_SUFFIX))}`, `var ${exportsName} = ${moduleName}.exports`);
812
+ else if (exportMode === "exports") imports.push(`import { __exports as ${exportsName} } from ${JSON.stringify(wrapId(id, EXPORTS_SUFFIX))}`);
813
+ const requiresBySource = collectSources(requireExpressions);
814
+ processRequireExpressions(imports, await resolveRequireSourcesAndUpdateMeta(id, needsRequireWrapper ? IS_WRAPPED_COMMONJS : !isEsModule, commonjsMeta, Object.keys(requiresBySource).map((source) => {
815
+ return {
816
+ source,
817
+ isConditional: requiresBySource[source].every((require) => require.isInsideConditional)
818
+ };
819
+ })), requiresBySource, getIgnoreTryCatchRequireStatementMode, magicString);
820
+ return imports.length ? `${imports.join(";\n")};\n\n` : "";
821
+ }
822
+ return {
823
+ addRequireExpression,
824
+ rewriteRequireExpressionsAndGetImportBlock
825
+ };
826
+ }
827
+ function collectSources(requireExpressions) {
828
+ const requiresBySource = Object.create(null);
829
+ for (const requireExpression of requireExpressions) {
830
+ const { sourceId } = requireExpression;
831
+ if (!requiresBySource[sourceId]) requiresBySource[sourceId] = [];
832
+ requiresBySource[sourceId].push(requireExpression);
833
+ }
834
+ return requiresBySource;
835
+ }
836
+ function processRequireExpressions(imports, requireTargets, requiresBySource, getIgnoreTryCatchRequireStatementMode, magicString) {
837
+ const generateRequireName = getGenerateRequireName();
838
+ for (const { source, id: resolvedId, isCommonJS, wrappedModuleSideEffects } of requireTargets) {
839
+ const requires = requiresBySource[source];
840
+ const name = generateRequireName(requires);
841
+ let usesRequired = false;
842
+ let needsImport = false;
843
+ for (const { node, usesReturnValue, toBeRemoved, isInsideTryBlock } of requires) {
844
+ const { canConvertRequire, shouldRemoveRequire } = isInsideTryBlock && isWrappedId(resolvedId, EXTERNAL_SUFFIX) ? getIgnoreTryCatchRequireStatementMode(source) : {
845
+ canConvertRequire: true,
846
+ shouldRemoveRequire: false
847
+ };
848
+ if (shouldRemoveRequire) if (usesReturnValue) magicString.overwrite(node.start, node.end, "undefined");
849
+ else magicString.remove(toBeRemoved.start, toBeRemoved.end);
850
+ else if (canConvertRequire) {
851
+ needsImport = true;
852
+ if (isCommonJS === IS_WRAPPED_COMMONJS) magicString.overwrite(node.start, node.end, `${wrappedModuleSideEffects ? "" : "/*@__PURE__*/ "}${name}()`);
853
+ else if (usesReturnValue) {
854
+ usesRequired = true;
855
+ magicString.overwrite(node.start, node.end, name);
856
+ } else magicString.remove(toBeRemoved.start, toBeRemoved.end);
857
+ }
858
+ }
859
+ if (needsImport) if (isCommonJS === IS_WRAPPED_COMMONJS) imports.push(`import { __require as ${name} } from ${JSON.stringify(resolvedId)}`);
860
+ else imports.push(`import ${usesRequired ? `${name} from ` : ""}${JSON.stringify(resolvedId)}`);
861
+ }
862
+ }
863
+ function getGenerateRequireName() {
864
+ let uid = 0;
865
+ return (requires) => {
866
+ let name;
867
+ const hasNameConflict = ({ scope }) => scope.contains(name);
868
+ do {
869
+ name = `require$$${uid}`;
870
+ uid += 1;
871
+ } while (requires.some(hasNameConflict));
872
+ return name;
873
+ };
874
+ }
875
+ const exportsPattern = /^(?:module\.)?exports(?:\.([a-zA-Z_$][a-zA-Z_$0-9]*))?$/;
876
+ const functionType = /^(?:FunctionDeclaration|FunctionExpression|ArrowFunctionExpression)$/;
877
+ async function transformCommonjs(parse, code, id, isEsModule, ignoreGlobal, ignoreRequire, ignoreDynamicRequires, getIgnoreTryCatchRequireStatementMode, sourceMap, isDynamicRequireModulesEnabled, dynamicRequireModules, commonDir, astCache, defaultIsModuleExports, needsRequireWrapper, resolveRequireSourcesAndUpdateMeta, isRequired, checkDynamicRequire, commonjsMeta) {
878
+ const ast = astCache || tryParse(parse, code, id);
879
+ const magicString = new MagicString(code);
880
+ const uses = {
881
+ module: false,
882
+ exports: false,
883
+ global: false,
884
+ require: false
885
+ };
886
+ const virtualDynamicRequirePath = isDynamicRequireModulesEnabled && getVirtualPathForDynamicRequirePath(dirname(id), commonDir);
887
+ let scope = attachScopes(ast, "scope");
888
+ let lexicalDepth = 0;
889
+ let programDepth = 0;
890
+ let classBodyDepth = 0;
891
+ let currentTryBlockEnd = null;
892
+ let shouldWrap = false;
893
+ const globals = /* @__PURE__ */ new Set();
894
+ let currentConditionalNodeEnd = null;
895
+ const conditionalNodes = /* @__PURE__ */ new Set();
896
+ const { addRequireExpression, rewriteRequireExpressionsAndGetImportBlock } = getRequireHandlers();
897
+ const reassignedNames = /* @__PURE__ */ new Set();
898
+ const topLevelDeclarations = [];
899
+ const skippedNodes = /* @__PURE__ */ new Set();
900
+ const moduleAccessScopes = new Set([scope]);
901
+ const exportsAccessScopes = new Set([scope]);
902
+ const moduleExportsAssignments = [];
903
+ let firstTopLevelModuleExportsAssignment = null;
904
+ const exportsAssignmentsByName = /* @__PURE__ */ new Map();
905
+ const topLevelAssignments = /* @__PURE__ */ new Set();
906
+ const topLevelDefineCompiledEsmExpressions = [];
907
+ const replacedGlobal = [];
908
+ const replacedThis = [];
909
+ const replacedDynamicRequires = [];
910
+ const importedVariables = /* @__PURE__ */ new Set();
911
+ const indentExclusionRanges = [];
912
+ walk(ast, {
913
+ enter(node, parent) {
914
+ if (skippedNodes.has(node)) {
915
+ this.skip();
916
+ return;
917
+ }
918
+ if (currentTryBlockEnd !== null && node.start > currentTryBlockEnd) currentTryBlockEnd = null;
919
+ if (currentConditionalNodeEnd !== null && node.start > currentConditionalNodeEnd) currentConditionalNodeEnd = null;
920
+ if (currentConditionalNodeEnd === null && conditionalNodes.has(node)) currentConditionalNodeEnd = node.end;
921
+ programDepth += 1;
922
+ if (node.scope) ({scope} = node);
923
+ if (functionType.test(node.type)) lexicalDepth += 1;
924
+ if (sourceMap) {
925
+ magicString.addSourcemapLocation(node.start);
926
+ magicString.addSourcemapLocation(node.end);
927
+ }
928
+ switch (node.type) {
929
+ case "AssignmentExpression":
930
+ if (node.left.type === "MemberExpression") {
931
+ const flattened = getKeypath(node.left);
932
+ if (!flattened || scope.contains(flattened.name)) return;
933
+ const exportsPatternMatch = exportsPattern.exec(flattened.keypath);
934
+ if (!exportsPatternMatch || flattened.keypath === "exports") return;
935
+ const [, exportName] = exportsPatternMatch;
936
+ uses[flattened.name] = true;
937
+ if (flattened.keypath === "module.exports") {
938
+ moduleExportsAssignments.push(node);
939
+ if (programDepth > 3) moduleAccessScopes.add(scope);
940
+ else if (!firstTopLevelModuleExportsAssignment) firstTopLevelModuleExportsAssignment = node;
941
+ } else if (exportName === KEY_COMPILED_ESM) if (programDepth > 3) shouldWrap = true;
942
+ else topLevelDefineCompiledEsmExpressions.push({
943
+ node,
944
+ type: flattened.name
945
+ });
946
+ else {
947
+ const exportsAssignments = exportsAssignmentsByName.get(exportName) || {
948
+ nodes: [],
949
+ scopes: /* @__PURE__ */ new Set()
950
+ };
951
+ exportsAssignments.nodes.push({
952
+ node,
953
+ type: flattened.name
954
+ });
955
+ exportsAssignments.scopes.add(scope);
956
+ exportsAccessScopes.add(scope);
957
+ exportsAssignmentsByName.set(exportName, exportsAssignments);
958
+ if (programDepth <= 3) topLevelAssignments.add(node);
959
+ }
960
+ skippedNodes.add(node.left);
961
+ } else for (const name of extractAssignedNames(node.left)) reassignedNames.add(name);
962
+ return;
963
+ case "CallExpression": {
964
+ const defineCompiledEsmType = getDefineCompiledEsmType(node);
965
+ if (defineCompiledEsmType) {
966
+ if (programDepth === 3 && parent.type === "ExpressionStatement") {
967
+ skippedNodes.add(node.arguments[0]);
968
+ topLevelDefineCompiledEsmExpressions.push({
969
+ node,
970
+ type: defineCompiledEsmType
971
+ });
972
+ } else shouldWrap = true;
973
+ return;
974
+ }
975
+ if (isDynamicRequireModulesEnabled && node.callee.object && isRequire(node.callee.object, scope) && node.callee.property.name === "resolve") {
976
+ checkDynamicRequire(node.start);
977
+ uses.require = true;
978
+ const requireNode = node.callee.object;
979
+ replacedDynamicRequires.push(requireNode);
980
+ skippedNodes.add(node.callee);
981
+ return;
982
+ }
983
+ if (!isRequireExpression(node, scope)) {
984
+ const keypath = getKeypath(node.callee);
985
+ if (keypath && importedVariables.has(keypath.name)) currentConditionalNodeEnd = Infinity;
986
+ return;
987
+ }
988
+ skippedNodes.add(node.callee);
989
+ uses.require = true;
990
+ if (hasDynamicArguments(node)) {
991
+ if (isDynamicRequireModulesEnabled) checkDynamicRequire(node.start);
992
+ if (!ignoreDynamicRequires) replacedDynamicRequires.push(node.callee);
993
+ return;
994
+ }
995
+ const requireStringArg = getRequireStringArg(node);
996
+ if (!ignoreRequire(requireStringArg)) {
997
+ const usesReturnValue = parent.type !== "ExpressionStatement";
998
+ const toBeRemoved = parent.type === "ExpressionStatement" && (!currentConditionalNodeEnd || currentTryBlockEnd !== null && currentTryBlockEnd < currentConditionalNodeEnd) ? parent : node;
999
+ addRequireExpression(requireStringArg, node, scope, usesReturnValue, currentTryBlockEnd !== null, currentConditionalNodeEnd !== null, toBeRemoved);
1000
+ if (parent.type === "VariableDeclarator" && parent.id.type === "Identifier") for (const name of extractAssignedNames(parent.id)) importedVariables.add(name);
1001
+ }
1002
+ return;
1003
+ }
1004
+ case "ClassBody":
1005
+ classBodyDepth += 1;
1006
+ return;
1007
+ case "ConditionalExpression":
1008
+ case "IfStatement":
1009
+ if (isFalsy(node.test)) skippedNodes.add(node.consequent);
1010
+ else if (isTruthy(node.test)) {
1011
+ if (node.alternate) skippedNodes.add(node.alternate);
1012
+ } else {
1013
+ conditionalNodes.add(node.consequent);
1014
+ if (node.alternate) conditionalNodes.add(node.alternate);
1015
+ }
1016
+ return;
1017
+ case "ArrowFunctionExpression":
1018
+ case "FunctionDeclaration":
1019
+ case "FunctionExpression":
1020
+ if (currentConditionalNodeEnd === null && !(parent.type === "CallExpression" && parent.callee === node)) currentConditionalNodeEnd = node.end;
1021
+ return;
1022
+ case "Identifier": {
1023
+ const { name } = node;
1024
+ if (!isReference(node, parent) || scope.contains(name) || isPropertyDefinitionKey(parent, node)) return;
1025
+ switch (name) {
1026
+ case "require":
1027
+ uses.require = true;
1028
+ if (isNodeRequirePropertyAccess(parent)) return;
1029
+ if (!ignoreDynamicRequires) {
1030
+ if (isShorthandProperty(parent)) {
1031
+ skippedNodes.add(parent.value);
1032
+ magicString.prependRight(node.start, "require: ");
1033
+ }
1034
+ replacedDynamicRequires.push(node);
1035
+ }
1036
+ return;
1037
+ case "module":
1038
+ case "exports":
1039
+ shouldWrap = true;
1040
+ uses[name] = true;
1041
+ return;
1042
+ case "global":
1043
+ uses.global = true;
1044
+ if (!ignoreGlobal) {
1045
+ if (isShorthandProperty(parent)) {
1046
+ skippedNodes.add(parent.value);
1047
+ magicString.prependRight(node.start, "global: ");
1048
+ }
1049
+ replacedGlobal.push(node);
1050
+ }
1051
+ return;
1052
+ case "define":
1053
+ magicString.overwrite(node.start, node.end, "undefined", { storeName: true });
1054
+ return;
1055
+ default:
1056
+ globals.add(name);
1057
+ return;
1058
+ }
1059
+ }
1060
+ case "LogicalExpression":
1061
+ if (node.operator === "&&") {
1062
+ if (isFalsy(node.left)) skippedNodes.add(node.right);
1063
+ else if (!isTruthy(node.left)) conditionalNodes.add(node.right);
1064
+ } else if (node.operator === "||") {
1065
+ if (isTruthy(node.left)) skippedNodes.add(node.right);
1066
+ else if (!isFalsy(node.left)) conditionalNodes.add(node.right);
1067
+ }
1068
+ return;
1069
+ case "MemberExpression":
1070
+ if (!isDynamicRequireModulesEnabled && isModuleRequire(node, scope)) {
1071
+ uses.require = true;
1072
+ replacedDynamicRequires.push(node);
1073
+ skippedNodes.add(node.object);
1074
+ skippedNodes.add(node.property);
1075
+ }
1076
+ return;
1077
+ case "ReturnStatement":
1078
+ if (lexicalDepth === 0) shouldWrap = true;
1079
+ return;
1080
+ case "ThisExpression":
1081
+ if (lexicalDepth === 0 && !classBodyDepth) {
1082
+ uses.global = true;
1083
+ if (!ignoreGlobal) replacedThis.push(node);
1084
+ }
1085
+ return;
1086
+ case "TryStatement":
1087
+ if (currentTryBlockEnd === null) currentTryBlockEnd = node.block.end;
1088
+ if (currentConditionalNodeEnd === null) currentConditionalNodeEnd = node.end;
1089
+ return;
1090
+ case "UnaryExpression":
1091
+ if (node.operator === "typeof") {
1092
+ const flattened = getKeypath(node.argument);
1093
+ if (!flattened) return;
1094
+ if (scope.contains(flattened.name)) return;
1095
+ if (!isEsModule && (flattened.keypath === "module.exports" || flattened.keypath === "module" || flattened.keypath === "exports")) magicString.overwrite(node.start, node.end, `'object'`, { storeName: false });
1096
+ }
1097
+ return;
1098
+ case "VariableDeclaration":
1099
+ if (!scope.parent) topLevelDeclarations.push(node);
1100
+ return;
1101
+ case "TemplateElement": if (node.value.raw.includes("\n")) indentExclusionRanges.push([node.start, node.end]);
1102
+ }
1103
+ },
1104
+ leave(node) {
1105
+ programDepth -= 1;
1106
+ if (node.scope) scope = scope.parent;
1107
+ if (functionType.test(node.type)) lexicalDepth -= 1;
1108
+ if (node.type === "ClassBody") classBodyDepth -= 1;
1109
+ }
1110
+ });
1111
+ const nameBase = getName(id);
1112
+ const exportsName = deconflict([...exportsAccessScopes], globals, nameBase);
1113
+ const moduleName = deconflict([...moduleAccessScopes], globals, `${nameBase}Module`);
1114
+ const requireName = deconflict([scope], globals, `require${capitalize(nameBase)}`);
1115
+ const isRequiredName = deconflict([scope], globals, `hasRequired${capitalize(nameBase)}`);
1116
+ const helpersName = deconflict([scope], globals, "commonjsHelpers");
1117
+ const dynamicRequireName = replacedDynamicRequires.length > 0 && deconflict([scope], globals, isDynamicRequireModulesEnabled ? CREATE_COMMONJS_REQUIRE_EXPORT : COMMONJS_REQUIRE_EXPORT);
1118
+ const deconflictedExportNames = Object.create(null);
1119
+ for (const [exportName, { scopes }] of exportsAssignmentsByName) deconflictedExportNames[exportName] = deconflict([...scopes], globals, exportName);
1120
+ for (const node of replacedGlobal) magicString.overwrite(node.start, node.end, `${helpersName}.commonjsGlobal`, {
1121
+ contentOnly: true,
1122
+ storeName: true
1123
+ });
1124
+ for (const node of replacedThis) magicString.overwrite(node.start, node.end, exportsName, { storeName: true });
1125
+ for (const node of replacedDynamicRequires) magicString.overwrite(node.start, node.end, isDynamicRequireModulesEnabled ? `${dynamicRequireName}(${JSON.stringify(virtualDynamicRequirePath)})` : dynamicRequireName, {
1126
+ contentOnly: true,
1127
+ storeName: true
1128
+ });
1129
+ shouldWrap = !isEsModule && (shouldWrap || uses.exports && moduleExportsAssignments.length > 0);
1130
+ if (!(shouldWrap || isRequired || needsRequireWrapper || uses.module || uses.exports || uses.require || topLevelDefineCompiledEsmExpressions.length > 0) && (ignoreGlobal || !uses.global)) return { meta: { commonjs: { isCommonJS: false } } };
1131
+ let leadingComment = "";
1132
+ if (code.startsWith("/*")) {
1133
+ const commentEnd = code.indexOf("*/", 2) + 2;
1134
+ leadingComment = `${code.slice(0, commentEnd)}\n`;
1135
+ magicString.remove(0, commentEnd).trim();
1136
+ }
1137
+ let shebang = "";
1138
+ if (code.startsWith("#!")) {
1139
+ const shebangEndPosition = code.indexOf("\n") + 1;
1140
+ shebang = code.slice(0, shebangEndPosition);
1141
+ magicString.remove(0, shebangEndPosition).trim();
1142
+ }
1143
+ const exportMode = isEsModule ? "none" : shouldWrap ? uses.module ? "module" : "exports" : firstTopLevelModuleExportsAssignment ? exportsAssignmentsByName.size === 0 && topLevelDefineCompiledEsmExpressions.length === 0 ? "replace" : "module" : moduleExportsAssignments.length === 0 ? "exports" : "module";
1144
+ const exportedExportsName = exportMode === "module" ? deconflict([], globals, `${nameBase}Exports`) : exportsName;
1145
+ const importBlock = await rewriteRequireExpressionsAndGetImportBlock(magicString, topLevelDeclarations, reassignedNames, helpersName, dynamicRequireName, moduleName, exportsName, id, exportMode, resolveRequireSourcesAndUpdateMeta, needsRequireWrapper, isEsModule, isDynamicRequireModulesEnabled, getIgnoreTryCatchRequireStatementMode, commonjsMeta);
1146
+ const usesRequireWrapper = commonjsMeta.isCommonJS === IS_WRAPPED_COMMONJS;
1147
+ const exportBlock = isEsModule ? "" : rewriteExportsAndGetExportsBlock(magicString, moduleName, exportsName, exportedExportsName, shouldWrap, moduleExportsAssignments, firstTopLevelModuleExportsAssignment, exportsAssignmentsByName, topLevelAssignments, topLevelDefineCompiledEsmExpressions, deconflictedExportNames, code, helpersName, exportMode, defaultIsModuleExports, usesRequireWrapper, requireName);
1148
+ if (shouldWrap) wrapCode(magicString, uses, moduleName, exportsName, indentExclusionRanges);
1149
+ if (usesRequireWrapper) {
1150
+ magicString.trim().indent(" ", { exclude: indentExclusionRanges });
1151
+ const exported = exportMode === "module" ? `${moduleName}.exports` : exportsName;
1152
+ magicString.prepend(`var ${isRequiredName};
1153
+
1154
+ function ${requireName} () {
1155
+ \tif (${isRequiredName}) return ${exported};
1156
+ \t${isRequiredName} = 1;
1157
+ `).append(`
1158
+ \treturn ${exported};
1159
+ }`);
1160
+ if (exportMode === "replace") magicString.prepend(`var ${exportsName};\n`);
1161
+ }
1162
+ magicString.trim().prepend(shebang + leadingComment + importBlock).append(exportBlock);
1163
+ return {
1164
+ code: magicString.toString(),
1165
+ map: sourceMap ? magicString.generateMap() : null,
1166
+ syntheticNamedExports: isEsModule || usesRequireWrapper ? false : "__moduleExports",
1167
+ meta: { commonjs: {
1168
+ ...commonjsMeta,
1169
+ shebang
1170
+ } }
1171
+ };
1172
+ }
1173
+ const PLUGIN_NAME = "commonjs";
1174
+ function commonjs(options = {}) {
1175
+ const { ignoreGlobal, ignoreDynamicRequires, requireReturnsDefault: requireReturnsDefaultOption, defaultIsModuleExports: defaultIsModuleExportsOption, esmExternals, requireNodeBuiltins = false } = options;
1176
+ const extensions = options.extensions || [".js"];
1177
+ const filter = createFilter(options.include, options.exclude);
1178
+ const isPossibleCjsId = (id) => {
1179
+ const extName = extname(id);
1180
+ return extName === ".cjs" || extensions.includes(extName) && filter(id);
1181
+ };
1182
+ const { strictRequiresFilter, detectCyclesAndConditional } = getStrictRequiresFilter(options);
1183
+ const getRequireReturnsDefault = typeof requireReturnsDefaultOption === "function" ? requireReturnsDefaultOption : () => requireReturnsDefaultOption;
1184
+ let esmExternalIds;
1185
+ const isEsmExternal = typeof esmExternals === "function" ? esmExternals : Array.isArray(esmExternals) ? (esmExternalIds = new Set(esmExternals), (id) => esmExternalIds.has(id)) : () => esmExternals;
1186
+ const getDefaultIsModuleExports = typeof defaultIsModuleExportsOption === "function" ? defaultIsModuleExportsOption : () => typeof defaultIsModuleExportsOption === "boolean" ? defaultIsModuleExportsOption : "auto";
1187
+ const dynamicRequireRoot = typeof options.dynamicRequireRoot === "string" ? resolve(options.dynamicRequireRoot) : process.cwd();
1188
+ const { commonDir, dynamicRequireModules } = getDynamicRequireModules(options.dynamicRequireTargets, dynamicRequireRoot);
1189
+ const isDynamicRequireModulesEnabled = dynamicRequireModules.size > 0;
1190
+ const ignoreRequire = typeof options.ignore === "function" ? options.ignore : Array.isArray(options.ignore) ? (id) => options.ignore.includes(id) : () => false;
1191
+ const getIgnoreTryCatchRequireStatementMode = (id) => {
1192
+ const mode = typeof options.ignoreTryCatch === "function" ? options.ignoreTryCatch(id) : Array.isArray(options.ignoreTryCatch) ? options.ignoreTryCatch.includes(id) : typeof options.ignoreTryCatch !== "undefined" ? options.ignoreTryCatch : true;
1193
+ return {
1194
+ canConvertRequire: mode !== "remove" && mode !== true,
1195
+ shouldRemoveRequire: mode === "remove"
1196
+ };
1197
+ };
1198
+ const { currentlyResolving, resolveId } = getResolveId(extensions, isPossibleCjsId);
1199
+ const sourceMap = options.sourceMap !== false;
1200
+ let requireResolver;
1201
+ function transformAndCheckExports(code, id) {
1202
+ const normalizedId = normalizePathSlashes(id);
1203
+ const { isEsModule, hasDefaultExport, hasNamedExports, ast } = analyzeTopLevelStatements(this.parse, code, id);
1204
+ const commonjsMeta = this.getModuleInfo(id).meta.commonjs || {};
1205
+ if (hasDefaultExport) commonjsMeta.hasDefaultExport = true;
1206
+ if (hasNamedExports) commonjsMeta.hasNamedExports = true;
1207
+ if (!dynamicRequireModules.has(normalizedId) && (!(hasCjsKeywords(code, ignoreGlobal) || requireResolver.isRequiredId(id)) || isEsModule && !options.transformMixedEsModules)) {
1208
+ commonjsMeta.isCommonJS = false;
1209
+ return { meta: { commonjs: commonjsMeta } };
1210
+ }
1211
+ const needsRequireWrapper = !isEsModule && (dynamicRequireModules.has(normalizedId) || strictRequiresFilter(id));
1212
+ const checkDynamicRequire = (position) => {
1213
+ const normalizedDynamicRequireRoot = normalizePathSlashes(dynamicRequireRoot);
1214
+ if (normalizedId.indexOf(normalizedDynamicRequireRoot) !== 0) this.error({
1215
+ code: "DYNAMIC_REQUIRE_OUTSIDE_ROOT",
1216
+ normalizedId,
1217
+ normalizedDynamicRequireRoot,
1218
+ message: `"${normalizedId}" contains dynamic require statements but it is not within the current dynamicRequireRoot "${normalizedDynamicRequireRoot}". You should set dynamicRequireRoot to "${dirname(normalizedId)}" or one of its parent directories.`
1219
+ }, position);
1220
+ };
1221
+ return transformCommonjs(this.parse, code, id, isEsModule, ignoreGlobal || isEsModule, ignoreRequire, ignoreDynamicRequires && !isDynamicRequireModulesEnabled, getIgnoreTryCatchRequireStatementMode, sourceMap, isDynamicRequireModulesEnabled, dynamicRequireModules, commonDir, ast, getDefaultIsModuleExports(id), needsRequireWrapper, requireResolver.resolveRequireSourcesAndUpdateMeta(this), requireResolver.isRequiredId(id), checkDynamicRequire, commonjsMeta);
1222
+ }
1223
+ return {
1224
+ name: PLUGIN_NAME,
1225
+ version,
1226
+ options(rawOptions) {
1227
+ const plugins = Array.isArray(rawOptions.plugins) ? [...rawOptions.plugins] : rawOptions.plugins ? [rawOptions.plugins] : [];
1228
+ plugins.unshift({
1229
+ name: "commonjs--resolver",
1230
+ resolveId
1231
+ });
1232
+ return {
1233
+ ...rawOptions,
1234
+ plugins
1235
+ };
1236
+ },
1237
+ buildStart({ plugins }) {
1238
+ validateVersion(this.meta.rollupVersion, peerDependencies.rollup, "rollup");
1239
+ const nodeResolve = plugins.find(({ name }) => name === "node-resolve");
1240
+ if (nodeResolve) validateVersion(nodeResolve.version, "^13.0.6", "@rollup/plugin-node-resolve");
1241
+ if (options.namedExports != null) this.warn("The namedExports option from \"@rollup/plugin-commonjs\" is deprecated. Named exports are now handled automatically.");
1242
+ requireResolver = getRequireResolver(extensions, detectCyclesAndConditional, currentlyResolving, requireNodeBuiltins);
1243
+ },
1244
+ buildEnd() {
1245
+ if (options.strictRequires === "debug") {
1246
+ const wrappedIds = requireResolver.getWrappedIds();
1247
+ if (wrappedIds.length) this.warn({
1248
+ code: "WRAPPED_IDS",
1249
+ ids: wrappedIds,
1250
+ message: `The commonjs plugin automatically wrapped the following files:\n[\n${wrappedIds.map((id) => `\t${JSON.stringify(relative(process.cwd(), id))}`).join(",\n")}\n]`
1251
+ });
1252
+ else this.warn({
1253
+ code: "WRAPPED_IDS",
1254
+ ids: wrappedIds,
1255
+ message: "The commonjs plugin did not wrap any files."
1256
+ });
1257
+ }
1258
+ },
1259
+ async load(id) {
1260
+ if (id === HELPERS_ID) return getHelpersModule();
1261
+ if (isWrappedId(id, MODULE_SUFFIX)) {
1262
+ const name = getName(unwrapId(id, MODULE_SUFFIX));
1263
+ return {
1264
+ code: `var ${name} = {exports: {}}; export {${name} as __module}`,
1265
+ meta: { commonjs: { isCommonJS: false } }
1266
+ };
1267
+ }
1268
+ if (isWrappedId(id, EXPORTS_SUFFIX)) {
1269
+ const name = getName(unwrapId(id, EXPORTS_SUFFIX));
1270
+ return {
1271
+ code: `var ${name} = {}; export {${name} as __exports}`,
1272
+ meta: { commonjs: { isCommonJS: false } }
1273
+ };
1274
+ }
1275
+ if (isWrappedId(id, EXTERNAL_SUFFIX)) {
1276
+ const actualId = unwrapId(id, EXTERNAL_SUFFIX);
1277
+ if (requireNodeBuiltins === true && actualId.startsWith("node:")) return getExternalBuiltinRequireProxy(actualId);
1278
+ return getUnknownRequireProxy(actualId, isEsmExternal(actualId) ? getRequireReturnsDefault(actualId) : true);
1279
+ }
1280
+ if (id.endsWith(ENTRY_SUFFIX)) {
1281
+ const acutalId = id.slice(0, -15);
1282
+ const { meta: { commonjs: commonjsMeta } } = this.getModuleInfo(acutalId);
1283
+ const shebang = commonjsMeta?.shebang ?? "";
1284
+ return getEntryProxy(acutalId, getDefaultIsModuleExports(acutalId), this.getModuleInfo, shebang);
1285
+ }
1286
+ if (isWrappedId(id, ES_IMPORT_SUFFIX)) {
1287
+ const actualId = unwrapId(id, ES_IMPORT_SUFFIX);
1288
+ return getEsImportProxy(actualId, getDefaultIsModuleExports(actualId), (await this.load({ id: actualId })).moduleSideEffects);
1289
+ }
1290
+ if (id === DYNAMIC_MODULES_ID) return getDynamicModuleRegistry(isDynamicRequireModulesEnabled, dynamicRequireModules, commonDir, ignoreDynamicRequires);
1291
+ if (isWrappedId(id, PROXY_SUFFIX)) {
1292
+ const actualId = unwrapId(id, PROXY_SUFFIX);
1293
+ return getStaticRequireProxy(actualId, getRequireReturnsDefault(actualId), this.load);
1294
+ }
1295
+ return null;
1296
+ },
1297
+ shouldTransformCachedModule(...args) {
1298
+ return requireResolver.shouldTransformCachedModule.call(this, ...args);
1299
+ },
1300
+ transform(code, id) {
1301
+ if (!isPossibleCjsId(id)) return null;
1302
+ try {
1303
+ return transformAndCheckExports.call(this, code, id);
1304
+ } catch (err) {
1305
+ return this.error(err, err.pos);
1306
+ }
1307
+ }
1308
+ };
1309
+ }
1310
+ //#endregion
1311
+ export { commonjs as t };