GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - uiwjs/babel-plugin-transform-remove-imports: Remove the specified import declaration when you use the babel transform to build the package.

BranchesTags
Open more actions menu

Latest commit

 

History

123 Commits
123 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
src
src
 
 
test
test
 
 
.babelrc
.babelrc
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
index.d.ts
index.d.ts
 
 
package.json
package.json
 
 
renovate.json
renovate.json
 
 

Repository files navigation

Using my app is also a way to support me:
DockLift: Windows, Here Zipora: Zip/RAR/7Z Unarchiver Scap: Screenshot & Markup Edit Screen Test Deskmark Keyzer Vidwall Hub VidCrop Vidwall Mousio Hint Mousio Musicer Audioer FileSentinel FocusCursor Videoer KeyClicker DayBar Iconed Menuist Quick RSS Quick RSS Web Serve Copybook Generator DevTutor for SwiftUI RegexMate Time Passage Iconize Folder Textsound Saver Create Custom Symbols DevHub Resume Revise Palette Genius Symbol Scribe

babel-plugin-transform-remove-imports

Buy me a coffee Follow On X NPM version CI Coverage Status Downloadss Repo 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 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';

Support require

Via .babelrc or babel-loader.

{
  "plugins": [
    [
      "babel-plugin-transform-remove-imports", {
        "test": "@babel/core",
      }
    ]
  ]
}
// Input Code
require('@babel/core');
const jest = require('jest');

// Output   ↓ ↓ ↓ ↓ ↓ ↓
var jest = 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 the test option. #3

// Input Code
import 'foo';
import Foo from 'foo';

// Output Code  ↓ ↓ ↓ ↓ ↓ ↓
import Foo from 'foo';

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';"

Contributors

As always, thanks to our amazing contributors!

Made with github-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.

uiwjs.github.io/babel-plugin-transform-remove-imports/

Topics

babelbabel-pluginbabel7ssruiw

Resources

Readme
MIT license
Activity
Custom properties

Stars

22 stars

Watchers

1 watching

Forks

3 forks
Report repository

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.