nitro 3.0.260311-beta → 3.0.260415-beta

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 (206) hide show
  1. package/dist/_build/common.mjs +630 -1602
  2. package/dist/_build/rolldown.mjs +0 -11
  3. package/dist/_build/rollup.mjs +0 -13
  4. package/dist/_build/vite.build.mjs +0 -2
  5. package/dist/_chunks/nitro.mjs +23 -216
  6. package/dist/_chunks/nitro2.mjs +0 -2
  7. package/dist/_chunks/nitro3.mjs +128 -121
  8. package/dist/_chunks/nitro4.mjs +127 -0
  9. package/dist/_chunks/utils.mjs +0 -7
  10. package/dist/_common.mjs +0 -2
  11. package/dist/_dev.d.mts +0 -3
  12. package/dist/_dev.mjs +0 -10
  13. package/dist/_libs/_.mjs +0 -1
  14. package/dist/_libs/_3.mjs +0 -1
  15. package/dist/_libs/_5.mjs +0 -1
  16. package/dist/_libs/_6.mjs +0 -2
  17. package/dist/_libs/_7.mjs +0 -3
  18. package/dist/_libs/c12+rc9.mjs +24 -22
  19. package/dist/_libs/c12+readdirp+chokidar.d.mts +0 -7
  20. package/dist/_libs/citty.mjs +134 -31
  21. package/dist/_libs/commondir+is-reference.mjs +2 -9
  22. package/dist/_libs/compatx.d.mts +0 -2
  23. package/dist/_libs/compatx.mjs +0 -2
  24. package/dist/_libs/esbuild.d.mts +0 -1
  25. package/dist/_libs/escape-string-regexp.mjs +0 -2
  26. package/dist/_libs/estree+pluginutils.d.mts +0 -5
  27. package/dist/_libs/estree-walker.mjs +3 -88
  28. package/dist/_libs/hasown+resolve+deepmerge.mjs +22 -85
  29. package/dist/_libs/httpxy.d.mts +9 -5
  30. package/dist/_libs/httpxy.mjs +284 -116
  31. package/dist/_libs/klona.mjs +0 -2
  32. package/dist/_libs/magic-string.d.mts +0 -2
  33. package/dist/_libs/mlly.d.mts +0 -2
  34. package/dist/_libs/nypm+tinyexec.mjs +111 -134
  35. package/dist/_libs/perfect-debounce.mjs +0 -20
  36. package/dist/_libs/pkg-types.d.mts +0 -3
  37. package/dist/_libs/plugin-alias.mjs +0 -2
  38. package/dist/_libs/plugin-inject.mjs +0 -2
  39. package/dist/_libs/plugin-json.mjs +0 -2
  40. package/dist/_libs/pluginutils.mjs +0 -26
  41. package/dist/_libs/readdirp+chokidar.mjs +0 -173
  42. package/dist/_libs/remapping.mjs +0 -2
  43. package/dist/_libs/resolve-uri+gen-mapping.mjs +0 -32
  44. package/dist/_libs/rou3.d.mts +0 -4
  45. package/dist/_libs/rou3.mjs +0 -29
  46. package/dist/_libs/std-env.d.mts +1 -3
  47. package/dist/_libs/tsconfck.mjs +0 -294
  48. package/dist/_libs/ultrahtml.mjs +0 -2
  49. package/dist/_libs/unimport+unplugin.mjs +1 -44
  50. package/dist/_libs/unplugin+unimport.d.mts +0 -7
  51. package/dist/_libs/unwasm.d.mts +0 -3
  52. package/dist/_presets.mjs +211 -80
  53. package/dist/builder.d.mts +1 -22
  54. package/dist/builder.mjs +0 -11
  55. package/dist/cli/_chunks/build.mjs +0 -2
  56. package/dist/cli/_chunks/common.mjs +0 -2
  57. package/dist/cli/_chunks/deploy.mjs +0 -3
  58. package/dist/cli/_chunks/dev.mjs +0 -5
  59. package/dist/cli/_chunks/docs.mjs +1 -3
  60. package/dist/cli/_chunks/list.mjs +0 -2
  61. package/dist/cli/_chunks/prepare.mjs +0 -2
  62. package/dist/cli/_chunks/preview.mjs +1 -4
  63. package/dist/cli/_chunks/run.mjs +0 -2
  64. package/dist/cli/_chunks/task.mjs +0 -2
  65. package/dist/cli/index.mjs +0 -2
  66. package/{skills/nitro/docs/docs/quick-start.md → dist/docs/0.docs/1.quick-start.md} +4 -4
  67. package/{skills/nitro/docs/docs/lifecycle.md → dist/docs/0.docs/10.lifecycle.md} +4 -4
  68. package/dist/docs/0.docs/11.openapi.md +291 -0
  69. package/{skills/nitro/docs/docs/plugins.md → dist/docs/0.docs/12.plugins.md} +2 -2
  70. package/{skills/nitro/docs/docs/tasks.md → dist/docs/0.docs/13.tasks.md} +6 -6
  71. package/dist/docs/0.docs/14.websocket.md +386 -0
  72. package/{skills/nitro/docs/docs/migration.md → dist/docs/0.docs/15.migration.md} +2 -4
  73. package/{skills/nitro/docs/docs/renderer.md → dist/docs/0.docs/2.renderer.md} +8 -8
  74. package/{skills/nitro/docs/docs/routing.md → dist/docs/0.docs/3.routing.md} +34 -34
  75. package/{skills/nitro/docs/docs/server-entry.md → dist/docs/0.docs/4.server-entry.md} +6 -6
  76. package/{skills/nitro/docs/docs/cache.md → dist/docs/0.docs/5.cache.md} +12 -12
  77. package/{skills/nitro/docs/docs/storage.md → dist/docs/0.docs/6.storage.md} +6 -6
  78. package/{skills/nitro/docs/docs/assets.md → dist/docs/0.docs/7.assets.md} +8 -8
  79. package/{skills/nitro/docs/docs/configuration.md → dist/docs/0.docs/8.configuration.md} +16 -16
  80. package/{skills/nitro/docs/docs/database.md → dist/docs/0.docs/9.database.md} +6 -6
  81. package/{skills/nitro/docs/deploy → dist/docs/1.deploy/0.index}/index.md +3 -3
  82. package/{skills/nitro/docs/deploy/providers/aws.md → dist/docs/1.deploy/2.providers/1.aws.md} +4 -4
  83. package/{skills/nitro/docs/deploy/providers/iis.md → dist/docs/1.deploy/2.providers/15.iis.md} +2 -2
  84. package/{skills/nitro/docs/deploy/providers/aws-amplify.md → dist/docs/1.deploy/2.providers/2.aws-amplify.md} +2 -2
  85. package/{skills/nitro/docs/deploy/providers/vercel.md → dist/docs/1.deploy/2.providers/21.vercel.md} +98 -7
  86. package/{skills/nitro/docs/deploy/providers/zephyr.md → dist/docs/1.deploy/2.providers/23.zephyr.md} +2 -2
  87. package/{skills/nitro/docs/deploy/providers/cloudflare.md → dist/docs/1.deploy/2.providers/5.cloudflare.md} +9 -15
  88. package/dist/docs/1.deploy/2.providers/8.edgeone.md +20 -0
  89. package/{skills/nitro/docs/config → dist/docs/2.config/0.index}/index.md +165 -91
  90. package/{skills/nitro/docs/examples/hono.md → dist/docs/3.examples/10.hono.md} +1 -1
  91. package/{skills/nitro/docs/examples/import-alias.md → dist/docs/3.examples/11.import-alias.md} +1 -4
  92. package/{skills/nitro/docs/examples/mono-jsx.md → dist/docs/3.examples/13.mono-jsx.md} +2 -2
  93. package/{skills/nitro/docs/examples/plugins.md → dist/docs/3.examples/15.plugins.md} +4 -4
  94. package/{skills/nitro/docs/examples/shiki.md → dist/docs/3.examples/19.shiki.md} +1 -1
  95. package/{skills/nitro/docs/examples/auto-imports.md → dist/docs/3.examples/2.auto-imports.md} +0 -1
  96. package/{skills/nitro/docs/examples/vite-nitro-plugin.md → dist/docs/3.examples/21.vite-nitro-plugin.md} +1 -1
  97. package/{skills/nitro/docs/examples/vite-rsc.md → dist/docs/3.examples/22.vite-rsc.md} +4 -4
  98. package/{skills/nitro/docs/examples/vite-ssr-html.md → dist/docs/3.examples/23.vite-ssr-html.md} +3 -3
  99. package/{skills/nitro/docs/examples/vite-ssr-preact.md → dist/docs/3.examples/24.vite-ssr-preact.md} +6 -6
  100. package/{skills/nitro/docs/examples/vite-ssr-react.md → dist/docs/3.examples/25.vite-ssr-react.md} +3 -3
  101. package/{skills/nitro/docs/examples/vite-ssr-solid.md → dist/docs/3.examples/26.vite-ssr-solid.md} +3 -3
  102. package/{skills/nitro/docs/examples/vite-ssr-tsr-react.md → dist/docs/3.examples/27.vite-ssr-tsr-react.md} +6 -6
  103. package/{skills/nitro/docs/examples/vite-ssr-tss-react.md → dist/docs/3.examples/28.vite-ssr-tss-react.md} +11 -11
  104. package/{skills/nitro/docs/examples/vite-ssr-vue-router.md → dist/docs/3.examples/29.vite-ssr-vue-router.md} +6 -5
  105. package/{skills/nitro/docs/examples/vite-trpc.md → dist/docs/3.examples/30.vite-trpc.md} +3 -3
  106. package/{skills/nitro/docs/examples/elysia.md → dist/docs/3.examples/6.elysia.md} +1 -1
  107. package/{skills/nitro/docs/examples/fastify.md → dist/docs/3.examples/8.fastify.md} +1 -1
  108. package/dist/docs/README.md +86 -0
  109. package/dist/node_modules/@speed-highlight/core/dist/index.js +4 -4
  110. package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -2
  111. package/dist/node_modules/@speed-highlight/core/package.json +1 -1
  112. package/dist/node_modules/cookie-es/dist/index.mjs +299 -250
  113. package/dist/node_modules/cookie-es/package.json +26 -23
  114. package/dist/node_modules/defu/dist/defu.mjs +2 -2
  115. package/dist/node_modules/defu/package.json +33 -28
  116. package/dist/node_modules/rendu/dist/_chunks/libs/cookie-es.mjs +151 -0
  117. package/dist/node_modules/rendu/dist/index.mjs +5 -112
  118. package/dist/node_modules/rendu/package.json +25 -24
  119. package/dist/node_modules/youch/package.json +2 -2
  120. package/dist/presets/_nitro/runtime/nitro-dev.mjs +3 -1
  121. package/dist/presets/_nitro/runtime/service-worker.mjs +1 -1
  122. package/dist/presets/aws-lambda/runtime/_utils.mjs +6 -6
  123. package/dist/presets/azure/runtime/_utils.mjs +5 -5
  124. package/dist/presets/azure/runtime/azure-swa.mjs +5 -5
  125. package/dist/presets/bun/runtime/bun.mjs +5 -3
  126. package/dist/presets/cloudflare/runtime/_module-handler.mjs +1 -1
  127. package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +4 -4
  128. package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +3 -3
  129. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +2 -2
  130. package/dist/presets/cloudflare/runtime/plugin.dev.mjs +10 -21
  131. package/dist/presets/deno/runtime/deno-deploy.mjs +4 -4
  132. package/dist/presets/deno/runtime/deno-server.mjs +5 -3
  133. package/dist/presets/edgeone/runtime/edgeone.mjs +10 -0
  134. package/dist/presets/netlify/runtime/netlify-edge.mjs +2 -2
  135. package/dist/presets/node/runtime/node-cluster.mjs +2 -2
  136. package/dist/presets/node/runtime/node-middleware.mjs +1 -1
  137. package/dist/presets/node/runtime/node-server.mjs +5 -3
  138. package/dist/presets/stormkit/runtime/stormkit.mjs +1 -1
  139. package/dist/presets/vercel/runtime/cron-handler.mjs +1 -1
  140. package/dist/presets/vercel/runtime/queue-handler.mjs +21 -0
  141. package/dist/presets/vercel/runtime/vercel.node.mjs +3 -3
  142. package/dist/presets/vercel/runtime/vercel.web.mjs +1 -1
  143. package/dist/presets/winterjs/runtime/winterjs.mjs +10 -10
  144. package/dist/runtime/internal/app.mjs +12 -11
  145. package/dist/runtime/internal/context.mjs +1 -9
  146. package/dist/runtime/internal/error/dev.mjs +10 -10
  147. package/dist/runtime/internal/route-rules.d.mts +3 -1
  148. package/dist/runtime/internal/route-rules.mjs +9 -7
  149. package/dist/runtime/internal/routes/dev-tasks.mjs +13 -12
  150. package/dist/runtime/internal/routes/openapi.mjs +2 -2
  151. package/dist/runtime/internal/routes/scalar.mjs +3 -3
  152. package/dist/runtime/internal/routes/swagger.mjs +7 -4
  153. package/dist/runtime/internal/runtime-config.mjs +2 -2
  154. package/dist/runtime/internal/task.mjs +5 -5
  155. package/dist/runtime/meta.d.mts +1 -0
  156. package/dist/runtime/meta.mjs +1 -0
  157. package/dist/runtime/nitro.mjs +3 -3
  158. package/dist/runtime/virtual/renderer-template.mjs +1 -1
  159. package/dist/runtime/virtual/tracing.d.mts +5 -0
  160. package/dist/runtime/virtual/tracing.mjs +1 -0
  161. package/dist/types/index.d.mts +155 -86
  162. package/dist/vite.d.mts +0 -5
  163. package/dist/vite.mjs +57 -28
  164. package/lib/tsconfig.json +3 -5
  165. package/package.json +56 -54
  166. package/skills/nitro/SKILL.md +0 -10
  167. package/skills/nitro/docs/TOC.md +0 -83
  168. package/skills/nitro/docs/_navigation.json +0 -679
  169. /package/{skills/nitro/docs/docs → dist/docs/0.docs/0.index}/index.md +0 -0
  170. /package/{skills/nitro/docs/docs/nightly.md → dist/docs/0.docs/16.nightly.md} +0 -0
  171. /package/{skills/nitro/docs/deploy/runtimes/node.md → dist/docs/1.deploy/1.runtimes/0.node.md} +0 -0
  172. /package/{skills/nitro/docs/deploy/runtimes/bun.md → dist/docs/1.deploy/1.runtimes/1.bun.md} +0 -0
  173. /package/{skills/nitro/docs/deploy/runtimes/deno.md → dist/docs/1.deploy/1.runtimes/2.deno.md} +0 -0
  174. /package/{skills/nitro/docs/deploy/providers/alwaysdata.md → dist/docs/1.deploy/2.providers/0.alwaysdata.md} +0 -0
  175. /package/{skills/nitro/docs/deploy/providers/flightcontrol.md → dist/docs/1.deploy/2.providers/10.flightcontrol.md} +0 -0
  176. /package/{skills/nitro/docs/deploy/providers/genezio.md → dist/docs/1.deploy/2.providers/11.genezio.md} +0 -0
  177. /package/{skills/nitro/docs/deploy/providers/github-pages.md → dist/docs/1.deploy/2.providers/12.github-pages.md} +0 -0
  178. /package/{skills/nitro/docs/deploy/providers/gitlab-pages.md → dist/docs/1.deploy/2.providers/13.gitlab-pages.md} +0 -0
  179. /package/{skills/nitro/docs/deploy/providers/heroku.md → dist/docs/1.deploy/2.providers/14.heroku.md} +0 -0
  180. /package/{skills/nitro/docs/deploy/providers/koyeb.md → dist/docs/1.deploy/2.providers/16.koyeb.md} +0 -0
  181. /package/{skills/nitro/docs/deploy/providers/netlify.md → dist/docs/1.deploy/2.providers/17.netlify.md} +0 -0
  182. /package/{skills/nitro/docs/deploy/providers/platform-sh.md → dist/docs/1.deploy/2.providers/18.platform-sh.md} +0 -0
  183. /package/{skills/nitro/docs/deploy/providers/render.md → dist/docs/1.deploy/2.providers/19.render.md} +0 -0
  184. /package/{skills/nitro/docs/deploy/providers/stormkit.md → dist/docs/1.deploy/2.providers/20.stormkit.md} +0 -0
  185. /package/{skills/nitro/docs/deploy/providers/zeabur.md → dist/docs/1.deploy/2.providers/22.zeabur.md} +0 -0
  186. /package/{skills/nitro/docs/deploy/providers/zerops.md → dist/docs/1.deploy/2.providers/24.zerops.md} +0 -0
  187. /package/{skills/nitro/docs/deploy/providers/azure.md → dist/docs/1.deploy/2.providers/3.azure.md} +0 -0
  188. /package/{skills/nitro/docs/deploy/providers/cleavr.md → dist/docs/1.deploy/2.providers/4.cleavr.md} +0 -0
  189. /package/{skills/nitro/docs/deploy/providers/deno-deploy.md → dist/docs/1.deploy/2.providers/6.deno-deploy.md} +0 -0
  190. /package/{skills/nitro/docs/deploy/providers/digitalocean.md → dist/docs/1.deploy/2.providers/7.digitalocean.md} +0 -0
  191. /package/{skills/nitro/docs/deploy/providers/firebase.md → dist/docs/1.deploy/2.providers/9.firebase.md} +0 -0
  192. /package/{skills/nitro/docs/examples → dist/docs/3.examples/0.index}/index.md +0 -0
  193. /package/{skills/nitro/docs/examples/api-routes.md → dist/docs/3.examples/1.api-routes.md} +0 -0
  194. /package/{skills/nitro/docs/examples/middleware.md → dist/docs/3.examples/12.middleware.md} +0 -0
  195. /package/{skills/nitro/docs/examples/nano-jsx.md → dist/docs/3.examples/14.nano-jsx.md} +0 -0
  196. /package/{skills/nitro/docs/examples/renderer.md → dist/docs/3.examples/16.renderer.md} +0 -0
  197. /package/{skills/nitro/docs/examples/runtime-config.md → dist/docs/3.examples/17.runtime-config.md} +0 -0
  198. /package/{skills/nitro/docs/examples/server-fetch.md → dist/docs/3.examples/18.server-fetch.md} +0 -0
  199. /package/{skills/nitro/docs/examples/virtual-routes.md → dist/docs/3.examples/20.virtual-routes.md} +0 -0
  200. /package/{skills/nitro/docs/examples/cached-handler.md → dist/docs/3.examples/3.cached-handler.md} +0 -0
  201. /package/{skills/nitro/docs/examples/websocket.md → dist/docs/3.examples/31.websocket.md} +0 -0
  202. /package/{skills/nitro/docs/examples/custom-error-handler.md → dist/docs/3.examples/4.custom-error-handler.md} +0 -0
  203. /package/{skills/nitro/docs/examples/database.md → dist/docs/3.examples/5.database.md} +0 -0
  204. /package/{skills/nitro/docs/examples/express.md → dist/docs/3.examples/7.express.md} +0 -0
  205. /package/{skills/nitro/docs/examples/hello-world.md → dist/docs/3.examples/9.hello-world.md} +0 -0
  206. /package/{skills/nitro → dist}/docs/index.md +0 -0
