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

fastcast

v0.0.3

Published

Programmatically modify JavaScript and TypeScript source codes with a simplified, elegant syntax. Powered by yuku-parser.

Readme

fastcast

Open on npmx.dev Downloads Licence

Programmatically modify JavaScript and TypeScript source codes with a simplified, elegant, and familiar syntax.

fastcast is a high-performance fork of magicast (originally created by Pooya Parsa and unjs), re-engineered to use yuku-parser and recast.

  • Intuitive Modification: Modify JS/TS source files and write them back just like modifying JSON objects.
  • High Performance: Powered by yuku-parser (written in Zig) delivering up to 25%+ faster parsing throughput.
  • Lightweight Footprint: 70%+ reduction in parser dependencies on disk compared to @babel/parser and @babel/types.
  • Imports & Exports: Easily inspect, mutate, add, or remove ESM imports and exports.
  • Function Arguments: Easily manipulate arguments passed to wrapper functions like defineConfig().
  • Style Preservation: Preserves code formatting styles (quotes, tabs, spaces, comments) from the original code.
  • Strict Type Safety: Full TypeScript type definitions with strict AST typing.

About This Fork

fastcast was created to modernize the parsing backend of magicast:

  • Replaced Babel (@babel/parser and @babel/types) with yuku-parser.
  • Reduced installed parser footprint from ~4.5 MB down to ~1.3 MB.
  • Faster cold start and parse throughput on modern runtimes.
  • Retains 100% test and API compatibility with magicast.

Repository: github.com/shiinasaku/fastcast

Install

Install the package:

pnpm add -D fastcast

npm install -D fastcast

yarn add --dev fastcast

Import utilities:

import { builders, generateCode, loadFile, parseModule, writeFile } from "fastcast";

Examples

Modify a configuration file

config.js:

export default {
  foo: ["a"],
};

Code to modify and append "b" to foo property of default:

import { loadFile, writeFile } from "fastcast";

const mod = await loadFile("config.js");

mod.exports.default.foo.push("b");

await writeFile(mod, "config.js");

Updated config.js:

export default {
  foo: ["a", "b"],
};

Direct AST manipulation

import { generateCode, parseModule } from "fastcast";

// Parse to AST proxy
const mod = parseModule(`export default { }`);

// Ensure foo is an array and append elements
mod.exports.default.foo ||= [];
mod.exports.default.foo.push("b");
mod.exports.default.foo.unshift("a");

// Generate code
const { code } = generateCode(mod);

Output:

export default {
  foo: ["a", "b"],
};

Working with wrapper functions (defineConfig)

import { parseModule } from "fastcast";

const mod = parseModule(`export default defineConfig({ foo: 'bar' })`);

// Access either bare object export or wrapped function arguments
const options
  = mod.exports.default.$type === "function-call"
    ? mod.exports.default.$args[0]
    : mod.exports.default;

console.log(options.foo); // 'bar'

Creating function calls

import { builders, parseModule } from "fastcast";

const mod = parseModule(`export default {}`);

mod.exports.default.list = builders.functionCall("create", [1, 2, 3]);

console.log(mod.generateCode());
// export default { list: create([1, 2, 3]) }

Notes

Because JavaScript and TypeScript can be very dynamic, fastcast is designed primarily for static or semi-static configuration files and declarations. For safe modifications, wrapping updates in a try/catch block is recommended:

import { loadFile, writeFile } from "fastcast";

async function updateConfig() {
  try {
    const mod = await loadFile("config.js");
    mod.exports.default.foo.push("b");
    await writeFile(mod);
  }
  catch (error) {
    console.error("Unable to automatically update config.js:", error);
  }
}

Browser and Worker Support

The main entrypoint includes Node filesystem utilities (loadFile, writeFile). If bundling for browser or worker environments, import from fastcast/core instead:

import { parseModule } from "fastcast/core";

High Level Helpers

fastcast provides helpers for common framework config operations via fastcast/helpers:

import {
  addNuxtModule,
  addVitePlugin,
  deepMergeObject,
  findVitePluginCall,
  updateVitePluginConfig,
} from "fastcast/helpers";

See the source code and test cases for full helper documentation.

Benchmark

Performance comparison between the latest upstream release ([email protected] using Babel) and fastcast (powered by yuku-parser).

Last updated: 2026-10-03 (Node.js v24.21.0, darwin arm64)

Performance & Throughput

| Benchmark Case | [email protected] | fastcast (yuku-parser) | Speedup | | :--- | :---: | :---: | :---: | | Small Config Parse (vite.config.ts) | 8,170 ops/s (0.122 ms) | 12,575 ops/s (0.080 ms) | +53.9% (1.54x) | | Medium Config Parse (nuxt.config.ts) | 3,399 ops/s (0.294 ms) | 5,215 ops/s (0.192 ms) | +53.4% (1.53x) | | Large TS Module Parse (~1,000 lines) | 101 ops/s (9.857 ms) | 127 ops/s (7.862 ms) | +25.7% (1.26x) | | E2E: Parse + Mutate + Codegen (Vite) | 2,861 ops/s (0.349 ms) | 3,380 ops/s (0.296 ms) | +18.1% (1.18x) | | E2E: Parse + Mutate + Codegen (Nuxt) | 1,470 ops/s (0.680 ms) | 1,734 ops/s (0.577 ms) | +18.0% (1.18x) |

Footprint & Efficiency

| Metric | [email protected] (Babel) | fastcast (yuku-parser) | Improvement | | :--- | :---: | :---: | :---: | | Parser Dependencies on Disk | 4.53 MB | 0.05 MB | -99.0% smaller | | Cold Start (Module Load) | 78.3 ms | 75.8 ms | ~3.2% faster | | Heap Memory Growth (1,000 parses) | 36.53 MB | 39.31 MB | +7.6% |

Development

  • Clone this repository: git clone https://github.com/shiinasaku/fastcast.git
  • Enable Corepack: corepack enable
  • Install dependencies: pnpm install
  • Run tests: pnpm test
  • Run benchmarks: pnpm run bench

Credits & License

fastcast is a fork of magicast created by Pooya Parsa and the unjs contributors.

Published under the [MIT License (./LICENSE).