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` 时运行 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',