npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@stackables/bridge-compiler

v2.5.1

Published

Compiles a BridgeDocument into highly optimized JavaScript code

Readme

github

The Bridge Compiler

🧪 Experimental: This package is currently in Beta. It passes all core test suites, but some edge-case Bridge language features may behave differently than the standard bridge-core interpreter. Use with caution in production.

The high-performance, native JavaScript execution engine for The Bridge.

While the standard @stackables/bridge-core package evaluates Bridge ASTs dynamically at runtime (an Interpreter), this package acts as a Just-In-Time (JIT) / Ahead-of-Time (AOT) Compiler. It takes a parsed Bridge AST, topologically sorts the dependencies, and generates a raw V8-optimized JavaScript function.

The result? Zero-allocation array loops, native JS math operators, and maximum throughput (RPS) that runs neck-and-neck with hand-coded Node.js.

Installing

npm install @stackables/bridge-compiler

When to Use This

Use the Compiler when you need maximum performance in a Node.js, Bun, or standard Deno environment. It is designed for the Compile-Once, Run-Many workflow.

On the very first request, the engine compiles the operation into native JavaScript and caches the resulting function in memory. Subsequent requests bypass the AST entirely and execute bare-metal JS.

The Drop-In Replacement

Because the API perfectly mirrors the standard engine, upgrading your production server to compiled code requires changing only a single line of code:

- import { executeBridge } from "@stackables/bridge-core";
+ import { executeBridge } from "@stackables/bridge-compiler";

Example Usage

import { parseBridge } from "@stackables/bridge-parser";
import { executeBridge } from "@stackables/bridge-compiler";
import { readFileSync } from "fs";

// 1. Parse your schema into an AST once at server startup
const document = parseBridge(readFileSync("endpoints.bridge", "utf8"));

// 2. Execute (Compiles to JS on the first run, uses cached function thereafter)
const { data } = await executeBridge({
  document,
  operation: "Query.searchTrains",
  input: { from: "Bern", to: "Zürich" },
  tools: {
    fetchSimple: async (args) => fetch(...),
  }
});

console.log(data);

Advanced: Extracting the Source Code

If you want to build a CLI that outputs physical .js files to disk (True AOT), you can use the underlying generator directly:

import { compileBridge } from "@stackables/bridge-compiler";

const { code, functionName } = compileBridge(document, {
  operation: "Query.searchTrains",
});

console.log(code); // Prints the raw `export default async function...` string

API: ExecuteBridgeOptions

| Option | Type | What it does | | ------------------ | --------------------- | -------------------------------------------------------------------------------- | | document | BridgeDocument | The parsed AST from @stackables/bridge-parser. | | operation | string | Which bridge to run, e.g. "Query.myField". | | input? | Record<string, any> | Input arguments — equivalent to GraphQL field args. | | tools? | ToolMap | Your custom tool functions (merged with built-in std). | | context? | Record<string, any> | Shared data available via with context as ctx in .bridge files. | | signal? | AbortSignal | Pass an AbortSignal to cancel execution and upstream HTTP requests mid-flight. | | toolTimeoutMs? | number | Fails the execution if a single tool takes longer than this threshold. | | logger? | Logger | Structured logger for tool calls. | | requestedFields? | string[] | Sparse fieldset filter — only resolve the listed output fields. Supports dot-separated paths and a trailing * wildcard (e.g. ["id", "legs.*"]). Omit to resolve all fields. |

Returns: Promise<{ data: T }>

⚠️ Runtime Compatibility (Edge vs Node)

Because this package dynamically evaluates generated strings into executable code (new AsyncFunction(...)), it requires a runtime that permits dynamic code evaluation.

  • Fully Supported: Node.js, Bun, Deno, AWS Lambda, standard Docker containers.
  • Not Supported: Cloudflare Workers, Vercel Edge, Deno Deploy (Strict V8 Isolates block code generation from strings for security reasons).

If you are deploying to an Edge runtime, use the standard interpreter (executeBridge from @stackables/bridge-core) instead, which executes the AST dynamically without string evaluation.

Part of the Bridge Ecosystem

| Package | What it does | | ------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------- | | @stackables/bridge | The All-in-One — everything in a single install | | @stackables/bridge-parser | The Parser — turns .bridge text into the instructions this engine runs | | @stackables/bridge-compiler | The Compiler — compiles BridgeDocument into optimized JavaScript | | @stackables/bridge-graphql | The Adapter — wires bridges into a GraphQL schema | | @stackables/bridge-stdlib | The Standard Library — httpCall, strings, arrays, and more | | @stackables/bridge-types | Shared TypesToolCallFn, ToolMap, CacheStore |