Registry / web-framework / vite-plugin-glob

vite-plugin-glob

JSON →
library0.3.2jsnpmunverified

An experimental Vite plugin providing an enhanced glob import API with support for multiple patterns, ignore, custom queries, and selective default/named exports. Current version 0.3.2. It served as a design experiment that influenced Vite's built-in import.meta.glob, offering features like HMR on file changes and Vite alias support before they were integrated into core. Active development but note that Vite v3.0 has since ported some of its features, making this plugin primarily useful for experimentation or using specific options not yet in core. Key differentiator: unified API with options like eager, query, as, and import, allowing fine-grained control over globbed imports.

npm install vite-plugin-glob
INSTALL
IMPORT
SIG · VITE-PLUGIN-GLOB
V
vite-plugin-glob
web-frameworkjavascriptv0.3.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import GlobPlugin from 'vite-plugin-glob'
const GlobPlugin = require('vite-plugin-glob')
ESM-only; CommonJS require not supported.
import.meta.importGlob
const modules = import.meta.importGlob('./dir/*.js')
const modules = import.meta.glob('./dir/*.js')
Use import.meta.importGlob to avoid conflict with Vite's built-in import.meta.glob unless setting takeover: true.
type Options
import type { Options } from 'vite-plugin-glob'
import { Options } from 'vite-plugin-glob'
Type-only import is correct for TypeScript; value import will cause runtime error.

Shows how to install the plugin in vite.config and use import.meta.importGlob with eager option to load all .ts files immediately.

// vite.config.ts import { defineConfig } from 'vite' import GlobPlugin from 'vite-plugin-glob' export default defineConfig({ plugins: [ GlobPlugin({ // Enable to have this plugin handle import.meta.glob instead of Vite // takeover: true, }), ], }) // In any module: const modules = import.meta.importGlob('./*.ts', { eager: true }) console.log(modules)
Debug
Known issues
breakingThe export option has been renamed to import in v0.3.0.
fix
Update usage: { export: 'default' } -> { import: 'default' }
affects: <=0.2.9
gotcharestoreQueryExtension option is disabled by default since v0.3.0, meaning file extensions may not be restored in queries.
fix
Set restoreQueryExtension: true if you need query extension restoration.
affects: >=0.3.0
deprecatedThe takeover feature may become unnecessary as Vite core incorporates similar features; check Vite version compatibility.
fix
Consider using Vite's native import.meta.glob with Vite >=3.0 if you don't need this plugin's specific options.
affects: *
gotchaUsing import.meta.importGlob with the same pattern as Vite's import.meta.glob may cause conflicts if takeover is not enabled.
fix
Either enable takeover: true or use distinct patterns to avoid confusion.
affects: >=0.3.0
gotchaHMR may not work correctly for newly created files in some scenarios; see issue #22.
fix
Upgrade to v0.3.2 or later for improved HMR handling.
affects: <=0.3.1
Errors
Common errors & fixes
ERR_MODULE_NOT_FOUND: Cannot find module 'vite-plugin-glob'
Package not installed or installed incorrectly.
fix
Run npm install -D vite-plugin-glob from project root.
Cannot use import statement outside a module
Using ES module import in a CommonJS file.
fix
Ensure your file is .mjs or set type: module in package.json, or use dynamic import().
Uncaught (in promise) TypeError: import.meta.importGlob is not a function
Missing plugin setup in vite.config or plugin not applied before usage.
fix
Add GlobPlugin() to vite.config plugins array and restart Vite dev server.
No matching export in 'vite-plugin-glob' for import 'Options'
Trying to import Options as a value instead of a type.
fix
Use import type { Options } from 'vite-plugin-glob'.
Upgrade
Version history
0.3.2latest on npm
Audit
Dependencies
viterequiredPeer dependency; plugin only works within Vite's build pipeline.
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
vite-plugin-glob — npm install vite-plugin-glob · libregistry