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

parcel-processor

v1.1.1

Published

write asset files to a package directry given an entry point

Downloads

18

Readme

parcel-processor

write asset files to a package directory given an entry point

build status

example

Given an entry point on process.argv[2], create a browserify bundle and write the inline assets to opts.dst:

var copier = require('parcel-processor');
var browserify = require('browserify');
var path = require('path');
var file = path.resolve(process.argv[2]);

copier(browserify(file), {
    keys: [ 'style' ],
    dst: __dirname + '/dst'
});

methods

var copier = require('parcel-processor')

var cp = copier(b, opts)

Given a browserify instance b and some options opts, copy asset files from the parcel-map output to the destination opts.dst.

The options are:

  • opts.dst - the destination root to start writing package files at
  • opts.keys - array of keys for parcel-map to read from the package.json
  • opts.defaults - object of default values passed directly through to parcel-map

The return value is an event emitter cp with some events documented below.

events

cp.on('bundle.css', function (file) {})

When the concatenated css bundle has been written, this event fires with the file path.

cp.on('bundle.js', function (file) {})

When the concatenated js bundle has been written, this event fires with the file path.

cp.on('package', function (pkg) {})

This event fires when a package is being written.

pkg has these properties:

  • pkg.isParcel - whether the package is a parcel
  • pkg.package - the package.json contents
  • pkg.assets - an array of assets paths declared in pkg
  • pkg.id - the package.json identifier from parcel-map
  • pkg.files - an object mapping the opts.keys types to arrays of matching file paths for each type
  • pkg.path - the path to the package root containing a package.json
  • pkg.dependencies - an array of dependency ids that pkg depends on
  • pkg.hash - the hash name used for the asset directory

Example pkg output:

{ package: 
   { view: 'view.html',
     main: 'main.js',
     style: '*.css',
     __dirname: '/home/substack/projects/parcel-processor/example/views/page1' },
  assets: [ '/home/substack/projects/parcel-processor/example/views/page1/x.css' ],
  id: '2814e2ae0d4b530be5c8adee15a7d5ce16246f96',
  files: { style: [ '/home/substack/projects/parcel-processor/example/views/page1/x.css' ] },
  path: '/home/substack/projects/parcel-processor/example/views/page1',
  dependencies: [],
  hash: '5c1f45e9747e602cfcda7c2b390b6779d11acb80' }

cp.on('map', function (map) {})

This event fires when the asset map from parcel-map is available.

cp.on('done', function () {})

When the package and all dependent packages are completely written, this event fires.

install

With npm do:

npm install parcel-processor

license

MIT