package/dist/vite.mjs CHANGED
@@ -1,31 +1,24 @@
1
- import "./_libs/c12+rc9.mjs";
2
1
  import { D as copyPublicAssets, E as prepare, F as prettyPath, H as v, V as m, at as dirname$1, ct as join$1, d as libChunkName, dt as resolve$1, f as baseBuildConfig, h as writeBuildInfo, it as basename$1, l as NODE_MODULES_RE, n as baseBuildPlugins, nt as resolveModulePath, st as isAbsolute$1, u as getChunkName } from "./_build/common.mjs";
3
2
  import { t as formatCompatibilityDate } from "./_libs/compatx.mjs";
4
- import "./_libs/klona.mjs";
5
3
  import { i as createNitro, r as prerender } from "./_chunks/nitro.mjs";
6
- import "./_libs/escape-string-regexp.mjs";
7
- import "./_libs/tsconfck.mjs";
8
4
  import { n as scanHandlers } from "./_chunks/nitro2.mjs";
9
- import "./_libs/rou3.mjs";
10
5
  import { n as watch$1 } from "./_libs/readdirp+chokidar.mjs";
11
6
  import { t as debounce } from "./_libs/perfect-debounce.mjs";
12
- import "./_libs/httpxy.mjs";
13
7
  import { r as NitroDevApp } from "./_dev.mjs";
