Skip to content

Commit d5ba7a2

Browse files
committed
feat(solidjs): Drop solid router dep and vendor in types instead
1 parent 85925d5 commit d5ba7a2

File tree

3 files changed

+43
-22
lines changed

3 files changed

+43
-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: 6 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"
@@ -27499,7 +27494,7 @@ seroval-plugins@^1.0.3:
2749927494
resolved "https://registry.yarnpkg.com/seroval-plugins/-/seroval-plugins-1.0.7.tgz#c02511a1807e9bc8f68a91fbec13474fa9cea670"
2750027495
integrity sha512-GO7TkWvodGp6buMEX9p7tNyIkbwlyuAWbI6G9Ec5bhcm7mQdu3JOK1IXbEUwb3FVzSc363GraG/wLW23NSavIw==
2750127496

27502-
seroval@^1.0.3:
27497+
seroval@^1.0.4:
2750327498
version "1.0.7"
2750427499
resolved "https://registry.yarnpkg.com/seroval/-/seroval-1.0.7.tgz#ee48ad8ba69f1595bdd5c55d1a0d1da29dee7455"
2750527500
integrity sha512-n6ZMQX5q0Vn19Zq7CIKNIo7E75gPkGCFUEqDpa8jgwpYr/vScjqnQ6H09t1uIiZ0ZSK0ypEGvrYK2bhBGWsGdw==
@@ -27941,13 +27936,13 @@ socks@^2.6.2:
2794127936
ip "^2.0.0"
2794227937
smart-buffer "^4.2.0"
2794327938

27944-
27945-
version "1.8.11"
27946-
resolved "https://registry.yarnpkg.com/solid-js/-/solid-js-1.8.11.tgz#0e7496a9834720b10fe739eaac250221d3f72cd5"
27947-
integrity sha512-WdwmER+TwBJiN4rVQTVBxocg+9pKlOs41KzPYntrC86xO5sek8TzBYozPEZPL1IRWDouf2lMrvSbIs3CanlPvQ==
27939+
solid-js@^1.8.11:
27940+
version "1.8.17"
27941+
resolved "https://registry.yarnpkg.com/solid-js/-/solid-js-1.8.17.tgz#780ed6f0fd8633009d1b3c29d56bf6b6bb33bd50"
27942+
integrity sha512-E0FkUgv9sG/gEBWkHr/2XkBluHb1fkrHywUgA6o6XolPDCJ4g1HaLmQufcBBhiF36ee40q+HpG/vCZu7fLpI3Q==
2794827943
dependencies:
2794927944
csstype "^3.1.0"
27950-
seroval "^1.0.3"
27945+
seroval "^1.0.4"
2795127946
seroval-plugins "^1.0.3"
2795227947

2795327948
solid-refresh@^0.6.3:

0 commit comments

Comments
 (0)