bundling

A custom system that combines TypeScript type definitions into one file so the Monaco code editor can provide code completion and type information. Monaco is the browser-based editor used in applications such as code playgrounds.

In plain words
What is it for?
Use it when maintaining the TypeScript declarations for @bubblelab/bubble-core and making them available to the Bubble Studio Monaco editor.
Why use it?
Monaco cannot directly find packages stored in a workspace or their outside dependencies. The bundled file gives the editor the type information it needs in one place.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/bubblelabai/bubblelab/bundling
Clone the repo
git clone --depth 1 https://github.com/bubblelabai/BubbleLab

Made for: Cursor.

Per session 1,505 This file is loaded in full into every session.
When invoked 1,505 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.01505 $0.01505
Opus 5 $0.00753 $0.00753
Sonnet 5 $0.00301 $0.00301
Haiku 4.5 $0.00151 $0.00151

Measured yesterday against content hash e79c26481f02, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

bundling scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/bundling.mdc · 213 lines

How it starts

The opening of the file, as written. The whole thing — 213 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Type Bundling for Monaco Editor

Overview

The project uses a custom type bundling system to provide full TypeScript IntelliSense support in the Monaco editor for @bubblelab/bubble-core and its dependencies. This is necessary because Monaco cannot directly resolve workspace packages or external dependencies.

Architecture

Key Files

  • Bundler Script: packages/bubble-core/scripts/bubble-bundler.ts

    • Processes TypeScript declaration files (.d.ts)
    • Inlines all dependencies into a single self-contained bundle
    • Runs as part of the build process: tsc && tsx scripts/bubble-bundler.ts
  • Bundle Output: packages/bubble-core/dist/bubble-bundle.d.ts

    • Self-contained TypeScript declarations
    • Includes Zod type stubs for type inference
    • Contains inlined types from @bubblelab/shared-schemas
    • All bubble-core types and classes
  • Monaco Integration: apps/bubble-studio/public/bubble-types.txt

    • Copy of the bundle served to the Monaco editor
    • Loaded in apps/bubble-studio/src/components/MonacoEditor.tsx

Bundling Process

  1. Compile TypeScript

    tsc  # Generates .d.ts files in dist/
    
  2. Bundle Types

    • Start from packages/bubble-core/dist/index.d.ts
    • Recursively process all imports:
      • Relative imports (./types/bubble.js) → inline the file content
      • External imports (@bubblelab/shared-schemas) → bundle separately then inline
      • Zod imports → remove (custom stubs provided)
  3. Shared Schemas Handling

    • @bubblelab/shared-schemas is bundled separately via bundleSharedSchemas()
    • Prevents cache key collisions (both packages have index.d.ts)
    • Uses absolute file paths as cache keys to avoid conflicts
    • Inlined content includes all shared types like:
      • BubbleOperationResult
      • BubbleResult<T>
      • BubbleTriggerEventRegistry
      • API schemas, credential types, etc.
  4. Bundle Structure

    // Header comment
    
    // Zod type stubs (for z.infer, z.ZodObject, etc.)
    declare namespace z { ... }
    
    // Inlined shared-schemas types
    export interface BubbleOperationResult { ... }
    export interface BubbleResult<T> { ... }
    
    // Bubble-core types and classes
    export class BubbleFlow { ... }
    export class ServiceBubble { ... }
    

Read the full file on GitHub · 213 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 213 lines · 1,505 tokens per session scan A e79c26481f02

Subscribe to this mod's changes

bundling is a cursor rule published in the GitHub repository bubblelabai/BubbleLab (1,094 stars, last pushed 4mo ago), licensed Apache-2.0. It adds 1,505 tokens to every session, about $0.0075 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.