Skip to content

[v9] "optimization": true breaks sourcemaps? #16909

@mstawick

Description

@mstawick

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, it was fine with v8

Description

There's a question mark, because either sourcemaps are broken, or my understanding of how they work is wrong. Here's my use case and "investigation".

I'm using Sentry for crash-tracking and for production builds I generate source maps and upload them directly to sentry. After switching to v9, all the resolved stack traces were wrong (ie. resolved methods are something else then they should be) - it's all garbage. After going back-and-forth, I've discovered that everything works fine if I disable optimization flag.

So I've created a simple project (ng new), add a small piece of code (button + onclick handler) and generated a production build with optimization enabled (ng build --prod --source-map). I've then decoded the map file using @bengourley/source-map-decoder and compared mapping with the actual minified js file. Turns out column number from the mapping is nowhere close to the actual code it should point to.

🔬 Minimal Reproduction

I've attached a reproduction. Inside is a folder help that contains files I've investigated - the main bundle, it's source map, decoded version, and relevant entries.

sourcemap-bug.zip

🌍 Your Environment


Angular CLI: 9.0.1
Node: 12.14.1
OS: linux x64

Angular: 9.0.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.1
@angular-devkit/build-angular     0.900.1
@angular-devkit/build-optimizer   0.900.1
@angular-devkit/build-webpack     0.900.1
@angular-devkit/core              9.0.1
@angular-devkit/schematics        9.0.1
@angular/cli                      9.0.1
@ngtools/webpack                  9.0.1
@schematics/angular               9.0.1
@schematics/update                0.900.1
rxjs                              6.5.4
typescript                        3.7.5
webpack                           4.41.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions