Skip to content

Commit 5fd5223

Browse files
committed
temp metro config
1 parent 8b316f0 commit 5fd5223

File tree

11 files changed

+757
-41
lines changed

11 files changed

+757
-41
lines changed

auto.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

metro.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
export * from "./dist/core/index.js"

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@
106106
],
107107
".": [
108108
"./dist/auto.d.ts"
109+
],
110+
"metro": [
111+
"./dist/plugins/metro.d.ts"
109112
]
110113
}
111114
},
@@ -114,8 +117,8 @@
114117
"package.json",
115118
"README.md",
116119
"LICENSE",
117-
"auto.d.ts",
118-
"native.js"
120+
"native.js",
121+
"metro.js"
119122
],
120123
"scripts": {
121124
"build": "NODE_ENV=production tsup",
@@ -125,11 +128,14 @@
125128
"publint": "publint"
126129
},
127130
"devDependencies": {
131+
"@react-native/metro-config": "^0.76.3",
128132
"@shopify/react-native-skia": "*",
133+
"@types/node": "^22.10.0",
129134
"@types/react": "^18.3.12",
130135
"@types/react-reconciler": "^0.28.8",
131136
"@vercel/style-guide": "^6.0.0",
132137
"eslint": "^8.57.1",
138+
"metro-transform-worker": "^0.76.3",
133139
"prettier": "^3.3.3",
134140
"publint": "^0.2.12",
135141
"react": "*",

pnpm-lock.yaml

Lines changed: 682 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

react-scan-0.0.15.tgz

7.05 KB
Binary file not shown.

src/core/native/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,8 @@ const ReactNativeScan = ({ id: _ }: { id: string }) => {
255255
</Canvas>
256256
);
257257
};
258+
259+
260+
261+
262+

src/core/native/instrument.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@ import { instrument, Render } from '../instrumentation';
55
import { getNearestHostFiber } from '../instrumentation/fiber';
66
import { getCopiedActiveOutlines, getLabelText } from '../utils';
77

8-
import { PendingOutline } from '../web/outline';
8+
import { genId, PendingOutline } from '../web/outline';
9+
910

10-
export const genId = () => {
11-
const timeStamp: number = performance.now();
12-
const randomNum: number = Math.floor(Math.random() * 1000);
13-
return `${timeStamp}-${randomNum}`;
14-
};
1511

1612
const measurementCache = new WeakMap<
1713
Fiber,

src/core/native/plugins/metro.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
type TransformParams = {
2+
src: string;
3+
filename: string;
4+
options?: any;
5+
};
6+
7+
type TransformResult = {
8+
code: string;
9+
map?: any;
10+
};
11+
12+
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
13+
14+
const defaultConfig = getDefaultConfig(__dirname);
15+
16+
const config = {
17+
transform: ({ src, filename }: TransformParams): TransformResult => {
18+
if (process.env.NODE_ENV !== 'production') {
19+
return { code: src };
20+
}
21+
22+
if (filename.includes('node_modules/react-scan/dist/core/native/')) {
23+
return {
24+
code: `export const ReactNativeScanEntryPoint = () => {
25+
/* NOOP */
26+
return null;
27+
};`,
28+
};
29+
}
30+
31+
return { code: src };
32+
},
33+
};
34+
module.exports = mergeConfig(defaultConfig, config);
35+

src/core/web/outline.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ import { getLabelText } from '../utils';
66
import { isOutlineUnstable, onIdle, throttle } from './utils';
77
import { log } from './log';
88
import { recalcOutlineColor } from './perf-observer';
9-
import { genId } from '../native/instrument';
9+
// import { genId } from '../native/instrument';
10+
11+
export const genId = () => {
12+
const timeStamp: number = performance.now();
13+
const randomNum: number = Math.floor(Math.random() * 1000);
14+
return `${timeStamp}-${randomNum}`;
15+
};
1016

1117
export const assertDom = (measurement: Measurement) => {
1218
if (measurement.kind !== 'dom') {

tsconfig.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
"compilerOptions": {
33
"moduleResolution": "bundler",
44
"skipLibCheck": true,
5-
"types": ["react-native", "@shopify/react-native-skia"],
5+
"types": ["react-native", "@shopify/react-native-skia", "node"],
66
"jsx": "react",
77
"allowJs": true,
88
"esModuleInterop": true,
99
"module": "ESNext",
1010
"lib": ["ESNext", "DOM", "DOM.Iterable"],
11-
"target": "ESNext"
11+
"target": "ESNext" ,
12+
"noUnusedLocals": false,
13+
"noUnusedParameters": false
1214
},
1315
"include": [
1416
"src/**/*"

0 commit comments

Comments
 (0)