nitro 3.0.260429-beta → 3.0.260522-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 (75) hide show
  1. package/dist/THIRD-PARTY-LICENSES.md.gz +0 -0
  2. package/dist/_build/common.mjs +119 -21
  3. package/dist/_build/rolldown.mjs +6 -6
  4. package/dist/_build/rollup.mjs +11 -11
  5. package/dist/_build/vite.build.mjs +3 -3
  6. package/dist/_build/vite.dev.mjs +149 -0
  7. package/dist/_build/vite.env.mjs +177 -0
  8. package/dist/_chunks/nitro.mjs +239 -12
  9. package/dist/_chunks/nitro2.mjs +117 -90
  10. package/dist/_chunks/utils.mjs +4 -4
  11. package/dist/_common.mjs +1 -1
  12. package/dist/_dev.d.mts +1 -1
  13. package/dist/_dev.mjs +5 -5
  14. package/dist/_libs/c12+rc9.mjs +11 -10
  15. package/dist/_libs/c12+readdirp+chokidar.d.mts +7 -8
  16. package/dist/_libs/citty.mjs +1 -1
  17. package/dist/_libs/common.d.mts +37 -0
  18. package/dist/_libs/commondir+is-reference.mjs +3 -3
  19. package/dist/_libs/compatx.d.mts +1 -1
  20. package/dist/_libs/compatx.mjs +1 -1
  21. package/dist/_libs/estree+pluginutils.d.mts +1 -1
  22. package/dist/_libs/estree-walker.mjs +1 -1
  23. package/dist/_libs/hasown+resolve+deepmerge.mjs +15 -15
  24. package/dist/_libs/httpxy.d.mts +1 -1
  25. package/dist/_libs/httpxy.mjs +8 -4
  26. package/dist/_libs/jsonc-parser+workers-utils.d.mts +1579 -0
  27. package/dist/_libs/klona.mjs +1 -1
  28. package/dist/_libs/magic-string.d.mts +1 -1
  29. package/dist/_libs/mlly.d.mts +1 -1
  30. package/dist/_libs/nypm+tinyexec.mjs +92 -99
  31. package/dist/_libs/openapi-types.d.mts +730 -0
  32. package/dist/_libs/perfect-debounce.mjs +1 -1
  33. package/dist/_libs/pkg-types.d.mts +1 -1
  34. package/dist/_libs/plugin-alias.mjs +2 -2
  35. package/dist/_libs/plugin-inject.mjs +3 -3
  36. package/dist/_libs/plugin-json.mjs +2 -2
  37. package/dist/_libs/pluginutils.mjs +16 -5
  38. package/dist/_libs/readdirp+chokidar.mjs +2 -2
  39. package/dist/_libs/remapping.mjs +2 -2
  40. package/dist/_libs/resolve-uri+gen-mapping.mjs +2 -5
  41. package/dist/_libs/rou3.d.mts +1 -1
  42. package/dist/_libs/rou3.mjs +1 -1
  43. package/dist/_libs/std-env.d.mts +1 -1
  44. package/dist/_libs/tsconfck.mjs +1 -1
  45. package/dist/_libs/ultrahtml.mjs +1 -1
  46. package/dist/_libs/{unimport+unplugin+oxc-parser.mjs → unimport+unplugin.mjs} +18 -8
  47. package/dist/_libs/unplugin+unimport.d.mts +3 -3
  48. package/dist/_libs/unwasm.d.mts +1 -1
  49. package/dist/_presets.mjs +117 -91
  50. package/dist/builder.d.mts +1 -1
  51. package/dist/builder.mjs +3 -3
  52. package/dist/cli/_chunks/build.mjs +3 -3
  53. package/dist/cli/_chunks/common.mjs +1 -1
  54. package/dist/cli/_chunks/deploy.mjs +2 -2
  55. package/dist/cli/_chunks/dev.mjs +4 -4
  56. package/dist/cli/_chunks/docs.mjs +1 -1
  57. package/dist/cli/_chunks/list.mjs +2 -2
  58. package/dist/cli/_chunks/prepare.mjs +3 -3
  59. package/dist/cli/_chunks/preview.mjs +4 -4
  60. package/dist/cli/_chunks/run.mjs +2 -2
  61. package/dist/cli/_chunks/task.mjs +1 -1
  62. package/dist/cli/index.mjs +1 -1
  63. package/dist/docs/1.deploy/2.providers/2.aws-amplify.md +3 -3
  64. package/dist/docs/1.deploy/2.providers/21.vercel.md +6 -0
  65. package/dist/docs/3.examples/27.vite-ssr-tsr-react.md +1 -1
  66. package/dist/presets/vercel/runtime/queue.dev.mjs +41 -0
  67. package/dist/runtime/internal/app.mjs +4 -111
  68. package/dist/runtime/virtual/app.d.mts +4 -0
  69. package/dist/runtime/virtual/app.mjs +32 -0
  70. package/dist/types/index.d.mts +21 -1756
  71. package/dist/vite.mjs +23 -337
  72. package/package.json +37 -39
  73. package/dist/THIRD-PARTY-LICENSES.md +0 -1676
  74. package/dist/_chunks/nitro3.mjs +0 -136
  75. package/dist/_chunks/nitro4.mjs +0 -127
