Repository navigation
Description
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 newpins 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-toastyAdd the documented toast import to app.tsx:
import { toast } from "sonner";
// ...call toast.success("hi") from any handlerThen:
npx tsc --noEmit # fails
bb plugin build # succeedsSmallest 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:
RUNTIME_SLOT_BY_SPECIFIER— includessonner,vaul, ten radix families,clsx,tailwind-merge,class-variance-authority.shimExportsOf— every non-SDK specifier resolves throughRUNTIME_EXPORT_MANIFEST[specifier], a generated table, so the package need not be present.- Generated by
generate-runtime-export-manifest.mjs.
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 --checkreportspin 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;vauland 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:
- 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.
- Have
bb plugin new --apppre-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
SawyerHood commentedon Aug 21, 2026
Reproduction & root-cause report: https://get-bb.github.io/reports/issues/2072.html
bb plugin types(syncPluginTypes in packages/templates/src/plugin-scaff…npm packtarball 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 independencieswas 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 adependenciesentry "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).
Declare every runtime-shimmed package for types in plugin scaffolds
Declare every runtime-shimmed package for types in plugin scaffolds (g…