Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Bun support #8039

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/create-cloudflare/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
logRaw,
startSection,
} from "@cloudflare/cli";
import { bgYellow, yellow } from "@cloudflare/cli/colors";

Check failure on line 12 in packages/create-cloudflare/src/cli.ts

View workflow job for this annotation

GitHub Actions / Checks

'yellow' is defined but never used. Allowed unused vars must match /^_/u

Check failure on line 12 in packages/create-cloudflare/src/cli.ts

View workflow job for this annotation

GitHub Actions / Checks

'yellow' is defined but never used
import { CancelError } from "@cloudflare/cli/error";
import { isInteractive } from "@cloudflare/cli/interactive";
import { cliDefinition, parseArgs } from "helpers/args";
Expand Down Expand Up @@ -41,6 +42,13 @@
const { npm } = detectPackageManager();

export const main = async (argv: string[]) => {
if (process.versions.bun || npm === "bun") {
console.warn(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a regression in Bun v1.2.0 that impacted this, but that regression was fixed in Bun v1.2.1. I manually verified it works without error in Bun v1.2.1 and Bun v1.2.2 (and that it regressed in Bun v1.2.0, which matches what you saw in the CI runs). We are adding more tests from Node.js' test suite to catch bugs like this in the future.

Is this warning still needed? We will fix anything else that comes up

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. Bun’s continued disregard for ecosystem compatibility puts burden on third party maintainers, as well as the community where often “use Node.js” is the solution to most issues once Bun is discovered to be used.

In my opinion, until Bun commits to join something like WinterTC and work closely with other runtimes before implementing ecosystem breaking or diverging features, I don’t imagine this burden will change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that the error has been changed to a warning, I'd personally still go with the error so users are aware - a good portion of the questions we get in the Discord could be resolved by the user if they read the message.

And with bun, most of the time the solution is to use node, and things magically start working.

bgYellow(
`Create Cloudflare does not support Bun. Please try this command again using npm, pnpm, or yarn (e.g. \`npm create cloudflare\`). If you continue to use Bun, things may work, but any issues you encounter will not necessarily be fixed by Cloudflare. Please report any incompatibilities or bugs to Bun: https://github.com/oven-sh/bun/issues/new`,
),
);
}
const result = await parseArgs(argv);

if (result.type === "unknown") {
Expand Down
15 changes: 14 additions & 1 deletion packages/create-cloudflare/src/helpers/packageManagers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import whichPmRuns from "which-pm-runs";
import { runCommand } from "./command";
import type { C3Context } from "types";

export type PmName = "pnpm" | "npm" | "yarn";
export type PmName = "pnpm" | "npm" | "yarn" | "bun";

/**
* Detects the package manager which was used to invoke C3 and provides a map of its associated commands.
Expand Down Expand Up @@ -63,6 +63,14 @@ export const detectPackageManager = () => {
npx: "yarn",
dlx: ["yarn"],
};
case "bun":
return {
name,
version,
npm: "bun",
npx: "bunx",
dlx: ["bunx"],
};

case "npm":
default:
Expand Down Expand Up @@ -122,5 +130,10 @@ export const detectPmMismatch = (ctx: C3Context) => {
return !existsSync(path.join(projectPath, "yarn.lock"));
case "pnpm":
return !existsSync(path.join(projectPath, "pnpm-lock.yaml"));
case "bun":
return (
!existsSync(path.join(projectPath, "bun.lockb")) &&
!existsSync(path.join(projectPath, "bun.lock"))
);
}
};
4 changes: 4 additions & 0 deletions packages/create-cloudflare/src/helpers/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export const installPackages = async (
cmd = "add";
saveFlag = config.dev ? "-D" : "";
break;
case "bun":
cmd = "add";
saveFlag = config.dev ? "-d" : "";
break;
case "npm":
case "pnpm":
default:
Expand Down
Loading