Socket
Book a DemoInstallSign in
Socket

babel-plugin-nukable-import

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-nukable-import

Babel plugin for nuking bindings from imports

latest
Source
npmnpm
Version
0.4.2
Version published
Maintainers
2
Created
Source

Build Status

Allows you to remove bindings from a specific import declaration source. The source is also used to remove any exports as well.

Example

import {
  expectStackChange,
  assert,
  check,
  CheckInterface,
  CheckFunction
} from '@glimmer/debug';

APPEND_OPCODES.app(123, (vm) => {
  let { stack } = vm;
  let mgr = check(stack.pop(), CheckInterface({ didRenderLayout: CheckFunction }));
  mgr.didRenderLayout();
  assert(stack.pop(), 'Must have a value');
  expectStackChange(stack, -2, 'PrimitiveReference');
});

Will be compiled as:

APPEND_OPCODES.app(123, (vm) => {
  let { stack } = vm;
  let mgr = stack.pop();
  mgr.didRenderLayout();
  stack.pop();
});

Basic Usage

{
  moduleIds: true,
  getModuleId() { ... },
  plugins: [
    ['nukable-import', { source: '@glimmer/debug' }]
  ]
}

Advanced Usage

If you need fine grain control over the bindings, you can implement a delegate that will be shown all the bindings that are CallExpressions and Identifiers. Note, this should be used for one-offs like removing a specific binding from from a specific source.

{
  moduleIds: true,
  getModuleId() { ... },
  plugins: [
    ['nukable-import', {
      source: '@glimmer/vm',
      delegate(bindingName, path, types) {
        if (bindingName === 'META_DATA') {
          path.remove();
        }
      }
    }]
  ]
}

Keywords

babel-plugin

FAQs

Package last updated on 14 Feb 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