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

Introduce experimental flag: bun build --auto-install <entry points...> #15510

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

Jarred-Sumner
Copy link
Collaborator

@Jarred-Sumner Jarred-Sumner commented Nov 30, 2024

What does this PR do?

This implements auto install for bun build.

When using bun's bundler, you can now automatically install dependencies -- and only the dependencies the bundled code is using. This means you can skip running bun install (or npm/yarn/pnpm install).

This can lead to smaller Docker containers and faster CI times than using something like turbo prune or "devDependencies" in package.json because dependencies which are not used by any code will not be installed.

To use it:

bun build --auto-install <entry-points...>
bun build -i <entry-points>

If a bun.lockb or a package-json.lock is present, it will continue to use the resolved versions from the lockfile (and will still save space because it only installs those which are referenced). If no lockfile is present, it will prefer the versions from package.json.

Tradeoffs:

  • This doesn't run any postinstall scripts
  • This doesn't support patch (though that could be fixed in the future)
  • If dependencies are not imported or required in any code visible to bun build, it will not be installed

This uses bun's global cache, which conserves disk space by avoiding a per-project node_modules folder.

How did you verify your code works?

TODO before merging:

  • Handle manifest download errors
  • Handle package download errors
  • Investigate difficulty of supporting Bun.build()
  • Be a little smarter about resolving package versions
  • Some tests

@robobun
Copy link

robobun commented Nov 30, 2024

