Description
🐞 Bug report
What modules are related to this issue?
- builders
- common
- express-engine
Is this a regression?
Unsure, the first version we have used is Angular 13, at which point the sourcemaps have already not been working properly.Description
Sometimes, errors occur on the SSR server. Those errors always only show the stack traces of the optimized and uglyfied version of the source code (e.g something/dist/project/server/main.js:1:123456
). Those traces make it very hard to debug the issue(s).
I tried to enable source maps when building & executing the app, but to no avail.
🔬 Minimal Reproduction
Either copy this demo repo here, or bootstrap a new Angular application, add Angular Universal, and throw an error somewhere. I decided to just throw an error in the AppModule, but anything goes as long as you can cause it.
Next, start the dev:ssr
server by running npm run dev:ssr
. For a more production-like test, build the project and run it with node --enable-source-maps dist/<project>/server/main.js
Then, trigger the error on the SSR server and look at the stack trace. It shows the line numbers of the compiled, uglified main.js file rather than the source-code lines. Neither the dev server provided by the ng
CLI, nor manually calling node --enable-source-maps dist/<project>/server/main.js
work.
🔥 Exception or Error
What I see is a stack like this one:
Error: BOOM
at new AppModule (dist/ssr-sourcemap-test/server/main.js:368:19)
at Object.AppModule_Factory [as useFactory] (dist/ssr-sourcemap-test/server/main.js:372:57)
[... omitted for bravery ... ]
But what I expect is something like this:
Error: BOOM
at new AppModule (src/app/app.module.ts:32:7)
// etc...
The server generates the main.map.js properly, but something appears to be broken when trying to parse it. I haven't figured out a way of fixing/debugging this, however.
🌍 Your Environment
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 14.2.2
Node: 16.14.0
Package Manager: npm 8.3.1
OS: linux x64
Angular: 14.2.1
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1402.2
@angular-devkit/build-angular 14.2.2
@angular-devkit/core 14.2.2
@angular-devkit/schematics 14.2.2
@angular/cli 14.2.2
@nguniversal/builders 14.2.0
@nguniversal/express-engine 14.2.0
@schematics/angular 14.2.2
rxjs 7.5.6
typescript 4.7.4