Skip to content

Worker and global style files do not respect sourceMap.hidden #27833

Closed
@csvn

Description

@csvn

Command

build

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

No response

Description

When setting build.options.sourceMap.hidden to true, there is two cases I've seen where //# sourceMappingURL= is still added to the bottom of the file: any scripts files added as worker, and for style files specified in build.options.styles. I cannot find a way to make all emitted files respect the hidden flag for sourcemaps.

Minimal Reproduction

  1. Generate a new Angular project:
    npx @angular/cli@latest new --style=css --ssr=false ng-repro
  2. Add angular.json config to use hidden sourcemaps:
    "build": {
      "builder": "@angular-devkit/build-angular:application",
        "options": {
          "sourceMap": {
            "hidden": true,
            "scripts": true,
            "styles": true
          },
          // ...
  3. Add a worker file at src/main.worker.ts:
    globalThis.postMessage('Hello! I am a worker!');
  4. Import the worker in main.ts, by adding this at the bottom:
    const worker = new Worker(new URL('./main.worker', import.meta.url));
    worker.addEventListener('message', e => console.log(e.data));
  5. Run the build step:
    npm run build

By checking styles-<hash>.css and worker-<hash>.js in the dist/<project>/browser folder, we can see that at the bottom of both files there is a //# sourceMappingURL= mapping, and thus the sourcemap is not hidden.

Exception or Error

No response

Your Environment

Angular CLI: 18.0.3
Node: 22.2.0
Package Manager: npm 10.7.0
OS: win32 x64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1800.3
@angular-devkit/build-angular   18.0.3
@angular-devkit/core            18.0.3
@angular-devkit/schematics      18.0.3
@angular/cli                    18.0.3
@schematics/angular             18.0.3
rxjs                            7.8.1
typescript                      5.4.5
zone.js                         0.14.7

Anything else relevant?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions