Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: getServerManifest should run first on prepare #6638

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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',

Expand Down
Loading