From bc565cd0aa5d510b3636b6dbb2c29c2cc09019a9 Mon Sep 17 00:00:00 2001 From: Ming Date: Fri, 2 Aug 2024 12:36:54 +0800 Subject: [PATCH] fix: should use dynamic import to import matchRoutes (#6033) --- .changeset/neat-schools-raise.md | 6 ++++++ packages/server/core/src/plugins/render/render.ts | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/neat-schools-raise.md diff --git a/.changeset/neat-schools-raise.md b/.changeset/neat-schools-raise.md new file mode 100644 index 000000000000..40cc8a26fabf --- /dev/null +++ b/.changeset/neat-schools-raise.md @@ -0,0 +1,6 @@ +--- +'@modern-js/server-core': patch +--- + +fix: should use dynamic import to import matchRoutes +fix: 应该使用 动态 import 来引入 matchRoutes diff --git a/packages/server/core/src/plugins/render/render.ts b/packages/server/core/src/plugins/render/render.ts index 7fc219e1541f..f53b7a388a21 100644 --- a/packages/server/core/src/plugins/render/render.ts +++ b/packages/server/core/src/plugins/render/render.ts @@ -3,7 +3,6 @@ import { Logger, Metrics, Reporter, ServerRoute } from '@modern-js/types'; import { cutNameByHyphen } from '@modern-js/utils/universal'; import { TrieRouter } from 'hono/router/trie-router'; import type { Router } from 'hono/router'; -import { matchRoutes } from '@modern-js/runtime-utils/router'; import type { Params } from '../../types/requestHandler'; import { parseQuery, @@ -256,6 +255,9 @@ async function renderHandler( const { nestedRoutesJson } = serverManifest; const routes = nestedRoutesJson?.[options.routeInfo.entryName!]; if (routes) { + const { matchRoutes } = await import( + '@modern-js/runtime-utils/remix-router' + ); // eslint-disable-next-line node/prefer-global/url const url = new URL(request.url); const matchedRoutes = matchRoutes(