An esbuild plugin for transforming import paths and module specifiers during the build process. Current version is 1.1.1, actively maintained. It supports conditional renaming based on platform (browser/node), inline text replacements, and simple path overrides. Differentiates from generic esbuild plugins by focusing specifically on import transformation with platform-aware rules, runtime-free operation, and TypeScript type definitions included.
npm install esbuild-plugin-import-transformNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates using esbuild-plugin-import-transform to replace lodash with lodash-es, inline text for ./utils, and conditionally map node:fs to memfs when platform is browser.
Use import statement in an ES module context (type: 'module' in package.json or .mjs file).
Use default import: import importTransform from 'esbuild-plugin-import-transform'.
Pin version or follow release notes.
Ensure esbuild platform is set (e.g., 'browser' or 'node') and that the platform key in the option matches exactly.
Use proper export syntax in the text string to avoid runtime errors.
Switch to import statement and ensure your project is configured for ES modules (type: 'module' in package.json, or use .mjs extension).
Use default import: import importTransform from 'esbuild-plugin-import-transform'.
Ensure each key is a string module specifier and each value is either a string (target) or an object with 'to', 'text', or 'platform' keys.