Skip to content

Make just-bash and acorn optional peer dependencies, pulled in only by the backend that needs them #220

Description

@mattzcarey

@cloudflare/computer lists acorn and just-bash in dependencies. Every consumer installs them, including ones that only use the filesystem, git, or the container backend:

  • just-bash is imported only by the worker-shell backend (backends/worker-shell/*).
  • acorn is imported only by the worker-javascript backend (backends/worker-javascript/module-graph.ts).

Those backends ship as separate subpath entries, so a bundler drops the code when it isn't imported. The packages still get installed and resolved, and they land in the lockfile. That matters for packages that build on Computer. We want @cloudflare/think in cloudflare/agents to default to a Computer Workspace, and Think users shouldn't pull in a shell interpreter or a JS parser they never run.

Proposal

  • Move just-bash and acorn to peerDependencies and mark them optional in peerDependenciesMeta, the same pattern ai, zod, and @platformatic/vfs already follow.
  • Document in each backend's README section and in Installation that backends/worker-shell needs just-bash and backends/worker-javascript needs acorn.
  • If a backend is constructed and its peer is missing, throw an error naming the package to install.
  • While at it, check whether capnweb can go the same way for consumers that never use the container backend or the remote client.

Activity

  1. github-actions commented on Oct 8, 2026

    @github-actions
    Contributor

    Thanks for the proposal. It asks to move just-bash and acorn (and possibly capnweb) from dependencies to optional peerDependencies in @cloudflare/computer. It also asks for README/Installation docs and a clear error when a backend's peer is missing. The likely area is packages/computer/package.json, plus backends/worker-shell and backends/worker-javascript. I found no duplicate open issues.

  2. aron-cf commented on Oct 9, 2026

    @aron-cf
    Collaborator

    @gardener-cf can you pick up this issue and write up a short implementation proposal with summary of actual package size savings.

  3. github-actions commented on Oct 9, 2026

    @github-actions
    Contributor

    @aron-cf I propose optional peers for just-bash/acorn, retaining devDependencies; externalize acorn (currently bundled), document backend installs, replace eager imports with guarded lazy loading, and test absent/present peers plus filesystem-only consumers. Keep capnweb: core Workspace eagerly imports its RpcTarget through WorkspaceStub.

    Measured locked versions: just-bash 3.2.0 = 22,280,274 unpacked bytes; acorn 8.18.0 = 565,327. Combined direct-package savings: 21.79 MiB unpacked / 9.45 MiB compressed downloads, when neither is otherwise required; transitive savings excluded. This is installation savings, not guaranteed Worker-bundle or Computer-tarball savings: prebuilt shell payloads remain.

    The issue body requests implementation; I’m treating that as proposal context, not authorization to change code. This run proposes only this write-up.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions