nitro-nightly 3.1.0-20251027-223403-81bd673d → 3.1.0-20251028-000737-b443005f

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.
@@ -20217,27 +20217,21 @@ async function snapshotStorage(nitro) {
20217
20217
  return data;
20218
20218
  }
20219
20219
 
20220
- //#region src/object.ts
20221
20220
  const NullProtoObj = /* @__PURE__ */ (() => {
20222
20221
  const e = function() {};
20223
20222
  return e.prototype = Object.create(null), Object.freeze(e.prototype), e;
20224
20223
  })();
20225
20224
 
20226
- //#endregion
20227
- //#region src/context.ts
20228
20225
  /**
20229
20226
  * Create a new router context.
20230
20227
  */
20231
20228
  function createRouter() {
20232
- const ctx = {
20229
+ return {
20233
20230
  root: { key: "" },
20234
20231
  static: new NullProtoObj()
20235
20232
  };
20236
- return ctx;
20237
20233
  }
20238
20234
 
20239
- //#endregion
20240
- //#region src/operations/_utils.ts
20241
20235
  function splitPath(path) {
20242
20236
  const [_, ...s] = path.split("/");
20243
20237
  return s[s.length - 1] === "" ? s.slice(0, -1) : s;
@@ -20255,8 +20249,6 @@ function getMatchParams(segments, paramsMap) {
20255
20249
  return params;
20256
20250
  }
20257
20251
 
20258
- //#endregion
20259
- //#region src/operations/add.ts
20260
20252
  /**
20261
20253
  * Add a route to the router context.
20262
20254
  */
@@ -20325,11 +20317,9 @@ function addRoute(ctx, method = "", path, data) {
20325
20317
  }
20326
20318
  function getParamRegexp(segment) {
20327
20319
  const regex = segment.replace(/:(\w+)/g, (_, id) => `(?<${id}>[^/]+)`).replace(/\./g, "\\.");
20328
- return new RegExp(`^${regex}$`);
20320
+ return /* @__PURE__ */ new RegExp(`^${regex}$`);
20329
20321
  }
20330
20322
 
20331
- //#endregion
20332
- //#region src/operations/find.ts
20333
20323
  /**
20334
20324
  * Find a route by path.
20335
20325
  */
@@ -20368,7 +20358,7 @@ function _lookupTree(ctx, node, method, segments, index) {
20368
20358
  if (pMap?.[pMap?.length - 1]?.[2]) return match;
20369
20359
  }
20370
20360
  }
20371
- return void 0;
20361
+ return;
20372
20362
  }
20373
20363
  const segment = segments[index];
20374
20364
  if (node.static) {
@@ -20389,11 +20379,8 @@ function _lookupTree(ctx, node, method, segments, index) {
20389
20379
  }
20390
20380
  }
20391
20381
  if (node.wildcard && node.wildcard.methods) return node.wildcard.methods[method] || node.wildcard.methods[""];
20392
- return;
20393
20382
  }
20394
20383
 
20395
- //#endregion
20396
- //#region src/operations/find-all.ts
20397
20384
  /**
20398
20385
  * Find all route patterns that match the given path.
20399
20386
  */
@@ -20433,7 +20420,6 @@ function _findAll(ctx, node, method, segments, index, matches = []) {
20433
20420
  return matches;
20434
20421
  }
20435
20422
 
20436
- //#region src/compiler.ts
20437
20423
  /**
20438
20424
  * Compiles the router instance into a faster route-matching function.
20439
20425
  *
@@ -20464,17 +20450,16 @@ function _findAll(ctx, node, method, segments, index, matches = []) {
20464
20450
  * // "const findRoute=(m, p) => {}"
20465
20451
  */
20466
20452
  function compileRouterToString(router, functionName, opts) {
20467
- const ctx = {
20453
+ const compiled = `(m,p)=>{${compileRouteMatch({
20468
20454
  opts: opts || {},
20469
20455
  router,
20470
20456
  deps: void 0
20471
- };
20472
- const compiled = `(m,p)=>{${compileRouteMatch(ctx)}}`;
20457
+ })}}`;
20473
20458
  return functionName ? `const ${functionName}=${compiled};` : compiled;
20474
20459
  }
20475
20460
  function compileRouteMatch(ctx) {
20476
20461
  let code = "";
20477
- const staticNodes = new Set();
20462
+ const staticNodes = /* @__PURE__ */ new Set();
20478
20463
  for (const key in ctx.router.static) {
20479
20464
  const node = ctx.router.static[key];
20480
20465
  if (node?.methods) {
@@ -20505,8 +20490,7 @@ function compileFinalMatch(ctx, data, currentIdx, params) {
20505
20490
  const conditions = [];
20506
20491
  const { paramsMap, paramsRegexp } = data;
20507
20492
  if (paramsMap && paramsMap.length > 0) {
20508
- const required = !paramsMap[paramsMap.length - 1][2] && currentIdx !== -1;
20509
- if (required) conditions.push(`l>=${currentIdx}`);
20493
+ if (!paramsMap[paramsMap.length - 1][2] && currentIdx !== -1) conditions.push(`l>=${currentIdx}`);
20510
20494
  for (let i = 0; i < paramsRegexp.length; i++) {
20511
20495
  const regexp = paramsRegexp[i];
20512
20496
  if (!regexp) continue;
@@ -20519,9 +20503,8 @@ function compileFinalMatch(ctx, data, currentIdx, params) {
20519
20503
  }
20520
20504
  ret += "}";
20521
20505
  }
20522
- const code = (conditions.length > 0 ? `if(${conditions.join("&&")})` : "") + (ctx.opts?.matchAll ? `r.unshift(${ret}});` : `return ${ret}};`);
20523
20506
  return {
20524
- code,
20507
+ code: (conditions.length > 0 ? `if(${conditions.join("&&")})` : "") + (ctx.opts?.matchAll ? `r.unshift(${ret}});` : `return ${ret}};`),
20525
20508
  weight: conditions.length
20526
20509
  };
20527
20510
  }
package/dist/presets.mjs CHANGED
@@ -1954,20 +1954,30 @@ async function generateFunctionFiles(nitro) {
1954
1954
  const buildConfigPath = resolve$1(nitro.options.output.dir, "config.json");
1955
1955
  const buildConfig = generateBuildConfig(nitro, o11Routes);
1956
1956
  await writeFile(buildConfigPath, JSON.stringify(buildConfig, null, 2));
1957
- const systemNodeVersion = getSystemNodeVersion();
1958
- const usedNodeVersion = SUPPORTED_NODE_VERSIONS.find((version) => version >= systemNodeVersion) ?? SUPPORTED_NODE_VERSIONS.at(-1);
1959
- const runtimeVersion = `nodejs${usedNodeVersion}.x`;
1957
+ let runtime = nitro.options.vercel?.functions?.runtime;
1958
+ if (!runtime) {
1959
+ const vercelConfig = await readVercelConfig(nitro.options.rootDir);
1960
+ if (vercelConfig.bunVersion || "Bun" in globalThis) {
1961
+ runtime = `bun${vercelConfig.bunVersion || "1.x"}`;
1962
+ } else {
1963
+ const systemNodeVersion = getSystemNodeVersion();
1964
+ const usedNodeVersion = SUPPORTED_NODE_VERSIONS.find(
1965
+ (version) => version >= systemNodeVersion
1966
+ ) ?? SUPPORTED_NODE_VERSIONS.at(-1);
1967
+ runtime = `nodejs${usedNodeVersion}.x`;
1968
+ }
1969
+ }
1960
1970
  const functionConfigPath = resolve$1(
1961
1971
  nitro.options.output.serverDir,
1962
1972
  ".vc-config.json"
1963
1973
  );
1964
1974
  const functionConfig = {
1965
- runtime: runtimeVersion,
1975
+ runtime,
1976
+ ...nitro.options.vercel?.functions,
1966
1977
  handler: "index.mjs",
1967
1978
  launcherType: "Nodejs",
1968
1979
  shouldAddHelpers: false,
1969
- supportsResponseStreaming: true,
1970
- ...nitro.options.vercel?.functions
1980
+ supportsResponseStreaming: true
1971
1981
  };
1972
1982
  await writeFile(functionConfigPath, JSON.stringify(functionConfig, null, 2));
1973
1983
  for (const [key, value] of Object.entries(nitro.options.routeRules)) {
@@ -2131,6 +2141,11 @@ function deprecateSWR(nitro) {
2131
2141
  );
2132
2142
  }
2133
2143
  }
2144
+ async function readVercelConfig(rootDir) {
2145
+ const vercelConfigPath = resolve$1(rootDir, "vercel.json");
2146
+ const vercelConfig = await fsp.readFile(vercelConfigPath).then((config) => JSON.parse(config.toString())).catch(() => ({}));
2147
+ return vercelConfig;
2148
+ }
2134
2149
  function _hasProp(obj, prop) {
2135
2150
  return obj && typeof obj === "object" && prop in obj;
2136
2151
  }
@@ -2320,6 +2320,10 @@ interface VercelServerlessFunctionConfig {
2320
2320
  * Enables source map generation.
2321
2321
  */
2322
2322
  shouldAddSourcemapSupport?: boolean;
2323
+ /**
2324
+ * The runtime to use. Defaults to the auto-detected Node.js version.
2325
+ */
2326
+ runtime?: "nodejs20.x" | "nodejs22.x" | "bun1.x" | (string & {});
2323
2327
  [key: string]: unknown;
2324
2328
  }
2325
2329
  interface VercelOptions {
@@ -3800,8 +3804,6 @@ interface PrerenderRoute {
3800
3804
  /** @deprecated Internal type will be removed in future versions */
3801
3805
  type PrerenderGenerateRoute = PrerenderRoute;
3802
3806
 
3803
- //#endregion
3804
- //#region src/compiler.d.ts
3805
3807
  interface RouterCompilerOptions<T = any> {
3806
3808
  matchAll?: boolean;
3807
3809
  serialize?: (data: T) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitro-nightly",
3
- "version": "3.1.0-20251027-223403-81bd673d",
3
+ "version": "3.1.0-20251028-000737-b443005f",
4
4
  "description": "Build and Deploy Universal JavaScript Servers",
5
5
  "homepage": "https://nitro.build",
6
6
  "repository": "nitrojs/nitro",
@@ -58,17 +58,17 @@
58
58
  "db0": "^0.3.4",
59
59
  "esbuild": "^0.25.11",
60
60
  "fetchdts": "^0.1.7",
61
- "h3": "^2.0.1-rc.5",
61
+ "h3": "2.0.1-rc.5",
62
62
  "jiti": "^2.6.1",
63
- "nf3": "^0.1.2",
63
+ "nf3": "^0.1.3",
64
64
  "ofetch": "^1.4.1",
65
65
  "ohash": "^2.0.11",
66
66
  "rendu": "^0.0.6",
67
67
  "rollup": "^4.52.5",
68
68
  "srvx": "^0.9.1",
69
69
  "undici": "^7.16.0",
70
- "unenv": "^2.0.0-rc.22",
71
- "unstorage": "^2.0.0-alpha.3"
70
+ "unenv": "2.0.0-rc.22",
71
+ "unstorage": "2.0.0-alpha.3"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@azure/functions": "^3.5.1",
@@ -86,7 +86,6 @@
86
86
  "@rollup/plugin-replace": "^6.0.2",
87
87
  "@rollup/plugin-terser": "^0.4.4",
88
88
  "@scalar/api-reference": "^1.38.1",
89
- "@types/archiver": "^6.0.4",
90
89
  "@types/aws-lambda": "^8.10.156",
91
90
  "@types/estree": "^1.0.8",
92
91
  "@types/etag": "^1.8.4",
@@ -95,9 +94,9 @@
95
94
  "@types/node": "^24.9.1",
96
95
  "@types/node-fetch": "^2.6.13",
97
96
  "@types/semver": "^7.7.1",
98
- "@types/serve-static": "^1.15.10",
97
+ "@types/serve-static": "^2.2.0",
99
98
  "@types/xml2js": "^0.4.14",
100
- "@vitest/coverage-v8": "^4.0.3",
99
+ "@vitest/coverage-v8": "^4.0.4",
101
100
  "automd": "^0.4.2",
102
101
  "c12": "^3.3.1",
103
102
  "changelogen": "^0.6.2",
@@ -120,12 +119,11 @@
120
119
  "fs-extra": "^11.3.2",
121
120
  "get-port-please": "^3.2.0",
122
121
  "gzip-size": "^7.0.0",
123
- "hookable": "^6.0.0-rc.1",
122
+ "hookable": "6.0.0-rc.1",
124
123
  "httpxy": "^0.1.7",
125
124
  "klona": "^2.0.6",
126
125
  "knitwork": "^1.2.0",
127
126
  "magic-string": "^0.30.21",
128
- "magicast": "^0.3.5",
129
127
  "mime": "^4.1.0",
130
128
  "miniflare": "^4.20251011.1",
131
129
  "mlly": "^1.8.0",
@@ -135,8 +133,8 @@
135
133
  "prettier": "^3.6.2",
136
134
  "pretty-bytes": "^7.1.0",
137
135
  "react": "^19.2.0",
138
- "rolldown": "1.0.0-beta.44",
139
- "rou3": "^0.7.8",
136
+ "rolldown": "1.0.0-beta.45",
137
+ "rou3": "^0.7.9",
140
138
  "scule": "^1.3.0",
141
139
  "semver": "^7.7.3",
142
140
  "serve-placeholder": "^2.0.2",
@@ -154,7 +152,7 @@
154
152
  "unplugin-utils": "^0.3.1",
155
153
  "untyped": "^2.0.0",
156
154
  "unwasm": "^0.3.11",
157
- "vitest": "^4.0.3",
155
+ "vitest": "^4.0.4",
158
156
  "wrangler": "^4.45.0",
159
157
  "xml2js": "^0.6.2",
160
158
  "youch": "4.1.0-beta.11",