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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@marko-polo/run-adapter-figma

v0.0.3

Published

Marko Run adapter to build self-contained UIs for Figma plugins, handling asset inlining, code bundling, and manifest updates.

Readme

This adapter configures your Marko Run project to build UI pages suitable for use within a Figma plugin. It simplifies the development workflow by:

  1. Using the @marko-polo/run-adapter-single-file to inline all CSS, JavaScript, and image assets into self-contained HTML files.
  2. Bundling your main Figma plugin code (Node.js) using esbuild.
  3. Organizing the build output into a .marko-run/figma-adapter/ directory.
  4. Automatically updating your manifest.json with the correct paths for the UI files and the main plugin code.

Installation

npm install @marko-polo/run-adapter-figma @marko-polo/run-adapter-single-file --save-dev
# or
yarn add @marko-polo/run-adapter-figma @marko-polo/run-adapter-single-file -D
# or
pnpm add @marko-polo/run-adapter-figma @marko-polo/run-adapter-single-file -D

Usage

In your vite.config.js or vite.config.ts, import and register the adapter with the @marko/run Vite plugin:

import { defineConfig } from "vite";
import marko from "@marko/run/vite";
import figmaAdapter from "@marko-polo/run-adapter-figma";

export default defineConfig({
  plugins: [
    marko({
      adapter: figmaAdapter({
        // --- Required ---
        // Entry point for your main Figma plugin logic (Node.js environment)
        code: {
          entryPoint: 'src/plugin/main.ts' // Path relative to project root
        },

        // --- Optional ---
        // Path to your manifest.json relative to the project root
        manifest: 'manifest.json', // Default

        // --- Optional: Options passed to the underlying single-file adapter ---
        // See @marko-polo/run-adapter-single-file README for details
        // e.g., deleteInlinedFiles: false, // Keep original assets in dist/
        // e.g., cdn: 'https://my-cdn.com/' // For assets not to be inlined
      })
    })
  ]
});

How it Works

The adapter streamlines the build process for Figma plugins:

  1. Static Build & Inlining: Leverages @marko-polo/run-adapter-single-file to generate static HTML files for each route and inline all local CSS, JavaScript (bundled via esbuild), and supported image assets (.png, .jpg, .jpeg, .gif, .svg, .webp). External assets (via CDN or absolute URLs) are not inlined.
  2. Code Bundling: Takes the code.entryPoint file and bundles it (along with its dependencies) using esbuild, targeting Node.js, into a single file within the output directory.
  3. File Organization: Moves the inlined HTML files and the bundled code file into .marko-run/figma-adapter/.
  4. Manifest Update: Reads the specified manifest.json file, updates the ui field to point to the generated HTML files (using route names as keys), and updates the main field to point to the bundled code file.
  5. Cleanup: Removes the intermediate Vite build output directory (dist/) unless deleteInlinedFiles is set to false in the options passed to the underlying single-file adapter.

Adapter Options

The figmaAdapter function accepts an options object:

  • code.entryPoint: string (Required)
    • The path (relative to the project root) to the entry point file (JS/TS) for your main Figma plugin logic.
  • manifest?: string (Optional, Default: 'manifest.json')
    • The path (relative to the project root) to your Figma plugin's manifest.json.
  • Other Options: Inherits all options from @marko-polo/run-adapter-single-file (which itself inherits from @marko/run-adapter-static). Common options include:
    • deleteInlinedFiles: boolean (default: true) - Control cleanup of original assets.
    • cdn: string - URL prefix for assets to exclude from inlining.

Contributing

This package follows the contribution guidelines and tooling setup of the Marko Run ecosystem. Refer to the main Marko Run repository for more details on contributing.

Tooling & Commands

This project uses standard tooling like ESLint, Prettier, TypeScript, and Vitest, often configured via moonrepo presets. Common commands (runnable via npm run <command> or yarn <command>) include:

  • build: Build the package for development.
  • clean: Remove build artifacts.
  • pack: Build the package for production/distribution.
  • lint: Check code style.
  • format: Format code.
  • test: Run unit tests.
  • type: Run TypeScript type checking.
  • check: Run lint, type check, and tests.