Skip to content

Commit 450cad7

Browse files
authored
fix(core): Babel register haste map only to for react-native modules (#19)
1 parent e330913 commit 450cad7

File tree

4 files changed

+132
-7
lines changed

4 files changed

+132
-7
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@
5757
"eslint-import-resolver-typescript": "^3.6.1",
5858
"eslint-plugin-etc": "^2.0.3",
5959
"eslint-plugin-import": "^2.29.1",
60-
"eslint-plugin-jsdoc": "^48.2.0",
60+
"eslint-plugin-jsdoc": "^48.2.1",
6161
"eslint-plugin-sonarjs": "^0.24.0",
6262
"mocha": "^10.3.0",
6363
"react": "18.2.0",
6464
"react-native": "^0.73.5",
65+
"react-native-svg": "^15.1.0",
6566
"react-test-renderer": "^18.2.0",
6667
"semantic-release": "^23.0.2",
6768
"semantic-release-yarn": "^3.0.2",

src/lib/babelRegister.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import register from "@babel/register";
22

33
register({
44
cache: true,
5-
only: [/node_modules[/\\](react-native|@react-native).*/],
5+
only: [/node_modules[/\\](react-native|@react-native)[/\\]/],
66
plugins: [
77
["module-resolver", {
88
resolvePath(sourcePath: string) {

test/unit/register.test.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { expect } from "@assertive-ts/core";
44
import { render, waitFor, userEvent } from "@testing-library/react-native";
55
import { ReactElement, useCallback, useRef, useState } from "react";
66
import { ActivityIndicator, Animated, Button, Image, Modal, ScrollView, Text, TextInput, View } from "react-native";
7+
import { Rect, Svg } from "react-native-svg";
78

89
function TestScreen(): ReactElement {
910

@@ -45,6 +46,15 @@ function TestScreen(): ReactElement {
4546
<Text>{"foo"}</Text>
4647
</Modal>
4748
</View>
49+
<Svg testID="svg-test">
50+
<Rect
51+
x={0}
52+
y={0}
53+
width={100}
54+
height={100}
55+
fill="red"
56+
/>
57+
</Svg>
4858
<Button title="Click Me!" onPress={animateView} />
4959
<Animated.View style={{ marginLeft: enterLeft }}>
5060
<Text>{`Animated view: ${animated}`}</Text>
@@ -61,6 +71,7 @@ describe("[Unit] register.test.ts", () => {
6171
getByPlaceholderText,
6272
getByDisplayValue,
6373
getByLabelText,
74+
getByTestId,
6475
findByText,
6576
} = render(<TestScreen />);
6677

@@ -71,6 +82,7 @@ describe("[Unit] register.test.ts", () => {
7182
expect(getByLabelText("Profile picture")).toBePresent();
7283
expect(getByText("I'm on a modal")).toBePresent();
7384
expect(() => getByText("foo")).toThrowError();
85+
expect(getByTestId("svg-test")).toBePresent();
7486
expect(getByText("Animated view: false")).toBePresent();
7587

7688
const clickMeButton = await findByText("Click Me!");

yarn.lock

Lines changed: 117 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3258,6 +3258,13 @@ __metadata:
32583258
languageName: node
32593259
linkType: hard
32603260

3261+
"boolbase@npm:^1.0.0":
3262+
version: 1.0.0
3263+
resolution: "boolbase@npm:1.0.0"
3264+
checksum: 10/3e25c80ef626c3a3487c73dbfc70ac322ec830666c9ad915d11b701142fab25ec1e63eff2c450c74347acfd2de854ccde865cd79ef4db1683f7c7b046ea43bb0
3265+
languageName: node
3266+
linkType: hard
3267+
32613268
"bottleneck@npm:^2.15.3":
32623269
version: 2.19.5
32633270
resolution: "bottleneck@npm:2.19.5"
@@ -4009,6 +4016,36 @@ __metadata:
40094016
languageName: node
40104017
linkType: hard
40114018

4019+
"css-select@npm:^5.1.0":
4020+
version: 5.1.0
4021+
resolution: "css-select@npm:5.1.0"
4022+
dependencies:
4023+
boolbase: "npm:^1.0.0"
4024+
css-what: "npm:^6.1.0"
4025+
domhandler: "npm:^5.0.2"
4026+
domutils: "npm:^3.0.1"
4027+
nth-check: "npm:^2.0.1"
4028+
checksum: 10/d486b1e7eb140468218a5ab5af53257e01f937d2173ac46981f6b7de9c5283d55427a36715dc8decfc0c079cf89259ac5b41ef58f6e1a422eee44ab8bfdc78da
4029+
languageName: node
4030+
linkType: hard
4031+
4032+
"css-tree@npm:^1.1.3":
4033+
version: 1.1.3
4034+
resolution: "css-tree@npm:1.1.3"
4035+
dependencies:
4036+
mdn-data: "npm:2.0.14"
4037+
source-map: "npm:^0.6.1"
4038+
checksum: 10/29710728cc4b136f1e9b23ee1228ec403ec9f3d487bc94a9c5dbec563c1e08c59bc917dd6f82521a35e869ff655c298270f43ca673265005b0cd05b292eb05ab
4039+
languageName: node
4040+
linkType: hard
4041+
4042+
"css-what@npm:^6.1.0":
4043+
version: 6.1.0
4044+
resolution: "css-what@npm:6.1.0"
4045+
checksum: 10/c67a3a2d0d81843af87f8bf0a4d0845b0f952377714abbb2884e48942409d57a2110eabee003609d02ee487b054614bdfcfc59ee265728ff105bd5aa221c1d0e
4046+
languageName: node
4047+
linkType: hard
4048+
40124049
"cssesc@npm:^3.0.0":
40134050
version: 3.0.0
40144051
resolution: "cssesc@npm:3.0.0"
@@ -4267,6 +4304,44 @@ __metadata:
42674304
languageName: node
42684305
linkType: hard
42694306

4307+
"dom-serializer@npm:^2.0.0":
4308+
version: 2.0.0
4309+
resolution: "dom-serializer@npm:2.0.0"
4310+
dependencies:
4311+
domelementtype: "npm:^2.3.0"
4312+
domhandler: "npm:^5.0.2"
4313+
entities: "npm:^4.2.0"
4314+
checksum: 10/e3bf9027a64450bca0a72297ecdc1e3abb7a2912268a9f3f5d33a2e29c1e2c3502c6e9f860fc6625940bfe0cfb57a44953262b9e94df76872fdfb8151097eeb3
4315+
languageName: node
4316+
linkType: hard
4317+
4318+
"domelementtype@npm:^2.3.0":
4319+
version: 2.3.0
4320+
resolution: "domelementtype@npm:2.3.0"
4321+
checksum: 10/ee837a318ff702622f383409d1f5b25dd1024b692ef64d3096ff702e26339f8e345820f29a68bcdcea8cfee3531776b3382651232fbeae95612d6f0a75efb4f6
4322+
languageName: node
4323+
linkType: hard
4324+
4325+
"domhandler@npm:^5.0.2, domhandler@npm:^5.0.3":
4326+
version: 5.0.3
4327+
resolution: "domhandler@npm:5.0.3"
4328+
dependencies:
4329+
domelementtype: "npm:^2.3.0"
4330+
checksum: 10/809b805a50a9c6884a29f38aec0a4e1b4537f40e1c861950ed47d10b049febe6b79ab72adaeeebb3cc8fc1cd33f34e97048a72a9265103426d93efafa78d3e96
4331+
languageName: node
4332+
linkType: hard
4333+
4334+
"domutils@npm:^3.0.1":
4335+
version: 3.1.0
4336+
resolution: "domutils@npm:3.1.0"
4337+
dependencies:
4338+
dom-serializer: "npm:^2.0.0"
4339+
domelementtype: "npm:^2.3.0"
4340+
domhandler: "npm:^5.0.3"
4341+
checksum: 10/9a169a6e57ac4c738269a73ab4caf785114ed70e46254139c1bbc8144ac3102aacb28a6149508395ae34aa5d6a40081f4fa5313855dc8319c6d8359866b6dfea
4342+
languageName: node
4343+
linkType: hard
4344+
42704345
"dot-prop-immutable@npm:^2.1.1":
42714346
version: 2.1.1
42724347
resolution: "dot-prop-immutable@npm:2.1.1"
@@ -4360,6 +4435,13 @@ __metadata:
43604435
languageName: node
43614436
linkType: hard
43624437

4438+
"entities@npm:^4.2.0":
4439+
version: 4.5.0
4440+
resolution: "entities@npm:4.5.0"
4441+
checksum: 10/ede2a35c9bce1aeccd055a1b445d41c75a14a2bb1cd22e242f20cf04d236cdcd7f9c859eb83f76885327bfae0c25bf03303665ee1ce3d47c5927b98b0e3e3d48
4442+
languageName: node
4443+
linkType: hard
4444+
43634445
"env-ci@npm:^11.0.0":
43644446
version: 11.0.0
43654447
resolution: "env-ci@npm:11.0.0"
@@ -4669,9 +4751,9 @@ __metadata:
46694751
languageName: node
46704752
linkType: hard
46714753

4672-
"eslint-plugin-jsdoc@npm:^48.2.0":
4673-
version: 48.2.0
4674-
resolution: "eslint-plugin-jsdoc@npm:48.2.0"
4754+
"eslint-plugin-jsdoc@npm:^48.2.1":
4755+
version: 48.2.1
4756+
resolution: "eslint-plugin-jsdoc@npm:48.2.1"
46754757
dependencies:
46764758
"@es-joy/jsdoccomment": "npm:~0.42.0"
46774759
are-docs-informative: "npm:^0.0.2"
@@ -4684,7 +4766,7 @@ __metadata:
46844766
spdx-expression-parse: "npm:^4.0.0"
46854767
peerDependencies:
46864768
eslint: ^7.0.0 || ^8.0.0 || ^9.0.0
4687-
checksum: 10/4a616f6d888311f63ccf0f4c697714c66978bb3717cb5a6a5af410615d9b28ff4febe3241939135a75636f2a4e95229563acbb7761db39e4ff7e7b23c2129262
4769+
checksum: 10/4b4e6592ea27646d2556b0feedda4427dac110f4a9adf858aa040aead0d673d263d5474673f774d1202492b8971065ff027fbe3531c20a2b255b11cbc06a90ca
46884770
languageName: node
46894771
linkType: hard
46904772

@@ -7125,6 +7207,13 @@ __metadata:
71257207
languageName: node
71267208
linkType: hard
71277209

7210+
"mdn-data@npm:2.0.14":
7211+
version: 2.0.14
7212+
resolution: "mdn-data@npm:2.0.14"
7213+
checksum: 10/64c629fcf14807e30d6dc79f97cbcafa16db066f53a294299f3932b3beb0eb0d1386d3a7fe408fc67348c449a4e0999360c894ba4c81eb209d7be4e36503de0e
7214+
languageName: node
7215+
linkType: hard
7216+
71287217
"memoize-one@npm:^5.0.0":
71297218
version: 5.2.1
71307219
resolution: "memoize-one@npm:5.2.1"
@@ -8048,6 +8137,15 @@ __metadata:
80488137
languageName: node
80498138
linkType: hard
80508139

8140+
"nth-check@npm:^2.0.1":
8141+
version: 2.1.1
8142+
resolution: "nth-check@npm:2.1.1"
8143+
dependencies:
8144+
boolbase: "npm:^1.0.0"
8145+
checksum: 10/5afc3dafcd1573b08877ca8e6148c52abd565f1d06b1eb08caf982e3fa289a82f2cae697ffb55b5021e146d60443f1590a5d6b944844e944714a5b549675bcd3
8146+
languageName: node
8147+
linkType: hard
8148+
80518149
"nullthrows@npm:^1.1.1":
80528150
version: 1.1.1
80538151
resolution: "nullthrows@npm:1.1.1"
@@ -8846,6 +8944,19 @@ __metadata:
88468944
languageName: node
88478945
linkType: hard
88488946

8947+
"react-native-svg@npm:^15.1.0":
8948+
version: 15.1.0
8949+
resolution: "react-native-svg@npm:15.1.0"
8950+
dependencies:
8951+
css-select: "npm:^5.1.0"
8952+
css-tree: "npm:^1.1.3"
8953+
peerDependencies:
8954+
react: "*"
8955+
react-native: "*"
8956+
checksum: 10/5733b9f8fd11ada31c6a2a3fff372ff144e6d729251553f2af0de638eec5150b860fb907449f236ae37ff83593c3742944354f7d72c017a8338fc8693ee0c117
8957+
languageName: node
8958+
linkType: hard
8959+
88498960
"react-native-testing-mocks@workspace:.":
88508961
version: 0.0.0-use.local
88518962
resolution: "react-native-testing-mocks@workspace:."
@@ -8871,11 +8982,12 @@ __metadata:
88718982
eslint-import-resolver-typescript: "npm:^3.6.1"
88728983
eslint-plugin-etc: "npm:^2.0.3"
88738984
eslint-plugin-import: "npm:^2.29.1"
8874-
eslint-plugin-jsdoc: "npm:^48.2.0"
8985+
eslint-plugin-jsdoc: "npm:^48.2.1"
88758986
eslint-plugin-sonarjs: "npm:^0.24.0"
88768987
mocha: "npm:^10.3.0"
88778988
react: "npm:18.2.0"
88788989
react-native: "npm:^0.73.5"
8990+
react-native-svg: "npm:^15.1.0"
88798991
react-test-renderer: "npm:^18.2.0"
88808992
semantic-release: "npm:^23.0.2"
88818993
semantic-release-yarn: "npm:^3.0.2"

0 commit comments

Comments
 (0)