Skip to content

Commit

Permalink
fix: fix modifyRoutes in ssr (#4219)
Browse files Browse the repository at this point in the history
* fix: fix `modifyRoutes` in ssr

* chore: changeset
  • Loading branch information
xuchaobei authored Jul 17, 2023
1 parent 645e111 commit b591092
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/stupid-zebras-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@modern-js/runtime': patch
---

fix: fix `modifyRoutes` in SSR
fix: 修复 SSR 时, `modifyRoutes` 执行时机
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const routerPlugin = ({
const _basename =
baseUrl === '/' ? urlJoin(baseUrl, basename) : baseUrl;

const routes = createRoutes
let routes = createRoutes
? createRoutes()
: createRoutesFromElements(
renderRoutes({
Expand All @@ -99,6 +99,9 @@ export const routerPlugin = ({
}),
);

const runner = (api as any).useHookRunners();
routes = runner.modifyRoutes(routes);

const { query } = createStaticHandler(routes, {
basename: _basename,
});
Expand All @@ -119,9 +122,6 @@ export const routerPlugin = ({
context.routeManifest = context.ssrContext!
.routeManifest as RouteManifest;

const runner = (api as any).useHookRunners();
runner.modifyRoutes(routes);

return next({ context });
},
hoc: ({ App }, next) => {
Expand Down

0 comments on commit b591092

Please sign in to comment.