nitro-nightly 3.0.1-20251104-010441-737f4e6e → 3.0.1-20251104-223815-3402cc78

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 (71) hide show
  1. package/dist/_build/common.mjs +5 -6
  2. package/dist/_build/rolldown.mjs +3 -4
  3. package/dist/_build/rollup.mjs +3 -4
  4. package/dist/_build/vite.build.mjs +3 -17
  5. package/dist/_build/vite.plugin.mjs +24 -24
  6. package/dist/_chunks/{DPnDpScB.mjs → 4aR05Iov.mjs} +1 -1
  7. package/dist/_chunks/{DnETaDxL.mjs → Bm-nZkJm.mjs} +1 -1
  8. package/dist/_chunks/{DXMHy5ca.mjs → Bqks5huO.mjs} +1 -13
  9. package/dist/_chunks/{vJX08MVt.mjs → nW-_zcmc.mjs} +36 -11
  10. package/dist/_dev.mjs +54 -11
  11. package/dist/_libs/c12.mjs +1 -1
  12. package/dist/_libs/commondir.mjs +1 -1
  13. package/dist/_libs/deepmerge.mjs +1 -1
  14. package/dist/_libs/duplexer.mjs +1 -1
  15. package/dist/_libs/etag.mjs +1 -1
  16. package/dist/_libs/function-bind.mjs +1 -1
  17. package/dist/_libs/giget.mjs +3 -3
  18. package/dist/_libs/gzip-size.mjs +1 -1
  19. package/dist/_libs/hasown.mjs +1 -1
  20. package/dist/_libs/is-core-module.mjs +1 -1
  21. package/dist/_libs/is-module.mjs +1 -1
  22. package/dist/_libs/is-reference.mjs +1 -1
  23. package/dist/_libs/js-tokens.mjs +1 -1
  24. package/dist/_libs/node-fetch-native.mjs +1 -1
  25. package/dist/_libs/path-parse.mjs +1 -1
  26. package/dist/_libs/picomatch.mjs +1 -1
  27. package/dist/_libs/plugin-commonjs.mjs +1 -1
  28. package/dist/_libs/plugin-node-resolve.mjs +1 -1
  29. package/dist/_libs/strip-literal.mjs +1 -1
  30. package/dist/_libs/tinyglobby.mjs +1 -1
  31. package/dist/_libs/unimport.mjs +1 -1
  32. package/dist/builder.mjs +2 -17
  33. package/dist/cli/_chunks/dev.mjs +1 -15
  34. package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +2 -2
  35. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +4 -2
  36. package/dist/presets/azure/runtime/azure-swa.mjs +2 -1
  37. package/dist/runtime/index.d.mts +1 -1
  38. package/dist/runtime/index.mjs +1 -1
  39. package/dist/runtime/internal/app.d.mts +7 -0
  40. package/dist/runtime/internal/app.mjs +22 -18
  41. package/dist/runtime/internal/cache.mjs +4 -4
  42. package/dist/runtime/internal/error/hooks.mjs +1 -1
  43. package/dist/runtime/internal/routes/dev-tasks.mjs +1 -1
  44. package/dist/runtime/internal/routes/renderer-template.dev.mjs +5 -1
  45. package/dist/runtime/internal/vite/dev-worker.mjs +4 -57
  46. package/dist/runtime/internal/vite/ssr-renderer.mjs +3 -1
  47. package/dist/runtime/nitro.d.mts +11 -0
  48. package/dist/runtime/nitro.mjs +31 -0
  49. package/dist/runtime/vite.d.mts +8 -0
  50. package/dist/runtime/vite.mjs +9 -0
  51. package/dist/types/index.d.mts +4 -5
  52. package/dist/vite.mjs +3 -17
  53. package/lib/config.mjs +1 -1
  54. package/package.json +3 -5
  55. package/dist/_libs/debug.mjs +0 -848
  56. package/dist/_libs/depd.mjs +0 -314
  57. package/dist/_libs/ee-first.mjs +0 -68
  58. package/dist/_libs/encodeurl.mjs +0 -49
  59. package/dist/_libs/escape-html.mjs +0 -58
  60. package/dist/_libs/fresh.mjs +0 -85
  61. package/dist/_libs/http-errors.mjs +0 -436
  62. package/dist/_libs/mime-db.mjs +0 -7642
  63. package/dist/_libs/mime-types.mjs +0 -162
  64. package/dist/_libs/on-finished.mjs +0 -170
  65. package/dist/_libs/parseurl.mjs +0 -103
  66. package/dist/_libs/range-parser.mjs +0 -102
  67. package/dist/_libs/send.mjs +0 -857
  68. package/dist/_libs/serve-static.mjs +0 -124
  69. package/dist/runtime/internal/vite/prod-setup.mjs +0 -53
  70. package/lib/index.d.mts +0 -1
  71. package/lib/index.mjs +0 -1
@@ -1,13 +1,13 @@
1
- import { s as __toESM } from "../_chunks/DXMHy5ca.mjs";
1
+ import { i as __toESM } from "../_chunks/Bqks5huO.mjs";
2
2
  import { T as resolve$1, _ as dirname$1, b as join$1, v as extname$1, w as relative$1 } from "../_libs/c12.mjs";
3
3
  import { i as unplugin } from "../_libs/unimport.mjs";
4
4
  import { t as glob } from "../_libs/tinyglobby.mjs";
5
- import { u as writeFile$1 } from "../_chunks/DnETaDxL.mjs";
5
+ import { u as writeFile$1 } from "../_chunks/Bm-nZkJm.mjs";
6
6
  import { t as src_default } from "../_libs/mime.mjs";
