Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/samualtnorman/babel-plugin-here
Replace instances of HERE identifier with code position strings.
https://github.com/samualtnorman/babel-plugin-here
babel babel-plugin here
Last synced: about 2 months ago
JSON representation
Replace instances of HERE identifier with code position strings.
- Host: GitHub
- URL: https://github.com/samualtnorman/babel-plugin-here
- Owner: samualtnorman
- License: mit
- Created: 2023-07-14T15:06:27.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-29T10:06:53.000Z (2 months ago)
- Last Synced: 2024-10-29T12:11:56.448Z (2 months ago)
- Topics: babel, babel-plugin, here
- Language: TypeScript
- Homepage:
- Size: 260 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# Babel Plugin Here (`babel-plugin-here`)
> Replace instances of `HERE` identifier with code position strings.## Why?
This plugin is useful when you don't have sourcemaps and you're looking at errors in the console and having trouble knowing where they've come from. You can setup this plugin, and use `HERE` in error message like ``throw new Error(`${HERE} Some useful message`)``.## Setup
### Install```sh
npm install --save-dev babel-plugin-here
```### Babel config
`babel.config.json`
```json
{
"plugins": [ "babel-plugin-here" ]
}
```### TSConfig (if using TypeScript)
`tsconfig.json`
```ts
{
"compilerOptions": {
"types": [ "babel-plugin-here/env" ]
}
}
```## Example
### In
`src/foo.js````js
console.log(HERE)
```### Out
`dist/foo.js`
```js
console.log("src/foo.js:1:13")
```