{"id":25290,"library":"esbuild-import-plugin","title":"esbuild-import-plugin","description":"An esbuild plugin that transforms import statements for enhanced module resolution and aliasing. Version 0.0.15, last updated in 2022, with sporadic maintenance. It provides a simple API to customize how imports are resolved during bundling, supporting option overrides for prefixes and base directories. Unlike more complex solutions like alias plugins, this plugin focuses on lightweight import manipulation without requiring extensive configuration. Its release cadence is low, with only a few versions published.","status":"active","version":"0.0.15","language":"javascript","source_language":"en","source_url":"https://github.com/teniryte/esbuild-import-plugin","tags":["javascript"],"install":[{"cmd":"npm install esbuild-import-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-import-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-import-plugin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package does not export named members; the default export is a function. CJS require works but breaks in ESM environments.","wrong":"const importPlugin = require('esbuild-import-plugin')","symbol":"default (importPlugin)","correct":"import importPlugin from 'esbuild-import-plugin'"},{"note":"Destructuring from require will yield undefined because there is no named export.","wrong":"const { importPlugin } = require('esbuild-import-plugin')","symbol":"importPlugin function","correct":"import importPlugin from 'esbuild-import-plugin'"},{"note":"Options are passed as object to default function; property names are 'prefix' and 'baseDir' (camelCase). Incorrect casing or extra slash will cause mismatched resolution.","wrong":"importPlugin({ prefix: '/@', basedir: './src' })","symbol":"Options (optional)","correct":"importPlugin({ prefix: '@', baseDir: './src' })"}],"quickstart":{"code":"import esbuild from 'esbuild';\nimport importPlugin from 'esbuild-import-plugin';\n\nawait esbuild.build({\n  entryPoints: ['./src/index.js'],\n  bundle: true,\n  outfile: './dist/app.js',\n  loader: { '.js': 'jsx' },\n  sourcemap: true,\n  target: ['chrome58', 'firefox57', 'safari11', 'edge16'],\n  define: { 'process.env.NODE_ENV': '\"development\"' },\n  plugins: [importPlugin()],\n});\nconsole.log('Build complete.');","lang":"javascript","description":"Shows how to use esbuild-import-plugin with esbuild to bundle an entry point, applying the import plugin with default settings."},"warnings":[{"fix":"Always call importPlugin() with explicit options matching your project structure.","message":"Plugin may not resolve imports with custom prefixes correctly if options are not provided.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider using esbuild's built-in alias support or more maintained plugins like esbuild-plugin-alias.","message":"Package has not been updated since 2022; may not work with newer esbuild versions.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Verify that baseDir is absolute or relative to project root, and prefix matches the import strings.","message":"Import resolution fails silently if prefix or baseDir options are mismatched, leading to runtime errors.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run npm install esbuild-import-plugin or yarn add esbuild-import-plugin.","cause":"Package not installed or incorrectly required.","error":"Error: Cannot find module 'esbuild-import-plugin'"},{"fix":"Use import importPlugin from 'esbuild-import-plugin' or const importPlugin = require('esbuild-import-plugin').default.","cause":"Using destructured import instead of default import.","error":"TypeError: importPlugin is not a function"},{"fix":"Ensure importPlugin is called with options that map '@' to the correct base directory, e.g., importPlugin({ prefix: '@', baseDir: './src' }).","cause":"The plugin's import resolution did not match the configured prefix or baseDir.","error":"Error: Build failed with 1 error: error: Could not resolve '@components/Button'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}