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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@bundles/bundles-filters

v0.2.1

Published

A bundler plugin for Bundles which allows you to create a series of dynamic filters to run through other bundlers.

Downloads

15

Readme

Bundles Filters Bundler

This is a bundler plugin for use with Bundles which filters files for use with other bundlers.

Environment support

| Node | CLI | ES Module | Browser | UMD | | :--: | :-: | :-------: | :-----: | :-: | | ✓ | ✓ | ✓ | x | x |

Install

Make sure Bundles is installed.

npm install @bundles/bundles-filters -D

Usage

See configuring Bundles for details on configuring Bundles and bundlers.

filters

filters is the only configuration option. It allows you to create one or more filters, each which do one of the following:

  1. Permanently remove specified output files from bundle.output.
  2. Run a series of bundlers on a temporarily filtered subset of output files from bundle.output. NOTE: This does not remove anything from bundle.output, the filter only applies temporarily while the configured bundlers run.

filter

Properties:

  • pattern {String|String[]|Function} (required) Use glob pattern(s) to test against each input source path. If the path matches, it will be included in the filter. Or you may pass a custom Function for more flexibility. Custom functions receive file, bundle, and micromatch as parameters, and must return a Boolean to tell Bundles if a file should be added to the filter. For example:
    function myCustomFilter(file, { bundle, micromatch }) {
      // Return `true` to add to filter.
      return true;
    }
  • type {string} Default: 'some' micromatch is used to test filter patterns. By default, the micromatch.some() method is used to test. You may tweak the behavior to your liking by passing 'every', 'any', 'all', 'not', or 'contains' to use the corresponding micromatch method.
  • options {Object} Options passed directly to micromatch.
  • reverse {Boolean} When true, files that do NOT match filter.pattern will be added to the filter.
  • bundlers {Object[]} When this property exists, files that match the filter will be run through these bundlers. This is useful to run certain bundlers only on a subset of a larger grouping of files. The bundlers property can be configured exactly like bundlers in bundle.bundlers. See configuring Bundles for more details.

Example:

const bundle = {
  input: [...],
  bundlers: [
    {
      run: require('@bundles/bundles-filters'),
      filters: [
        {
          // These files will be removed permanently.
          pattern: ['!*.yaml'],
        },
        {
          // All other filters will run their matching subset of files through
          // the configured bundlers, after which the original `bundle.output`
          // (minus the removed files) is restored.
          pattern: ['{one,two,three}.md'],
          bundlers: [markdown, footer],
        },
        {
          // Pattern can be a Function.
          pattern: (file, { bundle, micromatch }) => path.extname(file.source.path) === '.css',
          bundlers: [css],
        },
        {
          pattern: ['*.{css,js}', '!three.js'],
          bundlers: [banner, footer],
        },
        {
          pattern: '*.json',
          bundlers: [json],
        },
      ],
    },
  ];
}