Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ministryofjustice/module-alias

Package Overview
Dependencies
Maintainers
15
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ministryofjustice/module-alias

Module aliases (based on work by Nick Gavrilov artnikpro@gmail.com)

  • 1.0.18
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.9K
increased by13707.14%
Maintainers
15
Weekly downloads
 
Created
Source

@ministryofjustice/module-alias

Module Alias creates aliases to the location of any package on your file system from configuration in package.json.

Not:

require('../../../../some/very/deep/module')

But:

const module = require('@deep/module')

Or you can register directories that will behave like node_modules.

Install

npm i -P @ministryofjustice/module-alias

Usage

Add configuration to package.json:

Aliases

{
  "_moduleAliases": {
    "@root"      : ".",
    "@deep"      : "src/some/very/deep/directory/or/file",
    "@my_module" : "lib/some-file.js",
    "something"  : "src/foo"
  }
}

Directories

{
  "_moduleDirectories": [
    "src/node_modules_custom"
  ]
}

Module Alias will resolve the location of package.json and register any aliases contained in it before applying the alias to require during execution.

Registering from an entry point

Include this line at the top of your entry point JS file:

require('@ministryofjustice/module-alias/register')

The path to package.json is determined from the location of the process current working directory. (Ordinarily, this is root directory of the application.)

Registering from a module

Include this line at the top of any JS file:

require('@ministryofjustice/module-alias/register-module')(module)

The path to package.json is derived from the location of the module. (This is useful when the path to package.json cannot be determined from the location of the process current working directory.)

About this package

@ministryofjustice/module-alias is a fork of module-alias with an improved mechanism for resolving the location of package.json and the removal of some features we do not use.

Keywords

FAQs

Package last updated on 01 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc