Socket
Socket
Sign inDemoInstall

lerna-alias

Package Overview
Dependencies
1
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

lerna-alias

Get aliases for your lerna packages for the other tools


Version published
Weekly downloads
582
increased by72.19%
Maintainers
1
Install size
160 kB
Created
Weekly downloads
 

Readme

Source

lerna-alias

Simple package for getting alias object for packages managed by lerna, so other tools (such as webpack, rollup, jest and possibly more) can consume your packages directly from the source files, instead of the built and prepared distribution files.

It just eases development and setting up scripts depending on other lerna packages.

API

lernaAliases({
  // from which directory lerna monorepo should be searched for
  directory: string = process.cwd(),
  // optional array of `mainFields` that should be used to resolv package's entry point
  // similar to the https://webpack.js.org/configuration/resolve/#resolve-mainfields
  // using this takes precedence over default `sourceDirectory` option
  mainFields?: string[],
  // which directory should be considered as containing source files of a package
  // if specified as false it will use package's root and rely on a tool's (i.e. webpack) resolving algorithm
  sourceDirectory: string | false = 'src'
}): Aliases

Types

Aliases

type Aliases = {
  // value is a local directory path to the package
  // resolved using `sourceDirectory` and `mainFields` options
  [packageName: string]: string,
}

Usage

with webpack

const { webpack: lernaAliases } = require('lerna-alias')

module.exports = {
  // ...
  resolve: {
    // ...
    alias: lernaAliases(),
  },
}

with Rollup

const { rollup: lernaAliases } = require('lerna-alias')
const lernaAliases = require('lerna-alias')

module.exports = {
  // ...
  plugins: [
    // ...
    alias(lernaAliases()),
  ],
}

with Jest

const { jest: lernaAliases } = require('lerna-alias')

module.exports = {
  // ...
  moduleNameMapper: lernaAliases(),
}

using mainFields option

const { jest: lernaAliases } = require('lerna-alias')

module.exports = {
  // ...
  moduleNameMapper: lernaAliases({ mainFields: ['main'] }),
}

Keywords

FAQs

Last updated on 09 Mar 2018

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc