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

babel-plugin-alias-modules

Package Overview
Dependencies
Maintainers
14
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-alias-modules

A Babel plugin to rewrite aliased require() calls.

  • 2.32.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.7K
decreased by-16.14%
Maintainers
14
Weekly downloads
 
Created
Source

babel-plugin-alias-modules

A Babel plugin to rewrite aliased require() calls.

Configuration

The plugin can be configured using .npmbundlerrc global config section or in the plugin configuration itself.

In both cases the structure is the same:

{
	"resolve": {
		"aliasFields": ["browser"]
	}
}

This resembles webpack's resolve.aliasFields which serves the same purpose.

Normally global config is preferred, but you can leverage plugin configuration when you need different alias fields for different packages.

The default value for resolve.aliasFields is ['browser'] as in webpack.

Note that this plugin used to look for unpkg and jsdelivr fields too, but it caused problems (see https://github.com/liferay/liferay-js-toolkit/issues/365 for more information).

Technical Details

This plugin scans package.json for fields defined in resolve.aliasFields and redirects require()s for aliased modules.

This plugin only does one part of the whole implementation of the aliases. Aliases implementation have two parts:

  1. They redirect existing modules or provide virtual ones when seen from the outside, from another package.

  2. They make local requires divert to a different target.

This plugin does only the second part. The first one is performed by liferay-npm-bundler-plugin-replace-browser-modules.

Please read the browser field specification for more information.

FAQs

Package last updated on 05 Mar 2024

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