Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix modifyRoutes in ssr #4219

Merged
merged 3 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading