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

Build command in generated README.md does not work with Bun #614

Open
Hornwitser opened this issue Nov 14, 2024 · 3 comments · May be fixed by #615
Open

Build command in generated README.md does not work with Bun #614

Hornwitser opened this issue Nov 14, 2024 · 3 comments · May be fixed by #615
Labels
bug Something isn't working

Comments

@Hornwitser
Copy link

Describe the bug

When creating a project using bun create vue the generated readme contains the following instructions to run bun build in order to compile and minify the project.

### Compile and Minify for Production

```sh
bun build
```

But trying to run this gives a confusing error message

> bun build
bun build v1.1.34 (5e5e7c60)
error: Missing entrypoints. What would you like to bundle?

Usage:
  $ bun build <entrypoint> [...<entrypoints>] [...flags]

To see full documentation:
  $ bun build --help

This doesn't work because Bun has a built-in build command which gets executed instead of the build script defined in package.json.

Expected behavior

The generated readme uses bun run build instead, as this will run the build script instead of the built-in bun bundler.

How to reproduce

  1. Run bun create vue
  2. Accept all defaults
  3. Observe that vue-project/README.md mentions using bun build instead of bun run build
  4. Observe that running bun build gives an error message instead of invoking the build script.
@Hornwitser Hornwitser added the bug Something isn't working label Nov 14, 2024
@cexbrayat
Copy link
Member

Hi @Hornwitser

👍 Can you open a PR to fix this? We will gladly review and merge it!

The readme generator is in

export default function generateReadme({
I think there are no unit tests for this function, but you can add some in __test__ if you're up to it.

@Hornwitser
Copy link
Author

By fixing this, do you mean adding run between ${packageManager} and ${scriptName} here?

: `${packageManager} ${scriptName} ${args}`
} else {
return packageManager === 'npm' ? `npm run ${scriptName}` : `${packageManager} ${scriptName}`

What I will say is that while shortcuts like pnpm build or just yarn are nice, they make it more difficult for new developers to understand what's going on and find the relevant documentation. They also run the risk of the package managers adding new commands that clash with them.

@cexbrayat
Copy link
Member

I don't think we want to add it for every command, you can just add it for bun build, like:

if (scriptName === 'build') {
    return packageManager === 'bun' ? 'bun run build' : `${packageManager} build`
  }

@Hornwitser Hornwitser linked a pull request Nov 17, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants