Skip to content

Angular 15 regression: missing diagnostic on server build error #24612

Closed
@demurgos

Description

@demurgos

Command

other: ng run angular.io-example:server

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

14.2

Description

If an error occurs when compiling Angular for server-side rendering, the build process exits with error code 1 without printing any diagnostic. This makes it near impossible to figure out issues specific to SSR builds.

Minimal Reproduction

  1. Clone the Reproduction repository
  2. npm install
  3. npm build

The repro is a stripped down variant of the official universal example. There's a syntax error on line 10 of server.ts. Uncommenting from fixes the build.

Exception or Error

Full output for Angular 15:

$ npm run build

> angular.io-example@0.0.0 build
> ng run angular.io-example:server

✔ Server application bundle generation complete.
$ echo $?
1

Full output for Angular 14.2:

$ npm run build

> angular.io-example@0.0.0 build
> ng run angular.io-example:server

✔ Server application bundle generation complete.

Initial Chunk Files | Names         | Raw Size
main.js             | main          |  5.68 MB | 

                    | Initial Total |  5.68 MB

Build at: 2023-01-26T07:36:35.761Z - Hash: 2ce5cd4dbb2aca9e - Time: 6918ms

Error: server.ts:10:39 - error TS1005: 'from' expected.

10 import { AppServerModule } /* from */ './src/main.server';
                                         ~~~~~~~~~~~~~~~~~~~


Error: Optimization error [main.js]: SyntaxError: Unexpected token: punc ({)

$ echo $?
1

Your Environment

$ npm run ng version

> angular.io-example@0.0.0 ng
> ng version


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 15.1.3
Node: 18.13.0
Package Manager: npm 8.19.3
OS: linux x64

Angular: 15.1.2
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1501.3
@angular-devkit/build-angular   15.1.3
@angular-devkit/core            15.1.3
@angular-devkit/schematics      15.1.3
@angular/cli                    15.1.3
@nguniversal/builders           15.1.0
@nguniversal/express-engine     15.1.0
@schematics/angular             15.1.3
rxjs                            7.8.0
typescript                      4.8.4

Anything else relevant?

You have details about my environment above. I feel like I have a regular Linux machine. I'm very surprised however that this error would not have been detected earlier, so maybe something's wrong with my setup. EDIT: Reproduced in CI

The errors are properly reported with Angular 14.2.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions