angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.73k stars 11.98k forks source link

Server build in Angular 9 isn't generating an ngfactory #15646

Closed ca136 closed 4 years ago

ca136 commented 4 years ago

🐞 Bug report

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
- [x] server

Is this a regression?

Yes, the previous version in which this bug was not present was: 8 ### Description When upgrading an Angular 8 workspace that uses server-side rendering, it looks like `@angular-devkit/build-angular:server` isn't generating an `NgModuleFactory`. Previously running that builder would generate something like `AppServerModuleNgFactory`, but when upgrading to Angular 9 it looks like it generates an `AppServerModule` that isn't compatible with `renderModuleFactory` or `ngExpressEngine`. ## πŸ”¬ Minimal Reproduction Clone this repo (based on the angular-io universal example): https://github.com/ca136/no-ngfactory-angular9 Run a build: ``` npm run build:ssr ``` Run the server: ``` npm run serve:ssr ``` ## πŸ”₯ Exception or Error

Node server listening on http://localhost:4000
Error: You must pass in a NgModule or NgModuleFactory to be bootstrapped
    at View.engine (/Users/ca13/no-ngfactory-angular9/dist/server.js:219962:23)
    at View.render (/Users/ca136/no-ngfactory-angular9/dist/server.js:59638:8)
    at tryRender (/Users/ca136/no-ngfactory-angular9/dist/server.js:56525:10)
    at Function.render (/Users/ca136/no-ngfactory-angular9/dist/server.js:56477:3)
    at ServerResponse.render (/Users/ca136/no-ngfactory-angular9/dist/server.js:66408:7)
    at app.get (/Users/ca136/no-ngfactory-angular9/dist/server.js:138:9)
    at Layer.handle [as handle_request] (/Users/ca136/no-ngfactory-angular9/dist/server.js:58255:5)
    at next (/Users/ca136/no-ngfactory-angular9/dist/server.js:58003:13)
    at Route.dispatch (/Users/ca136/no-ngfactory-angular9/dist/server.js:57978:3)
    at Layer.handle [as handle_request] (/Users/ca136/no-ngfactory-angular9/dist/server.js:58255:5)
## 🌍 Your Environment



Angular CLI: 9.0.0-next.4 Node: 10.16.3 OS: darwin x64 Angular: 9.0.0-next.7 ... animations, common, compiler, compiler-cli, core, forms ... platform-browser, platform-browser-dynamic, platform-server ... router, upgrade

Package Version

@angular-devkit/architect 0.900.0-next.4 @angular-devkit/build-angular 0.900.0-next.4 @angular-devkit/build-optimizer 0.900.0-next.4 @angular-devkit/build-webpack 0.900.0-next.4 @angular-devkit/core 9.0.0-next.4 @angular-devkit/schematics 9.0.0-next.4 @angular/cli 9.0.0-next.4 @ngtools/webpack 9.0.0-next.4 @nguniversal/express-engine 8.1.1 @nguniversal/module-map-ngfactory-loader 8.1.1 @schematics/angular 9.0.0-next.4 @schematics/update 0.900.0-next.4 rxjs 6.5.3 typescript 3.5.3 webpack 4.39.3

Anything else relevant?

alan-agius4 commented 4 years ago

Kindly see: https://github.com/angular/angular-cli/issues/14646#issuecomment-529388013

Duplicate of #14646

angular-automatic-lock-bot[bot] commented 4 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.