Registry / devops / esbuild-plugin-import-pattern

esbuild-plugin-import-pattern

JSON →
library0.1.0jsnpmunverified

An esbuild plugin for importing modules using wildcard patterns (e.g. './files/*.js'). Current stable version is 0.1.0. It improves upon esbuild-plugin-import-glob by providing a simpler API and support for named import selection via hash syntax. The plugin integrates with esbuild's build process and is published on npm as a development dependency. Released under the MIT license, it is designed for Node.js environments and requires esbuild as a peer dependency.

npm install esbuild-plugin-import-pattern
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-IMP
E
esbuild-plugin-import-pattern
devopsjavascriptv0.1.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

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

importPatternPlugin
✓ const { importPatternPlugin } = require('esbuild-plugin-import-pattern')
✗ const importPatternPlugin = require('esbuild-plugin-import-pattern')
The package exports a named function, not a default export.
entries
✓ import { entries } from './files/*.js'
✗ import { entries } from './files/*.js#default'
The hash syntax is for selecting named exports; entries (array of [path, exports] tuples) is the default export from the wildcard module.
modules
✓ import { modules } from './files/*.js'
✗ import { modules } from './files/*.js#default'
modules gives an array of export objects without paths.

Install the plugin and configure esbuild with it. The plugin is applied as a plugin during build, allowing wildcard imports in source files. The build script demonstrates bundling with the plugin enabled.

npm install esbuild-plugin-import-pattern --save-dev const esbuild = require('esbuild'); const { importPatternPlugin } = require('esbuild-plugin-import-pattern'); esbuild.build({ entryPoints: ['src/index.js'], bundle: true, outfile: 'dist/bundle.js', plugins: [importPatternPlugin()], }).then(() => { console.log('Build succeeded'); }).catch((err) => { console.error(err); process.exit(1); });
Debug
Known issues
gotchaWildcard patterns must contain at least one '*' character.
fix
Ensure pattern includes a '*', e.g., './files/*.js'.
affects: >=0.1.0
gotchaDefault import from a wildcard module is not exported. You must use named imports like { entries }, { modules }, or { paths }.
fix
Use named imports: import { entries } from './files/*.js'.
affects: >=0.1.0
gotchaWhen using wildcard pattern with hash syntax for named exports, esbuild may still include unused exports. The hash only reduces bundling overhead but does not tree-shake unused exports.
fix
Use hash syntax (e.g., '#default') if all exports share the same named exports to avoid unnecessary code.
affects: >=0.1.0
gotchaIf multiple wildcard imports exist in the same file, they must be renamed using 'as' keyword.
fix
Use: import { entries as cats } from './cats/*.js' and import { entries as dogs } from './dogs/*.js'.
affects: >=0.1.0
Errors
Common errors & fixes
Error: The plugin "esbuild-plugin-import-pattern" is not found.
The plugin is not installed or not imported correctly.
fix
Run 'npm install esbuild-plugin-import-pattern --save-dev' and import as 'const { importPatternPlugin } = require("esbuild-plugin-import-pattern")'.
Error: Wildcard pattern must contain at least one '*'
The import pattern does not include a wildcard character.
fix
Change the import path to include '*', e.g., './files/*.js'.
TypeError: importPatternPlugin is not a function
The require or import incorrectly assigned the module.
fix
Use destructuring: const { importPatternPlugin } = require('esbuild-plugin-import-pattern') (not require('esbuild-plugin-import-pattern').default or direct assignment).
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
esbuild-plugin-import-pattern — npm install esbuild-plugin-import-pattern · libregistry