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

@soda-gql/babel-plugin

v0.10.2

Published

Babel plugin for soda-gql transformations

Readme

@soda-gql/babel-plugin

Note: This package is not yet published to npm. It is under active development and will be available in a future release.

Babel plugin for soda-gql zero-runtime GraphQL transformations.

Features

  • Transforms gql.default() calls to runtime registrations at build time
  • Removes GraphQL system imports and injects runtime imports
  • Supports both ESM and CommonJS module formats
  • Full TypeScript support
  • HMR-ready for development workflows

Installation

bun add -D @soda-gql/babel-plugin @soda-gql/cli
bun add @soda-gql/runtime

Quick Start

Babel Configuration

Add the plugin to your Babel configuration:

// babel.config.js
module.exports = {
  plugins: [
    [
      "@soda-gql/babel-plugin",
      {
        configPath: "./soda-gql.config.ts",
        artifact: {
          useBuilder: true,
        },
      },
    ],
  ],
};

Project Setup

  1. Generate your GraphQL system:
bun run soda-gql codegen
  1. Write GraphQL operations:
import { gql } from "@/graphql-system";

export const userQuery = gql.default(({ query, $var }) =>
  query.operation({
    name: "GetUser",
    variables: { ...$var("id").ID("!") },
    fields: ({ f, $ }) => ({
      ...f.user({ id: $.id })(({ f }) => ({ ...f.id(), ...f.name() })),
    }),
  }),
);
  1. The plugin transforms this to runtime calls:
import { gqlRuntime } from "@soda-gql/runtime";

export const userQuery = gqlRuntime.getOperation("canonicalId");

Configuration Options

PluginOptions

interface PluginOptions {
  /** Path to soda-gql.config.ts */
  configPath?: string;

  /** Artifact configuration */
  artifact?: {
    /** Use builder to generate artifacts (default: true) */
    useBuilder?: boolean;
    /** Path to pre-built artifact.json */
    path?: string;
  };

  /** Development mode options */
  dev?: {
    /** Enable HMR support (default: false) */
    hmr?: boolean;
  };
}

Configuration Examples

Production Build

{
  plugins: [
    [
      "@soda-gql/babel-plugin",
      {
        configPath: "./soda-gql.config.ts",
        artifact: {
          useBuilder: true,
        },
      },
    ],
  ],
}

Development with HMR

{
  plugins: [
    [
      "@soda-gql/babel-plugin",
      {
        configPath: "./soda-gql.config.ts",
        artifact: {
          useBuilder: true,
        },
        dev: {
          hmr: true,
        },
      },
    ],
  ],
}

Using Pre-built Artifact

{
  plugins: [
    [
      "@soda-gql/babel-plugin",
      {
        artifact: {
          useBuilder: false,
          path: "./dist/artifact.json",
        },
      },
    ],
  ],
}

Module Format Support

The plugin automatically handles both ESM and CommonJS:

Input (ESM):

import { gql } from "@/graphql-system";
export const fragment = gql.default(/* ... */);

Output (ESM):

import { gqlRuntime } from "@soda-gql/runtime";
export const fragment = gqlRuntime.fragment("canonicalId", /* ... */);

Output (CommonJS) - when using @babel/plugin-transform-modules-commonjs:

const { gqlRuntime } = require("@soda-gql/runtime");
module.exports.fragment = gqlRuntime.fragment("canonicalId", /* ... */);

Architecture

Transformation Pipeline

  1. Metadata Collection: Analyzes AST to identify gql.default() calls
  2. Canonical ID Resolution: Maps each call to a unique identifier (file path + AST path)
  3. Artifact Lookup: Retrieves build artifacts for each GraphQL element
  4. AST Transformation: Replaces builder calls with runtime calls
  5. Import Management: Removes GraphQL system imports, adds runtime imports

Supported GraphQL Elements

  • Fragments: Fragment definitions with data normalization
  • Operations: Query/mutation/subscription operations with field selections

Comparison with Other Plugins

| Feature | babel-plugin | plugin-swc | tsc-plugin | |---------|--------------|------------|------------| | Production Ready | ✅ | 🚧 In Development | ✅ | | ESM Support | ✅ | ✅ | ✅ | | CJS Support | ✅ | ✅ | ✅ | | HMR Support | ✅ | ⚠️ Planned | ✅ | | Build Speed | Good | Excellent | Fair | | Setup Complexity | Low | Low | Medium |

Troubleshooting

Plugin Not Transforming Code

  • Verify configPath points to a valid config file
  • Ensure GraphQL system is generated (bun run soda-gql codegen)
  • Check Babel is processing your source files

Type Errors After Transformation

  • Ensure @soda-gql/runtime is installed
  • Verify GraphQL system types are up to date
  • Check tsconfig.json includes transformed files

Module Not Found Errors

  • Confirm runtime import path is correct
  • For CJS, ensure @babel/plugin-transform-modules-commonjs is configured
  • Check module resolution in your bundler

Contributing

See the main CLAUDE.md for contribution guidelines.

License

MIT