Skip to content

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

Closed

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

Activity

  1. added
    freq1: low
    on Jun 13, 2024
  2. self-assigned this
    on Jun 13, 2024
  3. added 3 commits that reference this issue on Jun 13, 2024
    bad933a
    5e2bc6e
    fa30a7a
  4. added 2 commits that reference this issue on Jun 13, 2024
    8c37926
    791ef80
  5. angular-automatic-lock-bot commented on Jul 14, 2024

    @angular-automatic-lock-bot

    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.

  6. locked and limited conversation to collaborators on Jul 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: @angular/buildfreq1: lowseverity3: brokentype: bug/fix

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions