prettier-plugin-shorten-imports weekly downloads statistics
By porky-prince · npm · Prettier plugins
Prettier plugin that shortens local import paths
prettier-plugin-shorten-imports has 3 recorded weekly downloads on npm, a decrease of 57.1% over the past 30 days, ranking #2250 of 2,322 tracked listings.
About prettier-plugin-shorten-imports
prettier-plugin-shorten-imports
This plugin rewrites local import and export specifiers to the shortest path
depth based on your tsconfig.json or jsconfig.json paths mappings. You
can use it to keep imports consistent and avoid long relative paths.
Features
This section summarizes what the plugin does when Prettier formats a file.
- Supports
.js,.jsx,.ts,.tsx, and.vuefiles. - Rewrites only static
importandexport ... fromspecifiers. - Compares relative paths and
pathsaliases and keeps the shortest depth. - Preserves existing file extensions and normalizes to POSIX separators.
- Skips specifiers that resolve to
node_modulesor outside the project root.
Installation
Use your package manager to add the plugin as a development dependency.
pnpm add -D prettier-plugin-shorten-imports
Usage
You must register the plugin with Prettier before formatting your files.
prettier --plugin=prettier-plugin-shorten-imports --write "src/**/*.{ts,tsx}"
If you use a Prettier config file, add the plugin to the plugins list:
{
"plugins": ["prettier-plugin-shorten-imports"]
}
Configuration
The plugin reads the nearest tsconfig.json or jsconfig.json from the
current file location. It uses compilerOptions.paths and baseUrl from the
nearest config to resolve aliases, and it merges baseUrl and paths
through nested extends chains with the nearest config taking precedence.
If paths exist but baseUrl is missing, the plugin treats the config file
directory as the baseUrl root. If no paths are defined, the plugin does
not change specifiers.
Behavior
This section lists key rules that influence how specifiers are rewritten.
- The plugin keeps the original specifier when depth and string length tie.
- For
.vuefiles, it only updates<script>and<script setup>blocks. - It does not change
<script src="...">external scripts. - It does not touch dynamic
import()orrequire()calls.
Example
This example shows an alias winning over a deeper relative path.
tsconfig.json:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@app/*": ["src/*"]
}
}
}
Input:
import { formatName } from "../../utils/format";
Output:
import { formatName } from "@app/utils/format";
Description from the npm listing.
- prettier
- prettier-plugin
- shorten
- imports
- paths
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (122)Similar npm Prettier plugins plugins
All 20 prettier-plugin-shorten-imports alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/prettier-plugin-shorten-imports. First seen Oct 16, 2026; last successful collection Oct 20, 2026. See the methodology.