From 0935c2d0b1a3c85080c6495154b5a6eda8ca3b38 Mon Sep 17 00:00:00 2001 From: spencerHT <1019777269@qq.com> Date: Mon, 16 Dec 2024 14:33:36 +0800 Subject: [PATCH 1/2] chore: getServerManifest should run first on prepare --- packages/server/core/src/adapters/node/plugins/resource.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/server/core/src/adapters/node/plugins/resource.ts b/packages/server/core/src/adapters/node/plugins/resource.ts index bde2467393b2..ed96a2f44f0d 100644 --- a/packages/server/core/src/adapters/node/plugins/resource.ts +++ b/packages/server/core/src/adapters/node/plugins/resource.ts @@ -9,6 +9,7 @@ import { ROUTE_MANIFEST_FILE, SERVER_BUNDLE_DIRECTORY, compatibleRequire, + isProd, } from '@modern-js/utils'; import type { Middleware, @@ -147,6 +148,11 @@ export const injectResourcePlugin = (): ServerPlugin => ({ async prepare() { const { middlewares, routes, distDirectory: pwd } = api.useAppContext(); + // In Production, should warmup server bundles on prepare. + if (isProd()) { + getServerManifest(pwd, routes || [], console); + } + middlewares.push({ name: 'inject-server-manifest', From bb97b94d8a3f3049498cf0ffa6f096c85a014820 Mon Sep 17 00:00:00 2001 From: spencerHT <1019777269@qq.com> Date: Mon, 16 Dec 2024 14:37:35 +0800 Subject: [PATCH 2/2] chore: change --- .changeset/tasty-ears-bake.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/tasty-ears-bake.md diff --git a/.changeset/tasty-ears-bake.md b/.changeset/tasty-ears-bake.md new file mode 100644 index 000000000000..6780f3a41e02 --- /dev/null +++ b/.changeset/tasty-ears-bake.md @@ -0,0 +1,6 @@ +--- +'@modern-js/server-core': patch +--- + +chore: `getServerManifest` should run first on `prepare` +chore: `getServerManifest` 应该在 `prepare` 时运行