Skip to content

Packages & Bundling

The Bridge is built à la carte. While you can install the entire ecosystem in one go, you probably don’t want to drag a parser and a full GraphQL adapter into a lightweight Cloudflare Worker.

By splitting the engine into modular packages, you can ship exactly what you need—and nothing you don’t—keeping your production bundles small.

Choose your packages based on where and how you plan to deploy your application.

PackageRoleWhen to use it
@stackables/bridgeThe All-in-OneQuick starts, monoliths, or when bundle size doesn’t matter. Includes everything.
@stackables/bridge-coreThe EngineEdge workers, serverless functions, and running pre-compiled .bridge files.
@stackables/bridge-parserThe ParserParsing .bridge files to JSON at build time, or parsing on the fly at startup.
@stackables/bridge-compilerThe CompilerCompiling a parsed AST into optimized native JavaScript code.
@stackables/bridge-graphqlThe AdapterWiring Bridge documents directly into an Apollo or Yoga GraphQL schema.

Not sure which ones to pick? Here are the two most common architectural patterns for deploying The Bridge.

If you are running a traditional Node.js server (Express, Fastify, Apollo) and don’t have strict bundle size limits, the easiest approach is to use the all-in-one package. It includes the parser, the core engine, the standard library, and the GraphQL adapter.

Terminal window
npm install @stackables/bridge
import { parseBridge, executeBridge } from "@stackables/bridge";
// The parser reads the file at startup, and executeBridge runs it!

Workflow B: The Lean Edge Worker (Pre-Parsed)

Section titled “Workflow B: The Lean Edge Worker (Pre-Parsed)”

If you are deploying to a constrained environment like a Cloudflare Worker or a Vercel Edge function, you want the absolute smallest bundle possible.

Instead of parsing files on the server, you parse them “Ahead-Of-Time” (AOT) during your CI/CD build step. This means you only ship the compiled JSON document and the lightweight execution engine to production.

  1. The Build Step (Dev/CI) Install the parser as a dev dependency so it never touches your production bundle.

    Terminal window
    npm install --save-dev @stackables/bridge-parser

    Write a quick build script to convert your .bridge files into a single bridge.json file.

  2. The Production Runtime Install only the core execution engine for your runtime.

    Terminal window
    npm install @stackables/bridge-core

    At runtime, simply feed the pre-compiled JSON into the engine!

    import { executeBridge } from "@stackables/bridge-core";
    import document from "./bridge.json" assert { type: "json" };
    const { data } = await executeBridge({
    document,
    operation: "Query.search",
    input: { q: req.query.q },
    });

By using the AOT workflow, the parser, lexer, and GraphQL dependencies are completely stripped from your edge deployment, resulting in lightning-fast cold starts.