From 0ac591032d8b3718b390ba99cbd9bf27c2fe80a1 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 7 Sep 2023 18:12:29 +0200 Subject: [PATCH 1/2] fix: bun dev compatibility --- src/cli/index.ts | 6 +++--- src/presets/netlify.ts | 4 ++-- src/rollup/config.ts | 6 +++--- src/runtime/entries/nitro-dev.ts | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/cli/index.ts b/src/cli/index.ts index 6c95b9d8f9..bc54fdf59d 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -1,12 +1,12 @@ #!/usr/bin/env node import { defineCommand, runMain } from "citty"; -import { version } from "../../package.json"; +import nitroPkg from "../../package.json"; const main = defineCommand({ meta: { - name: "nitro", + name: nitroPkg.name, description: "Nitro CLI", - version, + version: nitroPkg.version, }, subCommands: { dev: () => import("./commands/dev").then((r) => r.default), diff --git a/src/presets/netlify.ts b/src/presets/netlify.ts index fb9fcc55dc..59a17461e0 100644 --- a/src/presets/netlify.ts +++ b/src/presets/netlify.ts @@ -2,7 +2,7 @@ import { existsSync, promises as fsp } from "node:fs"; import { join, dirname } from "pathe"; import { defineNitroPreset } from "../preset"; import type { Nitro } from "../types"; -import { name, version } from "../../package.json"; +import nitroPkg from "../../package.json"; // Netlify functions export const netlify = defineNitroPreset({ @@ -80,7 +80,7 @@ export const netlifyEdge = defineNitroPreset({ path: "/*", name: "nitro server handler", function: "server", - generator: `${name}@${version}`, + generator: `${nitroPkg.name}@${nitroPkg.version}`, }, ], }; diff --git a/src/rollup/config.ts b/src/rollup/config.ts index 636b0dcebb..952c25f930 100644 --- a/src/rollup/config.ts +++ b/src/rollup/config.ts @@ -19,7 +19,7 @@ import { hash } from "ohash"; import type { Nitro, NitroStaticBuildFlags } from "../types"; import { resolveAliases } from "../utils"; import { runtimeDir } from "../dirs"; -import { version } from "../../package.json"; +import nitroPkg from "../../package.json"; import { nitroRuntimeDependencies } from "../deps"; import { replace } from "./plugins/replace"; import { virtual } from "./plugins/virtual"; @@ -177,8 +177,8 @@ export const getRollupConfig = (nitro: Nitro): RollupConfig => { client: false, nitro: true, // @ts-expect-error - "versions.nitro": version, - "versions?.nitro": version, + "versions.nitro": nitroPkg.version, + "versions?.nitro": nitroPkg.version, // Internal _asyncContext: nitro.options.experimental.asyncContext, }; diff --git a/src/runtime/entries/nitro-dev.ts b/src/runtime/entries/nitro-dev.ts index 22e67907b3..8fa7cdb7fe 100644 --- a/src/runtime/entries/nitro-dev.ts +++ b/src/runtime/entries/nitro-dev.ts @@ -12,8 +12,8 @@ import { trapUnhandledNodeErrors } from "../utils"; const server = new Server(toNodeListener(nitroApp.h3App)); function getAddress() { - if (provider === "stackblitz" || process.env.NITRO_NO_UNIX_SOCKET) { - return "0"; + if (provider === "stackblitz" || process.env.NITRO_NO_UNIX_SOCKET || process.versions.bun) { + return 0; } const socketName = `worker-${process.pid}-${threadId}.sock`; if (isWindows) { From 324f15336594de72a409974bfcae66efc89ad663 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 7 Sep 2023 16:14:47 +0000 Subject: [PATCH 2/2] chore: apply automated lint fixes --- src/runtime/entries/nitro-dev.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/runtime/entries/nitro-dev.ts b/src/runtime/entries/nitro-dev.ts index 8fa7cdb7fe..fc79b54fd7 100644 --- a/src/runtime/entries/nitro-dev.ts +++ b/src/runtime/entries/nitro-dev.ts @@ -12,7 +12,11 @@ import { trapUnhandledNodeErrors } from "../utils"; const server = new Server(toNodeListener(nitroApp.h3App)); function getAddress() { - if (provider === "stackblitz" || process.env.NITRO_NO_UNIX_SOCKET || process.versions.bun) { + if ( + provider === "stackblitz" || + process.env.NITRO_NO_UNIX_SOCKET || + process.versions.bun + ) { return 0; } const socketName = `worker-${process.pid}-${threadId}.sock`;