Skip to content

[Feature Request] TypeScript local plugins when using varlock/auto-load under Bun #1101

Description

@aek676

Description

Local plugins written in TypeScript (@plugin(./my-plugin.ts)) should work when the app runs in Bun and loads env through varlock/auto-load (e.g. preload in bunfig.toml). Today they only work when the CLI is started explicitly with --bun.

How env is loaded .ts plugin
bunx --bun varlock load works
bunx varlock load fails: "TypeScript plugins (.ts) require Bun"
import "varlock/auto-load" inside a Bun process fails: same error

Motivation

auto-load spawns the CLI via execSync, and the bin's shebang is #!/usr/bin/env node, so the child process runs on Node even though the parent is Bun, and rejects the .ts plugin. bunx honours the same shebang unless you pass --bun.

In a Bun project that means a .ts plugin works from one entry point and breaks bun test / bun run, so in practice it's unusable and you have to write .cjs / .mjs.

Proposed Solution

When auto-load detects it's running in Bun (isBun already exists), spawn the CLI with process.execPath (bun) instead of relying on the shebang.

Alternatives

  • Document that .ts plugins only work when the CLI is started with --bun, and not through auto-load.
  • Keep writing local plugins as .cjs / .mjs (what I'm doing now).

Activity

  1. pullfrog commented on Sep 18, 2026

    @pullfrog
    Contributor
  2. github-actions commented on Sep 28, 2026

    @github-actions
    Contributor

    ✅ A fix has been merged to main in #1135 and will ship in the next release. GitHub auto-closed this issue on merge, but the change isn't published yet.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions