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

pkgify

v1.1.0

Published

Rewrite package/module require calls to local files in browserify"

Downloads

46

Readme

pkgify Build Status

Pkgify is a browserify transform that allows you to rewrite module/package-style require calls to local files. It is built using the browserify-transform-tools.

  • Clean up your require calls!
  • Supports individual files and entire directories
  • Supports nested packages (priorities deepest match)
  • Simple configuration
  • File-type indifferent
  • Efficient

But we already have aliasify and remapify?

Aliasify is designed for mapping individual files to new names. Remapify actually uses aliasify internally for it's mapping process which means it has to generate a list of all possible files that might be mapped from the source directory, and then compare them when processing files. This gives remapify less control since it isn't doing the transform itself.

Purpose

Say, for example, your project has the following tree structure:

myproject
  - /app
    - /views
      - /home
        - index.js
      - /about
        - index.js
    - /models
      - cars.js
    - log.js

Normally, if you wanted to access log.js and models/cars.js from either of the two view files, you would have to do it like so:

var log = require("../../log");
var Cars = require("../../models/cars");

With pkgify, however, you can save yourself time and clean up your code so it looks like this:

var log = require("log");
var Cars = require("models/cars");

Installation

npm install --save-dev pkgify

Usage

Usage is identical to any other browserify-transform-tools transforms:

package.json

Directly in package.json:

{
  "pkgify": {
    "packages": {
      "views": "./app/views",
      "log": "./app/log.js"
    }
  }
}

or using referencing a separate JS file in package.json:

{
  "pkgify": "./pkgifyConfig.js"
}

Browserify API

var pkgify = require("pkgify");

b.transform(pkgify, {
  packages: {
    views: "./app/views",
    log: "./app/log.js"
  },
  relativeTo: __dirname
});

Configuration options

packages

  • Type: object
  • Required: yes
  • Description: A mapping of package names to their source. The source is resolved in relation to the relativeTo option and can reference either a file or directory. If a file is specified it's extension must be included.

relativeTo

  • Type: string
  • Required: no
  • Description: Path to resolve package sources against. If using package.json for configuration, this value will default to the location of the package.json file. If you are using the API, it will default to the location you are configuring from. It is advisable to always explicitly set this option when using the API using __dirname.

appliesTo

  • Type: object
  • Required: no
  • Description: Control what files are processed by the transform. This is an option provided by browserify-transform-tools.

Contributing

Setup

make bootstrap

Running tests

make test

Commit messages

  • Use the present tense ("Add feature" not "Added feature")
  • Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
  • Limit the first line to 72 characters or less
  • Reference issues and pull requests liberally
  • Consider starting the commit message with an applicable emoji:
    • :lipstick: :lipstick: when improving the format/structure of the code
    • :racehorse: :racehorse: when improving performance
    • :non-potable_water: :non-potable_water: when plugging memory leaks
    • :memo: :memo: when writing docs
    • :penguin: :penguin: when fixing something on Linux
    • :apple: :apple: when fixing something on Mac OS
    • :checkered_flag: :checkered_flag: when fixing something on Windows
    • :bug: :bug: when fixing a bug
    • :fire: :fire: when removing code or files
    • :green_heart: :green_heart: when fixing the CI build
    • :white_check_mark: :white_check_mark: when adding tests
    • :lock: :lock: when dealing with security
    • :arrow_up: :arrow_up: when upgrading dependencies
    • :arrow_down: :arrow_down: when downgrading dependencies

(From atom)