esbuild-shim-plugin
v1.0.3
Published
A plugin for esbuild to shim imports for commonjs and esm modules.
Downloads
4,832
Maintainers
Readme
esbuild-shim-plugin
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.
📦 Installation
pnpm i -D esbuild-shim-plugin📖 Usage
import { build } from 'esbuild';
import { shimPlugin } from 'esbuild-shim-plugin';
await build({
format: 'esm',
plugins: [shimPlugin()],
// ... rest of the configuration
});With tsup configuration
import { shimPlugin } from 'esbuild-shim-plugin';
import { defineConfig } from 'tsup';
export default defineConfig([
{
format: ['cjs', 'esm'],
esbuildPlugins: [shimPlugin()],
// ... rest of the configuration
},
]);🤝 Contributing
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! 🙏
Relevant
License
MIT © Shahrad Elahi and contributors.
