@shiage/jsx-transform
v0.1.0
Published
Babel plugin that stamps data-shiage-loc source-location attributes onto JSX host elements.
Maintainers
Readme
@shiage/jsx-transform
Babel plugin for Shiage — stamps data-shiage-loc source-location
attributes onto JSX host elements during dev so the browser runtime can identify which
file, line, and column an element came from.
You almost never use this directly. The
@shiage/viteand@shiage/nextplugins wire this in for you. Use it standalone only if you're building a new Shiage framework adapter.
What it does
- Visits
JSXOpeningElementand stampsdata-shiage-loc="${relPath}:${line}:${col}". - Lowercase host elements only — skips uppercase React components,
JSXFragment, andJSXMemberExpression. - Skips elements that already have the attribute (idempotent across passes).
- Paths are relative to
projectRoot(privacy + portability across machines). - Must run before React's JSX transform.
Options
{
projectRoot: string // required; used to compute relative paths
enabled?: boolean // default true in dev; set false to disable
}Conventions to know
data-shiage-locline/column are 1-based by Shiage convention. Babel'sloc.start.columnis 0-based, so this plugin adds one. The mapper in@shiage/coresubtracts one when resolving back into the AST.- Production builds disable the stamp; built output has no
data-shiage-locattrs.
License
MIT — © 2026 Horace Choi.
