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

@alpaca-headless/dynamic-renderings-engine

v1.0.4697

Published

Isolated dynamic component compiler and QuickJS runtime. No CMS or SDK runtime dependencies.

Readme

@alpaca-headless/dynamic-renderings-engine

Compiles Alpaca Headless dynamic renderings and runs them, inside the rendering host's own process:

  • Compile threads (dist/compile-thread.mjs): esbuild-wasm bundles a rendering with an import allowlist that never touches the file system; Tailwind compiles its classes against the host's theme and the tenant's tokens; the stylesheet policy scopes the result to the rendering. Nothing here runs rendering code. A queue, a deadline that ends the thread, and a heap limit bound them.
  • Render threads (dist/render-thread.mjs): one per active tenant, each with its own QuickJS (WebAssembly) instance running dist/runtime.js. Rendering code sees only that runtime and returns a JSON render tree. QuickJS's memory limit and interrupt deadline bound every call; the pool's watchdog ends a thread that does not stop in time.

A rendering may have client code, which its code imports as ./client. The compiler builds it twice: a minified browser ES module whose react, react/jsx-runtime and react-dom imports resolve to globalThis.__alpaca_dynamic_react ({ React, ReactDOM, jsxRuntime }, set by the host), and a CommonJS module for the render threads. There, every client component the server code renders becomes an island node with a first paint: the component rendered once by react-dom/server inside QuickJS (hooks start at their initial values, effects and event handlers do not run) and parsed back into render nodes, with an islandChildren node where its children go. Client code only ever runs in QuickJS or, as the browser module, in the page.

The main entry (dist/engine.mjs) only supervises the threads, so the host's main thread loads neither the compiler nor QuickJS. It is used by @alpaca-headless/dynamic-renderings; heads do not call it directly, but must load it unbundled (withDynamicRenderings does that for Next.js).

import { createEngine } from "@alpaca-headless/dynamic-renderings-engine";
const engine = createEngine({ renderThreads: 4, compileThreads: 2 });
const compiled = await engine.compile({ renderingId, code, clientCode, themeCss, themeTokens });
const module = { server: compiled.compiledServer, client: compiled.compiledClientNode, clientExports: compiled.clientExports };
const [result] = await engine.renderPage({ tenant, components: [{ key, buildId, dto }], sources: { [buildId]: module } });
await engine.close();

The entry and the threads bundle everything they run into dist/, with the licences in THIRD_PARTY_LICENSES. The package also owns the render protocol (/protocol) and the stylesheet policy (/css-policy); the stylesheet policy is shipped unbundled and needs postcss at runtime. It does not depend on the host package, the Alpaca SDK or Next.js. Build and test (from Headless/):

npm run test --workspace=@alpaca-headless/dynamic-renderings-engine