An esbuild plugin that polyfills import.meta.url for ESM modules and require/__filename/__dirname for CommonJS modules. Stable v1.0.3, released 2023. Lightweight, zero dependencies, ships TypeScript types. Key differentiator: solves the common problem of using Node.js module globals when bundling with esbuild, especially useful for mixed CJS/ESM codebases. Release cadence is low; no major changes expected.
npm install esbuild-shim-pluginVerified import paths — ran on the pinned version, not inferred.
Bundles an ESM project using esbuild with shimPlugin to polyfill import.meta.url, require, __filename, and __dirname.
Only use the plugin when you actually need to access require, __filename, __dirname, or import.meta.url in bundled code. Consider alternatives like setting the 'platform' to 'node'.
Use dynamic import() or ensure your project is configured for ESM.
Pin to a specific version if you rely on exact behavior.
Test plugin order and compatibility when using multiple esbuild plugins.
Run `npm install esbuild-shim-plugin --save-dev` or `pnpm add -D esbuild-shim-plugin`.
Use `import { shimPlugin } from 'esbuild-shim-plugin'` and ensure your project uses ESM or dynamic import.Use `import { shimPlugin } from 'esbuild-shim-plugin'` instead of `import shimPlugin from 'esbuild-shim-plugin'`.No dependency data recorded yet.