Skip to content

Commit 04d2dd3

Browse files
committed
feat(solidjs): Drop solid router dep and vendor in types instead
1 parent 9529018 commit 04d2dd3

File tree

3 files changed

+46
-22
lines changed

3 files changed

+46
-22
lines changed

packages/solidjs/package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,13 @@
4848
"@sentry/utils": "8.5.0"
4949
},
5050
"peerDependencies": {
51-
"solid-js": "1.8.x"
51+
"solid-js": "^1.8.4"
5252
},
5353
"devDependencies": {
5454
"@solidjs/testing-library": "0.8.5",
55-
"solid-js": "1.8.11",
55+
"solid-js": "^1.8.11",
5656
"vite-plugin-solid": "^2.8.2"
5757
},
58-
"optionalDependencies": {
59-
"@solidjs/router": "0.13.3"
60-
},
6158
"scripts": {
6259
"build": "run-p build:transpile build:types",
6360
"build:dev": "yarn build",

packages/solidjs/src/solidrouter.ts

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,54 @@ import {
1515
} from '@sentry/core';
1616
import type { Client, Integration, Span } from '@sentry/types';
1717
import { logger } from '@sentry/utils';
18-
import type { BeforeLeaveEventArgs, Location, RouteSectionProps, RouterProps } from '@solidjs/router';
1918
import { createEffect, mergeProps, splitProps } from 'solid-js';
2019
import type { Component, JSX, ParentProps } from 'solid-js';
2120
import { createComponent } from 'solid-js/web';
2221
import { DEBUG_BUILD } from './debug-build';
2322

24-
const CLIENTS_WITH_INSTRUMENT_NAVIGATION = new WeakSet<Client>();
23+
// Vendored solid router types so that we don't need to depend on solid router.
24+
// These are not exhaustive and loose on purpose.
25+
interface Location {
26+
pathname: string;
27+
}
2528

26-
type UserBeforeLeave = (listener: (e: BeforeLeaveEventArgs) => void) => void;
27-
type UseLocation = () => Location;
29+
interface BeforeLeaveEventArgs {
30+
from: Location;
31+
to: string | number;
32+
}
2833

29-
let _useBeforeLeave: UserBeforeLeave;
30-
let _useLocation: UseLocation;
34+
interface RouteSectionProps<T = unknown> {
35+
location: Location;
36+
data?: T;
37+
children?: JSX.Element;
38+
}
39+
40+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
41+
type RouteDefinition<S extends string | string[] = any, T = unknown> = {
42+
path?: S;
43+
children?: RouteDefinition | RouteDefinition[];
44+
component?: Component<RouteSectionProps<T>>;
45+
};
46+
47+
interface RouterProps {
48+
base?: string;
49+
root?: Component<RouteSectionProps>;
50+
children?: JSX.Element | RouteDefinition | RouteDefinition[];
51+
}
3152

3253
interface SolidRouterOptions {
3354
useBeforeLeave: UserBeforeLeave;
3455
useLocation: UseLocation;
3556
}
3657

58+
type UserBeforeLeave = (listener: (e: BeforeLeaveEventArgs) => void) => void;
59+
type UseLocation = () => Location;
60+
61+
const CLIENTS_WITH_INSTRUMENT_NAVIGATION = new WeakSet<Client>();
62+
63+
let _useBeforeLeave: UserBeforeLeave;
64+
let _useLocation: UseLocation;
65+
3766
function handleNavigation(location: string): void {
3867
const client = getClient();
3968
if (!client || !CLIENTS_WITH_INSTRUMENT_NAVIGATION.has(client)) {

yarn.lock

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7768,11 +7768,6 @@
77687768
resolved "https://registry.yarnpkg.com/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz#96116f2a912e0c02817345b3c10751069920d553"
77697769
integrity sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==
77707770

7771-
"@solidjs/[email protected]":
7772-
version "0.13.3"
7773-
resolved "https://registry.yarnpkg.com/@solidjs/router/-/router-0.13.3.tgz#f520362d716a58c0416a33372ae9e5ed1a26be9a"
7774-
integrity sha512-p8zznlvnN3KySMXqT8irhubgDNTETNa/guaGHU/cZl7kuiPO3PmkWNYfoNCygtEpoxLmLpf62/ZKeyhFdZexsw==
7775-
77767771
"@solidjs/[email protected]":
77777772
version "0.8.5"
77787773
resolved "https://registry.yarnpkg.com/@solidjs/testing-library/-/testing-library-0.8.5.tgz#97061b2286d8641bd43bf474e624c3bb47e486a6"
@@ -26123,6 +26118,7 @@ react-is@^18.0.0:
2612326118
"@remix-run/router" "1.0.2"
2612426119

2612526120
"react-router-6@npm:[email protected]", [email protected]:
26121+
name react-router-6
2612626122
version "6.3.0"
2612726123
resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.3.0.tgz#3970cc64b4cb4eae0c1ea5203a80334fdd175557"
2612826124
integrity sha512-7Wh1DzVQ+tlFjkeo+ujvjSqSJmkt1+8JO+T5xklPlgrh70y7ogx75ODRW0ThWhY7S+6yEDks8TYrtQe/aoboBQ==
@@ -27506,7 +27502,7 @@ seroval-plugins@^1.0.3:
2750627502
resolved "https://registry.yarnpkg.com/seroval-plugins/-/seroval-plugins-1.0.7.tgz#c02511a1807e9bc8f68a91fbec13474fa9cea670"
2750727503
integrity sha512-GO7TkWvodGp6buMEX9p7tNyIkbwlyuAWbI6G9Ec5bhcm7mQdu3JOK1IXbEUwb3FVzSc363GraG/wLW23NSavIw==
2750827504

27509-
seroval@^1.0.3:
27505+
seroval@^1.0.4:
2751027506
version "1.0.7"
2751127507
resolved "https://registry.yarnpkg.com/seroval/-/seroval-1.0.7.tgz#ee48ad8ba69f1595bdd5c55d1a0d1da29dee7455"
2751227508
integrity sha512-n6ZMQX5q0Vn19Zq7CIKNIo7E75gPkGCFUEqDpa8jgwpYr/vScjqnQ6H09t1uIiZ0ZSK0ypEGvrYK2bhBGWsGdw==
@@ -27948,13 +27944,13 @@ socks@^2.6.2:
2794827944
ip "^2.0.0"
2794927945
smart-buffer "^4.2.0"
2795027946

27951-
27952-
version "1.8.11"
27953-
resolved "https://registry.yarnpkg.com/solid-js/-/solid-js-1.8.11.tgz#0e7496a9834720b10fe739eaac250221d3f72cd5"
27954-
integrity sha512-WdwmER+TwBJiN4rVQTVBxocg+9pKlOs41KzPYntrC86xO5sek8TzBYozPEZPL1IRWDouf2lMrvSbIs3CanlPvQ==
27947+
solid-js@^1.8.11:
27948+
version "1.8.17"
27949+
resolved "https://registry.yarnpkg.com/solid-js/-/solid-js-1.8.17.tgz#780ed6f0fd8633009d1b3c29d56bf6b6bb33bd50"
27950+
integrity sha512-E0FkUgv9sG/gEBWkHr/2XkBluHb1fkrHywUgA6o6XolPDCJ4g1HaLmQufcBBhiF36ee40q+HpG/vCZu7fLpI3Q==
2795527951
dependencies:
2795627952
csstype "^3.1.0"
27957-
seroval "^1.0.3"
27953+
seroval "^1.0.4"
2795827954
seroval-plugins "^1.0.3"
2795927955

2796027956
solid-refresh@^0.6.3:
@@ -28456,6 +28452,7 @@ string-template@~0.2.1:
2845628452
integrity sha1-QpMuWYo1LQH8IuwzZ9nYTuxsmt0=
2845728453

2845828454
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
28455+
name string-width-cjs
2845928456
version "4.2.3"
2846028457
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
2846128458
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -31204,6 +31201,7 @@ workerpool@^6.4.0:
3120431201
integrity sha512-i3KR1mQMNwY2wx20ozq2EjISGtQWDIfV56We+yGJ5yDs8jTwQiLLaqHlkBHITlCuJnYlVRmXegxFxZg7gqI++A==
3120531202

3120631203
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
31204+
name wrap-ansi-cjs
3120731205
version "7.0.0"
3120831206
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
3120931207
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==

0 commit comments

Comments
 (0)