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

vite-plugin-raw-asset-uprooter

v1.0.0

Published

Vite & Rolldown plugin to bypass package.json 'exports' validation for raw non-ESM scripts and adapt the build manifest for backend frameworks (Twig, Blade, PHP).

Readme

vite-plugin-raw-asset-uprooter

A lightweight, zero-dependency Vite & Rolldown plugin to bypass strict package encapsulation (exports field validation) for raw non-ESM/monolithic scripts and seamlessly adapt the build manifest for backend frameworks (such as Twig, Blade, PHP).

Why?

Modern bundlers like Vite 6+ (powered by Rolldown) enforce strict package encapsulation. If a package (e.g., @tko/build.knockout) restricts access via the exports field in its package.json, Vite will crash with a [rolldown:vite-resolve] error when you try to import a monolithic browser script directly using the ?url suffix.

Furthermore, when working with backend template engines (like Twig or Blade), the engine expects a clean path as a key in manifest.json (e.g., "node_modules/package/dist/file.js"). Vite natively pollutes the manifest with virtual keys for non-imported raw assets.

This plugin fixes both issues by completely hiding the original package from Vite's resolution graph during compilation, while post-processing manifest.json to generate flawless keys for your backend templates.

Installation

npm install vite-plugin-raw-asset-uprooter --save-dev

Usage

1. Configure the Plugin

Add the plugin to your vite.config.js and specify a virtual import name mapped to the actual physical path of the asset inside node_modules:

import { defineConfig } from 'vite';
import { viteRawAssetUprooter } from 'vite-plugin-raw-asset-uprooter';

export default defineConfig({
  plugins: [
    viteRawAssetUprooter({
      // 'virtual-import-name': 'path/to/the/raw/asset/from/project/root'
      'virtual:tko-core': 'node_modules/@tko/build.knockout/dist/browser.min.js'
    })
  ]
});

2. Import in your JavaScript

Use the registered virtual name instead of the raw package path. The plugin will automatically return the correct hashed asset URL:

import tkoUrl from 'virtual:tko-core';

console.log(tkoUrl); // Output: /assets/build/js/browser.min.DKXLBUw1.js

3. Result in manifest.json

The plugin rewrites the final manifest so your backend template engine can easily find the asset path without any regex workarounds:

{
  "node_modules/@tko/build.knockout/dist/browser.min.js": {
    "file": "js/browser.min.DKXLBUw1.js",
    "src": "node_modules/@tko/build.knockout/dist/browser.min.js",
    "type": "asset"
  }
}

License

MIT

Advanced: Shared Utilities

This package also exports the internal helper function replaceAllAliases, which allows you to manually resolve and expand Vite path aliases (like @, @public, etc.) inside any arbitrary path string.

It is highly useful for writing custom build scripts or hooks where you need to parse configured outDirs or target paths manually.

Usage of replaceAllAliases

import { replaceAllAliases } from 'vite-plugin-raw-asset-uprooter';

export default {
  plugins: [
    {
      name: 'my-custom-script',
      configResolved(resolvedConfig) {
        const rawPath = resolvedConfig.build.outDir; // e.g. "./@public/assets/build"
        
        // This will expand the aliases safely based on length sorting
        const absolutePath = replaceAllAliases(rawPath, resolvedConfig);
        
        console.log(absolutePath); // Output: /Users/.../project/www/assets/build
      }
    }
  ]
}

License

MIT