typescript2/README.md
VSCode extension and web app for the BAML Playground.
typescript2/
├── app-vscode-ext/ # VSCode extension (hosts the webview)
├── app-vscode-webview/ # Vite React app (rendered in VSCode webview)
├── app-promptfiddle/ # Standalone web app
└── pkg-playground/ # Shared playground logic
# Install dependencies
pnpm install
# Build all packages
pnpm build && pnpm build:wasm
# Type check all packages
pnpm typecheck
Run these in separate terminals:
# Terminal 1: Watch-build the extension
pnpm dev:vscode
# Terminal 2: Run Vite dev server for webview
# Depends on 'pnpm build:wasm' or 'pnpm dev:wasm'
pnpm dev:webview
# Terminal 3 (optional): Watch and rebuild WASM on Rust changes
pnpm dev:wasm
Then in VSCode, press F5 and select "Launch VS Code extension (v2)".
From typescript2/, build and package the VS Code extension with:
pnpm vscode:package
The VSIX is written to:
app-vscode-ext/app-vscode-ext-0.1.0.vsix
What pnpm vscode:package does:
Removes stale packaged outputs:
rm -rf app-vscode-webview/dist app-vscode-ext/dist app-vscode-ext/*.vsix
Builds the browser WASM bridge:
pnpm build:wasm
The VSIX is platform-neutral. It does not bundle baml-cli; the extension launches baml lsp through the configured baml wrapper or baml on PATH.
Generates protobuf TypeScript bindings:
pnpm --filter @b/pkg-proto generate
Builds the packaged React webview:
pnpm --filter app-vscode-webview build
Builds the VS Code extension host bundle:
pnpm --filter baml-language build
Stages runtime assets into the extension package:
rm -rf app-vscode-ext/dist/playground
mkdir -p app-vscode-ext/dist/playground
cp -R app-vscode-webview/dist/. app-vscode-ext/dist/playground/
Packages the VSIX:
cd app-vscode-ext
pnpm dlx @vscode/vsce package --no-dependencies --allow-missing-repository --skip-license
The packaged extension includes dist/extension.js and the built webview under dist/playground. It launches baml lsp through the wrapper, so the same VSIX can work across supported platforms and project toolchain pins.
pnpm dev:promptfiddle
The VSCode extension uses Vitest for unit testing.
pnpm --filter app-vscode-ext test # watch mode
pnpm --filter app-vscode-ext test:run # single run
Tests are located in app-vscode-ext/src/**/__tests__/.
The webview app (app-vscode-webview) uses Vitest with React Testing Library for component testing.
pnpm --filter app-vscode-webview test:browser # watch mode
pnpm --filter app-vscode-webview test:browser:run # single run
pnpm --filter app-vscode-webview test:unit
pnpm --filter app-vscode-webview test:unit:run
*.browser.test.ts,tsx) by default: these allow testing components that depend on WASM.
wasm-bindgen shim that we need to initWasm() requires a browser-based implementation of fetch, so testing anything that depends on WASM must go in a browser test*.test.ts,tsx excluding the above) if you don't need to depend on WASM or other browser APIs. These use @testing-library/react which is backed by jsdom, a fake browser implementation.# From the typescript2 directory
pnpm --filter app-vscode-ext test:run
pnpm --filter app-vscode-webview test:run # Runs unit and browser tests