Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/martonlederer/esbuild-plugin-fileloc
Support __filename, __dirname, __line and additional global variables to get information about the source file with esbuild
https://github.com/martonlederer/esbuild-plugin-fileloc
Last synced: 14 days ago
JSON representation
Support __filename, __dirname, __line and additional global variables to get information about the source file with esbuild
- Host: GitHub
- URL: https://github.com/martonlederer/esbuild-plugin-fileloc
- Owner: martonlederer
- License: mit
- Created: 2021-04-19T12:55:12.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-06-04T11:01:06.000Z (over 2 years ago)
- Last Synced: 2024-10-06T23:35:04.491Z (about 1 month ago)
- Language: TypeScript
- Homepage:
- Size: 30.3 KB
- Stars: 12
- Watchers: 1
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# esbuild-plugin-fileloc
Support `__dirname`, `__filename`, `__line` and additional global variables with esbuild
## Install
```sh
yarn add -D esbuild-plugin-fileloc
```or
```sh
npm i -D esbuild-plugin-fileloc
```## Usage
There are 5 global variables available currently:
```ts
console.log(__dirname); // absolute dirname in source
console.log(__filename); // absolute filename in source
console.log(__relativedirname); // relative dirname in source
console.log(__relativefilename); // relative filename in source
console.log(__line); // line number
```## Typescript declarations
To add type declarations for the global variables to your project you can just add this line to your ts file:
```ts
///
```