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

babel-plugin-module-selector

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-module-selector

Replace modules based on a selector

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-module-selector

This plugin allows you to replace one module reference with another module reference based on your setting. You can use this plugin if you have a project where customization of modules is a requirement.

Installation

npm install babel-plugin-module-selector

Usage

Configure your .babelrc to use this plugin. An example of it is provided below.

{
  "plugins": [
    ["module-selector", {
      "roots": ["src"],
      "selectorsRoot": "customizations"
    }]
  ]
}

In roots you define the folders under which transformations will apply. selectorsRoot is the root folder where you place all your customization selectors. selectorsRoot should be within roots. Each customization selector can mirror a part of the folder structure of your root. I.e:

project
  src
    a
    b
    customizations
      selectorA
        a
      selectorB
        b

With the example folder structure above, when we build with selector selectorA, src/customizations/selectorA/a is used whenever a is required/imported. However b is still required/imported from src/b.

This model allows you to partialy replace a standard version of your app while still reusing most of the code.

You can use the BABEL_MODULE_SELECTOR environment variable to control which selector to use for builds, or you can add a selector config to your .babelrc to do the same.

Keywords

FAQs

Package last updated on 10 May 2017

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