An esbuild plugin that replaces __dirname, __filename, __line, __relativedirname, and __relativefilename with actual source file metadata at build time. Version 0.0.6, no release cadence documented. Unlike Node.js's __dirname (which resolves to the output file), this plugin provides the original source path, and the __line variable is unique among Node-like bundlers. Ships TypeScript declarations. Lightweight, no dependencies. Suitable for esbuild bundling projects that need source-level location globals.
npm install esbuild-plugin-filelocVerified import paths — ran on the pinned version, not inferred.
Build a TypeScript file with esbuild and replace __dirname, __filename, __line, etc. with source location values.
Use filelocPlugin() in the plugins array.
Ensure all files that use these globals are bundled by esbuild with the plugin applied.
Add /// <reference types="esbuild-plugin-fileloc" /> at the top of files that use the globals.
N/A
Add /// <reference types="esbuild-plugin-fileloc" /> at the top of your file.
Change plugins: [filelocPlugin] to plugins: [filelocPlugin()].
Use ESM import: import filelocPlugin from 'esbuild-plugin-fileloc'.
No dependency data recorded yet.