Skip to content

feat: add bun support#159

Merged
beeman merged 1 commit intomainfrom
feat/add-bun-support
Jun 16, 2025
Merged

feat: add bun support#159
beeman merged 1 commit intomainfrom
feat/add-bun-support

Conversation

@tobeycodes
Copy link
Contributor

@tobeycodes tobeycodes commented Jun 13, 2025

Closes #139

@changeset-bot
Copy link

changeset-bot bot commented Jun 13, 2025

🦋 Changeset detected

Latest commit: c51ef37

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
create-solana-dapp Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment on lines 19 to 36
export function detectInvokedPackageManager(): PackageManager {
let detectedPackageManager: PackageManager = 'npm'
const invoker = require.main

if (!invoker) {
return detectedPackageManager
if (process.env.npm_config_user_agent) {
for (const pm of packageManagers) {
if (process.env.npm_config_user_agent.startsWith(`${pm}/`)) {
return pm
}
}
}

for (const pkgManager of packageManagers) {
if (invoker.path.includes(pkgManager)) {
detectedPackageManager = pkgManager
break
if (process.env.npm_execpath) {
for (const pm of packageManagers) {
if (process.env.npm_execpath.split(sep).includes(pm)) {
return pm
}
}
}
return detectedPackageManager
return 'npm'
}
Copy link
Contributor Author

@tobeycodes tobeycodes Jun 13, 2025

Choose a reason for hiding this comment

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

@beeman i am not sure if this function needs to change or not but this is what nx is using now https://github.com/nrwl/nx/blob/master/packages/create-nx-workspace/src/utils/package-manager.ts

is there a way to test bun create with a local build of solana-create-app? i get the error warn: bun create [local file] only supports .jsx and .tsx files currently

currently this code is working for bunx but otherwise untested

Copy link
Collaborator

@beeman beeman Jun 13, 2025

Choose a reason for hiding this comment

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

I'll take a look at the differences between those.

This is what I'm getting with bun create
image
image

Copy link
Contributor Author

@tobeycodes tobeycodes Jun 13, 2025

Choose a reason for hiding this comment

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

it would appear that the old way with require.main has some weird cases oven-sh/bun#8113

For example if I do bun exec ~/Developer/create-solana-dapp/dist/bin/index.cjs then process.env.verisons.bun is undefined but bun ~/Developer/create-solana-dapp/dist/bin/index.cjs (without the exec) has it

Also, if you currently try bun on the current version it thinks it'syarn

> $ bun create solana-dapp --verbose                                                                                                                                                     
  packageManager: 'yarn',

i think the changes i made to the function should work for bun create though oven-sh/bun#11016

Copy link
Collaborator

Choose a reason for hiding this comment

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

I just did some local testing and managed to get a working project with bun.

I reckon we can merge it and see how it works in the wild and fix any issues

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That sounds good to me

@beeman beeman self-assigned this Jun 14, 2025
@beeman beeman force-pushed the feat/add-bun-support branch from 292c562 to c51ef37 Compare June 16, 2025 10:46
@beeman beeman merged commit c51ef37 into main Jun 16, 2025
64 checks passed
@beeman beeman deleted the feat/add-bun-support branch June 16, 2025 10:56
@github-actions github-actions bot mentioned this pull request Jun 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add 1st class support for bun

2 participants