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

@studiometa/playground

v0.3.4

Published

[![NPM Version](https://img.shields.io/npm/v/@studiometa/playground.svg?style=flat&colorB=3e63dd&colorA=414853)](https://www.npmjs.com/package/@studiometa/playground/) [![Downloads](https://img.shields.io/npm/dm/@studiometa/playground?style=flat&colorB=3e

Readme

@studiometa/playground

NPM Version Downloads Size Dependency Status

A packaged small code editor for shareable demo, deploy it in seconds.

Screenshots of the playground in light and dark mode

Usage

Install the package:

npm install @studiometa/playground

Create the following files:

src/templates/pages/index.twig

{% include '@playground/pages/index.twig' %}

meta.config.js

import { playgroundPreset, defineWebpackConfig } from '@studiometa/playground/preset';

export default defineWebpackConfig({
  presets: [playgroundPreset()],
});

tailwind.config.js

import { tailwindConfig } from '@studiometa/playground/tailwind';

export default tailwindConfig();

And then run npx meta dev and open http://localhost:3000.

You can configure the playground by passing a configuration object to the playgroundPreset function. Have a look at the demo for all available options.

When you are ready, run npx meta build and you can deploy the generated dist/ folder to any static hosting of your choice.

Import Map

Relative paths in the importMap option are automatically resolved to absolute URLs at runtime using window.location.origin. This allows build tools to use natural relative paths:

playgroundPreset({
  importMap: {
    '@studiometa/js-toolkit': '/static/js-toolkit/index.js',
  },
});

Dependencies

The dependencies option provides a declarative way to manage packages available in the script editor. It automatically generates import map entries and, for self-hosted dependencies, bundles them into .js + .d.ts files with tsdown.

esm.sh (default)

The simplest way to add a dependency is a plain string. It resolves via esm.sh, which serves proper ESM bundles with TypeScript types out of the box:

playgroundPreset({
  dependencies: ['deepmerge', '@motionone/easing'],
});

Versions are inferred from your package.json when available. You can also pin them explicitly:

playgroundPreset({
  dependencies: [{ specifier: 'deepmerge', version: '5.1.0' }],
});

Subpath imports are fully supported. The version is resolved from the package name and placed correctly in the esm.sh URL:

playgroundPreset({
  dependencies: [
    '@studiometa/js-toolkit',
    '@studiometa/js-toolkit/utils',
    // → https://esm.sh/@studiometa/js-toolkit@<version>/utils
  ],
});

Self-hosted

Adding a source field bundles the dependency with tsdown into a single ESM file (.js) and a bundled type declaration (.d.ts). All npm types are inlined in the .d.ts output so the browser-based TypeScript editor can resolve them without additional fetches.

The source field must be a local file path (relative, absolute, or glob). Bare npm package names (e.g. "morphdom") are not supported as source values — npm packages should use esm.sh resolution instead (omit the source field).

From local TypeScript sources:

The source field supports glob patterns. Use entry to specify the main entry point when the source is a glob:

playgroundPreset({
  dependencies: [
    {
      specifier: '@studiometa/ui',
      source: '../ui/**/*.ts',
      entry: '../ui/index.ts',
    },
  ],
});

Mixed (local sources re-exporting from npm):

Local TypeScript sources can re-export from npm packages — tsdown will inline the external types in the bundled .d.ts:

// lib/index.ts
export { greet, type GreetOptions } from './greeter.js';
export { isDefined } from '@studiometa/js-toolkit/utils';
playgroundPreset({
  dependencies: [
    {
      specifier: 'demo-lib',
      source: './lib/**/*.ts',
      entry: './lib/index.ts',
    },
  ],
});

Note: Self-hosted dependencies require tsdown as a devDependency. Install it with npm install -D tsdown.

Bundle deduplication

Self-hosted bundles automatically externalize any specifier that already exists in the import map. This prevents inlining shared dependencies that the browser already resolves via esm.sh.

For example, if @studiometa/ui is self-hosted and depends on @studiometa/js-toolkit, and @studiometa/js-toolkit is also in the import map (via esm.sh), the bundled @studiometa/ui/index.js will contain import ... from "@studiometa/js-toolkit" instead of inlining it. The browser's import map resolves that to the esm.sh URL at runtime — no duplication.

playgroundPreset({
  dependencies: [
    '@motionone/easing',
    'deepmerge',
    'morphdom',
    '@studiometa/js-toolkit',
    '@studiometa/js-toolkit/utils',
    {
      specifier: '@studiometa/ui',
      source: '../ui/**/*.ts',
      entry: '../ui/index.ts',
    },
  ],
});
// @studiometa/ui bundle will NOT inline @studiometa/js-toolkit, deepmerge, etc.

Type resolution

The browser-based Monaco editor discovers type declarations via the x-typescript-types HTTP response header on .js files. The build emits a _headers file that maps each bundled .js to its .d.ts counterpart:

/static/deps/demo-lib/index.js
  x-typescript-types: /static/deps/demo-lib/index.d.ts

This file is natively supported by Cloudflare Pages and Netlify. For other hosting environments, configure your server to serve the same headers:

location ~ ^/static/deps/(.+)/index\.js$ {
  add_header x-typescript-types /static/deps/$1/index.d.ts;
}
<FilesMatch "^index\.js$">
  <If "%{REQUEST_URI} =~ m#^/static/deps/(.+)/index\.js$#">
    Header set x-typescript-types /static/deps/%1/index.d.ts
  </If>
</FilesMatch>
app.use('/static/deps', (req, res, next) => {
  if (req.path.endsWith('/index.js')) {
    res.set('x-typescript-types', req.path.replace(/\.js$/, '.d.ts'));
  }
  next();
});

For local development, the demo includes a preview server (preview.js) that parses the _headers file and applies the headers automatically.

Combining with importMap

The dependencies option can be combined with the importMap option. Manual importMap entries take precedence over entries generated from dependencies:

playgroundPreset({
  dependencies: ['deepmerge'],
  importMap: {
    // This overrides the esm.sh URL for deepmerge
    deepmerge: '/static/custom/deepmerge.js',
  },
});