@@ -65,4 +65,4 @@ function debounce(fn, wait = 25, options = {}) {
65
65
  async function _applyPromised(fn, _this, args) {
66
66
  return await fn.apply(_this, args);
67
67
  }
68
- export { debounce as t };
68
+ export { debounce };
@@ -20,4 +20,4 @@ interface TSConfig {
20
20
  * @param tsconfig - The contents of `tsconfig.json` as an object. See {@link TSConfig}.
21
21
  * @returns the same `tsconfig.json` object.
22
22
  */
23
- export { TSConfig as t };
23
+ export type { TSConfig };
@@ -1,4 +1,4 @@
1
- import { n as __exportAll } from "../_common.mjs";
1
+ import { __exportAll } from "../_common.mjs";
2
2
  import path from "node:path";
3
3
  var dist_exports = /* @__PURE__ */ __exportAll({ default: () => alias });
4
4
  function matches(pattern, importee) {
@@ -59,4 +59,4 @@ function alias(options = {}) {
59
59
  }
60
60
  };
61
61
  }
62
- export { dist_exports as n, alias as t };
62
+ export { alias, dist_exports };
@@ -1,5 +1,5 @@
1
- import { n as __exportAll } from "../_common.mjs";
2
- import { S as MagicString, c as walk, i as createFilter, r as attachScopes, s as makeLegalIdentifier } from "../_build/common.mjs";
1
+ import { __exportAll } from "../_common.mjs";
2
+ import { MagicString, attachScopes, createFilter, makeLegalIdentifier, walk } from "../_build/common.mjs";
3
3
  import { sep } from "path";
4
4
  var es_exports = /* @__PURE__ */ __exportAll({ default: () => inject });
5
5
  var escape = function(str) {
@@ -128,4 +128,4 @@ function inject(options) {
128
128
  }
129
129
  };
130
130
  }
131
- export { inject as n, es_exports as t };
131
+ export { es_exports, inject };
@@ -1,4 +1,4 @@
1
- import { a as dataToEsm, i as createFilter } from "../_build/common.mjs";
1
+ import { createFilter, dataToEsm } from "../_build/common.mjs";
2
2
  function json(options) {
3
3
  if (options === void 0) options = {};
4
4
  var filter = createFilter(options.include, options.exclude);
@@ -29,4 +29,4 @@ function json(options) {
29
29
  }
30
30
  };
31
31
  }
32
- export { json as t };
32
+ export { json };
@@ -1,11 +1,10 @@
1
- import { n as __exportAll } from "../_common.mjs";
2
- import { S as MagicString, x as stripLiteral } from "../_build/common.mjs";
1
+ import { __exportAll } from "../_common.mjs";
2
+ import { MagicString, stripLiteral } from "../_build/common.mjs";
3
3
  import fs from "node:fs";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import path from "node:path";
6
6
  import "node:assert";
7
7
  import { createHash } from "node:crypto";
8
- import { isCSSRequest, normalizePath } from "vite";
9
8
  import assert$1 from "node:assert/strict";
10
9
  function exactRegex(str, flags) {
11
10
  return new RegExp(`^${escapeRegex(str)}$`, flags);
@@ -82,6 +81,13 @@ function slash(p) {
82
81
  return p.replace(windowsSlashRE, "/");
83
82
  }
84
83
  const isWindows = typeof process !== "undefined" && process.platform === "win32";
84
+ function normalizePath(id) {
85
+ return path.posix.normalize(isWindows ? slash(id) : id);
86
+ }
87
+ const CSS_LANGS_RE = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
88
+ function isCSSRequest(request) {
89
+ return CSS_LANGS_RE.test(request);
90
+ }
85
91
  function injectQuery(url, queryToInject) {
86
92
  const { file, postfix } = splitFileAndPostfix(url);
87
93
  return `${isWindows ? slash(file) : file}?${queryToInject}${postfix[0] === "?" ? `&${postfix.slice(1)}` : postfix}`;
@@ -491,7 +497,12 @@ function collectAssetDepsInner(fileName, bundle) {
491
497
  };
492
498
  }
493
499
  function patchViteClientPlugin() {
494
- const viteClientPath = normalizePath(fileURLToPath(import.meta.resolve("vite/dist/client/client.mjs")));
500
+ let viteClientPath;
501
+ try {
502
+ viteClientPath = normalizePath(fileURLToPath(import.meta.resolve("vite/dist/client/client.mjs")));
503
+ } catch {
504
+ return null;
505
+ }
495
506
  function endIndexOf(code, searchValue) {
496
507
  const i = code.lastIndexOf(searchValue);
497
508
  return i === -1 ? i : i + searchValue.length;
@@ -619,4 +630,4 @@ function mergeAssets(...args) {
619
630
  });
620
631
  }
621
632
  }
622
- export { assetsPlugin as n, runtime_exports as t };
633
+ export { assetsPlugin };
@@ -1,4 +1,4 @@
1
- import { n as __exportAll } from "../_common.mjs";
1
+ import { __exportAll } from "../_common.mjs";
2
2
  import { stat, unwatchFile, watch, watchFile } from "node:fs";
3
3
  import { lstat, open, readdir, realpath, stat as stat$1 } from "node:fs/promises";
4
4
  import { type } from "node:os";
@@ -1431,4 +1431,4 @@ var chokidar_default = {
1431
1431
  watch: watch$1,
1432
1432
  FSWatcher
1433
1433
  };
1434
- export { watch$1 as n, chokidar_exports as t };
1434
+ export { chokidar_exports, watch$1 as watch };
@@ -1,4 +1,4 @@
1
- import { a as toDecodedMap, c as decodedMappings, i as setSourceContent, l as traceSegment, n as maybeAddSegment, o as toEncodedMap, r as setIgnore, s as TraceMap, t as GenMapping } from "./resolve-uri+gen-mapping.mjs";
1
+ import { GenMapping, TraceMap, decodedMappings, maybeAddSegment, setIgnore, setSourceContent, toDecodedMap, toEncodedMap, traceSegment } from "./resolve-uri+gen-mapping.mjs";
2
2
  var SOURCELESS_MAPPING = /* @__PURE__ */ SegmentObject("", -1, -1, "", null, false);
3
3
  var EMPTY_SOURCES = [];
4
4
  function SegmentObject(source, line, column, name, content, ignore) {
@@ -110,4 +110,4 @@ function remapping(input, loader, options) {
110
110
  };
111
111
  return new SourceMap(traceMappings(buildSourceMapTree(input, loader)), opts);
112
112
  }
113
- export { remapping as t };
113
+ export { remapping };
@@ -1,4 +1,4 @@
1
- import { C as decode, w as encode } from "../_build/common.mjs";
1
+ import { decode, encode } from "../_build/common.mjs";
2
2
  const schemeRegex = /^[\w+.-]+:\/\//;
3
3
  const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
4
4
  const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
@@ -358,8 +358,6 @@ function addSegmentInternal(skipable, map, genLine, genColumn, source, sourceLin
358
358
  if (skipable && skipSourceless(line, index)) return;
359
359
  return insert(line, index, [genColumn]);
360
360
  }
361
- assert(sourceLine);
362
- assert(sourceColumn);
363
361
  const sourcesIndex = put(sources, source);
364
362
  const namesIndex = name ? put(names, name) : NO_NAME;
365
363
  if (sourcesIndex === sourcesContent.length) sourcesContent[sourcesIndex] = content != null ? content : null;
@@ -377,7 +375,6 @@ function addSegmentInternal(skipable, map, genLine, genColumn, source, sourceLin
377
375
  sourceColumn
378
376
  ]);
379
377
  }
380
- function assert(_val) {}
381
378
  function getIndex(arr, index) {
382
379
  for (let i = arr.length; i <= index; i++) arr[i] = [];
383
380
  return arr[index];
@@ -407,4 +404,4 @@ function skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIn
407
404
  if (prev.length === 1) return false;
408
405
  return sourcesIndex === prev[SOURCES_INDEX] && sourceLine === prev[SOURCE_LINE] && sourceColumn === prev[SOURCE_COLUMN] && namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME);
409
406
  }
410
- export { toDecodedMap as a, decodedMappings as c, setSourceContent as i, traceSegment as l, maybeAddSegment as n, toEncodedMap as o, setIgnore as r, TraceMap as s, GenMapping as t };
407
+ export { GenMapping, TraceMap, decodedMappings, maybeAddSegment, setIgnore, setSourceContent, toDecodedMap, toEncodedMap, traceSegment };
@@ -37,4 +37,4 @@ interface RouterCompilerOptions<T = any> {
37
37
  *
38
38
  * @param router - The router context to compile.
39
39
  */
40
- export { RouterContext as n, RouterCompilerOptions as t };
40
+ export { RouterCompilerOptions, type RouterContext };
@@ -464,4 +464,4 @@ function serializeData(ctx, value) {
464
464
  }
465
465
  return `$${index}`;
466
466
  }
467
- export { findRoute as a, findAllRoutes as i, addRoute as n, createRouter as r, compileRouterToString as t };
467
+ export { addRoute, compileRouterToString, createRouter, findAllRoutes, findRoute };
@@ -7,4 +7,4 @@ type ProviderName = (string & {}) | "appveyor" | "aws_amplify" | "azure_pipeline
7
7
  /**
8
8
  * Provides information about a CI/CD or Deployment provider, including its name and possibly other metadata.
9
9
  */
10
- export { ProviderName as t };
10
+ export type { ProviderName };
@@ -516,4 +516,4 @@ var TSConfckCache = class {
516
516
  #configPaths = /* @__PURE__ */ new Map();
517
517
  #parsed = /* @__PURE__ */ new Map();
518
518
  };
519
- export { parse as n, TSConfckCache as t };
519
+ export { TSConfckCache, parse };
@@ -122,4 +122,4 @@ var T = class {
122
122
  function z(e, t) {
123
123
  return new T(t).visit(e);
124
124
  }
125
- export { z as n, P as t };
125
+ export { P, z };
@@ -1,12 +1,11 @@
1
- import { i as __toESM, n as __exportAll } from "../_common.mjs";
2
- import { N as require_picomatch, S as MagicString, T as parse$2, b as getMagicString, ct as isAbsolute$2, ft as resolve$1, lt as join$1, y as createUnimport } from "../_build/common.mjs";
3
- import { t as walk } from "./estree-walker.mjs";
4
- import { t as remapping } from "./remapping.mjs";
1
+ import { __exportAll, __toESM } from "../_common.mjs";
2
+ import { MagicString, createUnimport, getMagicString, importModule, isAbsolute as isAbsolute$2, isPackageExists, join as join$1, parse as parse$1, require_picomatch, resolve as resolve$1 } from "../_build/common.mjs";
3
+ import { walk } from "./estree-walker.mjs";
4
+ import { remapping } from "./remapping.mjs";
5
5
  import { createRequire } from "node:module";
6
6
  import fs, { promises } from "node:fs";
7
7
  import path, { basename, dirname, extname, isAbsolute, normalize, resolve } from "node:path";
8
8
  import process$1 from "node:process";
9
- import { parseSync } from "rolldown/utils";
10
9
  import { Buffer } from "node:buffer";
11
10
  import * as querystring from "node:querystring";
12
11
  function createEstreeDetector(parse) {
@@ -190,13 +189,24 @@ function createVirtualImports(importMap, virtualImports = []) {
190
189
  };
191
190
  }
192
191
  var detect_acorn_exports = /* @__PURE__ */ __exportAll({ detectImportsAcorn: () => detectImportsAcorn });
193
- const detectImportsAcorn = createEstreeDetector((code) => parse$2(code, {
192
+ const detectImportsAcorn = createEstreeDetector((code) => parse$1(code, {
194
193
  sourceType: "module",
195
194
  ecmaVersion: "latest",
196
195
  locations: true
197
196
  }));
198
197
  var detect_oxc_exports = /* @__PURE__ */ __exportAll({ detectImportsOxc: () => detectImportsOxc });
199
- const detectImportsOxc = createEstreeDetector((code) => parseSync("", code, { sourceType: "module" }).program);
198
+ let detectorPromise;
199
+ async function loadDetector() {
200
+ let parseSync;
201
+ if (isPackageExists("rolldown")) parseSync = (await importModule("rolldown/utils")).parseSync;
202
+ else if (isPackageExists("oxc-parser")) parseSync = (await importModule("oxc-parser")).parseSync;
203
+ else throw new Error("[unimport] the `oxc` parser requires either `rolldown` or `oxc-parser` to be installed.");
204
+ return createEstreeDetector((code) => parseSync("", code, { sourceType: "module" }).program);
205
+ }
206
+ async function detectImportsOxc(code, ctx, options) {
207
+ detectorPromise ??= loadDetector();
208
+ return (await detectorPromise)(code, ctx, options);
209
+ }
200
210
  var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch(), 1);
201
211
  function toArray$2(array) {
202
212
  array = array || [];
@@ -1650,4 +1660,4 @@ const unplugin = createUnplugin((options = {}) => {
1650
1660
  }
1651
1661
  };
1652
1662
  });
1653
- export { detect_oxc_exports as n, detect_acorn_exports as r, unplugin_exports as t };
1663
+ export { detect_acorn_exports, detect_oxc_exports, unplugin_exports };
@@ -1,5 +1,5 @@
1
- import { t as MagicString } from "./magic-string.mjs";
2
- import { t as ESMExport } from "./mlly.mjs";
1
+ import { MagicString } from "./magic-string.mjs";
2
+ import { ESMExport } from "./mlly.mjs";
3
3
  //#region src/filter.d.ts
4
4
  /**
5
5
  * A valid `picomatch` glob pattern, or array of patterns.
@@ -413,4 +413,4 @@ interface UnimportPluginOptions extends UnimportOptions {
413
413
  */
414
414
  autoImport?: boolean;
415
415
  }
416
- export { type Unimport as n, type UnimportPluginOptions as t };
416
+ export { Unimport, type UnimportPluginOptions };
@@ -23,4 +23,4 @@ interface UnwasmPluginOptions {
23
23
  silent?: boolean;
24
24
  } //#endregion
25
25
  //#region src/plugin/index.d.ts
26
- export { UnwasmPluginOptions as t };
26
+ export type { UnwasmPluginOptions };
package/dist/_presets.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { F as prettyPath$1, G as findFile, J as readGitConfig, K as findNearestFile, L as writeFile$2, M as glob, Q as a, U as v, V as f, X as i, Y as readPackageJSON, dt as relative$1, ft as resolve$1, lt as join$1, ot as dirname$1, rt as resolveModulePath, tt as r, z as R } from "./_build/common.mjs";
2
- import { r as resolveCompatibilityDatesFromEnv, t as formatCompatibilityDate } from "./_libs/compatx.mjs";
3
- import { t as Router } from "./_chunks/nitro3.mjs";
4
- import { t as importDep } from "./_chunks/utils.mjs";
1
+ import { R, a, dirname as dirname$1, f, findFile, findNearestFile, glob, i, join as join$1, prettyPath as prettyPath$1, r, readGitConfig, readPackageJSON, relative as relative$1, resolve as resolve$1, resolveModulePath, v, writeFile as writeFile$2 } from "./_build/common.mjs";
2
+ import { formatCompatibilityDate, resolveCompatibilityDatesFromEnv } from "./_libs/compatx.mjs";
3
+ import { Router } from "./_chunks/nitro.mjs";
4
+ import { importDep } from "./_chunks/utils.mjs";
5
5
  import { builtinModules } from "node:module";
6
6
  import consola from "consola";
7
7
  import { presetsDir, runtimeDir, version } from "nitro/meta";
@@ -223,11 +223,10 @@ async function writeSWARoutes(nitro) {
223
223
  route: "/",
224
224
  rewrite: "/api/server"
225
225
  });
226
- const suffix = 11;
227
226
  for (const { fileName } of routeFiles) {
228
227
  if (!fileName || !fileName.endsWith("/index.html")) continue;
229
228
  config.routes.unshift({
230
- route: fileName.slice(0, -suffix) || "/",
229
+ route: fileName.slice(0, -11) || "/",
231
230
  rewrite: fileName
232
231
  });
233
232
  }
@@ -1486,7 +1485,7 @@ function generateBuildConfig(nitro, o11Routes) {
1486
1485
  };
1487
1486
  return {
1488
1487
  src,
1489
- dest: withLeadingSlash(normalizeRouteDest(key) + ISR_SUFFIX + `?${ISR_URL_PARAM}=$${ISR_URL_PARAM}`)
1488
+ dest: withLeadingSlash(normalizeRouteDest(key) + `-isr?${ISR_URL_PARAM}=$${ISR_URL_PARAM}`)
1490
1489
  };
1491
1490
  }), ...nitro.options.vercel?.functionRules ? Object.keys(nitro.options.vercel.functionRules).map((pattern) => ({
1492
1491
  src: joinURL(nitro.options.baseURL, normalizeRouteSrc(pattern)),
@@ -1617,96 +1616,123 @@ async function writePrerenderConfig(filename, isrConfig, bypassToken) {
1617
1616
  if (prerenderConfig.allowQuery && !prerenderConfig.allowQuery.includes("__isr_route")) prerenderConfig.allowQuery.push(ISR_URL_PARAM);
1618
1617
  await writeFile$1(filename, JSON.stringify(prerenderConfig, null, 2));
1619
1618
  }
1620
- var preset_default$4 = [defineNitroPreset({
1621
- entry: "./vercel/runtime/vercel.{format}",
1622
- manifest: { deploymentId: process.env.VERCEL_DEPLOYMENT_ID },
1623
- vercel: {
1624
- skewProtection: !!process.env.VERCEL_SKEW_PROTECTION_ENABLED,
1625
- cronHandlerRoute: "/_vercel/cron"
1626
- },
1627
- output: {
1628
- dir: "{{ rootDir }}/.vercel/output",
1629
- serverDir: "{{ output.dir }}/functions/__server.func",
1630
- publicDir: "{{ output.dir }}/static/{{ baseURL }}"
1631
- },
1632
- commands: {
1633
- preview: "npx srvx --static ../../static ./functions/__server.func/index.mjs",
1634
- deploy: "npx vercel deploy --prebuilt"
1635
- },
1636
- hooks: {
1637
- "build:before": async (nitro) => {
1638
- const logger = nitro.logger.withTag("vercel");
1639
- const runtime = await resolveVercelRuntime(nitro);
1640
- if (runtime.startsWith("bun") && !nitro.options.exportConditions.includes("bun")) nitro.options.exportConditions.push("bun");
1641
- logger.info(`Using \`${runtime}\` runtime.`);
1642
- let serverFormat = nitro.options.vercel?.entryFormat;
1643
- if (!serverFormat) serverFormat = nitro.routing.routes.routes.flatMap((r) => r.data).some((h) => h.format === "node") ? "node" : "web";
1644
- logger.info(`Using \`${serverFormat}\` entry format.`);
1645
- nitro.options.entry = nitro.options.entry.replace("{format}", serverFormat);
1646
- if (nitro.options.experimental.tasks && Object.keys(nitro.options.scheduledTasks || {}).length > 0) nitro.options.handlers.push({
1647
- route: nitro.options.vercel.cronHandlerRoute || "/_vercel/cron",
1648
- lazy: true,
1649
- handler: join$1(presetsDir, "vercel/runtime/cron-handler")
1650
- });
1651
- const queues = nitro.options.vercel?.queues;
1652
- if (queues?.triggers?.length) {
1653
- await importDep({
1654
- id: "@vercel/queue",
1655
- dir: nitro.options.rootDir,
1656
- reason: "Vercel Queues"
1657
- });
1658
- const handlerRoute = queues.handlerRoute || "/_vercel/queues/consumer";
1659
- nitro.options.handlers.push({
1660
- route: handlerRoute,
1619
+ async function vercelDevModule(nitro) {
1620
+ if (!nitro.options.dev) return;
1621
+ const triggers = nitro.options.vercel?.queues?.triggers;
1622
+ if (!triggers?.length) return;
1623
+ if (nitro.options.devServer.runner !== "vercel") throw new Error(`[vercel:queue] Local queue delivery requires the \`vercel\` dev runner, but \`devServer.runner\` is set to "${nitro.options.devServer.runner}". Remove the \`devServer.runner\` override in your \`nitro.config.ts\` or set it explicitly to \`"vercel"\`.`);
1624
+ nitro.options.runtimeConfig.vercel = {
1625
+ ...nitro.options.runtimeConfig.vercel,
1626
+ queues: { triggers: triggers.map((t) => ({ ...t })) }
1627
+ };
1628
+ nitro.options.plugins = nitro.options.plugins || [];
1629
+ nitro.options.plugins.unshift(resolveModulePath("./vercel/runtime/queue.dev", {
1630
+ from: presetsDir,
1631
+ extensions: [".mjs", ".ts"]
1632
+ }));
1633
+ }
1634
+ var preset_default$4 = [
1635
+ defineNitroPreset({
1636
+ entry: "./vercel/runtime/vercel.{format}",
1637
+ manifest: { deploymentId: process.env.VERCEL_DEPLOYMENT_ID },
1638
+ vercel: {
1639
+ skewProtection: !!process.env.VERCEL_SKEW_PROTECTION_ENABLED,
1640
+ cronHandlerRoute: "/_vercel/cron"
1641
+ },
1642
+ output: {
1643
+ dir: "{{ rootDir }}/.vercel/output",
1644
+ serverDir: "{{ output.dir }}/functions/__server.func",
1645
+ publicDir: "{{ output.dir }}/static/{{ baseURL }}"
1646
+ },
1647
+ commands: {
1648
+ preview: "npx srvx --static ../../static ./functions/__server.func/index.mjs",
1649
+ deploy: "npx vercel deploy --prebuilt"
1650
+ },
1651
+ hooks: {
1652
+ "build:before": async (nitro) => {
1653
+ const logger = nitro.logger.withTag("vercel");
1654
+ const runtime = await resolveVercelRuntime(nitro);
1655
+ if (runtime.startsWith("bun") && !nitro.options.exportConditions.includes("bun")) nitro.options.exportConditions.push("bun");
1656
+ logger.info(`Using \`${runtime}\` runtime.`);
1657
+ let serverFormat = nitro.options.vercel?.entryFormat;
1658
+ if (!serverFormat) serverFormat = nitro.routing.routes.routes.flatMap((r) => r.data).some((h) => h.format === "node") ? "node" : "web";
1659
+ logger.info(`Using \`${serverFormat}\` entry format.`);
1660
+ nitro.options.entry = nitro.options.entry.replace("{format}", serverFormat);
1661
+ if (nitro.options.experimental.tasks && Object.keys(nitro.options.scheduledTasks || {}).length > 0) nitro.options.handlers.push({
1662
+ route: nitro.options.vercel.cronHandlerRoute || "/_vercel/cron",
1661
1663
  lazy: true,
1662
- handler: join$1(presetsDir, "vercel/runtime/queue-handler")
1664
+ handler: join$1(presetsDir, "vercel/runtime/cron-handler")
1663
1665
  });
1664
- const queueTriggers = queues.triggers.map(({ topic, ...opts }) => ({
1665
- type: "queue/v2beta",
1666
- topic,
1667
- ...opts
1668
- }));
1669
- nitro.options.vercel ??= {};
1670
- nitro.options.vercel.functionRules ??= {};
1671
- const existingRule = nitro.options.vercel.functionRules[handlerRoute];
1672
- nitro.options.vercel.functionRules[handlerRoute] = {
1673
- ...existingRule,
1674
- experimentalTriggers: [...existingRule?.experimentalTriggers || [], ...queueTriggers]
1675
- };
1666
+ const queues = nitro.options.vercel?.queues;
1667
+ if (queues?.triggers?.length) {
1668
+ await importDep({
1669
+ id: "@vercel/queue",
1670
+ dir: nitro.options.rootDir,
1671
+ reason: "Vercel Queues"
1672
+ });
1673
+ const handlerRoute = queues.handlerRoute || "/_vercel/queues/consumer";
1674
+ nitro.options.handlers.push({
1675
+ route: handlerRoute,
1676
+ lazy: true,
1677
+ handler: join$1(presetsDir, "vercel/runtime/queue-handler")
1678
+ });
1679
+ const queueTriggers = queues.triggers.map(({ topic, ...opts }) => ({
1680
+ type: "queue/v2beta",
1681
+ topic,
1682
+ ...opts
1683
+ }));
1684
+ nitro.options.vercel ??= {};
1685
+ nitro.options.vercel.functionRules ??= {};
1686
+ const existingRule = nitro.options.vercel.functionRules[handlerRoute];
1687
+ nitro.options.vercel.functionRules[handlerRoute] = {
1688
+ ...existingRule,
1689
+ experimentalTriggers: [...existingRule?.experimentalTriggers || [], ...queueTriggers]
1690
+ };
1691
+ }
1692
+ },
1693
+ "rollup:before": (nitro) => {
1694
+ deprecateSWR(nitro);
1695
+ },
1696
+ async compiled(nitro) {
1697
+ await generateFunctionFiles(nitro);
1676
1698
  }
1677
- },
1678
- "rollup:before": (nitro) => {
1679
- deprecateSWR(nitro);
1680
- },
1681
- async compiled(nitro) {
1682
- await generateFunctionFiles(nitro);
1683
1699
  }
1684
- }
1685
- }, {
1686
- name: "vercel",
1687
- stdName: "vercel"
1688
- }), defineNitroPreset({
1689
- extends: "static",
1690
- manifest: { deploymentId: process.env.VERCEL_DEPLOYMENT_ID },
1691
- vercel: { skewProtection: !!process.env.VERCEL_SKEW_PROTECTION_ENABLED },
1692
- output: {
1693
- dir: "{{ rootDir }}/.vercel/output",
1694
- publicDir: "{{ output.dir }}/static/{{ baseURL }}"
1695
- },
1696
- commands: { preview: "npx serve ./static" },
1697
- hooks: {
1698
- "rollup:before": (nitro) => {
1699
- deprecateSWR(nitro);
1700
+ }, {
1701
+ name: "vercel",
1702
+ stdName: "vercel"
1703
+ }),
1704
+ defineNitroPreset({
1705
+ extends: "static",
1706
+ manifest: { deploymentId: process.env.VERCEL_DEPLOYMENT_ID },
1707
+ vercel: { skewProtection: !!process.env.VERCEL_SKEW_PROTECTION_ENABLED },
1708
+ output: {
1709
+ dir: "{{ rootDir }}/.vercel/output",
1710
+ publicDir: "{{ output.dir }}/static/{{ baseURL }}"
1700
1711
  },
1701
- async compiled(nitro) {
1702
- await generateStaticFiles(nitro);
1712
+ commands: { preview: "npx serve ./static" },
1713
+ hooks: {
1714
+ "rollup:before": (nitro) => {
1715
+ deprecateSWR(nitro);
1716
+ },
1717
+ async compiled(nitro) {
1718
+ await generateStaticFiles(nitro);
1719
+ }
1703
1720
  }
1704
- }
1705
- }, {
1706
- name: "vercel-static",
1707
- stdName: "vercel",
1708
- static: true
1709
- })];
1721
+ }, {
1722
+ name: "vercel-static",
1723
+ stdName: "vercel",
1724
+ static: true
1725
+ }),
1726
+ defineNitroPreset({
1727
+ extends: "nitro-dev",
1728
+ devServer: { runner: "vercel" },
1729
+ modules: [vercelDevModule]
1730
+ }, {
1731
+ name: "vercel-dev",
1732
+ aliases: ["vercel"],
1733
+ dev: true
1734
+ })
1735
+ ];
1710
1736
  var preset_default$3 = [defineNitroPreset({
1711
1737
  extends: "base-worker",
1712
1738
  entry: "./winterjs/runtime/winterjs",
@@ -1,4 +1,4 @@
1
- import { t as NitroDevApp } from "./_dev.mjs";
1
+ import { NitroDevApp } from "./_dev.mjs";
2
2
  import { RunnerMessageListener, RunnerRPCHooks } from "env-runner";
3
3
  import { IncomingMessage } from "node:http";
4
4
  import { Socket } from "node:net";
package/dist/builder.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { D as copyPublicAssets, E as prepare, _ as writeTypes, j as build, m as getBuildInfo } from "./_build/common.mjs";
2
- import { a as loadOptions, i as createNitro, n as runTask, r as prerender, t as listTasks } from "./_chunks/nitro.mjs";
3
- import { n as createDevServer } from "./_dev.mjs";
1
+ import { build, copyPublicAssets, getBuildInfo, prepare, writeTypes } from "./_build/common.mjs";
2
+ import { createNitro, listTasks, loadOptions, prerender, runTask } from "./_chunks/nitro.mjs";
3
+ import { createDevServer } from "./_dev.mjs";
4
4
  export { build, copyPublicAssets, createDevServer, createNitro, getBuildInfo, listTasks, loadOptions, prepare, prerender, runTask, writeTypes };
@@ -1,6 +1,6 @@
1
- import { ft as resolve } from "../../_build/common.mjs";
2
- import { t as defineCommand } from "../../_libs/citty.mjs";
3
- import { t as commonArgs } from "./common.mjs";
1
+ import { resolve } from "../../_build/common.mjs";
2
+ import { defineCommand } from "../../_libs/citty.mjs";
3
+ import { commonArgs } from "./common.mjs";
4
4
  import { build, copyPublicAssets, createNitro, prepare, prerender } from "nitro/builder";
5
5
  const buildArgs = {
6
6
  ...commonArgs,
@@ -9,4 +9,4 @@ const commonArgs = {
9
9
  description: "project root directory (prefer using `--dir`)"
10
10
  }
11
11
  };
12
- export { commonArgs as t };
12
+ export { commonArgs };
@@ -1,5 +1,5 @@
1
- import { dt as relative, ft as resolve, m as getBuildInfo } from "../../_build/common.mjs";
2
- import { t as defineCommand } from "../../_libs/citty.mjs";
1
+ import { getBuildInfo, relative, resolve } from "../../_build/common.mjs";
2
+ import { defineCommand } from "../../_libs/citty.mjs";
3
3
  import build_default, { buildArgs } from "./build.mjs";
4
4
  import consola from "consola";
5
5
  import { execSync } from "node:child_process";
@@ -1,7 +1,7 @@
1
- import { ft as resolve } from "../../_build/common.mjs";
2
- import { t as NitroDevServer } from "../../_dev.mjs";
3
- import { t as defineCommand } from "../../_libs/citty.mjs";
4
- import { t as commonArgs } from "./common.mjs";
1
+ import { resolve } from "../../_build/common.mjs";
2
+ import { NitroDevServer } from "../../_dev.mjs";
3
+ import { defineCommand } from "../../_libs/citty.mjs";
4
+ import { commonArgs } from "./common.mjs";
5
5
  import { consola as consola$1 } from "consola";
6
6
  import { build, createNitro, prepare } from "nitro/builder";
7
7
  const hmrKeyRe = /^runtimeConfig\.|routeRules\./;
@@ -1,4 +1,4 @@
1
- import { t as defineCommand } from "../../_libs/citty.mjs";
1
+ import { defineCommand } from "../../_libs/citty.mjs";
2
2
  import { docsDir } from "nitro/meta";
3
3
  import { execSync } from "node:child_process";
4
4
  var docs_default = defineCommand({
@@ -1,5 +1,5 @@
1
- import { ft as resolve } from "../../_build/common.mjs";
2
- import { t as defineCommand } from "../../_libs/citty.mjs";
1
+ import { resolve } from "../../_build/common.mjs";
2
+ import { defineCommand } from "../../_libs/citty.mjs";
3
3
  import { consola as consola$1 } from "consola";
4
4
  import { listTasks, loadOptions } from "nitro/builder";
5
5
  var list_default = defineCommand({
@@ -1,6 +1,6 @@
1
- import { ft as resolve } from "../../_build/common.mjs";
2
- import { t as defineCommand } from "../../_libs/citty.mjs";
3
- import { t as commonArgs } from "./common.mjs";
1
+ import { resolve } from "../../_build/common.mjs";
2
+ import { defineCommand } from "../../_libs/citty.mjs";
3
+ import { commonArgs } from "./common.mjs";
4
4
  import { createNitro, writeTypes } from "nitro/builder";
5
5
  var prepare_default = defineCommand({
6
6
  meta: {
@@ -1,7 +1,7 @@
1
- import { ft as resolve } from "../../_build/common.mjs";
2
- import { t as defineCommand } from "../../_libs/citty.mjs";
3
- import { t as startPreview } from "../../_chunks/nitro4.mjs";
4
- import { t as commonArgs } from "./common.mjs";
1
+ import { resolve } from "../../_build/common.mjs";
2
+ import { defineCommand } from "../../_libs/citty.mjs";
3
+ import { startPreview } from "../../_chunks/nitro2.mjs";
4
+ import { commonArgs } from "./common.mjs";
5
5
  import { serve } from "srvx";
6
6
  import { log } from "srvx/log";
7
7
  var preview_default = defineCommand({
@@ -1,5 +1,5 @@
1
- import { ft as resolve } from "../../_build/common.mjs";
2
- import { t as defineCommand } from "../../_libs/citty.mjs";
1
+ import { resolve } from "../../_build/common.mjs";
2
+ import { defineCommand } from "../../_libs/citty.mjs";
3
3
  import { consola as consola$1 } from "consola";
4
4
  import destr from "destr";
5
5
  import { loadOptions, runTask } from "nitro/builder";
@@ -1,4 +1,4 @@
1
- import { t as defineCommand } from "../../_libs/citty.mjs";
1
+ import { defineCommand } from "../../_libs/citty.mjs";
2
2
  var task_default = defineCommand({
3
3
  meta: {
4
4
  name: "task",