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

workerd-yoga

v1.0.1

Published

Yoga layout for Cloudflare workerd using a static WebAssembly module.

Readme

workerd-yoga

npm version CI License: MIT

Yoga layout for Cloudflare workerd using a static WebAssembly module.

Problem

The published yoga-layout package currently fails in Workers/workerd with:

WebAssembly.instantiate(): Wasm code generation disallowed by embedder

Workers disallow dynamic Wasm compilation from bytes at runtime. workerd can run Wasm when it is imported as a static module, because the runtime sees the .wasm artifact at bundle time instead of compiling arbitrary bytes inside request handling code.

Install

npm install workerd-yoga

Migration

-import Yoga from "yoga-layout";
+import Yoga from "workerd-yoga";

Root API

import Yoga from "workerd-yoga";

const root = Yoga.Node.create();
const header = Yoga.Node.create();
const body = Yoga.Node.create();

try {
  root.setWidth(320);
  root.setHeight(240);
  root.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);

  header.setHeight(48);
  body.setFlexGrow(1);

  root.insertChild(header, 0);
  root.insertChild(body, 1);
  root.calculateLayout(undefined, undefined);

  console.log({
    headerHeight: header.getComputedHeight(),
    bodyTop: body.getComputedTop(),
    bodyHeight: body.getComputedHeight(),
  });
} finally {
  root.freeRecursive();
}

Always free Yoga nodes when finished. freeRecursive() releases the root and inserted descendants.

Explicit loader

The root export loads Yoga for the common case. If you want to control loading explicitly, import loadYoga() from the load subpath:

import { loadYoga } from "workerd-yoga/load";

const Yoga = await loadYoga();

Measure callbacks

Measure callbacks are synchronous, matching Yoga's layout API:

import Yoga from "workerd-yoga";

const root = Yoga.Node.create();
const text = Yoga.Node.create();

try {
  text.setMeasureFunc((width, widthMode, height, heightMode) => {
    void width;
    void widthMode;
    void height;
    void heightMode;
    return { width: 37, height: 19 };
  });

  root.insertChild(text, 0);
  root.calculateLayout(undefined, undefined);

  console.log(text.getComputedWidth(), text.getComputedHeight());
} finally {
  root.freeRecursive();
}

How it works

workerd-yoga vendors the Yoga 3.2.1 Emscripten JavaScript wrapper and imports the official Yoga .wasm file as a static module. In Workers/workerd, that static .wasm import is provided to JavaScript as a WebAssembly.Module. The adapter passes the module through Emscripten's instantiateWasm hook and creates the runtime with new WebAssembly.Instance(...), avoiding runtime byte compilation.

Compatibility

  • Yoga version: 3.2.1 only.
  • Runtime target: Cloudflare Workers/workerd only.
  • Node and browsers are used for development checks where useful, but this package does not promise a production Node or browser runtime.

Artifact provenance

The vendored Wasm artifact is the Yoga 3.2.1 package artifact with:

  • Byte length: 71736
  • SHA-256: 7ba9c9483c8c38a468e9aef4a95ed72fad8a43594be8e5123eb3bdb6479edf5b

Generation and verification scripts pin and check the downloaded artifact identity.

Stable-only policy and non-goals

This package tracks stable Yoga releases only. It is not a fork for experimental Yoga changes, unstable Emscripten output, alternative layout engines, or runtime-specific behavior beyond adapting the stable Yoga package to workerd static Wasm imports.

Non-goals include:

  • Reimplementing Yoga.
  • Changing Yoga API semantics.
  • Supporting arbitrary Yoga versions at runtime.
  • Promising browser or Node production compatibility.

Development

npm run generate:check
npm run check

Focused commands:

npm run lint
npm run fmt:check
npm run build
npm run dist:check
npm run pack:check
npm run types:lint
npm run typecheck
npm run test:node
npm run test:workers
npm run pack:consumer

npm run check is the canonical complete verification command.

Security

Report security vulnerabilities through GitHub private vulnerability reporting. Do not disclose vulnerabilities in public issues.

License

workerd-yoga is an independent project. It is not official Meta, React, or Cloudflare software.

The adapter code is MIT licensed. Yoga is MIT licensed; see LICENSE.yoga for the upstream Yoga license.