
Research
/Security News
Chrome and Firefox Extensions Posing as Free VPNs Add Clipboard Stealers via Malicious Updates
Malicious Chrome and Firefox extensions posed as free VPNs while stealing clipboard data through later extension updates.
@shined/babel-plugin-transform-import-declaration
Advanced tools
A Babel plugin to transform import declarations for tree-shaking and on-demand loading
A Babel plugin to transform import declarations for tree-shaking and on-demand loading.
npm install --save-dev @shined/babel-plugin-transform-import-declaration
# or
pnpm add -D @shined/babel-plugin-transform-import-declaration
# or
yarn add -D @shined/babel-plugin-transform-import-declaration
.babelrc
{
"plugins": [
[
"@shined/babel-plugin-transform-import-declaration",
{
"config": [
{
"source": "antd",
"filename": "kebabCase",
"output": ["antd/es/{{ filename }}.js"]
}
]
}
]
]
}
Input:
import { Button, DatePicker } from 'antd';
Output:
import Button from 'antd/es/button.js';
import DatePicker from 'antd/es/date-picker.js';
{
"config": [
{
"source": "antd",
"filename": "kebabCase",
"output": [
"antd/es/{{ filename }}.js",
"antd/es/{{ filename }}/style/css"
]
}
]
}
Output:
import Button from 'antd/es/button.js';
import 'antd/es/button/style/css';
import DatePicker from 'antd/es/date-picker.js';
import 'antd/es/date-picker/style/css';
{
"config": [
{
"source": "antd",
"filename": "kebabCase",
"output": ["antd/es/{{ filename }}.js"],
"exclude": ["Button"]
}
]
}
Input:
import { Button, DatePicker } from 'antd';
Output:
import { Button } from 'antd';
import DatePicker from 'antd/es/date-picker.js';
{
"config": [
{
"source": "antd",
"filename": "kebabCase",
"output": [
"antd/es/{{ filename }}.js",
"antd/css/{{ filename }}.css"
],
"exclude": ["Button"]
},
{
"source": "antd",
"filename": "kebabCase",
"output": [
"antd/es/{{ filename }}.js",
"antd/css/{{ filename }}.png"
],
"include": ["Button"]
}
]
}
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
source | string | Yes | - | Source module name to match |
filename | FilenameCase | Yes | - | Filename transformation rule |
output | string[] | Yes | - | Output path templates |
specifier | SpecifierType | No | 'default' | Import specifier type |
include | string[] | No | - | Only process these components (whitelist) |
exclude | string[] | No | - | Exclude these components (blacklist) |
Note: include and exclude are mutually exclusive. You cannot use both in the same config.
| Value | Description | Example |
|---|---|---|
kebabCase | Lowercase with hyphens | Button → button, DatePicker → date-picker |
camelCase | First letter lowercase | Button → button, DatePicker → datePicker |
snakeCase | Lowercase with underscores | Button → button, DatePicker → date_picker |
pascalCase | Keep as PascalCase | Button → Button, DatePicker → DatePicker |
| Value | Generated Import | Use Case |
|---|---|---|
default | import Button from "path" | Module uses export default |
named | import { Button } from "path" | Module uses export { Button } |
namespace | import * as Button from "path" | Import entire module as object |
// Config
{
"source": "antd",
"filename": "kebabCase",
"output": ["antd/es/{{ filename }}.js"]
}
// Input
import { Button } from "antd";
// Output
import Button from "antd/es/button.js";
// Config
{
"source": "lodash",
"filename": "kebabCase",
"output": ["lodash/{{ filename }}.js"],
"specifier": "named"
}
// Input
import { debounce } from "lodash";
// Output
import { debounce } from "lodash/debounce.js";
// Config
{
"source": "utils",
"filename": "camelCase",
"output": ["utils/{{ filename }}.js"],
"specifier": "namespace"
}
// Input
import { DateUtils } from "utils";
// Output
import * as DateUtils from "utils/dateUtils.js";
// snakeCase
import { DatePicker } from "antd";
// → import DatePicker from "antd/es/date_picker.js";
// PascalCase
import { DatePicker } from "antd";
// → import DatePicker from "antd/es/DatePicker.js";
# Install dependencies
pnpm install
# Run tests
pnpm test
# Watch mode
pnpm test:watch
# Build
pnpm build
# Watch build
pnpm dev
This plugin includes comprehensive tests:
All 22 tests pass ✅
If you're looking for better performance, consider using the SWC version:
MIT
ityuany
Found a bug or want to contribute? Visit our GitHub repository
FAQs
A Babel plugin to transform import declarations for tree-shaking and on-demand loading
The npm package @shined/babel-plugin-transform-import-declaration receives a total of 10 weekly downloads. As such, @shined/babel-plugin-transform-import-declaration popularity was classified as not popular.
We found that @shined/babel-plugin-transform-import-declaration demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?

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.

Research
/Security News
Malicious Chrome and Firefox extensions posed as free VPNs while stealing clipboard data through later extension updates.

Research
/Security News
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.

Security News
Rolldown paused Rust React Compiler integration after a 5MB binary size increase raised concerns about shipping React-specific code to all Vite users.