unplugin-jsx-source
Version:
[](https://www.npmjs.com/package/unplugin-jsx-source)
119 lines (85 loc) • 2.19 kB
Markdown
# unplugin-jsx-source
[](https://www.npmjs.com/package/unplugin-jsx-source)
A plugin designed to automatically annotate your JSX components with a `data-at`(configurable) attribute, indicating the file name and line number for easier debugging and development.
<img width="822" alt="image" src="https://github.com/user-attachments/assets/cb9a2073-3466-4e47-a988-16a7cbcba957" />
## Install
```bash
npm i unplugin-jsx-source
```
<details>
<summary>Vite</summary><br>
```ts
// vite.config.ts
import jsxSource from 'unplugin-jsx-source/vite'
export default defineConfig({
plugins: [
jsxSource({ /* options */ }),
],
})
```
Example: [`playground/`](./playground/)
<br></details>
<details>
<summary>Rollup</summary><br>
```ts
// rollup.config.js
import jsxSource from 'unplugin-jsx-source/rollup'
export default {
plugins: [
jsxSource({ /* options */ }),
],
}
```
<br></details>
<details>
<summary>Webpack</summary><br>
```ts
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-jsx-source/webpack')({ /* options */ })
]
}
```
<br></details>
<details>
<summary>Nuxt</summary><br>
```ts
// nuxt.config.js
export default defineNuxtConfig({
modules: [
['unplugin-jsx-source/nuxt', { /* options */ }],
],
})
```
> This module works for both Nuxt 2 and [Nuxt Vite](https://github.com/nuxt/vite)
<br></details>
<details>
<summary>Vue CLI</summary><br>
```ts
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require('unplugin-jsx-source/webpack')({ /* options */ }),
],
},
}
```
<br></details>
<details>
<summary>esbuild</summary><br>
```ts
// esbuild.config.js
import { build } from 'esbuild'
import jsxSource from 'unplugin-jsx-source/esbuild'
build({
plugins: jsxSource()],
})
```
<br></details>
## Made with
https://github.com/unplugin/unplugin-starter
cause I saw that idea again from Nate (Tamagui's author) https://x.com/natebirdman/status/1890913196967419958
although Astro also has it with `<div data-astro-source-file="/absolute/path/file.astro" data-astro-source-loc="72:49"`