@ssv/aspnet-prerendering
v1.0.1-dev.12
Published
aspnet SPA Services Node prerendering ESM compatible.
Downloads
33
Maintainers
Readme
@ssv/aspnet-prerendering
Port of aspnet-prerendering which supports ESM.
This allows using vite/esbuild angular (was tested only with angular - @angular-devkit/build-angular:application
)
Quick links
Change logs | Project Repository
Installation
Get library via npm
npm install @ssv/aspnet-prerendering
Usage
import { renderModule } from "@angular/platform-server";
import { APP_BASE_HREF } from "@angular/common";
// import { createServerRenderer } from "aspnet-prerendering";
import { createServerRenderer } from "@ssv/aspnet-prerendering";
import { AppServerModule } from "./app/app.server.module";
interface TransferData {
originalHtml: string;
startupContext: StartupContext; // custom
request: any;
}
export default createServerRenderer(params => {
const { startupContext, originalHtml } = params.data as TransferData;
const extraProviders = [
{ provide: APP_BASE_HREF, useValue: startupContext.virtualPath },
{ provide: "BASE_URL", useValue: params.origin + params.baseUrl },
];
const options = {
document: originalHtml,
url: params.url,
extraProviders
};
const renderPromise = renderModule(AppServerModule, options);
return renderPromise.then(html => ({ html }));
});
Contributions
Check out the development guide.