14
- import "./_libs/ultrahtml.mjs";
15
- import { t as startPreview } from "./_chunks/nitro3.mjs";
8
+ import { t as startPreview } from "./_chunks/nitro4.mjs";
16
9
  import { n as assetsPlugin } from "./_libs/pluginutils.mjs";
10
+ import { runtimeDependencies, runtimeDir } from "nitro/meta";
17
11
  import { existsSync, watch } from "node:fs";
18
12
  import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
19
13
  import { join, resolve } from "node:path";
20
14
  import { defu } from "defu";
21
- import { runtimeDependencies, runtimeDir } from "nitro/meta";
15
+ import { withBase } from "ufo";
22
16
  import { colors } from "consola/utils";
23
17
  import { RunnerManager, loadRunner } from "env-runner";
24
18
  import { NodeRequest, sendNodeResponse } from "srvx/node";
25
19
  import "node:http";
26
20
  import { DevEnvironment } from "vite";
27
21
  import { createViteHotChannel } from "env-runner/vite";
28
- //#region src/build/vite/bundler.ts
29
22
  const getBundlerConfig = async (ctx) => {
30
23
  const nitro = ctx.nitro;
31
24
  const base = baseBuildConfig(nitro);
@@ -33,9 +26,6 @@ const getBundlerConfig = async (ctx) => {
33
26
  input: nitro.options.entry,
34
27
  external: [...base.env.external],
35
28
  plugins: [...await baseBuildPlugins(nitro, base)].filter(Boolean),
36
- treeshake: { moduleSideEffects(id) {
37
- return nitro.options.moduleSideEffects.some((p) => id.startsWith(p));
38
- } },
39
29
  onwarn(warning, warn) {
40
30
  if (!base.ignoreWarningCodes.has(warning.code || "")) warn(warning);
41
31
  },
@@ -86,8 +76,6 @@ const getBundlerConfig = async (ctx) => {
86
76
  };
87
77
  }
88
78
  };
