SWC plugin that injects source location data attributes into DOM elements.
npm install @vybe-adk/swc-dom-sourceAdd the plugin to your Next.js config:
// next.config.js
module.exports = {
experimental: {
swcPlugins: [
["@vybe-adk/swc-dom-source", { attr: "data-source", exclude: ["components/ui"] }],
],
},
};| Option | Type | Default | Description |
|---|---|---|---|
attr |
string |
"data-source" |
The attribute name to inject |
exclude |
string[] |
[] |
File path patterns to exclude from transformation |
The plugin adds a data attribute to host JSX elements (lowercase tags like div, span, etc.) with the format:
filename:line:column
Example output:
<div data-source="src/components/Button.tsx:15:4">Click me</div>This plugin must match the swc_core version used by your framework. Using a mismatched version will cause runtime errors.
swc_core version |
Next.js version | Status |
|---|---|---|
| 35.x | 15.x | Supported |
| 36.x+ | 16.x | Not yet supported |
This plugin currently uses swc_core v35.0.0, which aligns with Next.js 15. Next.js 16 ships a newer SWC version and is not yet supported.
Requires Rust with the wasm32-wasip1 target:
rustup target add wasm32-wasip1
npm run buildContributions are welcome! Please see CONTRIBUTING.md for guidelines.
MIT