Skip to content

Commit

Permalink
chore: upgrade react-router and export all react-router APIs (#5419)
Browse files Browse the repository at this point in the history
  • Loading branch information
yimingjfe authored Feb 21, 2024
1 parent 1a755f4 commit 9464c9c
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 155 deletions.
9 changes: 9 additions & 0 deletions .changeset/rude-flowers-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@modern-js/plugin-garfish': patch
'@modern-js/runtime': patch
'@modern-js/runtime-utils': patch
'@modern-js/plugin-ssg': patch
---

chore: upgrade react-router and export all react-router APIs
chore: 升级 react-router 相关依赖,并导出所有 react-router API
2 changes: 1 addition & 1 deletion packages/cli/plugin-ssg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"jest": "^29",
"react": "^18",
"react-dom": "^18",
"react-router-dom": "6.17.0",
"react-router-dom": "6.22.0",
"typescript": "^5"
},
"sideEffects": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/plugin-garfish/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"jest-fetch-mock": "^3.0.3",
"react": "^18",
"react-dom": "^18",
"react-router-dom": "6.17.0",
"react-router-dom": "6.22.0",
"typescript": "^5"
},
"sideEffects": false,
Expand Down
132 changes: 2 additions & 130 deletions packages/runtime/plugin-runtime/src/router/runtime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { useRouteLoaderData as useRouteData } from '@modern-js/runtime-utils/rou
import { routerPlugin } from './plugin';
import type { SingleRouteConfig, RouterConfig } from './types';

export * from '@modern-js/runtime-utils/router';

export type { SingleRouteConfig, RouterConfig };
export { renderRoutes } from './utils';

Expand All @@ -26,133 +28,3 @@ export {
} from './routeModule';

export type { LoaderFunction, LoaderFunctionArgs } from './types';

// Note: Keep in sync with react-router-dom exports!
export type {
// below are react-router-dom exports
FormEncType,
FormMethod,
GetScrollRestorationKeyFunction,
ParamKeyValuePair,
SubmitOptions,
URLSearchParamsInit,
FetcherWithComponents,
BrowserRouterProps,
HashRouterProps,
HistoryRouterProps,
FormProps,
ScrollRestorationProps,
SubmitFunction,

// below are react-router exports
ActionFunction,
ActionFunctionArgs,
AwaitProps,
unstable_Blocker,
unstable_BlockerFunction,
DataRouteMatch,
DataRouteObject,
Fetcher,
Hash,
IndexRouteObject,
IndexRouteProps,
JsonFunction,
LayoutRouteProps,
Location,
MemoryRouterProps,
NavigateFunction,
NavigateOptions,
NavigateProps,
Navigation,
Navigator,
NonIndexRouteObject,
OutletProps,
Params,
ParamParseKey,
Path,
PathMatch,
Pathname,
PathPattern,
PathRouteProps,
RedirectFunction,
RelativeRoutingType,
RouteMatch,
RouteObject,
RouteProps,
RouterProps,
RouterProviderProps,
RoutesProps,
Search,
ShouldRevalidateFunction,
To,
} from '@modern-js/runtime-utils/router';

// Note: Keep in sync with react-router-dom exports!
export {
// Routers
createBrowserRouter,
createHashRouter,
createMemoryRouter,
RouterProvider,

// Router Components
BrowserRouter,
HashRouter,
MemoryRouter,
Router,

// Components
Await,
Form,
Navigate,
Outlet,
Route,
Routes,
ScrollRestoration,

// Hooks
useActionData,
useAsyncError,
useAsyncValue,
useBeforeUnload,
useFetcher,
useFetchers,
useFormAction,
useHref,
useInRouterContext,
useLinkClickHandler,
useLoaderData,
useLocation,
useMatch,
useMatches,
useNavigate,
useNavigation,
useNavigationType,
useOutlet,
useOutletContext,
useParams,
useResolvedPath,
useRevalidator,
useRouteError,
useRoutes,
useSearchParams,
useSubmit,
unstable_useViewTransitionState,

// Utilities
createRoutesFromChildren,
createRoutesFromElements,
createSearchParams,
generatePath,
isRouteErrorResponse,
matchPath,
matchRoutes,
renderMatches,
resolvePath,
createPath,
unstable_useBlocker,
unstable_usePrompt,
defer,
json,
redirect,
} from '@modern-js/runtime-utils/router';
4 changes: 2 additions & 2 deletions packages/toolkit/runtime-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@
"@modern-js/utils": "workspace:*",
"lru-cache": "^6.0.0",
"serialize-javascript": "^6.0.0",
"react-router-dom": "6.17.0",
"@remix-run/router": "1.10.0",
"react-router-dom": "6.22.0",
"@remix-run/router": "1.15.0",
"@swc/helpers": "0.5.3"
},
"peerDependencies": {
Expand Down
40 changes: 20 additions & 20 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/e2e/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"lodash": "^4.17.21",
"react": "^18",
"react-dom": "^18",
"react-router-dom": "6.17.0",
"react-router-dom": "6.22.0",
"vue": "^3.3.4"
},
"devDependencies": {
Expand Down

0 comments on commit 9464c9c

Please sign in to comment.