Skip to content

research: can Bun zero-install respect package.json versions (not fetch latest)? #684

Description

@vivek7405

Question

Can a zero-install Bun app (bun create webjs --no-install, then bun run dev / start via the webjs-bun.mjs bootstrap with no node_modules) RESPECT the package.json versions (and ideally bun.lock) instead of fetching latest?

Seed finding (verified this session, fresh cache)

Bun's bun --bun <file> auto-install (the exact zero-install run path) IGNORES both package.json versions AND a committed bun.lock, fetching latest for any bare import not physically in node_modules:

  • A package.json pinning zod EXACTLY to 3.22.4 ran zod 4.4.3.
  • Keeping a bun.lock that pinned 3.22.4 (with node_modules deleted) STILL ran 4.4.3.
  • Only bun install (which materializes node_modules) honors the manifest/lockfile.

So the #675 zero-install path runs UNPINNED LATEST deps, a breaking-major hazard. This is why #682 (defaulting bun create to --no-install) was closed, and why #683 corrects the docs to say so plainly. If this research finds a version-respecting mechanism, #682's default-flip becomes viable.

Avenues to investigate (for the agent who picks this up)

  1. A bunfig.toml [install] setting, or any Bun flag / env var, that makes auto-install honor the manifest/lockfile rather than fetching latest.
  2. Bun.plugin onResolve: webjs already registers a Bun.plugin for TS-strip + action seeding (packages/server/src/action-seed-bun.js). An onResolve hook could intercept bare specifiers and resolve them to the package.json/bun.lock-pinned version (read the manifest + lockfile at boot, rewrite resolution to the pinned tarball in the cache).
  3. A lightweight pre-resolve step: on first run, read package.json + bun.lock and warm Bun's global cache at the EXACT versions (without a full node_modules materialize), so the subsequent auto-install resolves the pinned copies from cache.
  4. Whether a private registry mirror + a warmed/pinned cache (the sandbox+PaaS direction) is the only robust fix at scale.
  5. Confirm whether bun run <script> differs from bun --bun <file> here, and whether a newer Bun version changes the behavior (re-test on the latest Bun).

Cross-references

This is a forward-looking research task. Findings go into this same issue (comments + a curated conclusion in the body), then close it when the research concludes.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

researchResearch/design/decision record (no code); filter these to read design history

Type

No type

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions