nitro-nightly 4.0.0-20251030-091344-d4418b98 → 4.0.0-20251030-121649-98b56dfe

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 (334) hide show
  1. package/dist/_build/common.mjs +763 -0
  2. package/dist/_build/rolldown.mjs +216 -0
  3. package/dist/_build/rollup.mjs +359 -0
  4. package/dist/_build/vite.build.mjs +67 -0
  5. package/dist/_build/vite.plugin.mjs +747 -0
  6. package/dist/_chunks/B-7HiF0V.mjs +1303 -0
  7. package/dist/_chunks/B3asVbT4.mjs +151 -0
  8. package/dist/_chunks/B5ooyfLk.mjs +372 -0
  9. package/dist/_chunks/DXMHy5ca.mjs +43 -0
  10. package/dist/_dev.d.mts +12 -0
  11. package/dist/_dev.mjs +675 -0
  12. package/dist/_libs/acorn.mjs +5034 -0
  13. package/dist/_libs/c12.mjs +2798 -0
  14. package/dist/_libs/chokidar.mjs +1560 -0
  15. package/dist/_libs/citty.mjs +333 -0
  16. package/dist/_libs/commondir.mjs +22 -0
  17. package/dist/_libs/compatx.mjs +46 -0
  18. package/dist/_libs/confbox.mjs +2920 -0
  19. package/dist/_libs/debug.mjs +848 -0
  20. package/dist/_libs/deepmerge.mjs +86 -0
  21. package/dist/_libs/depd.mjs +314 -0
  22. package/dist/_libs/dot-prop.mjs +138 -0
  23. package/dist/_libs/duplexer.mjs +71 -0
  24. package/dist/_libs/ee-first.mjs +68 -0
  25. package/dist/_libs/encodeurl.mjs +49 -0
  26. package/dist/_libs/escape-html.mjs +58 -0
  27. package/dist/_libs/escape-string-regexp.mjs +8 -0
  28. package/dist/_libs/estree-walker.mjs +330 -0
  29. package/dist/_libs/etag.mjs +75 -0
  30. package/dist/{_chunks/_deps → _libs}/fdir.mjs +49 -104
  31. package/dist/_libs/fresh.mjs +85 -0
  32. package/dist/_libs/function-bind.mjs +63 -0
  33. package/dist/_libs/gen-mapping.mjs +612 -0
  34. package/dist/_libs/giget.mjs +19076 -0
  35. package/dist/_libs/gzip-size.mjs +21 -0
  36. package/dist/_libs/hasown.mjs +14 -0
  37. package/dist/_libs/http-errors.mjs +436 -0
  38. package/dist/_libs/httpxy.mjs +410 -0
  39. package/dist/_libs/is-core-module.mjs +220 -0
  40. package/dist/_libs/is-module.mjs +13 -0
  41. package/dist/_libs/is-reference.mjs +32 -0
  42. package/dist/{_chunks/_deps → _libs}/js-tokens.mjs +83 -112
  43. package/dist/_libs/klona.mjs +90 -0
  44. package/dist/_libs/knitwork.mjs +124 -0
  45. package/dist/_libs/local-pkg.mjs +1686 -0
  46. package/dist/{_chunks/_deps → _libs}/magic-string.mjs +272 -629
  47. package/dist/_libs/mime-db.mjs +7642 -0
  48. package/dist/_libs/mime-types.mjs +162 -0
  49. package/dist/_libs/mime.mjs +1391 -0
  50. package/dist/_libs/node-fetch-native.mjs +173 -0
  51. package/dist/_libs/on-finished.mjs +170 -0
  52. package/dist/_libs/parseurl.mjs +103 -0
  53. package/dist/_libs/path-parse.mjs +47 -0
  54. package/dist/_libs/pathe.mjs +41 -0
  55. package/dist/_libs/picomatch.mjs +1673 -0
  56. package/dist/_libs/plugin-alias.mjs +64 -0
  57. package/dist/_libs/plugin-commonjs.mjs +1489 -0
  58. package/dist/_libs/plugin-inject.mjs +135 -0
  59. package/dist/_libs/plugin-json.mjs +36 -0
  60. package/dist/_libs/plugin-node-resolve.mjs +1553 -0
  61. package/dist/_libs/plugin-replace.mjs +104 -0
  62. package/dist/_libs/pretty-bytes.mjs +116 -0
  63. package/dist/_libs/range-parser.mjs +102 -0
  64. package/dist/_libs/remapping.mjs +117 -0
  65. package/dist/{_chunks/_deps → _libs}/rou3.mjs +7 -22
  66. package/dist/_libs/send.mjs +857 -0
  67. package/dist/_libs/serve-static.mjs +124 -0
  68. package/dist/_libs/std-env.mjs +158 -0
  69. package/dist/_libs/strip-literal.mjs +51 -0
  70. package/dist/{_chunks/_deps → _libs}/tinyglobby.mjs +32 -33
  71. package/dist/_libs/ultrahtml.mjs +138 -0
  72. package/dist/_libs/unimport.mjs +3520 -0
  73. package/dist/_libs/untyped.mjs +271 -0
  74. package/dist/_libs/unwasm.mjs +5825 -0
  75. package/dist/{_chunks/_deps/@pi0 → _libs}/vite-plugin-fullstack.mjs +28 -42
  76. package/dist/_presets.mjs +1723 -0
  77. package/dist/builder.d.mts +37 -35
  78. package/dist/builder.mjs +45 -117
  79. package/dist/cli/_chunks/build.mjs +43 -0
  80. package/dist/cli/_chunks/common.mjs +15 -0
  81. package/dist/cli/_chunks/detect-acorn.mjs +12 -0
  82. package/dist/cli/_chunks/dev.mjs +79 -0
  83. package/dist/cli/_chunks/dist.mjs +3 -0
  84. package/dist/cli/_chunks/dist2.mjs +4 -0
  85. package/dist/cli/_chunks/esm.mjs +3 -0
  86. package/dist/cli/_chunks/json5.mjs +4 -0
  87. package/dist/cli/_chunks/jsonc.mjs +4 -0
  88. package/dist/cli/_chunks/list.mjs +27 -0
  89. package/dist/cli/_chunks/multipart-parser.mjs +6 -0
  90. package/dist/cli/_chunks/prepare.mjs +19 -0
  91. package/dist/cli/_chunks/run.mjs +55 -0
  92. package/dist/cli/_chunks/task.mjs +16 -0
  93. package/dist/cli/_chunks/toml.mjs +4 -0
  94. package/dist/cli/_chunks/yaml.mjs +4 -0
  95. package/dist/cli/index.d.mts +1 -1
  96. package/dist/cli/index.mjs +19 -18
  97. package/dist/presets/_nitro/runtime/nitro-dev.d.mts +1 -0
  98. package/dist/presets/_nitro/runtime/nitro-dev.mjs +42 -33
  99. package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +2 -2
  100. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +4 -8
  101. package/dist/presets/_nitro/runtime/service-worker.d.mts +1 -0
  102. package/dist/presets/_nitro/runtime/service-worker.mjs +14 -11
  103. package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +1 -0
  104. package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +6 -5
  105. package/dist/presets/aws-lambda/runtime/_utils.d.mts +8 -13
  106. package/dist/presets/aws-lambda/runtime/_utils.mjs +95 -81
  107. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +1 -2
  108. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +25 -27
  109. package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +7 -7
  110. package/dist/presets/azure/runtime/_utils.mjs +43 -43
  111. package/dist/presets/azure/runtime/azure-swa.d.mts +2 -2
  112. package/dist/presets/azure/runtime/azure-swa.mjs +22 -21
  113. package/dist/presets/bun/runtime/bun.d.mts +1 -0
  114. package/dist/presets/bun/runtime/bun.mjs +18 -17
  115. package/dist/presets/cloudflare/runtime/_module-handler.d.mts +10 -7
  116. package/dist/presets/cloudflare/runtime/_module-handler.mjs +78 -87
  117. package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +6 -14
  118. package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +53 -58
  119. package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +1 -7
  120. package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +12 -14
  121. package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +12 -12
  122. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +35 -39
  123. package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +2 -2
  124. package/dist/presets/cloudflare/runtime/plugin.dev.mjs +86 -76
  125. package/dist/presets/deno/runtime/deno-deploy.d.mts +1 -0
  126. package/dist/presets/deno/runtime/deno-deploy.mjs +12 -11
  127. package/dist/presets/deno/runtime/deno-server.d.mts +2 -1
  128. package/dist/presets/deno/runtime/deno-server.mjs +31 -39
  129. package/dist/presets/netlify/runtime/netlify-edge.d.mts +2 -1
  130. package/dist/presets/netlify/runtime/netlify-edge.mjs +14 -11
  131. package/dist/presets/netlify/runtime/netlify.mjs +11 -17
  132. package/dist/presets/node/runtime/node-cluster.mjs +49 -48
  133. package/dist/presets/node/runtime/node-middleware.d.mts +3 -2
  134. package/dist/presets/node/runtime/node-middleware.mjs +7 -6
  135. package/dist/presets/node/runtime/node-server.mjs +33 -23
  136. package/dist/presets/standard/runtime/server.d.mts +1 -3
  137. package/dist/presets/standard/runtime/server.mjs +1 -3
  138. package/dist/presets/stormkit/runtime/stormkit.d.mts +13 -13
  139. package/dist/presets/stormkit/runtime/stormkit.mjs +20 -20
  140. package/dist/presets/vercel/runtime/vercel.d.mts +3 -3
  141. package/dist/presets/vercel/runtime/vercel.mjs +15 -14
  142. package/dist/presets/winterjs/runtime/winterjs.d.mts +2 -0
  143. package/dist/presets/winterjs/runtime/winterjs.mjs +72 -68
  144. package/dist/presets/zeabur/runtime/zeabur.d.mts +1 -1
  145. package/dist/runtime/index.d.mts +12 -1
  146. package/dist/runtime/index.mjs +12 -7
  147. package/dist/runtime/internal/app.mjs +175 -162
  148. package/dist/runtime/internal/cache.d.mts +10 -4
  149. package/dist/runtime/internal/cache.mjs +247 -216
  150. package/dist/runtime/internal/context.d.mts +9 -9
  151. package/dist/runtime/internal/context.mjs +17 -10
  152. package/dist/runtime/internal/database.mjs +8 -10
  153. package/dist/runtime/internal/error/dev.d.mts +5 -4
  154. package/dist/runtime/internal/error/dev.mjs +106 -105
  155. package/dist/runtime/internal/error/prod.d.mts +2 -2
  156. package/dist/runtime/internal/error/prod.mjs +48 -52
  157. package/dist/runtime/internal/error/utils.d.mts +4 -4
  158. package/dist/runtime/internal/error/utils.mjs +1 -1
  159. package/dist/runtime/internal/index.d.mts +2 -0
  160. package/dist/runtime/internal/index.mjs +2 -0
  161. package/dist/runtime/internal/lib/http-graceful-shutdown.d.mts +14 -14
  162. package/dist/runtime/internal/lib/http-graceful-shutdown.mjs +248 -209
  163. package/dist/runtime/internal/meta.d.mts +1 -1
  164. package/dist/runtime/internal/meta.mjs +1 -1
  165. package/dist/runtime/internal/plugin.d.mts +2 -2
  166. package/dist/runtime/internal/plugin.mjs +1 -1
  167. package/dist/runtime/internal/renderer.mjs +39 -31
  168. package/dist/runtime/internal/route-rules.d.mts +8 -8
  169. package/dist/runtime/internal/route-rules.mjs +53 -51
  170. package/dist/runtime/internal/routes/dev-tasks.d.mts +1 -30
  171. package/dist/runtime/internal/routes/dev-tasks.mjs +15 -17
  172. package/dist/runtime/internal/routes/openapi.d.mts +1 -0
  173. package/dist/runtime/internal/routes/openapi.mjs +81 -87
  174. package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
  175. package/dist/runtime/internal/routes/renderer-template.dev.d.mts +1 -2
  176. package/dist/runtime/internal/routes/renderer-template.dev.mjs +10 -17
  177. package/dist/runtime/internal/routes/renderer-template.mjs +1 -1
  178. package/dist/runtime/internal/routes/scalar.d.mts +1 -0
  179. package/dist/runtime/internal/routes/scalar.mjs +22 -23
  180. package/dist/runtime/internal/routes/swagger.d.mts +1 -0
  181. package/dist/runtime/internal/routes/swagger.mjs +9 -11
  182. package/dist/runtime/internal/runtime-config.d.mts +4 -4
  183. package/dist/runtime/internal/runtime-config.mjs +40 -35
  184. package/dist/runtime/internal/shutdown.d.mts +2 -7
  185. package/dist/runtime/internal/shutdown.mjs +30 -29
  186. package/dist/runtime/internal/static.mjs +63 -74
  187. package/dist/runtime/internal/storage.mjs +2 -2
  188. package/dist/runtime/internal/task.d.mts +6 -6
  189. package/dist/runtime/internal/task.mjs +56 -59
  190. package/dist/runtime/internal/utils.d.mts +1 -1
  191. package/dist/runtime/internal/utils.mjs +4 -10
  192. package/dist/types/index.d.mts +2566 -3851
  193. package/dist/types/index.mjs +1 -1
  194. package/dist/vite.d.mts +56 -52
  195. package/dist/vite.mjs +55 -132
  196. package/package.json +10 -10
  197. package/dist/_build/build.mjs +0 -368
  198. package/dist/_build/build2.mjs +0 -556
  199. package/dist/_build/info.mjs +0 -1002
  200. package/dist/_build/prepare.mjs +0 -1511
  201. package/dist/_build/snapshot.mjs +0 -185
  202. package/dist/_build/vite.mjs +0 -959
  203. package/dist/_build/vite2.mjs +0 -149
  204. package/dist/_chunks/_deps/@jridgewell/gen-mapping.mjs +0 -189
  205. package/dist/_chunks/_deps/@jridgewell/remapping.mjs +0 -137
  206. package/dist/_chunks/_deps/@jridgewell/resolve-uri.mjs +0 -231
  207. package/dist/_chunks/_deps/@jridgewell/sourcemap-codec.mjs +0 -173
  208. package/dist/_chunks/_deps/@jridgewell/trace-mapping.mjs +0 -170
  209. package/dist/_chunks/_deps/@rollup/plugin-alias.mjs +0 -89
  210. package/dist/_chunks/_deps/@rollup/plugin-commonjs.mjs +0 -2376
  211. package/dist/_chunks/_deps/@rollup/plugin-inject.mjs +0 -212
  212. package/dist/_chunks/_deps/@rollup/plugin-json.mjs +0 -37
  213. package/dist/_chunks/_deps/@rollup/plugin-node-resolve.mjs +0 -1386
  214. package/dist/_chunks/_deps/@rollup/plugin-replace.mjs +0 -133
  215. package/dist/_chunks/_deps/@rollup/pluginutils.mjs +0 -346
  216. package/dist/_chunks/_deps/acorn.mjs +0 -6225
  217. package/dist/_chunks/_deps/c12.mjs +0 -510
  218. package/dist/_chunks/_deps/chokidar.mjs +0 -1428
  219. package/dist/_chunks/_deps/citty.mjs +0 -460
  220. package/dist/_chunks/_deps/commondir.mjs +0 -77
  221. package/dist/_chunks/_deps/compatx.mjs +0 -76
  222. package/dist/_chunks/_deps/confbox.mjs +0 -300
  223. package/dist/_chunks/_deps/debug.mjs +0 -885
  224. package/dist/_chunks/_deps/deepmerge.mjs +0 -147
  225. package/dist/_chunks/_deps/depd.mjs +0 -550
  226. package/dist/_chunks/_deps/dot-prop.mjs +0 -282
  227. package/dist/_chunks/_deps/dotenv.mjs +0 -555
  228. package/dist/_chunks/_deps/duplexer.mjs +0 -1
  229. package/dist/_chunks/_deps/ee-first.mjs +0 -104
  230. package/dist/_chunks/_deps/encodeurl.mjs +0 -69
  231. package/dist/_chunks/_deps/escape-html.mjs +0 -87
  232. package/dist/_chunks/_deps/escape-string-regexp.mjs +0 -13
  233. package/dist/_chunks/_deps/estree-walker.mjs +0 -433
  234. package/dist/_chunks/_deps/etag.mjs +0 -147
  235. package/dist/_chunks/_deps/exsolve.mjs +0 -1416
  236. package/dist/_chunks/_deps/fresh.mjs +0 -145
  237. package/dist/_chunks/_deps/function-bind.mjs +0 -106
  238. package/dist/_chunks/_deps/giget.mjs +0 -451
  239. package/dist/_chunks/_deps/gzip-size.mjs +0 -19
  240. package/dist/_chunks/_deps/hasown.mjs +0 -19
  241. package/dist/_chunks/_deps/http-errors.mjs +0 -307
  242. package/dist/_chunks/_deps/httpxy.mjs +0 -580
  243. package/dist/_chunks/_deps/inherits.mjs +0 -57
  244. package/dist/_chunks/_deps/is-core-module.mjs +0 -596
  245. package/dist/_chunks/_deps/is-module.mjs +0 -25
  246. package/dist/_chunks/_deps/is-reference.mjs +0 -31
  247. package/dist/_chunks/_deps/klona.mjs +0 -137
  248. package/dist/_chunks/_deps/knitwork.mjs +0 -172
  249. package/dist/_chunks/_deps/local-pkg.mjs +0 -163
  250. package/dist/_chunks/_deps/mime-db.mjs +0 -11685
  251. package/dist/_chunks/_deps/mime-types.mjs +0 -287
  252. package/dist/_chunks/_deps/mime.mjs +0 -1172
  253. package/dist/_chunks/_deps/mlly.mjs +0 -2413
  254. package/dist/_chunks/_deps/ms.mjs +0 -172
  255. package/dist/_chunks/_deps/node-fetch-native.mjs +0 -3
  256. package/dist/_chunks/_deps/nypm.mjs +0 -219
  257. package/dist/_chunks/_deps/on-finished.mjs +0 -246
  258. package/dist/_chunks/_deps/parseurl.mjs +0 -168
  259. package/dist/_chunks/_deps/path-parse.mjs +0 -85
  260. package/dist/_chunks/_deps/pathe.mjs +0 -251
  261. package/dist/_chunks/_deps/perfect-debounce.mjs +0 -88
  262. package/dist/_chunks/_deps/picomatch.mjs +0 -2144
  263. package/dist/_chunks/_deps/pkg-types.mjs +0 -247
  264. package/dist/_chunks/_deps/pretty-bytes.mjs +0 -180
  265. package/dist/_chunks/_deps/quansync.mjs +0 -99
  266. package/dist/_chunks/_deps/range-parser.mjs +0 -171
  267. package/dist/_chunks/_deps/rc9.mjs +0 -219
  268. package/dist/_chunks/_deps/readdirp.mjs +0 -245
  269. package/dist/_chunks/_deps/resolve.mjs +0 -1260
  270. package/dist/_chunks/_deps/send.mjs +0 -1022
  271. package/dist/_chunks/_deps/serve-static.mjs +0 -228
  272. package/dist/_chunks/_deps/setprototypeof.mjs +0 -26
  273. package/dist/_chunks/_deps/statuses.mjs +0 -457
  274. package/dist/_chunks/_deps/std-env.mjs +0 -3
  275. package/dist/_chunks/_deps/strip-literal.mjs +0 -67
  276. package/dist/_chunks/_deps/supports-color.mjs +0 -44
  277. package/dist/_chunks/_deps/tinyexec.mjs +0 -552
  278. package/dist/_chunks/_deps/toidentifier.mjs +0 -41
  279. package/dist/_chunks/_deps/ultrahtml.mjs +0 -3
  280. package/dist/_chunks/_deps/unimport.mjs +0 -2267
  281. package/dist/_chunks/_deps/unplugin-utils.mjs +0 -65
  282. package/dist/_chunks/_deps/unplugin.mjs +0 -1294
  283. package/dist/_chunks/_deps/untyped.mjs +0 -375
  284. package/dist/_chunks/_deps/unwasm.mjs +0 -6959
  285. package/dist/_chunks/_deps/webpack-virtual-modules.mjs +0 -360
  286. package/dist/_chunks/_presets/_all.mjs +0 -59
  287. package/dist/_chunks/_presets/_nitro.mjs +0 -74
  288. package/dist/_chunks/_presets/_resolve.mjs +0 -64
  289. package/dist/_chunks/_presets/_static.mjs +0 -69
  290. package/dist/_chunks/_presets/_types.mjs +0 -3
  291. package/dist/_chunks/_presets/_utils.mjs +0 -31
  292. package/dist/_chunks/_presets/alwaysdata.mjs +0 -17
  293. package/dist/_chunks/_presets/aws-amplify.mjs +0 -111
  294. package/dist/_chunks/_presets/aws-lambda.mjs +0 -23
  295. package/dist/_chunks/_presets/azure.mjs +0 -162
  296. package/dist/_chunks/_presets/bun.mjs +0 -19
  297. package/dist/_chunks/_presets/cleavr.mjs +0 -15
  298. package/dist/_chunks/_presets/cloudflare.mjs +0 -608
  299. package/dist/_chunks/_presets/deno.mjs +0 -196
  300. package/dist/_chunks/_presets/digitalocean.mjs +0 -14
  301. package/dist/_chunks/_presets/firebase.mjs +0 -47
  302. package/dist/_chunks/_presets/flightcontrol.mjs +0 -14
  303. package/dist/_chunks/_presets/genezio.mjs +0 -13
  304. package/dist/_chunks/_presets/heroku.mjs +0 -14
  305. package/dist/_chunks/_presets/iis.mjs +0 -194
  306. package/dist/_chunks/_presets/index.mjs +0 -62
  307. package/dist/_chunks/_presets/koyeb.mjs +0 -14
  308. package/dist/_chunks/_presets/netlify.mjs +0 -241
  309. package/dist/_chunks/_presets/node.mjs +0 -54
  310. package/dist/_chunks/_presets/platform.mjs +0 -14
  311. package/dist/_chunks/_presets/render.mjs +0 -14
  312. package/dist/_chunks/_presets/standard.mjs +0 -23
  313. package/dist/_chunks/_presets/stormkit.mjs +0 -18
  314. package/dist/_chunks/_presets/vercel.mjs +0 -375
  315. package/dist/_chunks/_presets/winterjs.mjs +0 -22
  316. package/dist/_chunks/_presets/zeabur.mjs +0 -69
  317. package/dist/_chunks/_presets/zerops.mjs +0 -27
  318. package/dist/_chunks/app.mjs +0 -600
  319. package/dist/_chunks/builder.mjs +0 -648
  320. package/dist/_chunks/server.mjs +0 -256
  321. package/dist/_cli/build.mjs +0 -49
  322. package/dist/_cli/common.mjs +0 -13
  323. package/dist/_cli/dev.mjs +0 -121
  324. package/dist/_cli/index.mjs +0 -16
  325. package/dist/_cli/list.mjs +0 -33
  326. package/dist/_cli/prepare.mjs +0 -23
  327. package/dist/_cli/run.mjs +0 -59
  328. package/dist/presets/cloudflare/runtime/shims/workers.dev.d.mts +0 -21
  329. package/dist/runtime/internal/empty.d.mts +0 -0
  330. package/dist/runtime/internal/vite/dev-entry.d.mts +0 -1
  331. package/dist/runtime/internal/vite/dev-worker.d.mts +0 -1
  332. package/dist/runtime/internal/vite/prod-setup.d.mts +0 -4
  333. package/dist/runtime/internal/vite/ssr-renderer.d.mts +0 -4
  334. /package/lib/{indexd.mts → index.d.mts} +0 -0