89
- //#endregion
90
- //#region src/build/vite/prod.ts
91
79
  const BuilderNames = {
92
80
  nitro: colors.magenta("Nitro"),
93
81
  client: colors.green("Client"),
@@ -170,8 +158,6 @@ ${Object.keys(ctx.services).map((name) => {
170
158
  globalThis.__nitro_vite_envs__ = services;
171
159
  `;
172
160
  }
173
- //#endregion
174
- //#region src/build/vite/dev.ts
175
161
  function createFetchableDevEnvironment(name, config, devServer, entry, opts) {
176
162
  return new FetchableDevEnvironment(name, config, {
177
163
  hot: true,
@@ -270,6 +256,9 @@ async function configureViteDevServer(ctx, server) {
270
256
  const nitroDevMiddleware = async (nodeReq, nodeRes, next) => {
271
257
  if (!nodeReq.url || /^\/@(?:vite|fs|id)\//.test(nodeReq.url) || nodeReq._nitroHandled || server.middlewares.stack.map((mw) => mw.route).some((base) => base && nodeReq.url.startsWith(base))) return next();
272
258
  nodeReq._nitroHandled = true;
259
+ const baseURL = nitro.options.baseURL || "/";
260
+ const originalURL = nodeReq.url;
261
+ if (baseURL !== "/") nodeReq.url = withBase(nodeReq.url, baseURL);
273
262
  try {
274
263
  const req = new NodeRequest({
275
264
  req: nodeReq,
@@ -283,20 +272,22 @@ async function configureViteDevServer(ctx, server) {
283
272
  return await sendNodeResponse(nodeRes, envRes);
284
273
  } catch (error) {
285
274
  return next(error);
275
+ } finally {
276
+ if (baseURL !== "/") nodeReq.url = originalURL;
286
277
  }
287
278
  };
288
279
  server.middlewares.use(function nitroDevMiddlewarePre(req, res, next) {
289
280
  const fetchDest = req.headers["sec-fetch-dest"];
281
+ const ext = req.url.match(/\.([a-z0-9]+)(?:[?#]|$)/i)?.[1];
282
+ const isNitroRoute = ext ? !!nitro.routing.routes.match(req.method || "", new URL(withBase(req.url, nitro.options.baseURL), "http://localhost").pathname) : false;
290
283
  res.setHeader("vary", "sec-fetch-dest");
291
- if ((!fetchDest || /^(document|iframe|frame|empty)$/.test(fetchDest)) && !req.url.match(/\.([a-z0-9]+)(?:[?#]|$)/i)?.[1] && !/^\/(?:__|@)/.test(req.url)) nitroDevMiddleware(req, res, next);
284
+ if ((!fetchDest || /^(document|iframe|frame|empty)$/.test(fetchDest)) && (!ext || isNitroRoute) && !/^\/(?:__|@)/.test(req.url)) nitroDevMiddleware(req, res, next);
292
285
  else next();
293
286
  });
294
287
  return () => {
295
288
  server.middlewares.use(nitroDevMiddleware);
296
289
  };
297
290
  }
298
- //#endregion
299
- //#region src/build/vite/env.ts
300
291
  function createNitroEnvironment(ctx) {
301
292
  const isWorkerdRunner = _isWorkerdRunner(ctx);
302
293
  return {
@@ -338,7 +329,10 @@ function createServiceEnvironment(ctx, name, serviceConfig) {
338
329
  return {
339
330
  consumer: "server",
340
331
  build: {
341
- rollupOptions: { input: { index: serviceConfig.entry } },
332
+ rollupOptions: {
333
+ input: { index: serviceConfig.entry },
334
+ external: [/^nitro(\/|$)/]
335
+ },
342
336
  minify: ctx.nitro.options.minify,
343
337
  sourcemap: ctx.nitro.options.sourcemap,
344
338
  outDir: join(ctx.nitro.options.buildDir, "vite/services", name),
@@ -412,6 +406,39 @@ async function _loadRunner(ctx, manager) {
412
406
  });
413
407
  await manager.reload(runner);
414
408
  }
409
+ const NITRO_PROXY_PREFIX = "\0nitro-env-proxy:";
410
+ function nitroServiceProxy() {
411
+ return {
412
+ name: "nitro:service-proxy",
413
+ enforce: "pre",
414
+ applyToEnvironment: (env) => env.name !== "nitro" && env.config.consumer === "server",
415
+ apply: (_config, configEnv) => configEnv.command === "serve",
416
+ resolveId: {
417
+ filter: { id: /^nitro(\/|$)/ },
418
+ handler(id) {
419
+ if (id === "nitro" || id.startsWith("nitro/")) return {
420
+ id: NITRO_PROXY_PREFIX + id,
421
+ moduleSideEffects: false
422
+ };
423
+ }
424
+ },
425
+ load: {
426
+ filter: { id: /^\0nitro-env-proxy:/ },
427
+ handler(id) {
428
+ if (!id.startsWith(NITRO_PROXY_PREFIX)) return;
429
+ const originalId = id.slice(17);
430
+ return {
431
+ code: [
432
+ `const _mod = await globalThis.__VITE_ENVIRONMENT_RUNNER_IMPORT__("nitro", ${JSON.stringify(originalId)});`,
433
+ `__vite_ssr_exportAll__(_mod);`,
434
+ `export default _mod.default;`
435
+ ].join("\n"),
436
+ map: null
437
+ };
438
+ }
439
+ }
440
+ };
441
+ }
415
442
  function _isWorkerdRunner(ctx) {
416
443
  return (ctx.nitro.options.devServer.runner || process.env.NITRO_DEV_RUNNER || "node-worker") === "miniflare";
417
444
  }
@@ -431,8 +458,6 @@ function tryResolve(id) {
431
458
  try: true
432
459
  }) || id;
433
460
  }
434
- //#endregion
435
- //#region src/build/vite/preview.ts
436
461
  function nitroPreviewPlugin(ctx) {
437
462
  return {
438
463
  name: "nitro:preview",
@@ -462,8 +487,6 @@ function nitroPreviewPlugin(ctx) {
462
487
  }
463
488
  };
464
489
  }
465
- //#endregion
466
- //#region src/build/vite/plugin.ts
467
490
  const DEFAULT_EXTENSIONS = [
468
491
  ".ts",
469
492
  ".js",
@@ -482,6 +505,7 @@ function nitro(pluginConfig = {}) {
482
505
  nitroMain(ctx),
483
506
  nitroPrepare(ctx),
484
507
  nitroService(ctx),
508
+ nitroServiceProxy(),
485
509
  nitroPreviewPlugin(ctx),
486
510
  pluginConfig.experimental?.vite?.assetsImport !== false && assetsPlugin({ experimental: { clientBuildFallback: false } })
487
511
  ].filter(Boolean);
@@ -585,8 +609,14 @@ function nitroMain(ctx) {
585
609
  debug("[main] Generating manifest and entry points for environment:", environment.name);
586
610
  const isRegisteredService = Object.keys(ctx.services).includes(environment.name);
587
611
  let entryFile;
588
- for (const [_name, file] of Object.entries(bundle)) if (file.type === "chunk" && isRegisteredService && file.isEntry) if (entryFile === void 0) entryFile = file.fileName;
589
- else this.warn(`Multiple entry points found for service "${environment.name}"`);
612
+ const serviceEntry = isRegisteredService && ctx.services[environment.name]?.entry ? resolve$1(ctx.services[environment.name].entry) : void 0;
613
+ for (const [_name, file] of Object.entries(bundle)) if (file.type === "chunk" && isRegisteredService && file.isEntry) {
614
+ if (serviceEntry && file.facadeModuleId && resolve$1(file.facadeModuleId) === serviceEntry) {
615
+ entryFile = file.fileName;
616
+ break;
617
+ }
618
+ if (entryFile === void 0) entryFile = file.fileName;
619
+ }
590
620
  if (isRegisteredService) {
591
621
  if (entryFile === void 0) this.error(`No entry point found for service "${this.environment.name}".`);
592
622
  ctx._entryPoints[this.environment.name] = entryFile;
@@ -736,5 +766,4 @@ function getEntry(input) {
736
766
  function flattenPlugins(plugins) {
737
767
  return plugins.flatMap((plugin) => Array.isArray(plugin) ? flattenPlugins(plugin) : [plugin]).filter((p) => p && !(p instanceof Promise));
738
768
  }
739
- //#endregion
740
769
  export { nitro };
package/lib/tsconfig.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "ESNext",
4
+ "lib": ["ESNext", "DOM"],
4
5
  "module": "ESNext",
5
6
  "moduleResolution": "Bundler",
6
7
  "moduleDetection": "force",
@@ -13,15 +14,12 @@
13
14
  "noEmit": true,
14
15
  "skipLibCheck": true,
15
16
  "resolveJsonModule": true,
16
- "esModuleInterop": true,
17
17
  "allowSyntheticDefaultImports": true,
18
- "noUncheckedIndexedAccess": true,
19
18
  "noImplicitOverride": true,
19
+ "resolvePackageJsonImports": true,
20
20
 
21
21
  "forceConsistentCasingInFileNames": true,
22
22
  "noImplicitReturns": true,
23
- "noFallthroughCasesInSwitch": true,
24
- "useUnknownInCatchVariables": true,
25
- "noUnusedLocals": true
23
+ "noFallthroughCasesInSwitch": true
26
24
  }
27
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitro",
3
- "version": "3.0.260311-beta",
3
+ "version": "3.0.260415-beta",
4
4
  "description": "Build and Deploy Universal JavaScript Servers",
5
5
  "keywords": [
6
6
  "api-routes",
@@ -62,63 +62,63 @@
62
62
  "nitro": "node ./src/cli/index.ts",
63
63
  "release": "node ./scripts/release.js",
64
64
  "stub": "obuild --stub",
65
- "test": "pnpm lint && pnpm typecheck && pnpm test:rollup && pnpm test:rolldown",
65
+ "test": "pnpm lint && pnpm build && pnpm typecheck && pnpm test:rollup && pnpm test:rolldown",
66
66
  "test:rolldown": "NITRO_BUILDER=rolldown pnpm vitest",
67
67
  "test:rollup": "NITRO_BUILDER=rollup pnpm vitest",
68
68
  "typecheck": "tsgo --noEmit --skipLibCheck"
69
69
  },
70
70
  "dependencies": {
71
71
  "consola": "^3.4.2",
72
- "crossws": "^0.4.4",
72
+ "crossws": "^0.4.5",
73
73
  "db0": "^0.3.4",
74
- "env-runner": "^0.1.6",
75
- "h3": "^2.0.1-rc.16",
76
- "hookable": "^6.0.1",
77
- "nf3": "^0.3.11",
78
- "ocache": "^0.1.2",
74
+ "env-runner": "^0.1.7",
75
+ "h3": "^2.0.1-rc.20",
76
+ "hookable": "^6.1.1",
77
+ "nf3": "^0.3.16",
78
+ "ocache": "^0.1.4",
79
79
  "ofetch": "^2.0.0-alpha.3",
80
80
  "ohash": "^2.0.11",
81
- "rolldown": "^1.0.0-rc.8",
82
- "srvx": "^0.11.9",
81
+ "rolldown": "^1.0.0-rc.15",
82
+ "srvx": "^0.11.15",
83
83
  "unenv": "^2.0.0-rc.24",
84
- "unstorage": "^2.0.0-alpha.6"
84
+ "unstorage": "^2.0.0-alpha.7"
85
85
  },
86
86
  "devDependencies": {
87
87
  "@azure/functions": "^3.5.1",
88
88
  "@azure/static-web-apps-cli": "^2.0.8",
89
- "@cloudflare/workers-types": "^4.20260310.1",
89
+ "@cloudflare/workers-types": "^4.20260414.1",
90
90
  "@deno/types": "^0.0.1",
91
91
  "@hiogawa/vite-plugin-fullstack": "^0.0.11",
92
- "@netlify/edge-functions": "^3.0.3",
93
- "@netlify/functions": "^5.1.2",
92
+ "@netlify/edge-functions": "^3.0.6",
93
+ "@netlify/functions": "^5.2.0",
94
94
  "@rollup/plugin-alias": "^6.0.0",
95
95
  "@rollup/plugin-commonjs": "^29.0.2",
96
96
  "@rollup/plugin-inject": "^5.0.5",
97
97
  "@rollup/plugin-json": "^6.1.0",
98
98
  "@rollup/plugin-node-resolve": "^16.0.3",
99
99
  "@rollup/plugin-replace": "^6.0.3",
100
- "@scalar/api-reference": "^1.48.2",
100
+ "@scalar/api-reference": "^1.52.1",
101
101
  "@types/aws-lambda": "^8.10.161",
102
102
  "@types/estree": "^1.0.8",
103
103
  "@types/etag": "^1.8.4",
104
- "@types/fs-extra": "^11.0.4",
105
104
  "@types/http-proxy": "^1.17.17",
106
- "@types/node": "^25.4.0",
105
+ "@types/node": "^25.6.0",
107
106
  "@types/node-fetch": "^2.6.13",
108
107
  "@types/semver": "^7.7.1",
109
108
  "@types/xml2js": "^0.4.14",
110
- "@typescript/native-preview": "7.0.0-dev.20260310.1",
111
- "@vitest/coverage-v8": "^4.0.18",
109
+ "@typescript/native-preview": "^7.0.0-dev.20260414.1",
110
+ "@vercel/queue": "^0.1.6",
111
+ "@vitest/coverage-v8": "^4.1.4",
112
112
  "automd": "^0.4.3",
113
- "c12": "^4.0.0-beta.3",
113
+ "c12": "^4.0.0-beta.4",
114
114
  "changelogen": "^0.6.2",
115
115
  "chokidar": "^5.0.0",
116
- "citty": "^0.2.1",
116
+ "citty": "^0.2.2",
117
117
  "compatx": "^0.2.0",
118
118
  "confbox": "^0.2.4",
119
- "cookie-es": "^2.0.0",
119
+ "cookie-es": "^3.1.1",
120
120
  "croner": "^10.0.1",
121
- "defu": "^6.1.4",
121
+ "defu": "^6.1.7",
122
122
  "destr": "^2.0.5",
123
123
  "dot-prop": "^10.1.0",
124
124
  "edge-runtime": "^4.0.1",
@@ -127,64 +127,67 @@
127
127
  "execa": "^9.6.1",
128
128
  "expect-type": "^1.3.0",
129
129
  "exsolve": "^1.0.8",
130
- "fs-extra": "^11.3.4",
131
130
  "get-port-please": "^3.2.0",
132
- "giget": "^3.1.2",
131
+ "giget": "^3.2.0",
133
132
  "gzip-size": "^7.0.0",
134
- "httpxy": "^0.3.1",
133
+ "httpxy": "^0.5.0",
135
134
  "klona": "^2.0.6",
136
135
  "knitwork": "^1.3.0",
137
136
  "magic-string": "^0.30.21",
138
- "mdzilla": "^0.0.5",
137
+ "mdzilla": "^0.2.1",
139
138
  "mime": "^4.1.0",
140
- "miniflare": "^4.20260305.0",
141
- "mlly": "^1.8.1",
139
+ "miniflare": "^4.20260410.0",
140
+ "mlly": "^1.8.2",
142
141
  "nypm": "^0.6.5",
143
- "obuild": "^0.4.32",
144
- "oxfmt": "^0.37.0",
145
- "oxlint": "^1.52.0",
142
+ "obuild": "^0.4.33",
143
+ "oxfmt": "^0.45.0",
144
+ "oxlint": "^1.60.0",
146
145
  "pathe": "^2.0.3",
147
146
  "perfect-debounce": "^2.1.0",
148
147
  "pkg-types": "^2.3.0",
149
148
  "pretty-bytes": "^7.1.0",
150
- "react": "^19.2.4",
151
- "rendu": "^0.0.7",
152
- "rollup": "^4.59.0",
149
+ "react": "^19.2.5",
150
+ "rendu": "^0.1.0",
151
+ "rollup": "^4.60.1",
153
152
  "rou3": "^0.8.1",
154
153
  "scule": "^1.3.0",
155
154
  "semver": "^7.7.4",
156
155
  "serve-placeholder": "^2.0.2",
157
156
  "source-map": "^0.7.6",
158
- "std-env": "^4.0.0",
159
- "tinyglobby": "^0.2.15",
157
+ "std-env": "^4.1.0",
158
+ "tinyglobby": "^0.2.16",
160
159
  "tsconfck": "^3.1.6",
161
- "typescript": "^5.9.3",
160
+ "typescript": "^6.0.2",
162
161
  "ufo": "^1.6.3",
163
162
  "ultrahtml": "^1.6.0",
164
163
  "uncrypto": "^0.1.3",
165
164
  "unctx": "^2.5.0",
166
- "unimport": "^6.0.1",
165
+ "unimport": "^6.1.0",
167
166
  "untyped": "^2.0.0",
168
167
  "unwasm": "^0.5.3",
169
- "vite": "^8.0.0-beta.18",
170
- "vite7": "npm:vite@^7.3.1",
171
- "vitest": "^4.0.18",
172
- "wrangler": "^4.71.0",
168
+ "vite": "^8.0.8",
169
+ "vite7": "npm:vite@^7.3.2",
170
+ "vitest": "^4.1.4",
171
+ "wrangler": "^4.82.2",
173
172
  "xml2js": "^0.6.2",
174
- "youch": "^4.1.0",
173
+ "youch": "^4.1.1",
175
174
  "youch-core": "^0.3.3",
176
- "zephyr-agent": "^0.1.15"
175
+ "zephyr-agent": "^1.0.1"
177
176
  },
178
177
  "peerDependencies": {
178
+ "@vercel/queue": "^0.1.4",
179
179
  "dotenv": "*",
180
180
  "giget": "*",
181
181
  "jiti": "^2.6.1",
182
- "rollup": "^4.59.0",
183
- "vite": "^7 || ^8 || >=8.0.0-0",
182
+ "rollup": "^4.60.1",
183
+ "vite": "^7 || ^8",
184
184
  "xml2js": "^0.6.2",
185
- "zephyr-agent": "^0.1.15"
185
+ "zephyr-agent": "^0.2.0"
186
186
  },
187
187
  "peerDependenciesMeta": {
188
+ "@vercel/queue": {
189
+ "optional": true
190
+ },
188
191
  "dotenv": {
189
192
  "optional": true
190
193
  },
@@ -208,19 +211,18 @@
208
211
  }
209
212
  },
210
213
  "resolutions": {
211
- "nitro": "link:.",
212
- "rolldown": "^1.0.0-rc.8",
213
- "vite": "^8.0.0-beta.18"
214
+ "cookie-es": "^3.1.1",
215
+ "nitro": "link:."
214
216
  },
215
217
  "engines": {
216
218
  "node": "^20.19.0 || >=22.12.0"
217
219
  },
218
- "packageManager": "pnpm@10.32.0",
220
+ "packageManager": "pnpm@10.33.0",
219
221
  "compatiblePackages": {
220
222
  "schemaVersion": 1,
221
223
  "vite": {
222
224
  "type": "compatible",
223
- "versions": "^7 || ^8 || >=8.0.0-0"
225
+ "versions": "^7 || ^8"
224
226
  },
225
227
  "rollup": {
226
228
  "type": "compatible",
@@ -228,7 +230,7 @@
228
230
  },
229
231
  "rolldown": {
230
232
  "type": "compatible",
231
- "versions": ">=1.0.0-beta.0"
233
+ "versions": ">=1.0.0-rc.0"
232
234
  }
233
235
  }
234
236
  }
@@ -1,10 +0,0 @@
1
- ---
2
- name: nitro
3
- description: Build and deploy universal JavaScript servers with Nitro
4
- ---
5
-
6
- @docs/TOC.md
7
-
8
- You can use `npx nitro docs [--page <path>] [...args]` to explore the documentation locally.
9
- For example, `npx nitro docs --page /docs/routing` will open the routing page of the guide section.
10
- If not available, fallback to https://nitro.build/llms.txt
@@ -1,83 +0,0 @@
1
- # Nitro Documentation
2
-
3
- - [Docs](./docs/index.md)
4
- - [Introduction](./docs/index.md)
5
- - [Quick Start](./docs/quick-start.md)
6
- - [Renderer](./docs/renderer.md)
7
- - [Routing](./docs/routing.md)
8
- - [Server Entry](./docs/server-entry.md)
9
- - [Cache](./docs/cache.md)
10
- - [KV Storage](./docs/storage.md)
11
- - [Assets](./docs/assets.md)
12
- - [Configuration](./docs/configuration.md)
13
- - [Database](./docs/database.md)
14
- - [Lifecycle](./docs/lifecycle.md)
15
- - [Plugins](./docs/plugins.md)
16
- - [Tasks](./docs/tasks.md)
17
- - [Migration Guide](./docs/migration.md)
18
- - [Nightly Channel](./docs/nightly.md)
19
- - [Deploy](./deploy/index.md)
20
- - [Deploy](./deploy/index.md)
21
- - [Node.js](./deploy/runtimes/node.md)
22
- - [Bun](./deploy/runtimes/bun.md)
23
- - [Deno](./deploy/runtimes/deno.md)
24
- - [Alwaysdata](./deploy/providers/alwaysdata.md)
25
- - [AWS Lambda](./deploy/providers/aws.md)
26
- - [AWS Amplify](./deploy/providers/aws-amplify.md)
27
- - [Azure](./deploy/providers/azure.md)
28
- - [Cleavr](./deploy/providers/cleavr.md)
29
- - [Cloudflare](./deploy/providers/cloudflare.md)
30
- - [Deno Deploy](./deploy/providers/deno-deploy.md)
31
- - [DigitalOcean](./deploy/providers/digitalocean.md)
32
- - [Firebase](./deploy/providers/firebase.md)
33
- - [Flightcontrol](./deploy/providers/flightcontrol.md)
34
- - [Genezio](./deploy/providers/genezio.md)
35
- - [GitHub Pages](./deploy/providers/github-pages.md)
36
- - [GitLab Pages](./deploy/providers/gitlab-pages.md)
37
- - [Heroku](./deploy/providers/heroku.md)
38
- - [IIS](./deploy/providers/iis.md)
39
- - [Koyeb](./deploy/providers/koyeb.md)
40
- - [Netlify](./deploy/providers/netlify.md)
41
- - [Platform.sh](./deploy/providers/platform-sh.md)
42
- - [Render.com](./deploy/providers/render.md)
43
- - [StormKit](./deploy/providers/stormkit.md)
44
- - [Vercel](./deploy/providers/vercel.md)
45
- - [Zeabur](./deploy/providers/zeabur.md)
46
- - [Zephyr Cloud](./deploy/providers/zephyr.md)
47
- - [Zerops](./deploy/providers/zerops.md)
48
- - [Config](./config/index.md)
49
- - [Config](./config/index.md)
50
- - [Examples](./examples/index.md)
51
- - [Examples](./examples/index.md)
52
- - [API Routes](./examples/api-routes.md)
53
- - [Auto Imports](./examples/auto-imports.md)
54
- - [Cached Handler](./examples/cached-handler.md)
55
- - [Custom Error Handler](./examples/custom-error-handler.md)
56
- - [Database](./examples/database.md)
57
- - [Elysia](./examples/elysia.md)
58
- - [Express](./examples/express.md)
59
- - [Fastify](./examples/fastify.md)
60
- - [Hello World](./examples/hello-world.md)
61
- - [Hono](./examples/hono.md)
62
- - [Import Alias](./examples/import-alias.md)
63
- - [Middleware](./examples/middleware.md)
64
- - [Mono JSX](./examples/mono-jsx.md)
65
- - [Nano JSX](./examples/nano-jsx.md)
66
- - [Plugins](./examples/plugins.md)
67
- - [Custom Renderer](./examples/renderer.md)
68
- - [Runtime Config](./examples/runtime-config.md)
69
- - [Server Fetch](./examples/server-fetch.md)
70
- - [Shiki](./examples/shiki.md)
71
- - [Virtual Routes](./examples/virtual-routes.md)
72
- - [Vite Nitro Plugin](./examples/vite-nitro-plugin.md)
73
- - [Vite RSC](./examples/vite-rsc.md)
74
- - [Vite SSR HTML](./examples/vite-ssr-html.md)
75
- - [SSR with Preact](./examples/vite-ssr-preact.md)
76
- - [SSR with React](./examples/vite-ssr-react.md)
77
- - [SSR with SolidJS](./examples/vite-ssr-solid.md)
78
- - [SSR with TanStack Router](./examples/vite-ssr-tsr-react.md)
79
- - [SSR with TanStack Start](./examples/vite-ssr-tss-react.md)
80
- - [SSR with Vue Router](./examples/vite-ssr-vue-router.md)
81
- - [Vite + tRPC](./examples/vite-trpc.md)
82
- - [WebSocket](./examples/websocket.md)
83
- - [Index](./index.md)