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

rollup-plugin-autorequire

v0.0.4

Published

Requires an additionnal list of files while bundling, those files being single files in each subfolder of a given folder

Readme

rollup-plugin-autorequire

A Rollup plugin used in the FormantJS framework.
It automatically requires files from given directories (and their subfolders) and bundles them together into a virtual module.

It is used for collecting component types and validators (or any other categories you define) into a single importable object.

Installation

npm install rollup-plugin-autorequire

Usage

Add it to your rollup.config.mjs:

import autoRequirePlugin from 'rollup-plugin-autorequire';

export default {
  input: 'src/index.js',
  plugins: [
    autoRequirePlugin({
		targets : [
        	{
				dir: codebaseFolder + 'FormantComponentLib/src/UI/categories',
				name : 'componentTypes',
				filter : '**/!(validators)/!(*Def).js'
			},
        	{
				dir: codebaseFolder + 'FormantComponentLib/src/UI/categories/validators',
				name : 'validators'
			},
        ]
    })
  ]
};
  • If filter is not specified, the plugin defaults to "**/*.js", meaning it will recursively collect all .js files under the given directory.
  • You can restrict the depth by providing your own glob patterns (e.g. "*.js" for flat, "*/*.js" for exactly one subfolder, etc.).

This generates a virtual module you can import anywhere in your code:

import modules from "virtual-modules";

// Components collected under "componentTypes"
modules.componentTypes.TextInput(componentTemplate, parentComponent);

// Validators collected under "validators"
// Use them as suggested in FormantJS documentation
modules.validators.emailInput;

In FormantJS, this allows us to reflect the component lib on the App type at bundle time (every defined component is bundled, we don't maintain an explicit list):

import {App} from "formantjs";

App.componentTypes.TextInput(componentTemplate, parentComponent);

Options

  • targets: Array of objects describing what to collect. Each target supports:

    • dir (string, required) → Root directory to traverse.

    • name (string, required) → Property name in the resulting object.

    • filter (string|string[], optional) → One or multiple glob patterns.

      • If omitted, defaults to "**/*.js".
      • If provided, your globbing patterns are trusted as-is (e.g. "**/*.json" will include JSON files).

Example with multiple filters:

{
  dir: "src/resources",
  name: "resources",
  filter: ["**/*.json", "**/*.yaml"]
}

Generated Output

The plugin injects a virtual module looking like this:

const modules = {
  componentTypes: {
    TextInput: require("/abs/path/FormantComponentLib/src/UI/categories/inputs/TextInput.js"),
    PasswordInput: require("/abs/path/FormantComponentLib/src/UI/categories/inputs/PasswordInput.js"),
    ClickableComponent: require("/abs/path/FormantComponentLib/src/UI/categories/buttons/ClickableComponent.js")
  },
  validators: {
    emailInput: require("/abs/path/FormantComponentLib/src/validators/emailInput.js"),
    passwordInput: require("/abs/path/FormantComponentLib/src/validators/passwordInput.js")
  }
};

module.exports = modules;

License

MIT


Notes

  • This plugin builds a virtual module at bundle-time (no runtime FS access needed in production).
  • By default, only .js files are included.
  • Primarily intended for internal builds with the FormantJS framework.