Skip to content

Plugin frontends cannot typecheck imports of BB-shimmed packages (sonner, vaul, most radix families) #2072

Closed

Description

@andrewkchan

Summary

bb plugin build shims a fixed set of packages to the host runtime, and the docs tell plugin authors to import them directly — import { toast } from "sonner" is the documented way to reach BB's toaster. That import builds correctly but does not typecheck: nothing ships type declarations for the shimmed specifiers, so tsc reports TS2307: Cannot find module 'sonner'. The workaround is a devDependency on a package that is never bundled and never needs to be installed for the build to work, which is both non-obvious and easy to get wrong in a harmful direction (putting it in dependencies is the intuitive fix, and that is exactly what must not happen).

Observed while writing a fileOpener plugin. I am confident about the build/typecheck asymmetry (verified below); the framing that this is a gap rather than intentional is my read.

Versions and environment

  • bb 0.38.0 (desktop app) for the packaged server, plus a dev build from source at 6be45053be92f964895038fc374a45e759087479 (main). Reproduces on both.
  • Plugin SDK 0.4.6 (the version bb plugin new pins on 0.38.0).
  • macOS 14 (Darwin 23.3.0), Node v26.7.0.
  • Plugin installed from a path (bb plugin install .).

Steps to reproduce

bb plugin new toasty --app
cd bb-plugin-toasty

Add the documented toast import to app.tsx:

import { toast } from "sonner";
// ...call toast.success("hi") from any handler

Then:

npx tsc --noEmit    # fails
bb plugin build     # succeeds

Smallest form: the import alone is enough; no call is required.

Does not reproduce for react or @radix-ui/react-dialog, because the scaffold happens to pre-install @types/react and @radix-ui/react-dialog for the vendored components. That is what hides the general problem.

Expected vs actual

Actual — typecheck fails while the build succeeds:

$ npx tsc --noEmit
components/FileToolbar.tsx(2,23): error TS2307: Cannot find module 'sonner' or its corresponding type declarations.

$ bb plugin build
dist/server.js
dist/server.meta.json
dist/app.js
dist/app.css
dist/app.meta.json

I confirmed the build genuinely does not need the package by deleting it first:

$ mv node_modules/sonner /tmp/parked
$ bb plugin build     # still succeeds, emits a correct shim
$ npx tsc --noEmit
components/FileToolbar.tsx(2,23): error TS2307: Cannot find module 'sonner' ...

Expected: a documented shimmed import typechecks out of the box, with no devDependency on a package that is never installed at runtime and not required to build.

Evidence

Shimmed specifiers come from a static slot map, and their export lists come from a generated manifest — not from the plugin's node_modules:

So BB already knows the exact export surface of these packages at build time. It just never turns that knowledge into declarations. grep -ci sonner node_modules/@get-bb/plugin-sdk/bundled-types/bb-plugin-sdk-app.d.ts → 0.

What a fresh bb plugin new --app covers today, of the shimmed set: react, react-dom (via @types/*) and @radix-ui/react-dialog. Uncovered: sonner, vaul, @pierre/diffs (+/react), and nine radix families — all documented as importable in the bb-plugin-authoring skill.

Related inconsistency in the same area, possibly worth folding in: the scaffold puts clsx, tailwind-merge, and class-variance-authority in dependencies even though all three are shimmed and never bundled. Harmless, but it points the author at the wrong section for exactly this class of package.

What you ruled out

  • Not a duplicate: searched open and closed issues for sonner, plugin shimmed package types, plugin sdk types devDependency, runtime export manifest — no matches.
  • Not a stale-pin problem: bb plugin types --check reports pin is 0.4.6, host is 0.4.6.
  • Not specific to sonner: it is the first shimmed package the scaffold does not already install types for; vaul and the other radix families have the same shape.
  • Not a build failure: the build succeeds with the package absent entirely, which is what makes the devDependency workaround confusing rather than merely tedious.

Suggested priority and effort

Low priority, small effort, no data loss — every plugin author hits it once and works around it with a devDependency. It costs an hour of confusion per author and invites the dependencies mistake that silently bloats a plugin bundle.

Two options, in rough order of principle:

  1. Ship ambient declarations for shimmed specifiers with the SDK, generated from the same source as the runtime export manifest, so the documented import typechecks with no devDependency at all.
  2. Have bb plugin new --app pre-install the shimmed packages as devDependencies with a comment. Cheaper, but an author who adds a shimmed import later hits the same wall.

Found in bb thread thr_nnk8m7d8gw while building a Monaco fileOpener plugin (see also #2026 for unrelated fileOpener fixes from the same work).

AGENT GENERATED: by Claude Opus 5

Activity

  1. added
    plugins
    on Aug 21, 2026
  2. added theissue type on Aug 21, 2026
  3. SawyerHood commented on Aug 21, 2026

    @SawyerHood
    Collaborator

    Reproduction & root-cause report: https://get-bb.github.io/reports/issues/2072.html

    • Verdict: REPRODUCED · root-cause confidence: high
    • Root cause (short): bb plugin build resolves the 21 shimmed specifiers via an esbuild onResolve filter + generated export manifest (never node_modules), while tsc uses node resolution and neither the scaffold (whose type-only devDependencies are only the shimmed packages the 4 starter components happen to import) nor the SDK's bundled .d.ts nor the docs supply declarations for 13 of them (sonner, vaul, @pierre/diffs(+/react), nine radix families).
    • Proposed fix: (1) In packages/templates/scripts/generate-plugin-scaffold.mjs, add every runtime-shimmed package (not just the starter-component subset) to the type-only devDependencies, versions mirrored from apps/app/package.json via the existing versionedDeps(); ideally move RUNTIME_SLOT_BY_SPECIFIER into a single data module shared by build-plugin-app.ts and the generator so the hand-copied SHIMMED_SPECIFIERS set (already missing @pierre/diffs) cannot drift. A prototype of this makes the repro test pass (diff in repro/). (2) Extend bb plugin types (syncPluginTypes in packages/templates/src/plugin-scaff…
    • Caveats: SDK 0.4.11 at base is unpublished, so the scaffold's pin was satisfied with an npm pack tarball of packages/plugin-sdk (the workaround the CLI itself prints); with a published SDK the steps are identical. The issue's side claim that clsx/tailwind-merge/cva land in dependencies was true for 0.38.0 but was already fixed by Stop committing generated modules; turbo generates them #1943 before the base commit. The claim that a dependencies entry "sile…

    The report has copy-paste repro steps, screenshots where the bug is visual, code permalinks at the base commit, and repro artifacts. It was independently re-run by a second agent (see its Verification section).

    AGENT GENERATED: by Claude Opus 5

  4. added
    confirmed-repro
    on Aug 21, 2026
  5. self-assigned this
    on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

confirmed-reproplugins

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions