Skip to content
PluginStats

vite-plugin-require weekly downloads statistics

By wangzongming · npm · Vite plugins

can let vite projects to support require

View on npm Fresh · Oct 17, 2026

vite-plugin-require has 19,294 recorded weekly downloads on npm, a decrease of 55.9% over the past 30 days.

It ranks #763 of 2,251 tracked npm listings by weekly downloads.

Over 90 days, weekly downloads changed by -67.7%.

PluginStats has 543 daily observations since Apr 23, 2025; the latest is from Oct 17, 2026.

Weekly downloads
19,294
Official API · Oct 17, 2026
7-day growth
-60.7%
-29.8K weekly downloads
30-day growth
-55.9%
-24.4K weekly downloads
90-day growth
-67.7%
-40.4K weekly downloads
Rank
#763
Among tracked npm listings

About vite-plugin-require

vite-plugin-require

Let Vite projects support require("xxx") syntax. vite-plugin-require

Install and use to achieve painless support for require("xxx").

If the project is useful to you, please click on star!

• 中文文档 • English

Other Projects

The simplest and lowest-cost solution for hardware + AI: https://github.com/wangzongming/esp-ai

Community

QQ Group: 952051286

Supported Vite Versions

• √ vite2 • √ vite3 • √ vite4 • √ vite5 • √ vite6 • √ vite7 • √ vite8

Install

Usage

Supported Features

File Types

By default, the plugin transforms files matching /(.jsx?|.tsx?|.vue)$/.

| Extension | Supported |

| .js / .jsx | √ | | .ts / .tsx | √ | | .vue | √ (must be placed after @vitejs/plugin-vue) |

Files under node_modules are excluded automatically.

require() Argument Types

1. String Literal

Static path, converted to a top-level import.

2. Identifier (Variable)

The variable must be initialized with a string literal in the same file. The plugin resolves the variable to a static path at compile time.

3. String Concatenation (BinaryExpression)

Supports + concatenation of string literals, variables, and nested expressions.

4. Conditional Expression (ConditionalExpression)

Supports ternary expressions inside require().

Both branches are static paths (default translateType: "import"):

The plugin imports both assets and replaces require() with a ternary expression.

Either branch is dynamic, or translateType: "importMetaUrl":

Falls back to new URL(..., import.meta.url).href.

5. Template Literal (TemplateLiteral)

No interpolation — treated as a static path:

With interpolation — converted to runtime URL resolution:

Path Resolution

• Relative paths (./, ../) are resolved relative to the current file. • Deeply nested directories are supported. • Vite resolve.alias is supported.

Conversion Modes (translateType)

| Mode | Description |

| import (default) | Hoists static assets to top-level import statements | | importMetaUrl | Converts to new URL(path, import.meta.url).href. See Vite assets docs |

translateType: "import"

All resolvable static require() calls are replaced with top-level imports.

translateType: "importMetaUrl"

Uses import.meta.url instead of import. Supports on-demand loading — the original code is not removed at build time.

Only works when the asset variable exists before rendering:

Do not put the conditional inside src, e.g. src={xx ? require("../imgs/logo.png") : null}. See issue #28.

Limitations

| Scenario | Status |

| Variable assigned a non-literal value | ✗ Cannot resolve | | Complex variable reassignment | ✗ Only simple const x = "path" is supported | | require() with unsupported argument types | ✗ Throws Unsupported type: xxx | | require(new URL(...)) (MemberExpression) | ✗ Not implemented yet |

Options

All options are optional.

fileRegex

Files to transform. Default: /(.jsx?|.tsx?|.vue)$/

translateType

Conversion mode. Default: "import"

log

Debug logger, receives internal transform info.

Demo

Suppose there are app.jsx and imgs folder in the src directory:

Upgrade Log

https://github.com/wangzongming/vite-plugin-require/blob/master/version-log.md

Alias

vite.config.js

page.jsx

FAQ

1. vitePluginRequire is not a function

2. Unsupported type: ConditionalExpression / TemplateLiteral

Upgrade to the latest version. Both are supported since v1.3.0+.

Description from the npm listing.

  • vite
  • require
  • vite-plugin
  • vite-plugin-require

Where vite-plugin-require sits in the listing

Each band is one page of 20. Weekly downloads on a log 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.

All npm2,248 listings · 113 pages · page 39, #3 (overall #763)
All npm: every listing in weekly downloads order
PNG SVG
Vite plugins250 listings · 13 pages · page 7, #6 (overall #126)
Vite plugins: every listing in weekly downloads order
PNG SVG

Charts

Images: 30d · 1y · all time · 1600×900 dark

Adoption over time

vite-plugin-require weekly downloads on npm, last 90 days: 19,294 weekly downloads as of Oct 17, 2026, -67.7% over 90 days.vite-plugin-requireWeekly downloads on npm · Last 90 days19,294downloads / week-67.7% over 90 days020K40K60K80K100KJul 19Aug 3Aug 18Sep 2Sep 17Oct 2Oct 17downloads / weekobservedarchived (Internet Archive)no observationsJul 20, 2026 – Oct 17, 2026 · 90 observations · Updated Oc…pluginstats.com
vite-plugin-require weekly downloads on npm, last 90 days: 19,294 weekly downloads as of Oct 17, 2026, -67.7% over 90 days.
PNG SVG

7/30/90-day growth

vite-plugin-require weekly downloads growth on npm: -60.7% over 7 days, -55.9% over 30 days, -67.7% over 90 days.vite-plugin-requireWeekly downloads growth on npm19,294downloads / week now7-day growth-29,846 weekly downloads-60.7%30-day growth-24,410 weekly downloads-55.9%90-day growth-40,438 weekly downloads-67.7%Growth vs. nearest observation to each baseline date · Updated Oct 17, 2026pluginstats.com
vite-plugin-require weekly downloads growth on npm: -60.7% over 7 days, -55.9% over 30 days, -67.7% over 90 days.
PNG SVG

Ranking history

vite-plugin-require npm ranking history: currently #763 (by weekly downloads).vite-plugin-requirenpm ranking · by weekly downloads · Last 90 days#763current rank#200#300#400#500#600#700#800Jul 20Aug 4Aug 19Sep 3Sep 18Oct 3Oct 18rankOct 17, 2026 – Oct 18, 2026 · 2 observations · Updated Oct 17, 2026pluginstats.com
vite-plugin-require npm ranking history: currently #763 (by weekly downloads).
PNG SVG

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.

Recent observations

Full history (543)
Recent weekly downloads observations for vite-plugin-require
Date (UTC)Weekly downloadsChange vs. previous
19,294-2.3K
21,564+219
21,345-10.7K
32,052-14.1K
46,1330
46,133-2.8K
48,946-194
49,140+27
49,113-484
49,597-1.1K
50,715+1.8K
48,921-13.2K
62,077-1.8K
63,911—

Similar npm Vite plugins plugins

Data 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/vite-plugin-require. First seen Oct 16, 2026; last successful collection Oct 18, 2026. See the methodology.