Skip to content

Commit

Permalink
chore: getServerManifest should run first on prepare (web-infra-dev#6638
Browse files Browse the repository at this point in the history
)
  • Loading branch information
spencerHT authored Dec 17, 2024
1 parent eab6089 commit 5c97ec2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/tasty-ears-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@modern-js/server-core': patch
---

chore: `getServerManifest` should run first on `prepare`
chore: `getServerManifest` 应该在 `prepare` 时运行
6 changes: 6 additions & 0 deletions packages/server/core/src/adapters/node/plugins/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ROUTE_MANIFEST_FILE,
SERVER_BUNDLE_DIRECTORY,
compatibleRequire,
isProd,
} from '@modern-js/utils';
import type {
Middleware,
Expand Down Expand Up @@ -148,6 +149,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',

Expand Down

0 comments on commit 5c97ec2

Please sign in to comment.