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

@xec-sh/loader

v0.9.0

Published

Universal script loader and module system for Xec

Readme

@xec-sh/loader

Script loading and module system with TypeScript transformation, CDN module loading, and REPL support.

Install

pnpm add @xec-sh/loader

Quick Start

import { ScriptExecutor, CodeEvaluator, ModuleLoader } from '@xec-sh/loader';

// Execute a TypeScript file
const executor = new ScriptExecutor();
const result = await executor.executeScript('./deploy.ts', {
  customGlobals: { API_KEY: process.env.API_KEY },
});

// Evaluate inline code with top-level await
const evaluator = new CodeEvaluator();
await evaluator.evaluateCode(`
  const res = await fetch('https://api.example.com/data');
  console.log(await res.json());
`);

// Load modules from CDNs
const loader = new ModuleLoader({ preferredCDN: 'esm.sh' });
const lodash = await loader.import('npm:[email protected]');
const std = await loader.import('jsr:@std/[email protected]');
import { REPLServer, FileWatcher, PluginManager } from '@xec-sh/loader';

// Interactive REPL
const repl = new REPLServer({ prompt: 'xec> ', includeBuiltins: true });
repl.start();

// File watching with debounce
const watcher = new FileWatcher();
watcher.watch('./src', { debounce: 300 }, (event) => {
  console.log(`${event.type}: ${event.path}`);
});

// Plugin system with lifecycle hooks
const plugins = new PluginManager();
plugins.register({
  name: 'my-plugin',
  setup: async (ctx) => { /* initialize */ },
  teardown: async () => { /* cleanup */ },
  resolveSpecifier: (spec) => spec.replace('@my/', 'https://cdn.my.dev/'),
  transformCode: (code) => code,
  beforeExecute: async (ctx) => { /* pre-exec */ },
  afterExecute: async (ctx, result) => { /* post-exec */ },
  onError: async (error) => { /* handle error */ },
});
import { streamExecute, streamLines, GlobalInjector } from '@xec-sh/loader';

// Streaming execution
for await (const event of streamExecute('./long-task.ts')) {
  if (event.type === 'stdout') process.stdout.write(event.data);
}

// Stream lines from execution
for await (const line of streamLines('./script.ts')) {
  console.log(line);
}

// Global injection with automatic cleanup
const injector = new GlobalInjector({ globals: { VERSION: '1.0.0' } });
await injector.execute(async () => {
  console.log(globalThis.VERSION); // '1.0.0'
});
// globals are restored after execution

API

| Export | Description | |--------|-------------| | ScriptExecutor | Execute TypeScript/JavaScript files with context injection | | CodeEvaluator | Evaluate inline code with TypeScript support | | ModuleLoader | Load modules from CDN, local, or node_modules | | REPLServer / REPLCommands | Interactive REPL with extensible commands | | FileWatcher / watchFiles | Native fs.watch file watcher with debounce | | PluginManager | Plugin system with lifecycle hooks | | streamExecute / streamLines | Streaming script execution | | GlobalInjector / createInjector | Safe global variable injection and restoration | | ScriptRuntime / createRuntime | Runtime utilities (cd, pwd, env, retry, within) | | TypeScriptTransformer | TypeScript-to-JS transformation via esbuild | | ImportTransformer | Import path rewriting for ESM compatibility | | CDNModuleResolver | Resolve modules from esm.sh, jsr.io, unpkg, skypack, jsdelivr | | NodeModuleResolver / LocalModuleResolver | Resolve from node_modules or local files | | MemoryCache | In-memory LRU cache with TTL | | FileSystemCache | Persistent disk cache with TTL | | HybridCache | Combined memory + filesystem caching | | ExecutionContext | Execution context for scripts |

Features

  • Execute TypeScript and JavaScript files with automatic esbuild transformation
  • Evaluate inline code with top-level await support
  • CDN module loading from esm.sh, jsr.io, unpkg, skypack, and jsdelivr
  • Module specifiers: npm:, esm:, jsr:, unpkg:, skypack:, jsdelivr:, direct URLs
  • Caching: MemoryCache (LRU), FileSystemCache (TTL), HybridCache (combined)
  • Interactive REPL with extensible command system and built-in commands
  • FileWatcher using native fs.watch with configurable debounce
  • Plugin system with hooks: setup, teardown, resolver, transformCode, resolveSpecifier, beforeExecute, afterExecute, onError
  • Streaming execution with streamExecute and streamLines
  • GlobalInjector for safe global variable injection with automatic restoration
  • Import path transformation for ESM compatibility
  • Local and node_modules module resolution

License

MIT