A Rust versions of babel-plugin-transform-remove-imports.
Modular import plugin for swc. Also works for cjs to delete imported CSS to avoid compilation errors.
npm:
npm i -D swc-plugin-transform-remove-imports
yarn:
yarn add -D swc-plugin-transform-remove-imports
You can check the compatibility of versions on https://plugins.swc.rs/
Via .swcrc
{
"jsc": {
"experimental": {
"plugins": [
[
"swc-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';
Type: Regex | Regex[]
A regular expression to match the imports that will be removed.
Optional. Possible values: 'effects'
Removing only side effects imports.
// Input Code
import "foo";
import Foo from "foo";
// Output Code ↓ ↓ ↓ ↓ ↓ ↓
import Foo from "foo";