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

babel-plugin-transform-remove-imports

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-remove-imports

Remove the specified import declaration when you use the babel transform to build the package.

  • 1.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23K
increased by11.66%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-transform-remove-imports

NPM version Build Status

Modular import plugin for babel for kkt-ssr server-side rendering.

Usage

npm install babel-plugin-transform-remove-imports --save-dev

Via .babelrc or babel-loader.

{
  "plugins": [
    [
      "babel-plugin-transform-remove-imports", {
        "test": "\\.(less|css)$"
      }
    ]
  ]
}
// Input Code
import './index.less';
import './index.main.less';
import { Button } from 'uiw';
import { Select } from '@uiw/core';

// Output   ↓ ↓ ↓ ↓ ↓ ↓
import { Button } from 'uiw';
import { Select } from '@uiw/core';

Output Result

- import './index.less';
- import './index.main.less';
import { Button } from 'uiw';
import { Select } from '@uiw/core';

Options

  • test: RegExp | string | (RegExp | string)[]

    A regular expression to match the imports that will be removed. It could be a string or a RegExp object. You could also pass an array here.

  • removeAll: boolean

    Deletes all imports.

Programmatic Usage

import plugin from 'babel-plugin-transform-remove-imports'
import { transform } from 'babel-core'
 
function replace (code) {
  return transform(code, {
    babelrc: false,
    plugins: [
      [plugin, { test: /\.(less|css)$/ }]
    ],
  }).code;
}
 
replace("import './index.main.less';import { Button } from 'uiw';")
//=> "import { Button } from 'uiw';"

License

MIT © Kenny Wong

Keywords

FAQs

Package last updated on 26 Nov 2019

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