bun icon indicating copy to clipboard operation
bun copied to clipboard

bun installer should support a `--prune` option

Open rubys opened this issue 2 years ago • 4 comments

What is the problem this feature would solve?

When building for deployment (i.e., there is a build step defined in package.json), a common paradigm is to install all dependencies (including devDependencies), run the build step, then prune the devDependencies. npm, yarn, and pnpm all support this feature.

What is the feature you are proposing to solve the problem?

A prune subcommand or option, much like npm, yarn, and pnpm already support.

What alternatives have you considered?

Here's what I'm currently emitting in Dockerfiles when Bun applications are launched at fly.io:

rm -rf node_modules && bun install --ci

See also: packagerPrune and Fly.io ❤️ Bun.

rubys avatar Jul 11 '23 17:07 rubys

+1

mmarifat avatar Aug 01 '24 09:08 mmarifat

this option would help a lot in Dockerfiles

an abbreviated example

FROM oven/bun:slim AS base

FROM base as dependencies
COPY bun.lockb package.json ./
RUN bun install

FROM dependencies AS production

RUN bun prune --production

FROM base
COPY --from=production node_modules/ ./node_modules/

nksfrank avatar Oct 21 '24 09:10 nksfrank

bun prune --production

This gives the following result:

Uh-oh. bun prune is a subcommand reserved for future use by Bun.

If you were trying to run a package.json script called prune, use bun run prune.

bun -v 1.1.33

anime-shed avatar Oct 30 '24 13:10 anime-shed

+1

Pahlaz avatar Dec 19 '24 16:12 Pahlaz

+1 I would love to be able to prune extraneous packages, especially in a workspace 👍

nwidynski avatar Apr 25 '25 13:04 nwidynski

It would be super useful

rokartur avatar Aug 06 '25 01:08 rokartur

Bump

hubertoschusch avatar Aug 06 '25 10:08 hubertoschusch