Skip to content

astahmer/unplugin-jsx-source

Repository files navigation

unplugin-jsx-source

NPM version

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.

image

Install

npm i unplugin-jsx-source
Vite
// vite.config.ts
import jsxSource from "unplugin-jsx-source/vite";

export default defineConfig({
	plugins: [
		jsxSource({
			/* options */
		}),
	],
});

Example: playground/


Rollup
// rollup.config.js
import jsxSource from "unplugin-jsx-source/rollup";

export default {
	plugins: [
		jsxSource({
			/* options */
		}),
	],
};


Webpack
// webpack.config.js
module.exports = {
	/* ... */
	plugins: [
		require("unplugin-jsx-source/webpack")({
			/* options */
		}),
	],
};


Nuxt
// nuxt.config.js
export default defineNuxtConfig({
	modules: [
		[
			"unplugin-jsx-source/nuxt",
			{
				/* options */
			},
		],
	],
});

This module works for both Nuxt 2 and Nuxt Vite


Vue CLI
// vue.config.js
module.exports = {
	configureWebpack: {
		plugins: [
			require("unplugin-jsx-source/webpack")({
				/* options */
			}),
		],
	},
};


esbuild
// esbuild.config.js
import { build } from 'esbuild'
import jsxSource from 'unplugin-jsx-source/esbuild'

build({
  plugins:  jsxSource()],
})


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"

About

Automatically annotate your JSX components with a `data-at` attribute indicating the file name and line number for easier debugging and development.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  
  •  

Contributors