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

rollup-plugin-data-files

v0.1.0

Published

Bundle web workers that work in nodejs and the browser, without a separate build target.

Downloads

101

Readme

Install

npm i -D rollup-plugin-data-files

Requirements

  • rollup v2.29.0 or later to allow for the addition of a file in a globbed directory to rebuild in this plugin

Usage

include rollup-plugin-data-files in your rollup plugins array for a build:

const dataFiles = require('rollup-plugin-data-files');

...
plugins: [
  dataFiles({
    something: {
      // files to include when data-files!something is imported
      include: 'test/fixtures/**',
      // these are binary files, give me a uint8array
      transform: 'binary'
    }
  })
]
...

When you want to include the data file use data-files!<configured-key> so for our example that would be:

import something from "data-files!something";

// get and console.log the uint8 array for some-file-name.jpg
console.log(something['some-file-name.jpg']());

Also know that you can find your file in the output bundle by searching for rollup-plugin-data-files and finding your key.

Options

The main Object that is passed to rollup-plugin-data-files takes keys that will refer to the reference id of your data file. The value for that key is the configuration for it's build. Those options are defined below.

.transform

Default: 'binary'

As a string

transform can be set 4 possible string values:

  1. 'binary' exports an object with functions that return a Uint8Array of file contents.
  2. 'string' exports an object with functions that will return a string of the file contents.
  3. 'json' exports an object with function that will return a JSON.parse of the file contents.
  4. 'js' exports an object with function that will return a the result of requiring the files specified.
As a function

Using transform as a function

transform: function(key, files) {
  let output = 'module.exports = {\n'

  files.forEach(function({filepath, contents}) {
    // filepath is a string, contents is a buffer.
    output += `'${filepath}': () => '${contents.toString()}',\n`
  });

  output += '};\n';
  return output;
}

.include

Note: if you want the addition of files to trigger a rebuild, make sure you are using a glob or directly pass in a directory here. A file, glob or an array of files/globs to include in your data-file.

.exclude

A file, glob or an array of files/globs to exclude from your data-file.

.extensions

Default: true

Should file extensions be included in the resulting object generated by string transform.

example for foo.txt with extensions true:

{
  'foo.txt': () => 'hello world'
}

example for foo.txt with extensions false:

{
  'foo': () => 'hello world'
}