Skip to content

Commit 1100224

Browse files
authored
chore: split up index.tsx file (#8686)
* chore: extract lib/router.ts file * chore: extract lib/context.ts file * chore: extract lib/hooks.ts file * chore: extract lib/components.tsx file * chore: rename index.tsx -> index.ts * chore: combine exports
1 parent dc37beb commit 1100224

File tree

10 files changed

+1565
-1419
lines changed

10 files changed

+1565
-1419
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"rollup": "^1.27.9",
5555
"rollup-plugin-babel": "^4.3.3",
5656
"rollup-plugin-copy": "^3.1.0",
57+
"rollup-plugin-extensions": "^0.1.0",
5758
"rollup-plugin-prettier": "^0.6.0",
5859
"rollup-plugin-terser": "^7.0.2",
5960
"semver": "^7.3.5",

packages/react-router/index.ts

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
import type { Hash, Location, Path, Pathname, Search, To } from "history";
2+
import { Action as NavigationType, parsePath, createPath } from "history";
3+
4+
import type {
5+
MemoryRouterProps,
6+
NavigateProps,
7+
OutletProps,
8+
RouteProps,
9+
PathRouteProps,
10+
LayoutRouteProps,
11+
IndexRouteProps,
12+
RouterProps,
13+
RoutesProps,
14+
} from "./lib/components";
15+
import {
16+
createRoutesFromChildren,
17+
renderMatches,
18+
MemoryRouter,
19+
Navigate,
20+
Outlet,
21+
Route,
22+
Router,
23+
Routes,
24+
} from "./lib/components";
25+
import type { Navigator } from "./lib/context";
26+
import {
27+
LocationContext,
28+
NavigationContext,
29+
RouteContext,
30+
} from "./lib/context";
31+
import type { NavigateFunction, NavigateOptions } from "./lib/hooks";
32+
import {
33+
useHref,
34+
useInRouterContext,
35+
useLocation,
36+
useMatch,
37+
useNavigationType,
38+
useNavigate,
39+
useOutlet,
40+
useOutletContext,
41+
useParams,
42+
useResolvedPath,
43+
useRoutes,
44+
} from "./lib/hooks";
45+
import type {
46+
Params,
47+
PathMatch,
48+
PathPattern,
49+
RouteMatch,
50+
RouteObject,
51+
} from "./lib/router";
52+
import {
53+
generatePath,
54+
matchPath,
55+
matchRoutes,
56+
resolvePath,
57+
} from "./lib/router";
58+
59+
// Expose react-router public API
60+
export type {
61+
Hash,
62+
IndexRouteProps,
63+
LayoutRouteProps,
64+
Location,
65+
MemoryRouterProps,
66+
NavigateFunction,
67+
NavigateOptions,
68+
NavigateProps,
69+
OutletProps,
70+
PathMatch,
71+
PathPattern,
72+
PathRouteProps,
73+
RouteMatch,
74+
RouteObject,
75+
RouteProps,
76+
RouterProps,
77+
RoutesProps,
78+
Navigator,
79+
Params,
80+
Path,
81+
Pathname,
82+
Search,
83+
To,
84+
};
85+
export {
86+
MemoryRouter,
87+
Navigate,
88+
NavigationType,
89+
Outlet,
90+
Route,
91+
Router,
92+
Routes,
93+
createPath,
94+
createRoutesFromChildren,
95+
generatePath,
96+
matchPath,
97+
matchRoutes,
98+
parsePath,
99+
renderMatches,
100+
resolvePath,
101+
useHref,
102+
useInRouterContext,
103+
useLocation,
104+
useMatch,
105+
useNavigate,
106+
useNavigationType,
107+
useOutlet,
108+
useOutletContext,
109+
useParams,
110+
useResolvedPath,
111+
useRoutes,
112+
};
113+
114+
///////////////////////////////////////////////////////////////////////////////
115+
// DANGER! PLEASE READ ME!
116+
// We provide these exports as an escape hatch in the event that you need any
117+
// routing data that we don't provide an explicit API for. With that said, we
118+
// want to cover your use case if we can, so if you feel the need to use these
119+
// we want to hear from you. Let us know what you're building and we'll do our
120+
// best to make sure we can support you!
121+
//
122+
// We consider these exports an implementation detail and do not guarantee
123+
// against any breaking changes, regardless of the semver release. Use with
124+
// extreme caution and only if you understand the consequences. Godspeed.
125+
///////////////////////////////////////////////////////////////////////////////
126+
127+
/** @internal */
128+
export {
129+
NavigationContext as UNSAFE_NavigationContext,
130+
LocationContext as UNSAFE_LocationContext,
131+
RouteContext as UNSAFE_RouteContext,
132+
};

0 commit comments

Comments
 (0)