Skip to content

Angular package executor creates sourcemaps that cause extract-i18n to crash #33081

@daiscog

Description

@daiscog

Current Behavior

Reopening #32586 as I've since narrowed this down to an issue with the build output of the @nx/angular:package executor.

Given:

  • I have a publishable Angular library that uses $localize
  • I build that with the @nx/angular:package executor then publish/pack the result
  • I install the built package in another Angular (or nx) workspace and consume it in my app

Then when I run ng extract-i18n (or nx extract-i18n) for the app, the process crashes with the following error:

[error] TypeError: Cannot read properties of undefined (reading 'startOfLinePositions')
    at MessageExtractor.getOriginalLocation (file:///.../node_modules/@angular/localize/tools/bundles/chunk-TZHZOBVD.js:183:41)
    ...

After first raising an issue with Angular at angular/angular#64379 I've since done some more digging and have found that the issue occurs when the source maps in the package contain a comment at the end of each sourcesContent entry like so:

//# sourceMappingURL=data:application/json;base64,ey...

If I delete this comment from the sourcemaps, delete the .angular cache, then rerun ng extract-i18n the process completes successfully.

Libraries built with @nx/angular:package version 20.8.2 do not result in this extra comment and therefore work just fine. We've found the problem after upgrading to nx 21.6.3 and Angular 20.

Also, to verify it's a problem with the @nx/angular:package executor and not (for example) tsconfig or similar, I've replaced the executor with Angular's native @angular/build:ng-packagr builder (no other config changes at all) and rebuilt the lib - the output of this builder does not include the sourceMappingURL=data:... comment in the source maps and when packaged and consumed in the app, the extract-i18n command completes successfully.

I'm therefore reopening as it could be argued that the issue is a regression in the @nx/angular:package executor as it's producing content the Angular CLI cannot handle.

Expected Behavior

I can build and publish an Angular library with the @nx/angular:package executor, consume that in another app, and successfully run extract-i18n in that app.

Nx Report

Node           : 22.14.0
OS             : darwin-arm64
Native Target  : aarch64-macos
npm            : 10.9.2

nx                     : 21.6.3
@nx/js                 : 21.6.3
@nx/jest               : 21.6.3
@nx/eslint             : 21.6.3
@nx/workspace          : 21.6.3
@nx/angular            : 21.6.3
@nx/cypress            : 21.6.3
@nx/devkit             : 21.6.3
@nx/eslint-plugin      : 21.6.3
@nx/module-federation  : 21.6.3
@nx/node               : 21.6.3
@nx/playwright         : 21.6.3
@nx/plugin             : 21.6.3
@nx/rollup             : 20.8.2
@nx/rspack             : 21.6.3
@nx/web                : 21.6.3
@nx/webpack            : 21.6.3
@nx/docker             : 21.6.3
nx-cloud               : 19.1.0
@nrwl/nx-cloud         : 19.1.0
typescript             : 5.9.3

---------------------------------------
Registered Plugins:
@nx/jest/plugin
---------------------------------------
Community plugins:
@ng-bootstrap/ng-bootstrap : 19.0.1
@ngneat/spectator          : 19.6.2
@ngrx/component            : 20.0.1
@ngrx/component-store      : 20.0.1
@ngrx/effects              : 20.0.1
@ngrx/entity               : 20.0.1
@ngrx/operators            : 20.0.1
@ngrx/router-store         : 20.0.1
@ngrx/schematics           : 20.0.1
@ngrx/signals              : 20.0.1
@ngrx/store                : 20.0.1
@ngrx/store-devtools       : 20.0.1
@nx/azure-cache            : 4.0.0
angular-eslint             : 20.3.0
ng-mocks                   : 14.13.5
nx-stylelint               : 17.1.5
---------------------------------------
Local workspace plugins:
---------------------------------------
Cache Usage: 669.95 KB / 92.64 GB
---------------------------------------

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions