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

broccoli-merge-files

v0.8.0

Published

Broccoli plugin to merge multiple files into one or multiple files

Downloads

78,136

Readme

broccoli-merge-files

Build Status npm version Download Total Node.js Versions code style: prettier dependencies devDependencies

Merge multiple trees of files into one or multiple files with a user-provided merge function.

Installation

yarn add -D broccoli-merge-files

Usage

const { BroccoliMergeFiles } = require('broccoli-merge-files');

const mergedNode = new BroccoliMergeFiles(inputNodes, {
  merge: entries => JSON.stringify(Object.fromEntries(entries))
});
  • inputNodes: An array of nodes, whose contents will be merged
  • options: A hash of options

Options

  • outputFileName?: string: Optional output file name, if merge returns just the file singular file contents.
  • async merge(files: [fileName, contents][]): Called with an array of all files to be merged.
    • If outputFileName is set, expected to return a string or Buffer.
    • If it is not set, expected to return an array or output files, like: [fileName, contents][], where fileName is a string and contents is a string or Buffer.
  • sort:
    • true (default): Sort in order of input nodes and then relative file path.
    • false: Skip any sorting. Must not be used in conjunction with DuplicateStrategy.KeepFirst or DuplicateStrategy.KeepLast.
    • (a: Entry, b: Entry) => number: Compare function that gets passed two entries. Basically what you would pass to [].sort().
  • duplicates: If multiple input nodes contain a file with the same relative file path...
    • 'prohibit' (default): an error will be thrown and the pipeline crashes.
    • 'keep-first': the file from the first input node containing it is kept.
    • 'keep-last': the file from the last input node containing it is kept.
    • 'keep-all': all files will be passed through to merge.
  • async transformFile?(path: string, contents: string | Buffer): any (optional): Lets you transform every file before passing it to merge.
  • patterns?: string | string[]: Glob patterns for fast-glob.
  • globOptions?: object: Glob options for fast-glob.
  • encoding?: string = 'utf8': The encoding to use when reading and writing files.
  • annotation?: string: A note to help tell multiple plugin instances apart.

Related projects

  • broccoli-merge-trees — Copies multiple trees of files on top of each other, resulting in a single merged tree. Does not merge any individual files.

  • broccoli-flatiron — Takes in a single input tree and merges all input files into a single JS module. Since this plugin is deprecated and not maintained any more, broccoli-merge-files includes a compatibility util to do the same thing:

    const { BroccoliMergeFiles } = require('broccoli-merge-files');
    const flatiron = require('broccoli-merge-files/flatiron');
    
    new BroccoliMergeFiles([inputNode], {
      merge: files =>
        flatiron(files, {
          // trimExtensions: false,
          // prefix: 'export default ',
          // suffix: ';'
        }),
      outputFileName: 'files.js'
    });