@reticlehq/babel-plugin 2.0.1 → 2.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/NOTICE +5 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/package.json +8 -3
package/NOTICE
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { PluginObj, PluginPass, types as BabelTypes } from '@babel/core';
|
|
2
|
-
export declare const SOURCE_ATTR = "data-reticle-source";
|
|
3
2
|
interface PluginApi {
|
|
4
3
|
types: typeof BabelTypes;
|
|
5
4
|
}
|
|
@@ -7,7 +6,13 @@ interface PluginApi {
|
|
|
7
6
|
* Stamps `data-reticle-source="relativeFile:line:col"` on every JSX host element (lowercase
|
|
8
7
|
* tag). @reticlehq/react reads it to map a DOM node back to its source — needed on React 19,
|
|
9
8
|
* which removed `_debugSource`. Intended for dev builds only.
|
|
9
|
+
*
|
|
10
|
+
* Exported with `export =` (CommonJS module.exports) — Babel loads a plugin via `require()` and takes
|
|
11
|
+
* the module object directly, so this ships as a bare `module.exports = fn` with no `__esModule`/`default`
|
|
12
|
+
* interop wrapper (which some bundlers mishandle) and no named exports (which an ESM consumer's static
|
|
13
|
+
* named import cannot see at runtime in a CJS module). The attribute name itself is exported from
|
|
14
|
+
* `@reticlehq/core` as `DATA_RETICLE_SOURCE_ATTR` for anyone who needs it.
|
|
10
15
|
*/
|
|
11
|
-
|
|
12
|
-
export
|
|
16
|
+
declare function reticleSourcePlugin({ types: t }: PluginApi): PluginObj<PluginPass>;
|
|
17
|
+
export = reticleSourcePlugin;
|
|
13
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AAK9E,UAAU,SAAS;IACjB,KAAK,EAAE,OAAO,UAAU,CAAC;CAC1B;AAED;;;;;;;;;;GAUG;AACH,iBAAS,mBAAmB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,GAAG,SAAS,CAAC,UAAU,CAAC,CA8B3E;AAED,SAAS,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
const node_path_1 = require("node:path");
|
|
3
|
+
/** The attribute this plugin stamps (mirrors DATA_RETICLE_SOURCE_ATTR in @reticlehq/core). */
|
|
4
|
+
const SOURCE_ATTR = 'data-reticle-source';
|
|
3
5
|
/**
|
|
4
6
|
* Stamps `data-reticle-source="relativeFile:line:col"` on every JSX host element (lowercase
|
|
5
7
|
* tag). @reticlehq/react reads it to map a DOM node back to its source — needed on React 19,
|
|
6
8
|
* which removed `_debugSource`. Intended for dev builds only.
|
|
9
|
+
*
|
|
10
|
+
* Exported with `export =` (CommonJS module.exports) — Babel loads a plugin via `require()` and takes
|
|
11
|
+
* the module object directly, so this ships as a bare `module.exports = fn` with no `__esModule`/`default`
|
|
12
|
+
* interop wrapper (which some bundlers mishandle) and no named exports (which an ESM consumer's static
|
|
13
|
+
* named import cannot see at runtime in a CJS module). The attribute name itself is exported from
|
|
14
|
+
* `@reticlehq/core` as `DATA_RETICLE_SOURCE_ATTR` for anyone who needs it.
|
|
7
15
|
*/
|
|
8
|
-
|
|
16
|
+
function reticleSourcePlugin({ types: t }) {
|
|
9
17
|
return {
|
|
10
18
|
name: 'reticle-source',
|
|
11
19
|
visitor: {
|
|
@@ -26,11 +34,12 @@ export default function reticleSourcePlugin({ types: t }) {
|
|
|
26
34
|
if (loc === null || loc === undefined)
|
|
27
35
|
return;
|
|
28
36
|
const filename = state.filename ?? 'unknown';
|
|
29
|
-
const rel = relative(process.cwd(), filename);
|
|
37
|
+
const rel = (0, node_path_1.relative)(process.cwd(), filename);
|
|
30
38
|
const value = `${rel}:${String(loc.start.line)}:${String(loc.start.column)}`;
|
|
31
39
|
node.attributes.push(t.jsxAttribute(t.jsxIdentifier(SOURCE_ATTR), t.stringLiteral(value)));
|
|
32
40
|
},
|
|
33
41
|
},
|
|
34
42
|
};
|
|
35
43
|
}
|
|
44
|
+
module.exports = reticleSourcePlugin;
|
|
36
45
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,yCAAqC;AAGrC,8FAA8F;AAC9F,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAM1C;;;;;;;;;;GAUG;AACH,SAAS,mBAAmB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAa;IAClD,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE;YACP,iBAAiB,CAAC,IAAI,EAAE,KAAiB;gBACvC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;gBACvB,yEAAyE;gBACzE,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,eAAe;oBAAE,OAAO;gBAC/C,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAChC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,KAAK,CAAC,WAAW,EAAE;oBAAE,OAAO;gBAEjE,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CACzC,CAAC,IAAI,EAAE,EAAE,CACP,IAAI,CAAC,IAAI,KAAK,cAAc;oBAC5B,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,eAAe;oBAClC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,WAAW,CACjC,CAAC;gBACF,IAAI,cAAc;oBAAE,OAAO;gBAE3B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;gBACrB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS;oBAAE,OAAO;gBAE9C,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,SAAS,CAAC;gBAC7C,MAAM,GAAG,GAAG,IAAA,oBAAQ,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC;gBAC9C,MAAM,KAAK,GAAG,GAAG,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;gBAE7E,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC7F,CAAC;SACF;KACF,CAAC;AACJ,CAAC;AAED,iBAAS,mBAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reticlehq/babel-plugin",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Babel plugin that stamps data-reticle-source=\"file:line:col\" on JSX host elements so @reticlehq/react can map a DOM node to its source (works on React 19, which dropped _debugSource).",
|
|
5
|
-
"type": "
|
|
5
|
+
"type": "commonjs",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"author": "Reticle contributors",
|
|
8
8
|
"repository": {
|
|
@@ -25,12 +25,14 @@
|
|
|
25
25
|
"exports": {
|
|
26
26
|
".": {
|
|
27
27
|
"types": "./dist/index.d.ts",
|
|
28
|
+
"require": "./dist/index.js",
|
|
28
29
|
"default": "./dist/index.js"
|
|
29
30
|
}
|
|
30
31
|
},
|
|
31
32
|
"files": [
|
|
32
33
|
"dist",
|
|
33
|
-
"README.md"
|
|
34
|
+
"README.md",
|
|
35
|
+
"NOTICE"
|
|
34
36
|
],
|
|
35
37
|
"peerDependencies": {
|
|
36
38
|
"@babel/core": "^7"
|
|
@@ -42,6 +44,9 @@
|
|
|
42
44
|
"publishConfig": {
|
|
43
45
|
"access": "public"
|
|
44
46
|
},
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=20.0.0"
|
|
49
|
+
},
|
|
45
50
|
"scripts": {
|
|
46
51
|
"build": "tsc -b",
|
|
47
52
|
"typecheck": "tsc -b",
|