✨ Transform imports in esbuild
📦 Installation
npm install -D esbuild esbuild-plugin-import-transform
📚 Usage
Add this to your build file
import { build } from "esbuild";
import importTransform from "esbuild-plugin-import-transform";
const yourConfig = {};
await build({
...yourConfig,
plugins: [
importTransform({
"imported-module": "imported-module/dist/index.js",
// This will transform all imports from "node:path" to "path-browserify"
// when esbuilds platform is set to "browser"
"node:path": {
platform: "browser",
to: "path-browserify"
},
"./locate": {
text: "export function locate() { return \"found\" }"
},
// will transform all imports from "./utils" to "./lib/utils2"
"./utils": "./lib/utils2"
})
]
});
📄 License
Published under MIT License.