7
7
  import { i as genSafeVariableName, t as genImport } from "../_libs/knitwork.mjs";
8
- import { t as require_etag } from "../_libs/etag.mjs";
9
8
  import { t as replace } from "../_libs/plugin-replace.mjs";
10
9
  import { t as rollup } from "../_libs/unwasm.mjs";
10
+ import { t as require_etag } from "../_libs/etag.mjs";
11
11
  import { dirname } from "node:path";
12
12
  import { camelCase } from "scule";
13
13
  import { promises } from "node:fs";
@@ -75,7 +75,6 @@ function baseBuildConfig(nitro) {
75
75
  _websocket: nitro.options.experimental.websocket,
76
76
  _tasks: nitro.options.experimental.tasks
77
77
  };
78
- const replaceDelimiters = [String.raw`\b`, String.raw`(?![\w.$])`];
79
78
  const replacements = {
80
79
  "typeof window": "\"undefined\"",
81
80
  _import_meta_url_: "import.meta.url",
@@ -101,7 +100,6 @@ function baseBuildConfig(nitro) {
101
100
  isNodeless,
102
101
  buildEnvVars,
103
102
  staticFlags,
104
- replaceDelimiters,
105
103
  replacements,
106
104
  env,
107
105
  aliases: resolveAliases({
@@ -627,8 +625,9 @@ function rendererTemplate(nitro) {
627
625
  const html = await readFile(nitro.options.renderer?.template, "utf8");
628
626
  if (hasTemplateSyntax(html)) return `
629
627
  import { renderToResponse } from 'rendu'
628
+ import { serverFetch } from 'nitro/runtime'
630
629
  const template = ${compileTemplateToString(html, { contextKeys: [...RENDER_CONTEXT_KEYS] })};
631
- export const rendererTemplate = (request) => renderToResponse(template, { request })
630
+ export const rendererTemplate = (request) => renderToResponse(template, { request, context: { serverFetch } })
632
631
  `;
633
632
  else return `
634
633
  import { HTTPResponse } from "h3";
@@ -14,20 +14,20 @@ import { t as formatCompatibilityDate } from "../_libs/compatx.mjs";
14
14
  import "../_libs/klona.mjs";
15
15
  import "../_libs/std-env.mjs";
16
16
  import "../_libs/dot-prop.mjs";
17
- import { n as writeTypes, o as scanHandlers } from "../_chunks/DnETaDxL.mjs";
17
+ import { n as writeTypes, o as scanHandlers } from "../_chunks/Bm-nZkJm.mjs";
18
18
  import "../_libs/mime.mjs";
19
19
  import "../_libs/pathe.mjs";
20
20
  import "../_libs/untyped.mjs";
21
21
  import "../_libs/knitwork.mjs";
22
22
  import { i as watch$1 } from "../_libs/chokidar.mjs";
23
- import "../_libs/etag.mjs";
24
23
  import "../_libs/estree-walker.mjs";
25
24
  import "../_libs/plugin-commonjs.mjs";
26
25
  import "../_libs/plugin-replace.mjs";
27
26
  import { i as replace, n as baseBuildPlugins, r as baseBuildConfig, t as writeBuildInfo } from "./common.mjs";
28
27
  import "../_libs/remapping.mjs";
29
28
  import "../_libs/unwasm.mjs";
30
- import { i as raw, n as generateFSTree, r as nitroServerName, t as snapshot } from "../_chunks/DPnDpScB.mjs";
29
+ import "../_libs/etag.mjs";
30
+ import { i as raw, n as generateFSTree, r as nitroServerName, t as snapshot } from "../_chunks/4aR05Iov.mjs";
31
31
  import "../_libs/duplexer.mjs";
32
32
  import "../_libs/gzip-size.mjs";
33
33
  import "../_libs/pretty-bytes.mjs";
@@ -59,7 +59,6 @@ const getRolldownConfig = (nitro) => {
59
59
  plugins: [
60
60
  ...baseBuildPlugins(nitro, base),
61
61
  replace({
62
- delimiters: base.replaceDelimiters,
63
62
  preventAssignment: true,
64
63
  values: base.replacements
65
64
  }),
@@ -14,13 +14,12 @@ import { t as formatCompatibilityDate } from "../_libs/compatx.mjs";
14
14
  import "../_libs/klona.mjs";
15
15
  import "../_libs/std-env.mjs";
16
16
  import "../_libs/dot-prop.mjs";
17
- import { n as writeTypes, o as scanHandlers } from "../_chunks/DnETaDxL.mjs";
17
+ import { n as writeTypes, o as scanHandlers } from "../_chunks/Bm-nZkJm.mjs";
18
18
  import "../_libs/mime.mjs";
19
19
  import "../_libs/pathe.mjs";
20
20
  import "../_libs/untyped.mjs";
21
21
  import "../_libs/knitwork.mjs";
22
22
  import { i as watch$1 } from "../_libs/chokidar.mjs";
23
- import "../_libs/etag.mjs";
24
23
  import { t as alias } from "../_libs/plugin-alias.mjs";
25
24
  import "../_libs/estree-walker.mjs";
26
25
  import { t as commonjs } from "../_libs/plugin-commonjs.mjs";
@@ -29,7 +28,8 @@ import "../_libs/plugin-replace.mjs";
29
28
  import { i as replace, n as baseBuildPlugins, r as baseBuildConfig, t as writeBuildInfo } from "./common.mjs";
30
29
  import "../_libs/remapping.mjs";
31
30
  import "../_libs/unwasm.mjs";
32
- import { i as raw, n as generateFSTree, r as nitroServerName, t as snapshot } from "../_chunks/DPnDpScB.mjs";
31
+ import "../_libs/etag.mjs";
32
+ import { i as raw, n as generateFSTree, r as nitroServerName, t as snapshot } from "../_chunks/4aR05Iov.mjs";
33
33
  import "../_libs/duplexer.mjs";
34
34
  import "../_libs/gzip-size.mjs";
35
35
  import "../_libs/pretty-bytes.mjs";
@@ -155,7 +155,6 @@ const getRollupConfig = (nitro) => {
155
155
  }),
156
156
  alias({ entries: base.aliases }),
157
157
  replace({
158
- delimiters: base.replaceDelimiters,
159
158
  preventAssignment: true,
160
159
  values: base.replacements
161
160
  }),
@@ -13,10 +13,10 @@ import "../_libs/tinyglobby.mjs";
13
13
  import "../_libs/compatx.mjs";
14
14
  import "../_libs/klona.mjs";
15
15
  import { n as a } from "../_libs/std-env.mjs";
16
- import "../_chunks/vJX08MVt.mjs";
16
+ import "../_chunks/nW-_zcmc.mjs";
17
17
  import "../_libs/escape-string-regexp.mjs";
18
18
  import "../_libs/dot-prop.mjs";
19
- import "../_chunks/DnETaDxL.mjs";
19
+ import "../_chunks/Bm-nZkJm.mjs";
20
20
  import "../_libs/rou3.mjs";
21
21
  import "../_libs/mime.mjs";
22
22
  import "../_libs/pathe.mjs";
@@ -25,21 +25,6 @@ import "../_libs/knitwork.mjs";
25
25
  import "../_libs/httpxy.mjs";
26
26
  import "../_dev.mjs";
27
27
  import "../_libs/chokidar.mjs";
28
- import "../_libs/encodeurl.mjs";
29
- import "../_libs/escape-html.mjs";
30
- import "../_libs/parseurl.mjs";
31
- import "../_libs/depd.mjs";
32
- import "../_libs/http-errors.mjs";
33
- import "../_libs/debug.mjs";
34
- import "../_libs/etag.mjs";
35
- import "../_libs/fresh.mjs";
36
- import "../_libs/mime-db.mjs";
37
- import "../_libs/mime-types.mjs";
38
- import "../_libs/ee-first.mjs";
39
- import "../_libs/on-finished.mjs";
40
- import "../_libs/range-parser.mjs";
41
- import "../_libs/send.mjs";
42
- import "../_libs/serve-static.mjs";
43
28
  import "../_libs/ultrahtml.mjs";
44
29
  import "../_libs/plugin-alias.mjs";
45
30
  import "../_libs/estree-walker.mjs";
@@ -49,6 +34,7 @@ import "../_libs/plugin-replace.mjs";
49
34
  import "./common.mjs";
50
35
  import "../_libs/remapping.mjs";
51
36
  import "../_libs/unwasm.mjs";
37
+ import "../_libs/etag.mjs";
52
38
  import { t as nitro } from "./vite.plugin.mjs";
53
39
  import "../_libs/vite-plugin-fullstack.mjs";
54
40
 
@@ -2,8 +2,8 @@ import { T as resolve$1, _ as dirname$1, b as join$1, f as resolveModulePath, g
2
2
  import { f as sanitizeFilePath } from "../_libs/local-pkg.mjs";
3
3
  import { t as formatCompatibilityDate } from "../_libs/compatx.mjs";
4
4
  import { n as a, t as T } from "../_libs/std-env.mjs";
5
- import { a as createNitro, n as prepare, r as copyPublicAssets } from "../_chunks/vJX08MVt.mjs";
6
- import { c as prettyPath, o as scanHandlers } from "../_chunks/DnETaDxL.mjs";
5
+ import { a as createNitro, n as prepare, r as copyPublicAssets } from "../_chunks/nW-_zcmc.mjs";
6
+ import { c as prettyPath, o as scanHandlers } from "../_chunks/Bm-nZkJm.mjs";
7
7
  import { t as createProxyServer } from "../_libs/httpxy.mjs";
8
8
  import { i as NodeDevWorker, r as NitroDevApp } from "../_dev.mjs";
9
9
  import { i as watch$1 } from "../_libs/chokidar.mjs";
@@ -59,7 +59,6 @@ const getViteRollupConfig = (ctx) => {
59
59
  ...baseBuildPlugins(nitro$1, base),
60
60
  alias({ entries: base.aliases }),
61
61
  replace({
62
- delimiters: base.replaceDelimiters,
63
62
  preventAssignment: true,
64
63
  values: base.replacements
65
64
  }),
@@ -171,7 +170,7 @@ async function buildEnvironments(ctx, builder) {
171
170
  if (nitroOptions.renderer?.template && nitroOptions.renderer?.template === clientInput) {
172
171
  const outputPath = resolve$1(nitroOptions.output.publicDir, basename$1(clientInput));
173
172
  if (existsSync(outputPath)) {
174
- const html = await readFile(outputPath, "utf8").then((r) => r.replace("<!--ssr-outlet-->", `{{{ fetch($REQUEST, { viteEnv: "ssr" }) }}}`));
173
+ const html = await readFile(outputPath, "utf8").then((r) => r.replace("<!--ssr-outlet-->", `{{{ globalThis.__nitro_vite_envs__?.["ssr"]?.fetch($REQUEST) || "" }}}`));
175
174
  await rm(outputPath);
176
175
  const tmp = resolve$1(nitroOptions.buildDir, "vite/index.html");
177
176
  await mkdir(dirname$1(tmp), { recursive: true });
@@ -198,15 +197,7 @@ async function buildEnvironments(ctx, builder) {
198
197
  }
199
198
  function prodSetup(ctx) {
200
199
  const services = ctx.pluginConfig.services || {};
201
- const serviceEntries = Object.keys(services).map((name) => {
202
- let entry;
203
- if (ctx.pluginConfig.experimental?.virtualBundle) entry = ctx._entryPoints[name];
204
- else entry = resolve$1(ctx.nitro.options.buildDir, "vite/services", name, ctx._entryPoints[name]);
205
- return [name, entry];
206
- });
207
200
  return `
208
- import { setupVite } from "${resolve$1(runtimeDir, "internal/vite/prod-setup.mjs")}";
209
-
210
201
  function lazyService(loader) {
211
202
  let promise, mod
212
203
  return {
@@ -221,10 +212,15 @@ function lazyService(loader) {
221
212
  }
222
213
 
223
214
  const services = {
224
- ${serviceEntries.map(([name, entry]) => `[${JSON.stringify(name)}]: lazyService(() => import(${JSON.stringify(entry)}))`).join(",\n")}
215
+ ${Object.keys(services).map((name) => {
216
+ let entry;
217
+ if (ctx.pluginConfig.experimental?.virtualBundle) entry = ctx._entryPoints[name];
218
+ else entry = resolve$1(ctx.nitro.options.buildDir, "vite/services", name, ctx._entryPoints[name]);
219
+ return [name, entry];
220
+ }).map(([name, entry]) => `[${JSON.stringify(name)}]: lazyService(() => import(${JSON.stringify(entry)}))`).join(",\n")}
225
221
  };
226
222
 
227
- setupVite({ services });
223
+ globalThis.__nitro_vite_envs__ = services;
228
224
  `;
229
225
  }
230
226
 
@@ -321,7 +317,7 @@ async function configureViteDevServer(ctx, server) {
321
317
  rootDirWatcher.close();
322
318
  });
323
319
  const hostIPC = { async transformHTML(html) {
324
- return server.transformIndexHtml("/", html).then((r) => r.replace("<!--ssr-outlet-->", `{{{ fetch($REQUEST, { viteEnv: "ssr" }) }}}`));
320
+ return server.transformIndexHtml("/", html).then((r) => r.replace("<!--ssr-outlet-->", `{{{ globalThis.__nitro_vite_envs__?.["ssr"]?.fetch($REQUEST) || "" }}}`));
325
321
  } };
326
322
  nitroEnv$1.devServer.onMessage(async (payload) => {
327
323
  if (payload.type === "custom" && payload.event === "nitro:vite-invoke") {
@@ -627,18 +623,19 @@ function nitroMain(ctx) {
627
623
  debug("[main] Configuring dev server");
628
624
  return configureViteDevServer(ctx, server);
629
625
  },
630
- hotUpdate(options) {
631
- if (this.environment.name === "client" || ctx.pluginConfig.experimental?.serverReload === false) return;
626
+ async hotUpdate({ server, modules, timestamp }) {
627
+ const env = this.environment;
628
+ if (ctx.pluginConfig.experimental?.serverReload === false || env.config.consumer === "client") return;
629
+ const clientEnvs = Object.values(server.environments).filter((env$1) => env$1.config.consumer === "client");
632
630
  let hasServerOnlyModule = false;
633
631
  const invalidated = /* @__PURE__ */ new Set();
634
- for (const mod of options.modules) {
635
- if (!mod.id) continue;
636
- if (options.server.environments.client.moduleGraph.getModuleById(mod.id)) continue;
637
- this.environment.moduleGraph.invalidateModule(mod, invalidated, options.timestamp, false);
632
+ for (const mod of modules) if (mod.id && !clientEnvs.some((env$1) => env$1.moduleGraph.getModuleById(mod.id))) {
638
633
  hasServerOnlyModule = true;
634
+ env.moduleGraph.invalidateModule(mod, invalidated, timestamp, false);
639
635
  }
640
636
  if (hasServerOnlyModule) {
641
- options.server.ws.send({ type: "full-reload" });
637
+ env.hot.send({ type: "full-reload" });
638
+ server.ws.send({ type: "full-reload" });
642
639
  return [];
643
640
  }
644
641
  }
@@ -689,7 +686,7 @@ function useNitro(ctx) {
689
686
  }
690
687
  async function setupNitroContext(ctx, configEnv, userConfig) {
691
688
  const nitroConfig = {
692
- dev: configEnv.mode === "development",
689
+ dev: configEnv.command === "serve",
693
690
  rootDir: userConfig.root,
694
691
  ...defu(ctx.pluginConfig.config, userConfig.nitro)
695
692
  };
@@ -746,7 +743,10 @@ async function setupNitroContext(ctx, configEnv, userConfig) {
746
743
  await ctx.nitro.hooks.callHook("build:before", ctx.nitro);
747
744
  ctx.rollupConfig = await getViteRollupConfig(ctx);
748
745
  await ctx.nitro.hooks.callHook("rollup:before", ctx.nitro, ctx.rollupConfig.config);
749
- if (ctx.nitro.options.dev && !ctx.devWorker) ctx.devWorker = createDevWorker(ctx);
746
+ if (ctx.nitro.options.dev && !ctx.devWorker) {
747
+ ctx.devWorker = createDevWorker(ctx);
748
+ ctx.nitro.fetch = (req) => ctx.devWorker.fetch(req);
749
+ }
750
750
  if (ctx.nitro.options.dev && !ctx.devApp) ctx.devApp = new NitroDevApp(ctx.nitro);
751
751
  }
752
752
  function getEntry(input) {
@@ -1,7 +1,7 @@
1
1
  import { T as resolve, _ as dirname, b as join, v as extname, w as relative } from "../_libs/c12.mjs";
2
2
  import { t as glob } from "../_libs/tinyglobby.mjs";
3
3
  import { n as a } from "../_libs/std-env.mjs";
4
- import { i as snapshotStorage, t as runParallel } from "./DnETaDxL.mjs";
4
+ import { i as snapshotStorage, t as runParallel } from "./Bm-nZkJm.mjs";
5
5
  import { t as src_default } from "../_libs/mime.mjs";
6
6
  import { t as gzipSize } from "../_libs/gzip-size.mjs";
7
7
  import { t as prettyBytes } from "../_libs/pretty-bytes.mjs";
@@ -1,4 +1,4 @@
1
- import { s as __toESM } from "./DXMHy5ca.mjs";
1
+ import { i as __toESM } from "./Bqks5huO.mjs";
2
2
  import { T as resolve, _ as dirname, b as join, f as resolveModulePath, w as relative, y as isAbsolute } from "../_libs/c12.mjs";
3
3
  import { c as parseNodeModulePath, s as lookupNodeModuleSubpath } from "../_libs/local-pkg.mjs";
4
4
  import { s as toExports } from "../_libs/unimport.mjs";
@@ -7,20 +7,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
7
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
8
  var __getProtoOf = Object.getPrototypeOf;
9
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __esm = (fn, res) => function() {
11
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
12
- };
13
10
  var __commonJS = (cb, mod) => function() {
14
11
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
12
  };
16
- var __export = (all) => {
17
- let target = {};
18
- for (var name in all) __defProp(target, name, {
19
- get: all[name],
20
- enumerable: true
21
- });
22
- return target;
23
- };
24
13
  var __copyProps = (to, from, except, desc) => {
25
14
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
26
15
  key = keys[i];
@@ -35,9 +24,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
35
24
  value: mod,
36
25
  enumerable: true
37
26
  }) : target, mod));
38
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
39
27
  var __toDynamicImportESM = (isNodeMode) => (mod) => __toESM(mod.default, isNodeMode);
40
28
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
41
29
 
42
30
  //#endregion
43
- export { __toCommonJS as a, __require as i, __esm as n, __toDynamicImportESM as o, __export as r, __toESM as s, __commonJS as t };
31
+ export { __toESM as i, __require as n, __toDynamicImportESM as r, __commonJS as t };
@@ -1,4 +1,4 @@
1
- import { s as __toESM } from "./DXMHy5ca.mjs";
1
+ import { i as __toESM } from "./Bqks5huO.mjs";
2
2
  import { T as resolve, b as join, f as resolveModulePath, o as findWorkspaceDir, r as loadConfig, t as watchConfig, w as relative, x as normalize } from "../_libs/c12.mjs";
3
3
  import { d as resolveModuleExportNames } from "../_libs/local-pkg.mjs";
4
4
  import { o as createUnimport } from "../_libs/unimport.mjs";
@@ -7,7 +7,7 @@ import { n as resolveCompatibilityDates, r as resolveCompatibilityDatesFromEnv }
7
7
  import { n as klona } from "../_libs/klona.mjs";
8
8
  import { n as a, r as d } from "../_libs/std-env.mjs";
9
9
  import { t as escapeStringRegexp } from "../_libs/escape-string-regexp.mjs";
10
- import { a as scanAndSyncOptions, c as prettyPath, l as resolveNitroPath, o as scanHandlers, r as createStorage, s as isDirectory, t as runParallel, u as writeFile$1 } from "./DnETaDxL.mjs";
10
+ import { a as scanAndSyncOptions, c as prettyPath, l as resolveNitroPath, o as scanHandlers, r as createStorage, s as isDirectory, t as runParallel, u as writeFile$1 } from "./Bm-nZkJm.mjs";
11
11
  import { a as findRoute, i as findAllRoutes, n as addRoute, r as createRouter, t as compileRouterToString } from "../_libs/rou3.mjs";
12
12
  import { t as src_default } from "../_libs/mime.mjs";
13
13
  import { n as z, t as P } from "../_libs/ultrahtml.mjs";
@@ -17,13 +17,13 @@ import { existsSync, promises } from "node:fs";
17
17
  import { joinURL, parseURL, withBase, withLeadingSlash, withTrailingSlash, withoutBase, withoutTrailingSlash } from "ufo";
18
18
  import { pathToFileURL } from "node:url";
19
19
  import fsp, { readFile } from "node:fs/promises";
20
- import { createJiti } from "jiti";
21
20
  import { defu } from "defu";
22
21
  import { pkgDir, runtimeDir } from "nitro/runtime/meta";
23
22
  import { colors } from "consola/utils";
24
23
  import { ofetch } from "ofetch";
25
24
  import { hash } from "ohash";
26
25
  import zlib from "node:zlib";
26
+ import { toRequest } from "h3";
27
27
 
28
28
  //#region src/config/defaults.ts
29
29
  const NitroDefaults = {
@@ -693,11 +693,8 @@ async function installModules(nitro) {
693
693
  async function _resolveNitroModule(mod, nitroOptions) {
694
694
  let _url;
695
695
  if (typeof mod === "string") {
696
- globalThis.defineNitroModule = globalThis.defineNitroModule || ((mod$1) => mod$1);
697
- const jiti = createJiti(nitroOptions.rootDir, { alias: nitroOptions.alias });
698
- const _modPath = jiti.esmResolve(mod);
699
- _url = _modPath;
700
- mod = await jiti.import(_modPath, { default: true });
696
+ _url = pathToFileURL(resolveNitroPath(mod, nitroOptions)).href;
697
+ mod = (await import(_url)).then((m) => m.default || m);
701
698
  }
702
699
  if (typeof mod === "function") mod = { setup: mod };
703
700
  if ("nitro" in mod) mod = mod.nitro;
@@ -894,6 +891,29 @@ function mergeCatchAll(router) {
894
891
  });
895
892
  }
896
893
 
894
+ //#endregion
895
+ //#region src/global.ts
896
+ const nitroInstances = globalThis.__nitro_instances__ ||= [];
897
+ const globalKey = "__nitro_builder__";
898
+ function registerNitroInstance(nitro) {
899
+ if (nitroInstances.includes(nitro)) return;
900
+ globalInit();
901
+ nitroInstances.unshift(nitro);
902
+ nitro.hooks.hookOnce("close", () => {
903
+ nitroInstances.splice(nitroInstances.indexOf(nitro), 1);
904
+ if (nitroInstances.length === 0) delete globalThis[globalKey];
905
+ });
906
+ }
907
+ function globalInit() {
908
+ if (globalThis[globalKey]) return;
909
+ globalThis[globalKey] = { async fetch(req) {
910
+ for (let r = 0; r < 10 && nitroInstances.length === 0; r++) await new Promise((resolve$1) => setTimeout(resolve$1, 300));
911
+ const nitro = nitroInstances[0];
912
+ if (!nitro) throw new Error("No Nitro instance is running.");
913
+ return nitro.fetch(req);
914
+ } };
915
+ }
916
+
897
917
  //#endregion
898
918
  //#region src/nitro.ts
899
919
  async function createNitro(config = {}, opts = {}) {
@@ -904,12 +924,16 @@ async function createNitro(config = {}, opts = {}) {
904
924
  routing: {},
905
925
  logger: consola.withTag("nitro"),
906
926
  scannedHandlers: [],
927
+ fetch: () => {
928
+ throw new Error("no dev server attached!");
929
+ },
907
930
  close: () => Promise.resolve(nitro.hooks.callHook("close")),
908
931
  storage: void 0,
909
932
  async updateConfig(config$1) {
910
933
  updateNitroConfig(nitro, config$1);
911
934
  }
912
935
  };
936
+ registerNitroInstance(nitro);
913
937
  initNitroRouting(nitro);
914
938
  await scanAndSyncOptions(nitro);
915
939
  nitro.storage = await createStorage(nitro);
@@ -1208,7 +1232,7 @@ async function prerender(nitro) {
1208
1232
  nitroRenderer.options.output.dir = nitro.options.output.dir;
1209
1233
  await build(nitroRenderer);
1210
1234
  const serverFilename = typeof nitroRenderer.options.rollupConfig?.output?.entryFileNames === "string" ? nitroRenderer.options.rollupConfig.output.entryFileNames : "index.mjs";
1211
- const { closePrerenderer, appFetch } = await import(pathToFileURL(resolve(nitroRenderer.options.output.serverDir, serverFilename)).href);
1235
+ const prerenderer = await import(pathToFileURL(resolve(nitroRenderer.options.output.serverDir, serverFilename)).href).then((m) => m.default);
1212
1236
  const routeRules = createRouter();
1213
1237
  for (const [route, rules] of Object.entries(nitro.options.routeRules)) addRoute(routeRules, void 0, route, rules);
1214
1238
  const _getRouteRules = (path$1) => defu({}, ...findAllRoutes(routeRules, void 0, path$1).map((r) => r.data).reverse());
@@ -1251,7 +1275,8 @@ async function prerender(nitro) {
1251
1275
  generatedRoutes.add(route);
1252
1276
  const _route = { route };
1253
1277
  const encodedRoute = encodeURI(route);
1254
- const res = await appFetch(withBase(encodedRoute, nitro.options.baseURL), { headers: [["x-nitro-prerender", encodedRoute]] });
1278
+ const req = toRequest(withBase(encodedRoute, nitro.options.baseURL), { headers: [["x-nitro-prerender", encodedRoute]] });
1279
+ const res = await prerenderer.fetch(req);
1255
1280
  let dataBuff = Buffer.from(await res.arrayBuffer());
1256
1281
  Object.defineProperty(_route, "contents", {
1257
1282
  get: () => {
@@ -1319,7 +1344,7 @@ async function prerender(nitro) {
1319
1344
  concurrency: nitro.options.prerender.concurrency,
1320
1345
  interval: nitro.options.prerender.interval
1321
1346
  });
1322
- await closePrerenderer();
1347
+ await prerenderer.close();
1323
1348
  await nitro.hooks.callHook("prerender:done", {
1324
1349
  prerenderedRoutes: nitro._prerenderedRoutes,
1325
1350
  failedRoutes: [...failedRoutes]
package/dist/_dev.mjs CHANGED
@@ -1,16 +1,16 @@
1
- import { s as __toESM } from "./_chunks/DXMHy5ca.mjs";
2
- import { T as resolve$1, n as debounce } from "./_libs/c12.mjs";
1
+ import { T as resolve$1, b as join$1, n as debounce, v as extname$1 } from "./_libs/c12.mjs";
3
2
  import { n as a, t as T } from "./_libs/std-env.mjs";
3
+ import { t as src_default } from "./_libs/mime.mjs";
4
4
  import { t as createProxyServer } from "./_libs/httpxy.mjs";
5
5
  import { i as watch$1 } from "./_libs/chokidar.mjs";
6
- import { t as require_serve_static } from "./_libs/serve-static.mjs";
7
6
  import consola$1 from "consola";
8
7
  import { dirname, resolve } from "node:path";
9
- import { existsSync } from "node:fs";
8
+ import { createReadStream, existsSync } from "node:fs";
10
9
  import { joinURL } from "ufo";
11
- import { readFile, rm, writeFile } from "node:fs/promises";
10
+ import { readFile, rm, stat, writeFile } from "node:fs/promises";
11
+ import { createBrotliCompress, createGzip } from "node:zlib";
12
12
  import { Worker } from "node:worker_threads";
13
- import { H3, HTTPError, defineHandler, fromNodeHandler, getRequestIP, getRequestURL, toEventHandler, withBase as withBase$1 } from "h3";
13
+ import { H3, HTTPError, defineHandler, fromNodeHandler, getRequestIP, getRequestURL, serveStatic, toEventHandler } from "h3";
14
14
  import { Agent } from "undici";
15
15
  import { version } from "nitro/meta";
16
16
  import { serve } from "srvx/node";
@@ -447,7 +447,6 @@ function fmtFrame(frame) {
447
447
 
448
448
  //#endregion
449
449
  //#region src/dev/app.ts
450
- var import_serve_static = /* @__PURE__ */ __toESM(require_serve_static(), 1);
451
450
  var NitroDevApp = class {
452
451
  nitro;
453
452
  fetch;
@@ -477,10 +476,12 @@ var NitroDevApp = class {
477
476
  }
478
477
  app.get("/_vfs/**", createVFSHandler(this.nitro));
479
478
  for (const asset of this.nitro.options.publicAssets) {
480
- const assetRoute = joinURL(this.nitro.options.runtimeConfig.app.baseURL, asset.baseURL || "/", "**");
481
- let handler = fromNodeHandler((0, import_serve_static.default)(asset.dir, { dotfiles: "allow" }));
482
- if (asset.baseURL?.length || false) handler = withBase$1(asset.baseURL, handler);
483
- app.use(assetRoute, handler);
479
+ const assetBase = joinURL(this.nitro.options.baseURL, asset.baseURL || "/");
480
+ app.use(joinURL(assetBase, "**"), (event) => serveStaticDir(event, {
481
+ dir: asset.dir,
482
+ base: assetBase,
483
+ fallthrough: asset.fallthrough
484
+ }));
484
485
  }
485
486
  const routes = Object.keys(this.nitro.options.devProxy).sort().reverse();
486
487
  for (const route of routes) {
@@ -493,6 +494,47 @@ var NitroDevApp = class {
493
494
  return app;
494
495
  }
495
496
  };
497
+ function serveStaticDir(event, opts) {
498
+ const dir = resolve$1(opts.dir) + "/";
499
+ const r = (id) => {
500
+ if (!id.startsWith(opts.base) || !extname$1(id)) return;
501
+ const resolved = join$1(dir, id.slice(opts.base.length));
502
+ if (resolved.startsWith(dir)) return resolved;
503
+ };
504
+ return serveStatic(event, {
505
+ fallthrough: opts.fallthrough,
506
+ getMeta: async (id) => {
507
+ const path$1 = r(id);
508
+ if (!path$1) return;
509
+ const s = await stat(path$1).catch(() => null);
510
+ if (!s?.isFile()) return;
511
+ const ext = extname$1(path$1);
512
+ return {
513
+ size: s.size,
514
+ mtime: s.mtime,
515
+ type: src_default.getType(ext) || "application/octet-stream"
516
+ };
517
+ },
518
+ getContents(id) {
519
+ const path$1 = r(id);
520
+ if (!path$1) return;
521
+ const stream = createReadStream(path$1);
522
+ const acceptEncoding = event.req.headers.get("accept-encoding") || "";
523
+ if (acceptEncoding.includes("br")) {
524
+ event.res.headers.set("Content-Encoding", "br");
525
+ event.res.headers.delete("Content-Length");
526
+ event.res.headers.set("Vary", "Accept-Encoding");
527
+ return stream.pipe(createBrotliCompress());
528
+ } else if (acceptEncoding.includes("gzip")) {
529
+ event.res.headers.set("Content-Encoding", "gzip");
530
+ event.res.headers.delete("Content-Length");
531
+ event.res.headers.set("Vary", "Accept-Encoding");
532
+ return stream.pipe(createGzip());
533
+ }
534
+ return stream;
535
+ }
536
+ });
537
+ }
496
538
 
497
539
  //#endregion
498
540
  //#region src/dev/server.ts
@@ -520,6 +562,7 @@ var NitroDevServer = class NitroDevServer extends NitroDevApp {
520
562
  const value = this[key];
521
563
  if (typeof value === "function" && key !== "constructor") this[key] = value.bind(this);
522
564
  }
565
+ nitro.fetch = this.fetch.bind(this);
523
566
  this.#entry = resolve$1(nitro.options.output.dir, nitro.options.output.serverDir, "index.mjs");
524
567
  nitro.hooks.hook("close", () => this.close());
525
568
  nitro.hooks.hook("dev:start", () => {
@@ -1,4 +1,4 @@
1
- import { i as __require, s as __toESM, t as __commonJS } from "../_chunks/DXMHy5ca.mjs";
1
+ import { i as __toESM, n as __require, t as __commonJS } from "../_chunks/Bqks5huO.mjs";
2
2
  import path, { isAbsolute, resolve } from "node:path";
3
3
  import process$1 from "node:process";
4
4
  import fs, { existsSync, lstatSync, promises, readFileSync, realpathSync, statSync } from "node:fs";
@@ -1,4 +1,4 @@
1
- import { i as __require, t as __commonJS } from "../_chunks/DXMHy5ca.mjs";
1
+ import { n as __require, t as __commonJS } from "../_chunks/Bqks5huO.mjs";
2
2
 
3
3
  //#region node_modules/.pnpm/commondir@1.0.1/node_modules/commondir/index.js
4
4
  var require_commondir = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/commondir@1.0.1/node_modules/commondir/index.js": ((exports, module) => {
@@ -1,4 +1,4 @@
1
- import { t as __commonJS } from "../_chunks/DXMHy5ca.mjs";
1
+ import { t as __commonJS } from "../_chunks/Bqks5huO.mjs";
2
2
 
3
3
  //#region node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js
4
4
  var require_cjs = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js": ((exports, module) => {
@@ -1,4 +1,4 @@
1
- import { i as __require, t as __commonJS } from "../_chunks/DXMHy5ca.mjs";
1
+ import { n as __require, t as __commonJS } from "../_chunks/Bqks5huO.mjs";
2
2
 
3
3
  //#region node_modules/.pnpm/duplexer@0.1.2/node_modules/duplexer/index.js
4
4
  var require_duplexer = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/duplexer@0.1.2/node_modules/duplexer/index.js": ((exports, module) => {
@@ -1,4 +1,4 @@
1
- import { i as __require, t as __commonJS } from "../_chunks/DXMHy5ca.mjs";
1
+ import { n as __require, t as __commonJS } from "../_chunks/Bqks5huO.mjs";
2
2
 
3
3
  //#region node_modules/.pnpm/etag@1.8.1/node_modules/etag/index.js
4
4
  var require_etag = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/etag@1.8.1/node_modules/etag/index.js": ((exports, module) => {
@@ -1,4 +1,4 @@
1
- import { t as __commonJS } from "../_chunks/DXMHy5ca.mjs";
1
+ import { t as __commonJS } from "../_chunks/Bqks5huO.mjs";
2
2
 
3
3
  //#region node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/implementation.js
4
4
  var require_implementation = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/implementation.js": ((exports, module) => {
@@ -1,4 +1,4 @@
1
- import { i as __require, o as __toDynamicImportESM, s as __toESM, t as __commonJS } from "../_chunks/DXMHy5ca.mjs";
1
+ import { i as __toESM, n as __require, r as __toDynamicImportESM, t as __commonJS } from "../_chunks/Bqks5huO.mjs";
2
2
  import { T as resolve$1, _ as dirname$1, b as join$1, g as basename$1, x as normalize$1 } from "./c12.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { createWriteStream, existsSync, readdirSync, renameSync } from "node:fs";
@@ -11,14 +11,14 @@ import { defu } from "defu";
11
11
  import Ds from "crypto";
12
12
  import nt from "events";
13
13
  import { pipeline } from "node:stream";
14
- import a$a from "util";
15
- import ot, { PassThrough } from "stream";
16
14
  import "node:child_process";
17
15
  import j$1 from "assert";
16
+ import ot, { PassThrough } from "stream";
18
17
  import ht from "string_decoder";
19
18
  import P from "buffer";
20
19
  import O$2 from "zlib";
21
20
  import nt$1, { cwd } from "process";
21
+ import a$a from "util";
22
22
  import { spawn as spawn$1 } from "child_process";
23
23
  import me from "readline";
24
24
 
@@ -1,4 +1,4 @@
1
- import { s as __toESM } from "../_chunks/DXMHy5ca.mjs";
1
+ import { i as __toESM } from "../_chunks/Bqks5huO.mjs";
2
2
  import { t as require_duplexer } from "./duplexer.mjs";
3
3
  import fs from "node:fs";
4
4
  import { promisify } from "node:util";
@@ -1,4 +1,4 @@
1
- import { t as __commonJS } from "../_chunks/DXMHy5ca.mjs";
1
+ import { t as __commonJS } from "../_chunks/Bqks5huO.mjs";
2
2
  import { t as require_function_bind } from "./function-bind.mjs";
3
3
 
4
4
  //#region node_modules/.pnpm/hasown@2.0.2/node_modules/hasown/index.js
@@ -1,4 +1,4 @@
1
- import { t as __commonJS } from "../_chunks/DXMHy5ca.mjs";
1
+ import { t as __commonJS } from "../_chunks/Bqks5huO.mjs";
2
2
  import { t as require_hasown } from "./hasown.mjs";
3
3
 
4
4
  //#region node_modules/.pnpm/is-core-module@2.16.1/node_modules/is-core-module/core.json
@@ -1,4 +1,4 @@
1
- import { t as __commonJS } from "../_chunks/DXMHy5ca.mjs";
1
+ import { t as __commonJS } from "../_chunks/Bqks5huO.mjs";
2
2
 
3
3
  //#region node_modules/.pnpm/is-module@1.0.0/node_modules/is-module/index.js
4
4
  var require_is_module = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/is-module@1.0.0/node_modules/is-module/index.js": ((exports, module) => {
@@ -1,4 +1,4 @@
1
- import { t as __commonJS } from "../_chunks/DXMHy5ca.mjs";
1
+ import { t as __commonJS } from "../_chunks/Bqks5huO.mjs";
2
2
 
3
3
  //#region node_modules/.pnpm/is-reference@1.2.1/node_modules/is-reference/dist/is-reference.js
4
4
  var require_is_reference = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/is-reference@1.2.1/node_modules/is-reference/dist/is-reference.js": ((exports, module) => {