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

parable

v1.0.0

Published

Parallel Babel runner

Downloads

179

Readme

Parable - Parallel Babel Runner

This is a module that makes use of Node's cluster module to run Babel transpilation in parallel. In addition it provides the ability to cache results on disk to speed up subsequent rebuilds.

This module, and it's documentation, is still under active development and will be likely be changing often.

Current implementations for other build related tools using Parable are:

Get in touch if you add one we can add to the list!

Usage

Basic usage as a module

const parable = require('parable');

parable.transformFiles(glob.sync('**/*.js'), {})
    .then(files => {
        console.log(files);
    });

Options

Default options:

{
    babelOptions: {},
    logLevel: 'error',
    scale: SCALE,
    processes: null,
    output: Output.STRING,
    outputDir: null,
    base: '',
    key: ''
}
babelOptions

The options to pass to the Babel transpiler (note that .babelrc files will also be read as normal). These are mostly passed as-is to Babel, so refer to Babel's options for documentation, with one exception - the two options that are a function - getModuleId and shouldPrintComment.

Since we pass options to the workers from the master using stringified JSON we can't pass a function, instead these options should be passed as a string which is the name of a module to require which will provide a function to be called. For example:

parable.transformFiles(glob.sync('**/*.js'), {
    babelOptions: {
        getModuleId: path.resolve('./babel-get-module-id')
    }
});
// babel-get-module-id.js
module.exports = (moduleName) => moduleName.toUpperCase(); // OK?!
logLevel

Level of logging to use - one of the usual suspects, error, warn, info, debug.

scale

Scale factor to apply to number of CPUs to determine how many parallel processes to run - default is 0.5 (ie. 4 processes for 8 cores). See also processes if you want to set an explicit number of processes.

processes

Number of parallel processes to run - default is number of cores / scale.

output

By default the workers will return the transpiled code, set this to parable.Output.FILE to write to a file instead. If you want to take advantage of caching between runs you will need to write to a file.

outputDir

The directory to write files to when the output is parable.Output.FILE. Defaults to a system temporary directory created using the tmp module.

base

The base directory to pass into Babel. This is used to calculate relative filenames, for example when naming AMD modules using Babel's moduleIds option.

This can be specified as a single string, or an array of base paths - if an array is supplied then the closest matching base path for the path being transpiled will be chosen. If no match is found, the path will be relative to the first entry in the base array.

key

Default is an empty string. A key for this config. As the config object is used when generating the hash, this is to ensure unique hashes if the only config differences are in .babelrc files.