Skip to content

make first load faster in production, import virtual server-build outer createRequestHandler #185

@ckcks12

Description

@ckcks12

I'm using express template.

this is a part of app.ts

app.use(
    createRequestHandler({
        build: () => import("virtual:react-router/server-build"),
    }),
);

when first load, then the import promise being resolved.
in produciton in normally it would take more then 500ms, but 1ms after first hit.

const build = import("virtual:react-router/server-build")
app.use(
    createRequestHandler({
        build: () => build,
    }),
);

just put it on top of app.use()

it's now fast enough.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions