nitro-nightly 3.1.0-20251028-152513-2890a45f → 3.1.0-20251028-163658-b34f0492

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.
@@ -214,6 +214,11 @@ function _resolveExportConditions(conditions, opts) {
214
214
  resolvedConditions.push("wasm", "unwasm");
215
215
  }
216
216
  resolvedConditions.push("import", "default");
217
+ if ("Bun" in globalThis) {
218
+ resolvedConditions.push("bun");
219
+ } else if ("Deno" in globalThis) {
220
+ resolvedConditions.push("deno");
221
+ }
217
222
  return resolvedConditions.filter(
218
223
  (c, i) => resolvedConditions.indexOf(c) === i
219
224
  );
@@ -20,30 +20,16 @@ async function generateFunctionFiles(nitro) {
20
20
  const buildConfigPath = resolve(nitro.options.output.dir, "config.json");
21
21
  const buildConfig = generateBuildConfig(nitro, o11Routes);
22
22
  await writeFile(buildConfigPath, JSON.stringify(buildConfig, null, 2));
23
- let runtime = nitro.options.vercel?.functions?.runtime;
24
- if (!runtime) {
25
- const vercelConfig = await readVercelConfig(nitro.options.rootDir);
26
- if (vercelConfig.bunVersion || "Bun" in globalThis) {
27
- runtime = `bun${vercelConfig.bunVersion || "1.x"}`;
28
- } else {
29
- const systemNodeVersion = getSystemNodeVersion();
30
- const usedNodeVersion = SUPPORTED_NODE_VERSIONS.find(
31
- (version) => version >= systemNodeVersion
32
- ) ?? SUPPORTED_NODE_VERSIONS.at(-1);
33
- runtime = `nodejs${usedNodeVersion}.x`;
34
- }
35
- }
36
23
  const functionConfigPath = resolve(
37
24
  nitro.options.output.serverDir,
38
25
  ".vc-config.json"
39
26
  );
40
27
  const functionConfig = {
41
- runtime,
42
- ...nitro.options.vercel?.functions,
43
28
  handler: "index.mjs",
44
29
  launcherType: "Nodejs",
45
30
  shouldAddHelpers: false,
46
- supportsResponseStreaming: true
31
+ supportsResponseStreaming: true,
32
+ ...nitro.options.vercel?.functions
47
33
  };
48
34
  await writeFile(functionConfigPath, JSON.stringify(functionConfig, null, 2));
49
35
  for (const [key, value] of Object.entries(nitro.options.routeRules)) {
@@ -207,6 +193,24 @@ function deprecateSWR(nitro) {
207
193
  );
208
194
  }
209
195
  }
196
+ async function resolveVercelRuntime(nitro) {
197
+ let runtime = nitro.options.vercel?.functions?.runtime;
198
+ if (runtime) {
199
+ return runtime;
200
+ }
201
+ const vercelConfig = await readVercelConfig(nitro.options.rootDir);
202
+ if (vercelConfig.bunVersion || "Bun" in globalThis) {
203
+ runtime = "bun1.x";
204
+ } else {
205
+ const systemNodeVersion = getSystemNodeVersion();
206
+ const usedNodeVersion = SUPPORTED_NODE_VERSIONS.find((version) => version >= systemNodeVersion) ?? SUPPORTED_NODE_VERSIONS.at(-1);
207
+ runtime = `nodejs${usedNodeVersion}.x`;
208
+ }
209
+ nitro.options.vercel ??= {};
210
+ nitro.options.vercel.functions ??= {};
211
+ nitro.options.vercel.functions.runtime = runtime;
212
+ return runtime;
213
+ }
210
214
  async function readVercelConfig(rootDir) {
211
215
  const vercelConfigPath = resolve(rootDir, "vercel.json");
212
216
  const vercelConfig = await fsp.readFile(vercelConfigPath).then((config) => JSON.parse(config.toString())).catch(() => ({}));
@@ -322,6 +326,12 @@ const vercel = defineNitroPreset(
322
326
  preview: ""
323
327
  },
324
328
  hooks: {
329
+ "build:before": async (nitro) => {
330
+ const runtime = await resolveVercelRuntime(nitro);
331
+ if (runtime.startsWith("bun") && !nitro.options.exportConditions.includes("bun")) {
332
+ nitro.options.exportConditions.push("bun");
333
+ }
334
+ },
325
335
  "rollup:before": (nitro) => {
326
336
  deprecateSWR(nitro);
327
337
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitro-nightly",
3
- "version": "3.1.0-20251028-152513-2890a45f",
3
+ "version": "3.1.0-20251028-163658-b34f0492",
4
4
  "description": "Build and Deploy Universal JavaScript Servers",
5
5
  "homepage": "https://nitro.build",
6
6
  "repository": "nitrojs/nitro",