esbuild-shim-plugin is an esbuild plugin that polyfills support for the import.meta.url property for ESM modules and the require, __filename, and __dirname properties for CommonJS modules.
pnpm i -D esbuild-shim-pluginimport { build } from 'esbuild';
import { shimPlugin } from 'esbuild-shim-plugin';
await build({
format: 'esm',
plugins: [shimPlugin()],
// ... rest of the configuration
});import { shimPlugin } from 'esbuild-shim-plugin';
import { defineConfig } from 'tsup';
export default defineConfig([
{
format: ['cjs', 'esm'],
esbuildPlugins: [shimPlugin()],
// ... rest of the configuration
},
]);Want to contribute? Awesome! To show your support is to star the project, or to raise issues on GitHub.
Thanks again for your support, it is much appreciated! 🙏
MIT © Shahrad Elahi and contributors.