Registry / web-framework / esbuild-fix-imports-plugin

esbuild-fix-imports-plugin

JSON →
library1.0.23jsnpmunverified

An ESBuild plugin (v1.0.23) that fixes import paths in bundleless ESBuild/tsup builds by resolving TypeScript path aliases, replacing directory imports with explicit index file paths, and appending correct file extensions. Released actively, it combines three sub-plugins (fixAliasPlugin, fixFolderImportsPlugin, fixExtensionsPlugin) and an optional writeFilePlugin for memory-based builds. Key differentiator: solves common issues when bundling is disabled and output files need correct relative imports for Node.js or browser consumption.

web-frameworkhttp-networkingserialization
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

Named export, not default. Works with ESM and CJS via separate entry points.

import { fixImportsPlugin } from 'esbuild-fix-imports-plugin'

Named export, available as sub-export. CommonJS require may fail if package is ESM-only in future versions.

import { fixAliasPlugin } from 'esbuild-fix-imports-plugin'

Separate file, not exported from main entry; used in the recommended esbuild.mjs pattern.

import { writeFilePlugin } from 'esbuild-fix-imports-plugin/dist/esm/writeFilePlugin.mjs'

Demonstrates using fixImportsPlugin with writeFilePlugin in an ESBuild script that fixes import paths in bundleless builds.

import { build } from 'esbuild'; import { fixImportsPlugin, writeFilePlugin } from 'esbuild-fix-imports-plugin'; import fg from 'fast-glob'; async function buildAll() { const entryPoints = await fg(['src/**/*'], { onlyFiles: true }); await build({ entryPoints, bundle: false, write: false, outdir: 'dist', platform: 'node', format: 'esm', plugins: [ fixImportsPlugin(), writeFilePlugin(), ], tsconfig: './tsconfig.json', }); } buildAll();
Debug
Known footguns
deprecatedtsup is discouraged; the README states 'Consider using ESBuild directly as TSUP is deprecated.'
gotchawrite: false is required when using writeFilePlugin; setting write: true will cause build failures as the plugin expects to write files in memory.
gotchaThe plugin expects tsconfig.json with paths defined; missing or incorrect tsconfig can cause alias resolution to fail silently.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
11 hits · last 30 days
ahrefsbot
4
gptbot
3
claudebot
3
bingbot
1
Resources