Angular has adopted Universal and made it a kid of its own! Today I will rewrite some old code we used to isolated express server as we documented before with the most extreme version of serving the same build for multiple languages from Express, we are also using a standalone version as we covered recently.
Let’s dig.
Find GitHub branch of cricketere with server implementation
Setup
We need to first install SSR package and remove any reference to Angular Universal. (Assuming we have upgraded to Angular 17.0)
npm install @angular/ssr
npm uninstall @nguniversal/common @nguniversal/express-engine @nguniversal/builders
Using ng add @angular/ssr
rewrites the server.ts
and it claims to add a config file somewhere. Yeah, nope!
In our last attempt for a skimmed down, standalone server.ts
, it looked like this
// the last server.ts
import { ngExpressEngine } from '@nguniversal/express-engine';
import 'zone.js/dist/zone-node';
// ...
const _app = () => bootstrapApplication(AppComponent, {
providers: [
importProvidersFrom(ServerModule),
// providers: providers array...
],
});
// export the bare minimum, let nodejs take care of everything else
export const AppEngine = ngExpressEngine({
bootstrap: _app
});
Now the ngExpressEngine
is gone. Here are three sources to dig into to see if we can create our own skimmed down engine.
Continue reading on Sekrab Garage