npm install esbuild-plugin-modify-entrypoints -D
Add the plugin to your esbuild plugins
.
import { build } from 'esbuild';
import { modifyEntrypointsPlugin } from 'esbuild-plugin-modify-entrypoints';
const results = await build({
entryPoints: ['your-file.ts'],
plugins: [
modifyEntrypointsPlugin(({ contents }) => {
return {
contents: `console.log('First');\n${contents}`,
loader: 'ts',
};
}),
],
});