@@ -1,1386 +0,0 @@
1
- import sysPath__default, { resolve, dirname, normalize, sep, extname } from 'path';
2
- import { builtinModules } from 'module';
3
- import { d as deepMerge } from '../deepmerge.mjs';
4
- import { i as isModule } from '../is-module.mjs';
5
- import V__default, { realpathSync } from 'fs';
6
- import { promisify } from 'util';
7
- import { fileURLToPath, pathToFileURL } from 'url';
8
- import { r as resolve$1 } from '../resolve.mjs';
9
- import { c as createFilter } from './pluginutils.mjs';
10
-
11
- var version = "16.0.3";
12
- var peerDependencies = {
13
- rollup: "^2.78.0||^3.0.0||^4.0.0"
14
- };
15
-
16
- promisify(V__default.access);
17
- const readFile$1 = promisify(V__default.readFile);
18
- const realpath = promisify(V__default.realpath);
19
- const stat = promisify(V__default.stat);
20
- async function fileExists(filePath) {
21
- try {
22
- const res = await stat(filePath);
23
- return res.isFile();
24
- }
25
- catch {
26
- return false;
27
- }
28
- }
29
- async function resolveSymlink(path) {
30
- return (await fileExists(path)) ? realpath(path) : path;
31
- }
32
-
33
- const onError = (error) => {
34
- if (error.code === 'ENOENT') {
35
- return false;
36
- }
37
- throw error;
38
- };
39
-
40
- const makeCache = (fn) => {
41
- const cache = new Map();
42
- const wrapped = async (param, done) => {
43
- if (cache.has(param) === false) {
44
- cache.set(
45
- param,
46
- fn(param).catch((err) => {
47
- cache.delete(param);
48
- throw err;
49
- })
50
- );
51
- }
52
-
53
- try {
54
- const result = cache.get(param);
55
- const value = await result;
56
- return done(null, value);
57
- } catch (error) {
58
- return done(error);
59
- }
60
- };
61
-
62
- wrapped.clear = () => cache.clear();
63
-
64
- return wrapped;
65
- };
66
-
67
- const isDirCached = makeCache(async (file) => {
68
- try {
69
- const stats = await stat(file);
70
- return stats.isDirectory();
71
- } catch (error) {
72
- return onError(error);
73
- }
74
- });
75
-
76
- const isFileCached = makeCache(async (file) => {
77
- try {
78
- const stats = await stat(file);
79
- return stats.isFile();
80
- } catch (error) {
81
- return onError(error);
82
- }
83
- });
84
-
85
- const readCachedFile = makeCache(readFile$1);
86
-
87
- function handleDeprecatedOptions(opts) {
88
- const warnings = [];
89
-
90
- if (opts.customResolveOptions) {
91
- const { customResolveOptions } = opts;
92
- if (customResolveOptions.moduleDirectory) {
93
- // eslint-disable-next-line no-param-reassign
94
- opts.moduleDirectories = Array.isArray(customResolveOptions.moduleDirectory)
95
- ? customResolveOptions.moduleDirectory
96
- : [customResolveOptions.moduleDirectory];
97
-
98
- warnings.push(
99
- 'node-resolve: The `customResolveOptions.moduleDirectory` option has been deprecated. Use `moduleDirectories`, which must be an array.'
100
- );
101
- }
102
-
103
- if (customResolveOptions.preserveSymlinks) {
104
- throw new Error(
105
- 'node-resolve: `customResolveOptions.preserveSymlinks` is no longer an option. We now always use the rollup `preserveSymlinks` option.'
106
- );
107
- }
108
-
109
- [
110
- 'basedir',
111
- 'package',
112
- 'extensions',
113
- 'includeCoreModules',
114
- 'readFile',
115
- 'isFile',
116
- 'isDirectory',
117
- 'realpath',
118
- 'packageFilter',
119
- 'pathFilter',
120
- 'paths',
121
- 'packageIterator'
122
- ].forEach((resolveOption) => {
123
- if (customResolveOptions[resolveOption]) {
124
- throw new Error(
125
- `node-resolve: \`customResolveOptions.${resolveOption}\` is no longer an option. If you need this, please open an issue.`
126
- );
127
- }
128
- });
129
- }
130
-
131
- return { warnings };
132
- }
133
-
134
- // returns the imported package name for bare module imports
135
- function getPackageName(id) {
136
- if (id.startsWith('.') || id.startsWith('/')) {
137
- return null;
138
- }
139
-
140
- const split = id.split('/');
141
-
142
- // @my-scope/my-package/foo.js -> @my-scope/my-package
143
- // @my-scope/my-package -> @my-scope/my-package
144
- if (split[0][0] === '@') {
145
- return `${split[0]}/${split[1]}`;
146
- }
147
-
148
- // my-package/foo.js -> my-package
149
- // my-package -> my-package
150
- return split[0];
151
- }
152
-
153
- function getMainFields(options) {
154
- let mainFields;
155
- if (options.mainFields) {
156
- ({ mainFields } = options);
157
- } else {
158
- mainFields = ['module', 'main'];
159
- }
160
- if (options.browser && mainFields.indexOf('browser') === -1) {
161
- return ['browser'].concat(mainFields);
162
- }
163
- if (!mainFields.length) {
164
- throw new Error('Please ensure at least one `mainFields` value is specified');
165
- }
166
- return mainFields;
167
- }
168
-
169
- function getPackageInfo(options) {
170
- const {
171
- cache,
172
- extensions,
173
- pkg,
174
- mainFields,
175
- preserveSymlinks,
176
- useBrowserOverrides,
177
- rootDir,
178
- ignoreSideEffectsForRoot
179
- } = options;
180
- let { pkgPath } = options;
181
-
182
- if (cache.has(pkgPath)) {
183
- return cache.get(pkgPath);
184
- }
185
-
186
- // browserify/resolve doesn't realpath paths returned in its packageFilter callback
187
- if (!preserveSymlinks) {
188
- pkgPath = realpathSync(pkgPath);
189
- }
190
-
191
- const pkgRoot = dirname(pkgPath);
192
-
193
- const packageInfo = {
194
- // copy as we are about to munge the `main` field of `pkg`.
195
- packageJson: { ...pkg },
196
-
197
- // path to package.json file
198
- packageJsonPath: pkgPath,
199
-
200
- // directory containing the package.json
201
- root: pkgRoot,
202
-
203
- // which main field was used during resolution of this module (main, module, or browser)
204
- resolvedMainField: 'main',
205
-
206
- // whether the browser map was used to resolve the entry point to this module
207
- browserMappedMain: false,
208
-
209
- // the entry point of the module with respect to the selected main field and any
210
- // relevant browser mappings.
211
- resolvedEntryPoint: ''
212
- };
213
-
214
- let overriddenMain = false;
215
- for (let i = 0; i < mainFields.length; i++) {
216
- const field = mainFields[i];
217
- if (typeof pkg[field] === 'string') {
218
- pkg.main = pkg[field];
219
- packageInfo.resolvedMainField = field;
220
- overriddenMain = true;
221
- break;
222
- }
223
- }
224
-
225
- const internalPackageInfo = {
226
- cachedPkg: pkg,
227
- hasModuleSideEffects: () => null,
228
- hasPackageEntry: overriddenMain !== false || mainFields.indexOf('main') !== -1,
229
- packageBrowserField:
230
- useBrowserOverrides &&
231
- typeof pkg.browser === 'object' &&
232
- Object.keys(pkg.browser).reduce((browser, key) => {
233
- let resolved = pkg.browser[key];
234
- if (resolved && resolved[0] === '.') {
235
- resolved = resolve(pkgRoot, resolved);
236
- }
237
- /* eslint-disable no-param-reassign */
238
- browser[key] = resolved;
239
- if (key[0] === '.') {
240
- const absoluteKey = resolve(pkgRoot, key);
241
- browser[absoluteKey] = resolved;
242
- if (!extname(key)) {
243
- extensions.reduce((subBrowser, ext) => {
244
- subBrowser[absoluteKey + ext] = subBrowser[key];
245
- return subBrowser;
246
- }, browser);
247
- }
248
- }
249
- return browser;
250
- }, {}),
251
- packageInfo
252
- };
253
-
254
- const browserMap = internalPackageInfo.packageBrowserField;
255
- if (
256
- useBrowserOverrides &&
257
- typeof pkg.browser === 'object' &&
258
- // eslint-disable-next-line no-prototype-builtins
259
- browserMap.hasOwnProperty(pkg.main)
260
- ) {
261
- packageInfo.resolvedEntryPoint = browserMap[pkg.main];
262
- packageInfo.browserMappedMain = true;
263
- } else {
264
- // index.node is technically a valid default entrypoint as well...
265
- packageInfo.resolvedEntryPoint = resolve(pkgRoot, pkg.main || 'index.js');
266
- packageInfo.browserMappedMain = false;
267
- }
268
-
269
- if (!ignoreSideEffectsForRoot || rootDir !== pkgRoot) {
270
- const packageSideEffects = pkg.sideEffects;
271
- if (typeof packageSideEffects === 'boolean') {
272
- internalPackageInfo.hasModuleSideEffects = () => packageSideEffects;
273
- } else if (Array.isArray(packageSideEffects)) {
274
- const finalPackageSideEffects = packageSideEffects.map((sideEffect) => {
275
- /*
276
- * The array accepts simple glob patterns to the relevant files... Patterns like .css, which do not include a /, will be treated like **\/.css.
277
- * https://webpack.js.org/guides/tree-shaking/
278
- */
279
- if (sideEffect.includes('/')) {
280
- return sideEffect;
281
- }
282
- return `**/${sideEffect}`;
283
- });
284
- internalPackageInfo.hasModuleSideEffects = createFilter(finalPackageSideEffects, null, {
285
- resolve: pkgRoot
286
- });
287
- }
288
- }
289
-
290
- cache.set(pkgPath, internalPackageInfo);
291
- return internalPackageInfo;
292
- }
293
-
294
- function normalizeInput(input) {
295
- if (Array.isArray(input)) {
296
- return input;
297
- } else if (typeof input === 'object') {
298
- return Object.values(input);
299
- }
300
-
301
- // otherwise it's a string
302
- return [input];
303
- }
304
-
305
- /* eslint-disable no-await-in-loop */
306
- function isModuleDir(current, moduleDirs) {
307
- return moduleDirs.some((dir) => current.endsWith(dir));
308
- }
309
- async function findPackageJson(base, moduleDirs) {
310
- const { root } = sysPath__default.parse(base);
311
- let current = base;
312
- while (current !== root && !isModuleDir(current, moduleDirs)) {
313
- const pkgJsonPath = sysPath__default.join(current, 'package.json');
314
- if (await fileExists(pkgJsonPath)) {
315
- const pkgJsonString = V__default.readFileSync(pkgJsonPath, 'utf-8');
316
- return { pkgJson: JSON.parse(pkgJsonString), pkgPath: current, pkgJsonPath };
317
- }
318
- current = sysPath__default.resolve(current, '..');
319
- }
320
- return null;
321
- }
322
- function isUrl(str) {
323
- try {
324
- return !!new URL(str);
325
- }
326
- catch (_) {
327
- return false;
328
- }
329
- }
330
- /**
331
- * Conditions is an export object where all keys are conditions like 'node' (aka do not with '.')
332
- */
333
- function isConditions(exports) {
334
- return typeof exports === 'object' && Object.keys(exports).every((k) => !k.startsWith('.'));
335
- }
336
- /**
337
- * Mappings is an export object where all keys start with '.
338
- */
339
- function isMappings(exports) {
340
- return typeof exports === 'object' && !isConditions(exports);
341
- }
342
- /**
343
- * Check for mixed exports, which are exports where some keys start with '.' and some do not
344
- */
345
- function isMixedExports(exports) {
346
- const keys = Object.keys(exports);
347
- return keys.some((k) => k.startsWith('.')) && keys.some((k) => !k.startsWith('.'));
348
- }
349
- function createBaseErrorMsg(importSpecifier, importer) {
350
- return `Could not resolve import "${importSpecifier}" in ${importer}`;
351
- }
352
- function createErrorMsg(context, reason, isImports) {
353
- const { importSpecifier, importer, pkgJsonPath } = context;
354
- const base = createBaseErrorMsg(importSpecifier, importer);
355
- const field = isImports ? 'imports' : 'exports';
356
- return `${base} using ${field} defined in ${pkgJsonPath}.${reason ? ` ${reason}` : ''}`;
357
- }
358
- class ResolveError extends Error {
359
- }
360
- class InvalidConfigurationError extends ResolveError {
361
- constructor(context, reason) {
362
- super(createErrorMsg(context, `Invalid "exports" field. ${reason}`));
363
- }
364
- }
365
- class InvalidModuleSpecifierError extends ResolveError {
366
- constructor(context, isImports, reason) {
367
- super(createErrorMsg(context, reason, isImports));
368
- }
369
- }
370
- class InvalidPackageTargetError extends ResolveError {
371
- constructor(context, reason) {
372
- super(createErrorMsg(context, reason));
373
- }
374
- }
375
-
376
- /* eslint-disable no-await-in-loop, no-undefined */
377
- /**
378
- * Check for invalid path segments
379
- */
380
- function includesInvalidSegments(pathSegments, moduleDirs) {
381
- const invalidSegments = ['', '.', '..', ...moduleDirs];
382
- // contains any "", ".", "..", or "node_modules" segments, including percent encoded variants
383
- return pathSegments.some((v) => invalidSegments.includes(v) || invalidSegments.includes(decodeURI(v)));
384
- }
385
- async function resolvePackageTarget(context, { target, patternMatch, isImports }) {
386
- // If target is a String, then
387
- if (typeof target === 'string') {
388
- // If target does not start with "./", then
389
- if (!target.startsWith('./')) {
390
- // If isImports is false, or if target starts with "../" or "/", or if target is a valid URL, then
391
- if (!isImports || ['/', '../'].some((p) => target.startsWith(p)) || isUrl(target)) {
392
- // Throw an Invalid Package Target error.
393
- throw new InvalidPackageTargetError(context, `Invalid mapping: "${target}".`);
394
- }
395
- // If patternMatch is a String, then
396
- if (typeof patternMatch === 'string') {
397
- // Return PACKAGE_RESOLVE(target with every instance of "*" replaced by patternMatch, packageURL + "/")
398
- const result = await context.resolveId(target.replace(/\*/g, patternMatch), context.pkgURL.href);
399
- return result ? pathToFileURL(result.location).href : null;
400
- }
401
- // Return PACKAGE_RESOLVE(target, packageURL + "/").
402
- const result = await context.resolveId(target, context.pkgURL.href);
403
- return result ? pathToFileURL(result.location).href : null;
404
- }
405
- // TODO: Drop if we do not support Node <= 16 anymore
406
- // This behavior was removed in Node 17 (deprecated in Node 14), see DEP0148
407
- if (context.allowExportsFolderMapping) {
408
- target = target.replace(/\/$/, '/*');
409
- }
410
- // If target split on "/" or "\"
411
- {
412
- const pathSegments = target.split(/\/|\\/);
413
- // after the first "." segment
414
- const firstDot = pathSegments.indexOf('.');
415
- firstDot !== -1 && pathSegments.slice(firstDot);
416
- if (firstDot !== -1 &&
417
- firstDot < pathSegments.length - 1 &&
418
- includesInvalidSegments(pathSegments.slice(firstDot + 1), context.moduleDirs)) {
419
- throw new InvalidPackageTargetError(context, `Invalid mapping: "${target}".`);
420
- }
421
- }
422
- // Let resolvedTarget be the URL resolution of the concatenation of packageURL and target.
423
- const resolvedTarget = new URL(target, context.pkgURL);
424
- // Assert: resolvedTarget is contained in packageURL.
425
- if (!resolvedTarget.href.startsWith(context.pkgURL.href)) {
426
- throw new InvalidPackageTargetError(context, `Resolved to ${resolvedTarget.href} which is outside package ${context.pkgURL.href}`);
427
- }
428
- // If patternMatch is null, then
429
- if (!patternMatch) {
430
- // Return resolvedTarget.
431
- return resolvedTarget;
432
- }
433
- // If patternMatch split on "/" or "\" contains invalid segments
434
- if (includesInvalidSegments(patternMatch.split(/\/|\\/), context.moduleDirs)) {
435
- // throw an Invalid Module Specifier error.
436
- throw new InvalidModuleSpecifierError(context);
437
- }
438
- // Return the URL resolution of resolvedTarget with every instance of "*" replaced with patternMatch.
439
- return resolvedTarget.href.replace(/\*/g, patternMatch);
440
- }
441
- // Otherwise, if target is an Array, then
442
- if (Array.isArray(target)) {
443
- // If _target.length is zero, return null.
444
- if (target.length === 0) {
445
- return null;
446
- }
447
- let lastError = null;
448
- // For each item in target, do
449
- for (const item of target) {
450
- // Let resolved be the result of PACKAGE_TARGET_RESOLVE of the item
451
- // continuing the loop on any Invalid Package Target error.
452
- try {
453
- const resolved = await resolvePackageTarget(context, {
454
- target: item,
455
- patternMatch,
456
- isImports
457
- });
458
- // If resolved is undefined, continue the loop.
459
- // Else Return resolved.
460
- if (resolved !== undefined) {
461
- return resolved;
462
- }
463
- }
464
- catch (error) {
465
- if (!(error instanceof InvalidPackageTargetError)) {
466
- throw error;
467
- }
468
- else {
469
- lastError = error;
470
- }
471
- }
472
- }
473
- // Return or throw the last fallback resolution null return or error
474
- if (lastError) {
475
- throw lastError;
476
- }
477
- return null;
478
- }
479
- // Otherwise, if target is a non-null Object, then
480
- if (target && typeof target === 'object') {
481
- // For each property of target
482
- for (const [key, value] of Object.entries(target)) {
483
- // If exports contains any index property keys, as defined in ECMA-262 6.1.7 Array Index, throw an Invalid Package Configuration error.
484
- // TODO: We do not check if the key is a number here...
485
- // If key equals "default" or conditions contains an entry for the key, then
486
- if (key === 'default' || context.conditions.includes(key)) {
487
- // Let targetValue be the value of the property in target.
488
- // Let resolved be the result of PACKAGE_TARGET_RESOLVE of the targetValue
489
- const resolved = await resolvePackageTarget(context, {
490
- target: value,
491
- patternMatch,
492
- isImports
493
- });
494
- // If resolved is equal to undefined, continue the loop.
495
- // Return resolved.
496
- if (resolved !== undefined) {
497
- return resolved;
498
- }
499
- }
500
- }
501
- // Return undefined.
502
- return undefined;
503
- }
504
- // Otherwise, if target is null, return null.
505
- if (target === null) {
506
- return null;
507
- }
508
- // Otherwise throw an Invalid Package Target error.
509
- throw new InvalidPackageTargetError(context, `Invalid exports field.`);
510
- }
511
-
512
- /* eslint-disable no-await-in-loop */
513
- /**
514
- * Implementation of Node's `PATTERN_KEY_COMPARE` function
515
- */
516
- function nodePatternKeyCompare(keyA, keyB) {
517
- // Let baseLengthA be the index of "*" in keyA plus one, if keyA contains "*", or the length of keyA otherwise.
518
- const baseLengthA = keyA.includes('*') ? keyA.indexOf('*') + 1 : keyA.length;
519
- // Let baseLengthB be the index of "*" in keyB plus one, if keyB contains "*", or the length of keyB otherwise.
520
- const baseLengthB = keyB.includes('*') ? keyB.indexOf('*') + 1 : keyB.length;
521
- // if baseLengthA is greater, return -1, if lower 1
522
- const rval = baseLengthB - baseLengthA;
523
- if (rval !== 0)
524
- return rval;
525
- // If keyA does not contain "*", return 1.
526
- if (!keyA.includes('*'))
527
- return 1;
528
- // If keyB does not contain "*", return -1.
529
- if (!keyB.includes('*'))
530
- return -1;
531
- // If the length of keyA is greater than the length of keyB, return -1.
532
- // If the length of keyB is greater than the length of keyA, return 1.
533
- // Else Return 0.
534
- return keyB.length - keyA.length;
535
- }
536
- async function resolvePackageImportsExports(context, { matchKey, matchObj, isImports }) {
537
- // If matchKey is a key of matchObj and does not contain "*", then
538
- if (!matchKey.includes('*') && matchKey in matchObj) {
539
- // Let target be the value of matchObj[matchKey].
540
- const target = matchObj[matchKey];
541
- // Return the result of PACKAGE_TARGET_RESOLVE(packageURL, target, null, isImports, conditions).
542
- const resolved = await resolvePackageTarget(context, { target, patternMatch: '', isImports });
543
- return resolved;
544
- }
545
- // Let expansionKeys be the list of keys of matchObj containing only a single "*"
546
- const expansionKeys = Object.keys(matchObj)
547
- // Assert: ends with "/" or contains only a single "*".
548
- .filter((k) => k.endsWith('/') || k.includes('*'))
549
- // sorted by the sorting function PATTERN_KEY_COMPARE which orders in descending order of specificity.
550
- .sort(nodePatternKeyCompare);
551
- // For each key expansionKey in expansionKeys, do
552
- for (const expansionKey of expansionKeys) {
553
- const indexOfAsterisk = expansionKey.indexOf('*');
554
- // Let patternBase be the substring of expansionKey up to but excluding the first "*" character.
555
- const patternBase = indexOfAsterisk === -1 ? expansionKey : expansionKey.substring(0, indexOfAsterisk);
556
- // If matchKey starts with but is not equal to patternBase, then
557
- if (matchKey.startsWith(patternBase) && matchKey !== patternBase) {
558
- // Let patternTrailer be the substring of expansionKey from the index after the first "*" character.
559
- const patternTrailer = indexOfAsterisk !== -1 ? expansionKey.substring(indexOfAsterisk + 1) : '';
560
- // If patternTrailer has zero length,
561
- if (patternTrailer.length === 0 ||
562
- // or if matchKey ends with patternTrailer and the length of matchKey is greater than or equal to the length of expansionKey, then
563
- (matchKey.endsWith(patternTrailer) && matchKey.length >= expansionKey.length)) {
564
- // Let target be the value of matchObj[expansionKey].
565
- const target = matchObj[expansionKey];
566
- // Let patternMatch be the substring of matchKey starting at the index of the length of patternBase up to the length
567
- // of matchKey minus the length of patternTrailer.
568
- const patternMatch = matchKey.substring(patternBase.length, matchKey.length - patternTrailer.length);
569
- // Return the result of PACKAGE_TARGET_RESOLVE
570
- const resolved = await resolvePackageTarget(context, {
571
- target,
572
- patternMatch,
573
- isImports
574
- });
575
- return resolved;
576
- }
577
- }
578
- }
579
- throw new InvalidModuleSpecifierError(context, isImports);
580
- }
581
-
582
- /**
583
- * Implementation of PACKAGE_EXPORTS_RESOLVE
584
- */
585
- async function resolvePackageExports(context, subpath, exports) {
586
- // If exports is an Object with both a key starting with "." and a key not starting with "."
587
- if (isMixedExports(exports)) {
588
- // throw an Invalid Package Configuration error.
589
- throw new InvalidConfigurationError(context, 'All keys must either start with ./, or without one.');
590
- }
591
- // If subpath is equal to ".", then
592
- if (subpath === '.') {
593
- // Let mainExport be undefined.
594
- let mainExport;
595
- // If exports is a String or Array, or an Object containing no keys starting with ".", then
596
- if (typeof exports === 'string' || Array.isArray(exports) || isConditions(exports)) {
597
- // Set mainExport to exports
598
- mainExport = exports;
599
- // Otherwise if exports is an Object containing a "." property, then
600
- }
601
- else if (isMappings(exports)) {
602
- // Set mainExport to exports["."]
603
- mainExport = exports['.'];
604
- }
605
- // If mainExport is not undefined, then
606
- if (mainExport) {
607
- // Let resolved be the result of PACKAGE_TARGET_RESOLVE with target = mainExport
608
- const resolved = await resolvePackageTarget(context, {
609
- target: mainExport,
610
- patternMatch: '',
611
- isImports: false
612
- });
613
- // If resolved is not null or undefined, return resolved.
614
- if (resolved) {
615
- return resolved;
616
- }
617
- }
618
- // Otherwise, if exports is an Object and all keys of exports start with ".", then
619
- }
620
- else if (isMappings(exports)) {
621
- // Let resolved be the result of PACKAGE_IMPORTS_EXPORTS_RESOLVE
622
- const resolvedMatch = await resolvePackageImportsExports(context, {
623
- matchKey: subpath,
624
- matchObj: exports,
625
- isImports: false
626
- });
627
- // If resolved is not null or undefined, return resolved.
628
- if (resolvedMatch) {
629
- return resolvedMatch;
630
- }
631
- }
632
- // Throw a Package Path Not Exported error.
633
- throw new InvalidModuleSpecifierError(context);
634
- }
635
-
636
- async function resolvePackageImports({ importSpecifier, importer, moduleDirs, conditions, resolveId }) {
637
- const result = await findPackageJson(importer, moduleDirs);
638
- if (!result) {
639
- throw new Error(`${createBaseErrorMsg(importSpecifier, importer)}. Could not find a parent package.json.`);
640
- }
641
- const { pkgPath, pkgJsonPath, pkgJson } = result;
642
- const pkgURL = pathToFileURL(`${pkgPath}/`);
643
- const context = {
644
- importer,
645
- importSpecifier,
646
- moduleDirs,
647
- pkgURL,
648
- pkgJsonPath,
649
- conditions,
650
- resolveId
651
- };
652
- // Assert: specifier begins with "#".
653
- if (!importSpecifier.startsWith('#')) {
654
- throw new InvalidModuleSpecifierError(context, true, 'Invalid import specifier.');
655
- }
656
- // If specifier is exactly equal to "#" or starts with "#/", then
657
- if (importSpecifier === '#' || importSpecifier.startsWith('#/')) {
658
- // Throw an Invalid Module Specifier error.
659
- throw new InvalidModuleSpecifierError(context, true, 'Invalid import specifier.');
660
- }
661
- const { imports } = pkgJson;
662
- if (!imports) {
663
- throw new InvalidModuleSpecifierError(context, true);
664
- }
665
- // Let packageURL be the result of LOOKUP_PACKAGE_SCOPE(parentURL).
666
- // If packageURL is not null, then
667
- return resolvePackageImportsExports(context, {
668
- matchKey: importSpecifier,
669
- matchObj: imports,
670
- isImports: true
671
- });
672
- }
673
-
674
- const resolveImportPath = promisify(resolve$1);
675
- const readFile = promisify(V__default.readFile);
676
-
677
- async function getPackageJson(importer, pkgName, resolveOptions, moduleDirectories) {
678
- if (importer) {
679
- const selfPackageJsonResult = await findPackageJson(importer, moduleDirectories);
680
- if (selfPackageJsonResult && selfPackageJsonResult.pkgJson.name === pkgName) {
681
- // the referenced package name is the current package
682
- return selfPackageJsonResult;
683
- }
684
- }
685
-
686
- try {
687
- const pkgJsonPath = await resolveImportPath(`${pkgName}/package.json`, resolveOptions);
688
- const pkgJson = JSON.parse(await readFile(pkgJsonPath, 'utf-8'));
689
- return { pkgJsonPath, pkgJson, pkgPath: dirname(pkgJsonPath) };
690
- } catch (_) {
691
- return null;
692
- }
693
- }
694
-
695
- async function resolveIdClassic({
696
- importSpecifier,
697
- packageInfoCache,
698
- extensions,
699
- mainFields,
700
- preserveSymlinks,
701
- useBrowserOverrides,
702
- baseDir,
703
- moduleDirectories,
704
- modulePaths,
705
- rootDir,
706
- ignoreSideEffectsForRoot
707
- }) {
708
- let hasModuleSideEffects = () => null;
709
- let hasPackageEntry = true;
710
- let packageBrowserField = false;
711
- let packageInfo;
712
-
713
- const filter = (pkg, pkgPath) => {
714
- const info = getPackageInfo({
715
- cache: packageInfoCache,
716
- extensions,
717
- pkg,
718
- pkgPath,
719
- mainFields,
720
- preserveSymlinks,
721
- useBrowserOverrides,
722
- rootDir,
723
- ignoreSideEffectsForRoot
724
- });
725
-
726
- ({ packageInfo, hasModuleSideEffects, hasPackageEntry, packageBrowserField } = info);
727
-
728
- return info.cachedPkg;
729
- };
730
-
731
- const resolveOptions = {
732
- basedir: baseDir,
733
- readFile: readCachedFile,
734
- isFile: isFileCached,
735
- isDirectory: isDirCached,
736
- extensions,
737
- includeCoreModules: false,
738
- moduleDirectory: moduleDirectories,
739
- paths: modulePaths,
740
- preserveSymlinks,
741
- packageFilter: filter
742
- };
743
-
744
- let location;
745
- try {
746
- location = await resolveImportPath(importSpecifier, resolveOptions);
747
- } catch (error) {
748
- if (error.code !== 'MODULE_NOT_FOUND') {
749
- throw error;
750
- }
751
- return null;
752
- }
753
-
754
- return {
755
- location: preserveSymlinks ? location : await resolveSymlink(location),
756
- hasModuleSideEffects,
757
- hasPackageEntry,
758
- packageBrowserField,
759
- packageInfo
760
- };
761
- }
762
-
763
- async function resolveWithExportMap({
764
- importer,
765
- importSpecifier,
766
- exportConditions,
767
- packageInfoCache,
768
- extensions,
769
- mainFields,
770
- preserveSymlinks,
771
- useBrowserOverrides,
772
- baseDir,
773
- moduleDirectories,
774
- modulePaths,
775
- rootDir,
776
- ignoreSideEffectsForRoot,
777
- allowExportsFolderMapping
778
- }) {
779
- if (importSpecifier.startsWith('#')) {
780
- // this is a package internal import, resolve using package imports field
781
- const resolveResult = await resolvePackageImports({
782
- importSpecifier,
783
- importer,
784
- moduleDirs: moduleDirectories,
785
- conditions: exportConditions,
786
- // Resolve targets of "imports" mappings using the same algorithm
787
- // we use for normal specifiers: try export maps first and then
788
- // fall back to classic resolution. This is important for cases
789
- // like "#foo/*": "@scope/pkg/*" where the target package relies
790
- // on "exports" to expose subpaths. Using the classic resolver
791
- // alone would fail to find those subpaths.
792
- resolveId(id /* , parent*/) {
793
- return resolveImportSpecifiers({
794
- importer,
795
- importSpecifierList: [id],
796
- exportConditions,
797
- // pass-through of the rest of the context
798
- packageInfoCache,
799
- extensions,
800
- mainFields,
801
- preserveSymlinks,
802
- useBrowserOverrides,
803
- baseDir,
804
- moduleDirectories,
805
- modulePaths,
806
- rootDir,
807
- ignoreSideEffectsForRoot,
808
- allowExportsFolderMapping
809
- });
810
- }
811
- });
812
-
813
- if (resolveResult == null) {
814
- // When the target of an "imports" mapping cannot be resolved,
815
- // surface a proper resolve error instead of throwing from
816
- // fileURLToPath(null).
817
- throw new ResolveError(
818
- `Could not resolve import "${importSpecifier}" in ${importer} using imports.`
819
- );
820
- }
821
- const location = fileURLToPath(resolveResult);
822
- return {
823
- location: preserveSymlinks ? location : await resolveSymlink(location),
824
- hasModuleSideEffects: () => null,
825
- hasPackageEntry: true,
826
- packageBrowserField: false,
827
- // eslint-disable-next-line no-undefined
828
- packageInfo: undefined
829
- };
830
- }
831
-
832
- const pkgName = getPackageName(importSpecifier);
833
- if (pkgName) {
834
- // it's a bare import, find the package.json and resolve using package exports if available
835
- let hasModuleSideEffects = () => null;
836
- let hasPackageEntry = true;
837
- let packageBrowserField = false;
838
- let packageInfo;
839
-
840
- const filter = (pkg, pkgPath) => {
841
- const info = getPackageInfo({
842
- cache: packageInfoCache,
843
- extensions,
844
- pkg,
845
- pkgPath,
846
- mainFields,
847
- preserveSymlinks,
848
- useBrowserOverrides,
849
- rootDir,
850
- ignoreSideEffectsForRoot
851
- });
852
-
853
- ({ packageInfo, hasModuleSideEffects, hasPackageEntry, packageBrowserField } = info);
854
-
855
- return info.cachedPkg;
856
- };
857
-
858
- const resolveOptions = {
859
- basedir: baseDir,
860
- readFile: readCachedFile,
861
- isFile: isFileCached,
862
- isDirectory: isDirCached,
863
- extensions,
864
- includeCoreModules: false,
865
- moduleDirectory: moduleDirectories,
866
- paths: modulePaths,
867
- preserveSymlinks,
868
- packageFilter: filter
869
- };
870
-
871
- const result = await getPackageJson(importer, pkgName, resolveOptions, moduleDirectories);
872
-
873
- if (result && result.pkgJson.exports) {
874
- const { pkgJson, pkgJsonPath } = result;
875
- const subpath =
876
- pkgName === importSpecifier ? '.' : `.${importSpecifier.substring(pkgName.length)}`;
877
- const pkgDr = pkgJsonPath.replace('package.json', '');
878
- const pkgURL = pathToFileURL(pkgDr);
879
-
880
- const context = {
881
- importer,
882
- importSpecifier,
883
- moduleDirs: moduleDirectories,
884
- pkgURL,
885
- pkgJsonPath,
886
- allowExportsFolderMapping,
887
- conditions: exportConditions
888
- };
889
- const resolvedPackageExport = await resolvePackageExports(context, subpath, pkgJson.exports);
890
- const location = fileURLToPath(resolvedPackageExport);
891
- if (location) {
892
- return {
893
- location: preserveSymlinks ? location : await resolveSymlink(location),
894
- hasModuleSideEffects,
895
- hasPackageEntry,
896
- packageBrowserField,
897
- packageInfo
898
- };
899
- }
900
- }
901
- }
902
-
903
- return null;
904
- }
905
-
906
- async function resolveWithClassic({
907
- importer,
908
- importSpecifierList,
909
- exportConditions,
910
- warn,
911
- packageInfoCache,
912
- extensions,
913
- mainFields,
914
- preserveSymlinks,
915
- useBrowserOverrides,
916
- baseDir,
917
- moduleDirectories,
918
- modulePaths,
919
- rootDir,
920
- ignoreSideEffectsForRoot
921
- }) {
922
- for (let i = 0; i < importSpecifierList.length; i++) {
923
- // eslint-disable-next-line no-await-in-loop
924
- const result = await resolveIdClassic({
925
- importSpecifier: importSpecifierList[i],
926
- packageInfoCache,
927
- extensions,
928
- mainFields,
929
- preserveSymlinks,
930
- useBrowserOverrides,
931
- baseDir,
932
- moduleDirectories,
933
- modulePaths,
934
- rootDir,
935
- ignoreSideEffectsForRoot
936
- });
937
-
938
- if (result) {
939
- return result;
940
- }
941
- }
942
-
943
- return null;
944
- }
945
-
946
- // Resolves to the module if found or `null`.
947
- // The first import specifier will first be attempted with the exports algorithm.
948
- // If this is unsuccessful because export maps are not being used, then all of `importSpecifierList`
949
- // will be tried with the classic resolution algorithm
950
- async function resolveImportSpecifiers({
951
- importer,
952
- importSpecifierList,
953
- exportConditions,
954
- warn,
955
- packageInfoCache,
956
- extensions,
957
- mainFields,
958
- preserveSymlinks,
959
- useBrowserOverrides,
960
- baseDir,
961
- moduleDirectories,
962
- modulePaths,
963
- rootDir,
964
- ignoreSideEffectsForRoot,
965
- allowExportsFolderMapping
966
- }) {
967
- try {
968
- const exportMapRes = await resolveWithExportMap({
969
- importer,
970
- importSpecifier: importSpecifierList[0],
971
- exportConditions,
972
- packageInfoCache,
973
- extensions,
974
- mainFields,
975
- preserveSymlinks,
976
- useBrowserOverrides,
977
- baseDir,
978
- moduleDirectories,
979
- modulePaths,
980
- rootDir,
981
- ignoreSideEffectsForRoot,
982
- allowExportsFolderMapping
983
- });
984
- if (exportMapRes) return exportMapRes;
985
- } catch (error) {
986
- if (error instanceof ResolveError) {
987
- warn(error);
988
- return null;
989
- }
990
- throw error;
991
- }
992
-
993
- // package has no imports or exports, use classic node resolve
994
- return resolveWithClassic({
995
- importer,
996
- importSpecifierList,
997
- exportConditions,
998
- warn,
999
- packageInfoCache,
1000
- extensions,
1001
- mainFields,
1002
- preserveSymlinks,
1003
- useBrowserOverrides,
1004
- baseDir,
1005
- moduleDirectories,
1006
- modulePaths,
1007
- rootDir,
1008
- ignoreSideEffectsForRoot
1009
- });
1010
- }
1011
-
1012
- const versionRegexp = /\^(\d+\.\d+\.\d+)/g;
1013
-
1014
- function validateVersion(actualVersion, peerDependencyVersion) {
1015
- let minMajor = Infinity;
1016
- let minMinor = Infinity;
1017
- let minPatch = Infinity;
1018
- let foundVersion;
1019
- // eslint-disable-next-line no-cond-assign
1020
- while ((foundVersion = versionRegexp.exec(peerDependencyVersion))) {
1021
- const [foundMajor, foundMinor, foundPatch] = foundVersion[1].split('.').map(Number);
1022
- if (foundMajor < minMajor) {
1023
- minMajor = foundMajor;
1024
- minMinor = foundMinor;
1025
- minPatch = foundPatch;
1026
- }
1027
- }
1028
- if (!actualVersion) {
1029
- throw new Error(
1030
- `Insufficient Rollup version: "@rollup/plugin-node-resolve" requires at least rollup@${minMajor}.${minMinor}.${minPatch}.`
1031
- );
1032
- }
1033
- const [major, minor, patch] = actualVersion.split('.').map(Number);
1034
- if (
1035
- major < minMajor ||
1036
- (major === minMajor && (minor < minMinor || (minor === minMinor && patch < minPatch)))
1037
- ) {
1038
- throw new Error(
1039
- `Insufficient rollup version: "@rollup/plugin-node-resolve" requires at least rollup@${minMajor}.${minMinor}.${minPatch} but found rollup@${actualVersion}.`
1040
- );
1041
- }
1042
- }
1043
-
1044
- /* eslint-disable no-param-reassign, no-shadow, no-undefined */
1045
-
1046
- const ES6_BROWSER_EMPTY = '\0node-resolve:empty.js';
1047
- const deepFreeze = (object) => {
1048
- Object.freeze(object);
1049
-
1050
- for (const value of Object.values(object)) {
1051
- if (typeof value === 'object' && !Object.isFrozen(value)) {
1052
- deepFreeze(value);
1053
- }
1054
- }
1055
-
1056
- return object;
1057
- };
1058
-
1059
- const baseConditions = ['default', 'module'];
1060
- const baseConditionsEsm = [...baseConditions, 'import'];
1061
- const baseConditionsCjs = [...baseConditions, 'require'];
1062
- const defaults = {
1063
- dedupe: [],
1064
- // It's important that .mjs is listed before .js so that Rollup will interpret npm modules
1065
- // which deploy both ESM .mjs and CommonJS .js files as ESM.
1066
- extensions: ['.mjs', '.js', '.json', '.node'],
1067
- resolveOnly: [],
1068
- moduleDirectories: ['node_modules'],
1069
- modulePaths: [],
1070
- ignoreSideEffectsForRoot: false,
1071
- // TODO: set to false in next major release or remove
1072
- allowExportsFolderMapping: true
1073
- };
1074
- const nodeImportPrefix = /^node:/;
1075
-
1076
- deepFreeze(deepMerge({}, defaults));
1077
-
1078
- function nodeResolve(opts = {}) {
1079
- const { warnings } = handleDeprecatedOptions(opts);
1080
-
1081
- const options = { ...defaults, ...opts };
1082
- const { extensions, jail, moduleDirectories, modulePaths, ignoreSideEffectsForRoot } = options;
1083
- const exportConditions = options.exportConditions || [];
1084
- const devProdCondition =
1085
- exportConditions.includes('development') || exportConditions.includes('production')
1086
- ? []
1087
- : [
1088
- process.env.NODE_ENV && process.env.NODE_ENV !== 'production'
1089
- ? 'development'
1090
- : 'production'
1091
- ];
1092
- const conditionsEsm = [...baseConditionsEsm, ...exportConditions, ...devProdCondition];
1093
- const conditionsCjs = [...baseConditionsCjs, ...exportConditions, ...devProdCondition];
1094
- const packageInfoCache = new Map();
1095
- const idToPackageInfo = new Map();
1096
- const mainFields = getMainFields(options);
1097
- const useBrowserOverrides = mainFields.indexOf('browser') !== -1;
1098
- const isPreferBuiltinsSet = Object.prototype.hasOwnProperty.call(options, 'preferBuiltins');
1099
- const preferBuiltins = isPreferBuiltinsSet ? options.preferBuiltins : true;
1100
- const rootDir = resolve(options.rootDir || process.cwd());
1101
- let { dedupe } = options;
1102
- let rollupOptions;
1103
-
1104
- if (moduleDirectories.some((name) => name.includes('/'))) {
1105
- throw new Error(
1106
- '`moduleDirectories` option must only contain directory names. If you want to load modules from somewhere not supported by the default module resolution algorithm, see `modulePaths`.'
1107
- );
1108
- }
1109
-
1110
- if (typeof dedupe !== 'function') {
1111
- dedupe = (importee) =>
1112
- options.dedupe.includes(importee) || options.dedupe.includes(getPackageName(importee));
1113
- }
1114
-
1115
- // creates a function from the patterns to test if a particular module should be bundled.
1116
- const allowPatterns = (patterns) => {
1117
- const regexPatterns = patterns.map((pattern) => {
1118
- if (pattern instanceof RegExp) {
1119
- return pattern;
1120
- }
1121
- const normalized = pattern.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
1122
- return new RegExp(`^${normalized}$`);
1123
- });
1124
- return (id) => !regexPatterns.length || regexPatterns.some((pattern) => pattern.test(id));
1125
- };
1126
-
1127
- const resolveOnly =
1128
- typeof options.resolveOnly === 'function'
1129
- ? options.resolveOnly
1130
- : allowPatterns(options.resolveOnly);
1131
-
1132
- const browserMapCache = new Map();
1133
- let preserveSymlinks;
1134
-
1135
- const resolveLikeNode = async (context, importee, importer, custom) => {
1136
- // strip query params from import
1137
- const [importPath, params] = importee.split('?');
1138
- const importSuffix = `${params ? `?${params}` : ''}`;
1139
- importee = importPath;
1140
-
1141
- const baseDir = !importer || dedupe(importee) ? rootDir : dirname(importer);
1142
-
1143
- // https://github.com/defunctzombie/package-browser-field-spec
1144
- const browser = browserMapCache.get(importer);
1145
- if (useBrowserOverrides && browser) {
1146
- const resolvedImportee = resolve(baseDir, importee);
1147
- if (browser[importee] === false || browser[resolvedImportee] === false) {
1148
- return { id: ES6_BROWSER_EMPTY };
1149
- }
1150
- const browserImportee =
1151
- (importee[0] !== '.' && browser[importee]) ||
1152
- browser[resolvedImportee] ||
1153
- browser[`${resolvedImportee}.js`] ||
1154
- browser[`${resolvedImportee}.json`];
1155
- if (browserImportee) {
1156
- importee = browserImportee;
1157
- }
1158
- }
1159
-
1160
- const parts = importee.split(/[/\\]/);
1161
- let id = parts.shift();
1162
- let isRelativeImport = false;
1163
-
1164
- if (id[0] === '@' && parts.length > 0) {
1165
- // scoped packages
1166
- id += `/${parts.shift()}`;
1167
- } else if (id[0] === '.') {
1168
- // an import relative to the parent dir of the importer
1169
- id = resolve(baseDir, importee);
1170
- isRelativeImport = true;
1171
- }
1172
-
1173
- // if it's not a relative import, and it's not requested, reject it.
1174
- if (!isRelativeImport && !resolveOnly(id)) {
1175
- if (normalizeInput(rollupOptions.input).includes(importee)) {
1176
- return null;
1177
- }
1178
- return false;
1179
- }
1180
-
1181
- const importSpecifierList = [importee];
1182
-
1183
- if (importer === undefined && importee[0] && !importee[0].match(/^\.?\.?\//)) {
1184
- // For module graph roots (i.e. when importer is undefined), we
1185
- // need to handle 'path fragments` like `foo/bar` that are commonly
1186
- // found in rollup config files. If importee doesn't look like a
1187
- // relative or absolute path, we make it relative and attempt to
1188
- // resolve it.
1189
- importSpecifierList.push(`./${importee}`);
1190
- }
1191
-
1192
- // TypeScript files may import '.mjs' or '.cjs' to refer to either '.mts' or '.cts'.
1193
- // They may also import .js to refer to either .ts or .tsx, and .jsx to refer to .tsx.
1194
- if (importer && /\.(ts|mts|cts|tsx)$/.test(importer)) {
1195
- for (const [importeeExt, resolvedExt] of [
1196
- ['.js', '.ts'],
1197
- ['.js', '.tsx'],
1198
- ['.jsx', '.tsx'],
1199
- ['.mjs', '.mts'],
1200
- ['.cjs', '.cts']
1201
- ]) {
1202
- if (importee.endsWith(importeeExt) && extensions.includes(resolvedExt)) {
1203
- importSpecifierList.push(importee.slice(0, -importeeExt.length) + resolvedExt);
1204
- }
1205
- }
1206
- }
1207
-
1208
- const warn = (...args) => context.warn(...args);
1209
- const isRequire = custom && custom['node-resolve'] && custom['node-resolve'].isRequire;
1210
- const exportConditions = isRequire ? conditionsCjs : conditionsEsm;
1211
- if (useBrowserOverrides && !exportConditions.includes('browser'))
1212
- exportConditions.push('browser');
1213
-
1214
- const resolvedWithoutBuiltins = await resolveImportSpecifiers({
1215
- importer,
1216
- importSpecifierList,
1217
- exportConditions,
1218
- warn,
1219
- packageInfoCache,
1220
- extensions,
1221
- mainFields,
1222
- preserveSymlinks,
1223
- useBrowserOverrides,
1224
- baseDir,
1225
- moduleDirectories,
1226
- modulePaths,
1227
- rootDir,
1228
- ignoreSideEffectsForRoot,
1229
- allowExportsFolderMapping: options.allowExportsFolderMapping
1230
- });
1231
-
1232
- const importeeIsBuiltin = builtinModules.includes(importee.replace(nodeImportPrefix, ''));
1233
- const preferImporteeIsBuiltin =
1234
- typeof preferBuiltins === 'function' ? preferBuiltins(importee) : preferBuiltins;
1235
- const resolved =
1236
- importeeIsBuiltin && preferImporteeIsBuiltin
1237
- ? {
1238
- packageInfo: undefined,
1239
- hasModuleSideEffects: () => null,
1240
- hasPackageEntry: true,
1241
- packageBrowserField: false
1242
- }
1243
- : resolvedWithoutBuiltins;
1244
- if (!resolved) {
1245
- return null;
1246
- }
1247
-
1248
- const { packageInfo, hasModuleSideEffects, hasPackageEntry, packageBrowserField } = resolved;
1249
- let { location } = resolved;
1250
- if (packageBrowserField) {
1251
- if (Object.prototype.hasOwnProperty.call(packageBrowserField, location)) {
1252
- if (!packageBrowserField[location]) {
1253
- browserMapCache.set(location, packageBrowserField);
1254
- return { id: ES6_BROWSER_EMPTY };
1255
- }
1256
- location = packageBrowserField[location];
1257
- }
1258
- browserMapCache.set(location, packageBrowserField);
1259
- }
1260
-
1261
- if (hasPackageEntry && !preserveSymlinks) {
1262
- const exists = await fileExists(location);
1263
- if (exists) {
1264
- location = await realpath(location);
1265
- }
1266
- }
1267
-
1268
- idToPackageInfo.set(location, packageInfo);
1269
-
1270
- if (hasPackageEntry) {
1271
- if (importeeIsBuiltin && preferImporteeIsBuiltin) {
1272
- if (!isPreferBuiltinsSet && resolvedWithoutBuiltins && resolved !== importee) {
1273
- context.warn({
1274
- message:
1275
- `preferring built-in module '${importee}' over local alternative at '${resolvedWithoutBuiltins.location}', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning.` +
1276
- `or passing a function to 'preferBuiltins' to provide more fine-grained control over which built-in modules to prefer.`,
1277
- pluginCode: 'PREFER_BUILTINS'
1278
- });
1279
- }
1280
- return false;
1281
- } else if (jail && location.indexOf(normalize(jail.trim(sep))) !== 0) {
1282
- return null;
1283
- }
1284
- }
1285
-
1286
- if (options.modulesOnly && (await fileExists(location))) {
1287
- const code = await readFile$1(location, 'utf-8');
1288
- if (isModule(code)) {
1289
- return {
1290
- id: `${location}${importSuffix}`,
1291
- moduleSideEffects: hasModuleSideEffects(location)
1292
- };
1293
- }
1294
- return null;
1295
- }
1296
- return {
1297
- id: `${location}${importSuffix}`,
1298
- moduleSideEffects: hasModuleSideEffects(location)
1299
- };
1300
- };
1301
-
1302
- return {
1303
- name: 'node-resolve',
1304
-
1305
- version,
1306
-
1307
- buildStart(buildOptions) {
1308
- validateVersion(this.meta.rollupVersion, peerDependencies.rollup);
1309
- rollupOptions = buildOptions;
1310
-
1311
- for (const warning of warnings) {
1312
- this.warn(warning);
1313
- }
1314
-
1315
- ({ preserveSymlinks } = buildOptions);
1316
- },
1317
-
1318
- generateBundle() {
1319
- readCachedFile.clear();
1320
- isFileCached.clear();
1321
- isDirCached.clear();
1322
- },
1323
-
1324
- resolveId: {
1325
- order: 'post',
1326
- async handler(importee, importer, resolveOptions) {
1327
- if (importee === ES6_BROWSER_EMPTY) {
1328
- return importee;
1329
- }
1330
- // ignore IDs with null character, these belong to other plugins
1331
- if (importee && importee.includes('\0')) return null;
1332
-
1333
- const { custom = {} } = resolveOptions;
1334
- const { 'node-resolve': { resolved: alreadyResolved } = {} } = custom;
1335
- if (alreadyResolved) {
1336
- return alreadyResolved;
1337
- }
1338
-
1339
- if (importer && importer.includes('\0')) {
1340
- importer = undefined;
1341
- }
1342
-
1343
- const resolved = await resolveLikeNode(this, importee, importer, custom);
1344
- if (resolved) {
1345
- // This way, plugins may attach additional meta information to the
1346
- // resolved id or make it external. We do not skip node-resolve here
1347
- // because another plugin might again use `this.resolve` in its
1348
- // `resolveId` hook, in which case we want to add the correct
1349
- // `moduleSideEffects` information.
1350
- const resolvedResolved = await this.resolve(resolved.id, importer, {
1351
- ...resolveOptions,
1352
- skipSelf: false,
1353
- custom: { ...custom, 'node-resolve': { ...custom['node-resolve'], resolved, importee } }
1354
- });
1355
- if (resolvedResolved) {
1356
- // Handle plugins that manually make the result external
1357
- if (resolvedResolved.external) {
1358
- return false;
1359
- }
1360
- // Allow other plugins to take over resolution. Rollup core will not
1361
- // change the id if it corresponds to an existing file
1362
- if (resolvedResolved.id !== resolved.id) {
1363
- return resolvedResolved;
1364
- }
1365
- // Pass on meta information added by other plugins
1366
- return { ...resolved, meta: resolvedResolved.meta };
1367
- }
1368
- }
1369
- return resolved;
1370
- }
1371
- },
1372
-
1373
- load(importee) {
1374
- if (importee === ES6_BROWSER_EMPTY) {
1375
- return 'export default {};';
1376
- }
1377
- return null;
1378
- },
1379
-
1380
- getPackageInfoForId(id) {
1381
- return idToPackageInfo.get(id);
1382
- }
1383
- };
1384
- }
1385
-
1386
- export { nodeResolve as n };