From 100edf58ad9cb8d76ac49f51021a4d4b733ed5f4 Mon Sep 17 00:00:00 2001 From: kongjiacong Date: Mon, 23 Dec 2024 20:33:06 +0800 Subject: [PATCH] chore: remove html element inject --- .changeset/young-trains-judge.md | 7 +++++++ .../server/core/src/plugins/render/render.ts | 18 ++---------------- 2 files changed, 9 insertions(+), 16 deletions(-) create mode 100644 .changeset/young-trains-judge.md diff --git a/.changeset/young-trains-judge.md b/.changeset/young-trains-judge.md new file mode 100644 index 00000000000..d5dce43a2a1 --- /dev/null +++ b/.changeset/young-trains-judge.md @@ -0,0 +1,7 @@ +--- +'@modern-js/plugin-router-v5': patch +'@modern-js/runtime': patch +--- + +chore: remove server data parse when use convention routes +chore: 移除约定式路由时解析 server data 的逻辑 diff --git a/packages/server/core/src/plugins/render/render.ts b/packages/server/core/src/plugins/render/render.ts index 7b538479151..a77b71af63e 100644 --- a/packages/server/core/src/plugins/render/render.ts +++ b/packages/server/core/src/plugins/render/render.ts @@ -301,12 +301,10 @@ async function renderHandler( response = csrRender(options.html); } - const newRes = transformResponse(response, injectServerData(serverData)); - const { routeInfo } = options; - applyExtendHeaders(newRes, routeInfo); + applyExtendHeaders(response, routeInfo); - return newRes; + return response; function applyExtendHeaders(r: Response, route: ServerRoute) { Object.entries(route.responseHeaders || {}).forEach(([k, v]) => { @@ -357,15 +355,3 @@ function csrRender(html: string): Response { }), }); } - -function injectServerData(serverData: Record) { - const { head } = REPLACE_REG.before; - const searchValue = new RegExp(head); - - const replcaeCb = (beforeHead: string) => - `${beforeHead}`; - - return (template: string) => template.replace(searchValue, replcaeCb); -}