Change where a module dependency is resolved/imported from.
npm i --save-dev esbuild-plugin-resolve
import esbuild from 'esbuild';
import resolve from 'esbuild-plugin-resolve';
esbuild.build({
entryPoints: ['./src/index.js'],
bundle: true,
outfile: './lib/index.js',
plugins: [resolve({
test: 'test-two/lib/example'
})]
});
// The following will be rewritten
import test from 'test'
import test from 'test-two/lib/example'