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

@midkard/vite-plugin-wp-assetize

v1.0.1

Published

Vite plugin to create wp php assets files.

Readme

@dnt-theme/vite-plugin-wp-assetize

License: MIT

A Vite plugin that generates WordPress-compatible PHP asset files by analyzing JavaScript/TypeScript imports during the build process.

Features

  • 🔍 Automatic Dependency Detection - Scans your code for WordPress (@wordpress/*) and WooCommerce (@woocommerce/*) package imports
  • 📦 WordPress Integration - Generates .asset.php files with proper dependency arrays and version hashes
  • 🧩 Block Development Support - Special handling for WordPress blocks with block.json and render.php
  • 🎯 SHA-1 Version Hashing - Automatic cache-busting with content-based hashes
  • Vite Native - Built specifically for Vite with ES Modules support

Installation

npm install @dnt-theme/vite-plugin-wp-assetize --save-dev
# or
pnpm add -D @dnt-theme/vite-plugin-wp-assetize
# or
yarn add -D @dnt-theme/vite-plugin-wp-assetize

Usage

Basic Configuration

// vite.config.ts
import wpAssetize from '@dnt-theme/vite-plugin-wp-assetize'

export default {
  plugins: [
    wpAssetize.assetize(path.resolve(__dirname, 'src'))
  ]
}

With WordPress Externals

Use the provided wpExternals list for common WordPress package externalization:

import wpAssetize, { wpExternals } from '@dnt-theme/vite-plugin-wp-assetize'

export default {
  plugins: [
    wpAssetize.assetize(path.resolve(__dirname, 'src'))
  ],
  build: {
    rollupOptions: {
      external: wpExternals
    }
  }
}

How It Works

The plugin analyzes your source files during the Vite build process:

  1. Import Scanning - Parses JS/TS/JSX/TSX files to find imports from @wordpress/* and @woocommerce/* packages
  2. Dependency Mapping - Maps imports to WordPress script handles (e.g., @wordpress/api-fetchwp-api-fetch)
  3. Asset File Generation - Creates .asset.php files containing:
    • dependencies - Array of WordPress script handles
    • version - SHA-1 hash of the file content (first 20 chars)

Generated Asset File Example

<?php return ["dependencies" => ["wp-element","wp-api-fetch"], "version" => "a1b2c3d4e5f6g7h8i9j0"];

WordPress Block Development

When the plugin detects an entry point in src/blocks/{block-name}/, it automatically:

  • Generates blocks/{block-name}/asset.php
  • Copies block.json to the output directory
  • Copies render.php to the output directory

Block Structure Example

src/
└── blocks/
    └── my-block/
        ├── index.tsx      # Entry point
        ├── block.json     # Block metadata
        └── render.php     # Server-side render

Supported Packages

WordPress Packages (@wordpress/*)

All WordPress packages are supported with automatic mapping to their global variables:

  • @wordpress/elementwp.element (handle: wp-element)
  • @wordpress/api-fetchwp.apiFetch (handle: wp-api-fetch)
  • @wordpress/componentswp.components (handle: wp-components)
  • And many more...

WooCommerce Packages (@woocommerce/*)

Full support for WooCommerce packages:

  • @woocommerce/componentswc.components (handle: wc-components)
  • @woocommerce/datawc.data (handle: wc-store-data)
  • @woocommerce/blocks-checkoutwc.blocksCheckout (handle: wc-blocks-checkout)
  • And more...

Other Libraries

  • reactReact (handle: react)
  • react-domReactDOM (handle: react-dom)
  • lodash / lodash-eslodash (handle: lodash)
  • jqueryjQuery (handle: jquery)

API

assetize(srcDir: string): Plugin

Creates the Vite plugin instance.

Parameters:

  • srcDir - Source directory path to scan for imports (e.g., 'src')

Returns:

  • Vite plugin instance

wpExternals

A curated list of common WordPress externals for use with Rollup's external option.

import { wpExternals } from '@dnt-theme/vite-plugin-wp-assetize'

// Includes:
// - @wordpress/element
// - @wordpress/core-data
// - @wordpress/data
// - @wordpress/components
// - @wordpress/block-editor
// - react, react-dom, react/jsx-runtime
// - And all WooCommerce packages

WordPress Integration

In your WordPress PHP code, use the generated asset files like this:

$asset_file = include( plugin_dir_path( __FILE__ ) . 'build/index.asset.php' );

wp_register_script(
    'my-script',
    plugins_url( 'build/index.js', __FILE__ ),
    $asset_file['dependencies'],
    $asset_file['version'],
    true
);

Requirements

  • Node.js 22+
  • Vite 5+

License

MIT

Contributing

See CONTRIBUTING.md for development guidelines.

Support