{"id":25404,"library":"esbuild-plugin-resolve","title":"esbuild-plugin-resolve","description":"An esbuild plugin (v2.0.0, last updated 2023) that allows you to replace module import paths during bundling. It intercepts resolve calls and swaps dependencies, useful for mocking or aliasing in tests or builds. Differentiators: lightweight, no dependencies, regex-based matching. Released as v1.0.0 in 2022, with v2.0.0 switching to ES modules. Maintenance-mode with no recent commits.","status":"maintenance","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/markwylde/esbuild-plugin-resolve","tags":["javascript","esbuild","esbuild resolve","resolve","swap dependencies","import","dependencies"],"install":[{"cmd":"npm install esbuild-plugin-resolve","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-resolve","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-resolve","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export; v2.0.0 is ESM-only, require() fails.","wrong":"const resolve = require('esbuild-plugin-resolve')","symbol":"resolve","correct":"import resolve from 'esbuild-plugin-resolve'"},{"note":"It is a default export, not a named export. Named import will be undefined.","wrong":"import { resolve } from 'esbuild-plugin-resolve'","symbol":"resolve","correct":"import * as pkg from 'esbuild-plugin-resolve'; const resolve = pkg.default"},{"note":"Usage is straightforward; no wrong pattern beyond the import. The resolve function returns an esbuild plugin object.","wrong":"plugins: [resolve({ test: 'foo' })]","symbol":"resolve (as plugin function)","correct":"plugins: [resolve({ test: 'foo' })]"}],"quickstart":{"code":"import esbuild from 'esbuild';\nimport resolve from 'esbuild-plugin-resolve';\n\nawait esbuild.build({\n  entryPoints: ['src/index.js'],\n  bundle: true,\n  outfile: 'dist/bundle.js',\n  plugins: [resolve({\n    test: 'lodash',\n    replaceWith: 'lodash-es'\n  })]\n});","lang":"javascript","description":"Shows how to bundle with esbuild and replace 'lodash' imports with 'lodash-es' using the plugin."},"warnings":[{"fix":"Use ESM imports (import resolve from ...) or downgrade to v1.x.","message":"v2.0.0 switched to ES modules; CommonJS require() no longer works.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Check plugin API: in v2.0.0, options might be different. Refer to the repository's usage examples.","message":"The 'replaceWith' option is not documented in v2.0.0; the API changed from v1.x to v2.0.0.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Escape regex-special characters in the module name, e.g., use 'lodash\\.merge' instead of 'lodash.merge'.","message":"The 'test' option is treated as a regex pattern without escaping; special regex characters can cause unexpected matches.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade to v1.1.0 or later.","message":"If the original module has no default export, the plugin may not resolve correctly (fixed in v1.1.0 but verify).","severity":"gotcha","affected_versions":"<1.1.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 --save-dev esbuild-plugin-resolve' and use valid import syntax for your module system.","cause":"Package not installed or incorrect import path.","error":"Cannot find module 'esbuild-plugin-resolve'"},{"fix":"Use 'import resolve from \"esbuild-plugin-resolve\"' instead of 'import { resolve } from \"esbuild-plugin-resolve\"'.","cause":"Named import instead of default import (ESM).","error":"TypeError: resolve is not a function"},{"fix":"Call resolve() with options: plugins: [resolve({ test: 'foo' })].","cause":"The resolve function was not called; plugin array received the raw import.","error":"Error: The plugin must be an object with a name and setup function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}