App is the application abstraction for the Esmx framework, providing a unified interface to manage application lifecycle, static resources, and Server-Side Rendering.
export default {
async devApp(esmx) {
return import('@esmx/rspack').then((m) =>
m.createRspackHtmlApp(esmx, {
config(rc) {
}
})
);
}
}interface App {
middleware: Middleware;
render: (options?: RenderContextOptions) => Promise<RenderContext>;
build?: () => Promise<boolean>;
destroy?: () => Promise<boolean>;
}MiddlewareStatic resource handling middleware.
Development Environment:
Production Environment:
server.use(esmx.middleware);(options?: RenderContextOptions) => Promise<RenderContext>Server-Side Rendering function. Provides different implementations based on the runtime environment:
const rc = await esmx.render({
params: { url: '/page' }
});
res.end(rc.html);() => Promise<boolean>Production environment build function. Used for resource bundling and optimization. Returns true upon successful build, false upon failure.
() => Promise<boolean>Resource cleanup function. Used to close the server, disconnect connections, etc. Returns true upon successful cleanup, false upon failure.