@Jarred-Sumner, your commit 394701e has 15 failures in #7130:

  • test/js/bun/http/bun-serve-static.test.ts - timeout on 🐧 3.20 x64-baseline
  • test/cli/hot/hot.test.ts - timeout on 🐧 3.20 x64-baseline
  • test/cli/hot/hot.test.ts - timeout on 🐧 3.20 x64
  • test/js/web/timers/setTimeout.test.js - 1 failing on 🐧 22.04 x64
  • test/js/node/test/parallel/worker-nested-uncaught.test.js - segmentation fault on 🐧 3.20 x64-baseline
  • test/integration/next-pages/test/dev-server.test.ts - 1 failing on 🐧 3.20 x64-baseline
  • test/integration/next-pages/test/dev-server.test.ts - 1 failing on 🐧 3.20 x64
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 22.04 x64-baseline
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 3.20 aarch64
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 22.04 x64
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 3.20 x64-baseline
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 3.20 x64
  • test/v8/v8.test.ts - 22 failing on 🐧 3.20 aarch64
  • test/v8/v8.test.ts - 22 failing on 🐧 3.20 x64-baseline
  • test/v8/v8.test.ts - 22 failing on 🐧 3.20 x64
  • test/js/node/child_process/child_process.test.ts - 1 failing on 🐧 3.20 aarch64
  • test/js/node/child_process/child_process.test.ts - 1 failing on 🐧 3.20 x64-baseline
  • test/js/node/child_process/child_process.test.ts - 1 failing on 🐧 3.20 x64
  • test/js/bun/http/serve.test.ts - SIGTRAP on 🐧 3.20 aarch64
  • test/js/bun/http/serve.test.ts - SIGILL on 🐧 3.20 x64-baseline
  • test/js/bun/http/serve.test.ts - SIGILL on 🐧 3.20 x64
  • test/bake/dev/esm.test.ts - 1 failing on 🐧 3.20 aarch64
  • test/js/bun/http/serve-body-leak.test.ts - 1 failing on 🍎 13 aarch64
  • test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🪟 2019 x64-baseline
  • test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🪟 2019 x64
  • test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🍎 14 aarch64
  • test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🍎 13 aarch64
  • test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🍎 14 x64
  • test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🍎 13 x64
  • test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🐧 11 aarch64
  • test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🐧 12 aarch64
  • test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🐧 22.04 aarch64
  • test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🐧 20.04 aarch64
  • test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🐧 12 x64-baseline
  • test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🐧 11 x64-baseline
  • test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🐧 20.04 x64-baseline
  • test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🐧 12 x64
  • test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🐧 22.04 x64
  • test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🐧 3.20 aarch64
  • test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🐧 11 x64
  • test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🐧 20.04 x64
  • test/cli/install/registry/bun-install-registry.test.ts - timeout on 🐧 22.04 x64-baseline
  • test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🐧 3.20 x64-baseline
  • test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🐧 3.20 x64
  • test/cli/run/require-cache.test.ts - 1 failing on 🪟 2019 x64-baseline
  • test/cli/install/bun-workspaces.test.ts - 1 failing on 🪟 2019 x64
  • test/cli/install/bun-workspaces.test.ts - 1 failing on 🪟 2019 x64-baseline
  • test/cli/install/bun-workspaces.test.ts - 1 failing on 🍎 13 aarch64
  • test/cli/install/bun-workspaces.test.ts - 1 failing on 🍎 14 aarch64
  • test/cli/install/bun-workspaces.test.ts - 1 failing on 🍎 14 x64
  • test/cli/install/bun-workspaces.test.ts - 1 failing on 🍎 13 x64
  • test/cli/install/bun-workspaces.test.ts - 1 failing on 🐧 12 aarch64
  • test/cli/install/bun-workspaces.test.ts - 1 failing on 🐧 11 aarch64
  • test/cli/install/bun-workspaces.test.ts - 1 failing on 🐧 22.04 aarch64
  • test/cli/install/bun-workspaces.test.ts - 1 failing on 🐧 20.04 aarch64
  • test/cli/install/bun-workspaces.test.ts - 1 failing on 🐧 11 x64-baseline
  • test/cli/install/bun-workspaces.test.ts - 1 failing on 🐧 12 x64-baseline
  • test/cli/install/bun-workspaces.test.ts - 1 failing on 🐧 20.04 x64-baseline
  • test/cli/install/bun-workspaces.test.ts - 1 failing on 🐧 22.04 x64-baseline
  • test/cli/install/bun-workspaces.test.ts - 1 failing on 🐧 3.20 aarch64
  • test/cli/install/bun-workspaces.test.ts - 1 failing on 🐧 22.04 x64
  • test/cli/install/bun-workspaces.test.ts - 1 failing on 🐧 12 x64
  • test/cli/install/bun-workspaces.test.ts - 1 failing on 🐧 11 x64
  • test/cli/install/bun-workspaces.test.ts - 1 failing on 🐧 20.04 x64
  • test/cli/install/bun-workspaces.test.ts - 1 failing on 🐧 3.20 x64-baseline
  • test/cli/install/bun-workspaces.test.ts - 1 failing on 🐧 3.20 x64
  • test/cli/install/bun-run.test.ts - 2 failing on 🍎 13 aarch64
  • test/cli/install/bun-run.test.ts - 2 failing on 🍎 14 aarch64
  • test/cli/install/bun-run.test.ts - 2 failing on 🍎 13 x64
  • test/cli/install/bun-run.test.ts - 2 failing on 🍎 14 x64
  • test/cli/install/bun-run.test.ts - 2 failing on 🪟 2019 x64
  • test/cli/install/bun-run.test.ts - 2 failing on 🪟 2019 x64-baseline
  • test/cli/install/bun-run.test.ts - 2 failing on 🐧 12 aarch64
  • test/cli/install/bun-run.test.ts - 2 failing on 🐧 11 aarch64
  • test/cli/install/bun-run.test.ts - 2 failing on 🐧 22.04 aarch64
  • test/cli/install/bun-run.test.ts - 2 failing on 🐧 20.04 aarch64
  • test/cli/install/bun-run.test.ts - 2 failing on 🐧 11 x64-baseline
  • test/cli/install/bun-run.test.ts - 2 failing on 🐧 12 x64-baseline
  • test/cli/install/bun-run.test.ts - 2 failing on 🐧 20.04 x64-baseline
  • test/cli/install/bun-run.test.ts - 2 failing on 🐧 22.04 x64-baseline
  • test/cli/install/bun-run.test.ts - 2 failing on 🐧 3.20 aarch64
  • test/cli/install/bun-run.test.ts - 2 failing on 🐧 11 x64
  • test/cli/install/bun-run.test.ts - 2 failing on 🐧 12 x64
  • test/cli/install/bun-run.test.ts - 2 failing on 🐧 20.04 x64
  • test/cli/install/bun-run.test.ts - 2 failing on 🐧 22.04 x64
  • test/cli/install/bun-run.test.ts - 2 failing on 🐧 3.20 x64-baseline
  • test/cli/install/bun-run.test.ts - 2 failing on 🐧 3.20 x64
  • 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.

    2 participants