@insitue/swc-source-attr 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/insitue_swc_source_attr.wasm +0 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# `@insitue/swc-source-attr`
|
|
2
2
|
|
|
3
|
-
SWC plugin that stamps every JSX element with a `data-
|
|
3
|
+
SWC plugin that stamps every JSX element with a `data-insitue-source="file:line:col"`
|
|
4
4
|
attribute so the [InSitue](https://www.insitue.com) cloud agent can resolve in-app bug
|
|
5
5
|
reports to exact source coordinates and open the right pull request automatically.
|
|
6
6
|
|
|
7
7
|
> **Spelling note** — the npm package is `@insitue/*` (with the 'e'); the DOM attribute
|
|
8
|
-
> stays as `data-
|
|
8
|
+
> stays as `data-insitue-source` (no 'e'). The split is intentional: the brand evolves,
|
|
9
9
|
> the wire format doesn't.
|
|
10
10
|
|
|
11
11
|
## Why you need this
|
|
@@ -17,7 +17,7 @@ selector + DOM snapshot — and the cloud agent has to guess which file to edit.
|
|
|
17
17
|
drops below the resolution threshold and the report routes to `needs_human` instead of
|
|
18
18
|
auto-opening a draft PR.
|
|
19
19
|
|
|
20
|
-
This plugin fixes that by injecting `data-
|
|
20
|
+
This plugin fixes that by injecting `data-insitue-source` at compile time. Customers using
|
|
21
21
|
it land in the "auto-PR" path; customers without it stay in the "needs human review" path.
|
|
22
22
|
|
|
23
23
|
## Install
|
|
@@ -42,26 +42,26 @@ export default nextConfig;
|
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
That's it. Build your app normally — every JSX element in the output now carries
|
|
45
|
-
`data-
|
|
45
|
+
`data-insitue-source="<rel-path>:<line>:<col>"`.
|
|
46
46
|
|
|
47
47
|
## Options
|
|
48
48
|
|
|
49
49
|
| Option | Type | Default | What |
|
|
50
50
|
|---|---|---|---|
|
|
51
51
|
| `rootDir` | `string` | _none_ | Project root, used to make emitted paths relative + portable. Recommend `process.cwd()`. Without it, paths are absolute (still works but leaks your local filesystem layout into the bundle). |
|
|
52
|
-
| `attrName` | `string` | `"data-
|
|
52
|
+
| `attrName` | `string` | `"data-insitue-source"` | Override only if the default collides with another tool. The [`@insitue/sdk`](https://www.npmjs.com/package/@insitue/sdk) picker reads the default name — if you override here, override the SDK's matching option too. |
|
|
53
53
|
| `exclude` | `string[]` | `[]` | Substrings; files whose path contains any of these are skipped. Cheap substring match — no glob library on the compile hot path. E.g. `["node_modules/", "/generated/"]`. |
|
|
54
54
|
|
|
55
55
|
## How it behaves
|
|
56
56
|
|
|
57
|
-
- **Idempotent.** Elements that already have `data-
|
|
57
|
+
- **Idempotent.** Elements that already have `data-insitue-source` are left alone — safe to
|
|
58
58
|
run alongside the [Babel-plugin fallback](https://www.npmjs.com/package/@insitue/sdk)
|
|
59
59
|
during a migration.
|
|
60
60
|
- **Per-file skip via `exclude`.** Whole files matching any exclude substring are skipped
|
|
61
61
|
entirely (the plugin doesn't visit their AST at all).
|
|
62
62
|
- **Paths are POSIX, relative to `rootDir`.** If your `rootDir` is `/Users/you/app` and the
|
|
63
63
|
file is `/Users/you/app/src/components/Button.tsx`, the emitted attribute is
|
|
64
|
-
`data-
|
|
64
|
+
`data-insitue-source="src/components/Button.tsx:42:8"`. Line is 1-based; column is the
|
|
65
65
|
0-based byte offset (matches SWC's convention).
|
|
66
66
|
|
|
67
67
|
## Compatibility
|
|
@@ -95,7 +95,7 @@ function Button({ children }) {
|
|
|
95
95
|
return (
|
|
96
96
|
<button
|
|
97
97
|
className="bg-violet-500"
|
|
98
|
-
data-
|
|
98
|
+
data-insitue-source="src/components/Button.tsx:2:10"
|
|
99
99
|
>
|
|
100
100
|
{children}
|
|
101
101
|
</button>
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@insitue/swc-source-attr",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "SWC plugin that stamps every JSX element with data-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "SWC plugin that stamps every JSX element with data-insitue-source=\"file:line:col\" so the InSitue cloud agent can resolve captures to exact source coordinates.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "insitue_swc_source_attr.wasm",
|
|
7
7
|
"files": [
|