babel-plugin-here
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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

npm install --save-dev babel-plugin-here

Babel config

babel.config.json

{
	"plugins": [ "babel-plugin-here" ]
}

TSConfig (if using TypeScript)

tsconfig.json

{
	"compilerOptions": {
		"types": [ "babel-plugin-here/env" ]
	}
}

Example

In

src/foo.js

console.log(HERE)

Out

dist/foo.js

console.log("src/foo.js:1:13")

Readme

Keywords

Package Sidebar

Install

npm i babel-plugin-here

Weekly Downloads

19

Version

1.0.2

License

MIT

Unpacked Size

4.47 kB

Total Files

6

Last publish

Collaborators

  • samual