Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

License

NotificationsYou must be signed in to change notification settings

uiwjs/babel-plugin-transform-remove-imports

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Usingmy app is also a way tosupport me:
Vidwall HubVidCropVidwallMousio HintMousioMusicerAudioerFileSentinelFocusCursorVideoerKeyClickerDayBarIconedMousioQuick RSSQuick RSSWeb ServeCopybook GeneratorDevTutor for SwiftUIRegexMateTime PassageIconize FolderTextsound SaverCreate Custom SymbolsDevHubResume RevisePalette GeniusSymbol Scribe

babel-plugin-transform-remove-imports

NPM versionCICoverage StatusDownloadssRepo Dependents

Modular import plugin for babel for server-side rendering. Also works for cjs to delete imported CSS to avoid compilation errors..

Usage

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

Via.babelrc orbabel-loader.

{"plugins": [    ["babel-plugin-transform-remove-imports", {"test":"\\.(less|css)$"      }    ]  ]}
// Input Codeimport'./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';

Supportrequire

Via.babelrc orbabel-loader.

{"plugins": [    ["babel-plugin-transform-remove-imports", {"test":"@babel/core",      }    ]  ]}
// Input Coderequire('@babel/core');constjest=require('jest');// Output   ↓ ↓ ↓ ↓ ↓ ↓varjest=require('jest');

Output Result

- require('@babel/core');- const jest = require('jest');+ var jest = require('jest');

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.

  • remove?: 'effects'

Removing only side effects imports,Used with thetest option.#3

// Input Codeimport'foo';importFoofrom'foo';// Output Code  ↓ ↓ ↓ ↓ ↓ ↓importFoofrom'foo';

Programmatic Usage

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

Contributors

As always, thanks to our amazing contributors!

Made withgithub-action-contributors.

License

MIT ©Kenny Wong &Slava Fomin II

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors4

  •  
  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp