JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12829
  • Score
    100M100P100Q131972F
  • License MIT

Rewrite require calls in browserify modules.

Package Exports

  • aliasify

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (aliasify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Aliasify is a transform for browserify which lets you rewrite calls to require.

Installation

Install with npm install --save-dev aliasify.

Usage

To use, add a section to your package.json:

{
    "aliasify": {
        aliases: {
            "d3": "./shims/d3.js"
            "underscore": "lodash"
        }
    }
}

Now if you have a file in src/browserify/index.js which looks like:

d3 = require('d3')
_ = require('underscore')
...

This will automatically be transformed to:

d3 = require('../../shims/d3.js')
_ = require('lodash')
...

Any replacement that starts with a "." will be resolved as a relative path (as "d3" above.) Replacements that start with any other character will be replaced verbatim (as with "underscore" above.)

Configuration

Configuration can be loaded in multiple ways; You can put your configuration directly in package.json, as in the example above, or you can use an external json or js file. In your package.json:

{
    "aliasify": "./aliasifyConfig.js"
}

Then in aliasifyConfig.js:

module.exports = {
    aliases: {
        "d3": "./shims/d3.js"
    },
    verbose: false
};

Note that using a js file means you can change your configuration based on environment variables.

Alternatively, if you're using the Browserify API, you can configure your aliasify programatically:

aliasify = require('aliasify').configure({
    aliases: {
        "d3": "./shims/d3.js"
    },
    configDir: __dirname,
    verbose: false
});

note that configure() returns a new aliasify instance.

Configuration options:

  • aliases - An object mapping aliases to their replacements.
  • verbose - If true, then aliasify will print modificiations it is making to stdout.
  • configDir - An absolute path to resolve relative paths against. If you're using package.json, this will automatically be filled in for you with the directory containing package.json.