Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular 19.1 -> build error: Cannot read properties of undefined (reading 'map') #29465

Open
1 task done
meriturva opened this issue Jan 23, 2025 · 3 comments
Open
1 task done

Comments

@meriturva
Copy link

meriturva commented Jan 23, 2025

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

19.0

Description

Updating to angular 19.1 I get error just with a simple build command.

It was so difficult to make a simple and small repo to reproduce the issue but finally, I got it!

Here is the repo: https://github.com/meriturva/angular_19_1_issue_build

To reproduce:

  1. npm i
  2. ng build

and you have the error:

An unhandled exception occurred: Cannot read properties of undefined (reading 'map')
See "C:\Users\diego\AppData\Local\Temp\ng-TSQVA6\angular-errors.log" for further details.

Minimal Reproduction

  1. npm i
  2. ng build

Exception or Error

[error] TypeError: Cannot read properties of undefined (reading 'map')
    at originalPositionFor (D:\Projects\github.com\angular_19_1_issue_build\node_modules\@ampproject\remapping\dist\remapping.umd.js:77:21)
    at originalPositionFor (D:\Projects\github.com\angular_19_1_issue_build\node_modules\@ampproject\remapping\dist\remapping.umd.js:88:16)
    at traceMappings (D:\Projects\github.com\angular_19_1_issue_build\node_modules\@ampproject\remapping\dist\remapping.umd.js:56:30)
    at remapping (D:\Projects\github.com\angular_19_1_issue_build\node_modules\@ampproject\remapping\dist\remapping.umd.js:196:30)
    at transformWithBabel (D:\Projects\github.com\angular_19_1_issue_build\node_modules\@angular\build\src\tools\esbuild\i18n-inliner-worker.js:133:45)
    at async inlineLocale (D:\Projects\github.com\angular_19_1_issue_build\node_modules\@angular\build\src\tools\esbuild\i18n-inliner-worker.js:35:20)
    at async D:\Projects\github.com\angular_19_1_issue_build\node_modules\piscina\dist\worker.js:144:26

Your Environment

Angular CLI: 19.1.4
Node: 22.13.1
Package Manager: npm 10.9.2
OS: win32 x64

Angular: 19.1.3
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router, service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1901.4
@angular-devkit/build-angular   19.1.4
@angular-devkit/core            19.1.4
@angular-devkit/schematics      19.1.4
@angular/cdk                    19.1.1
@angular/cli                    19.1.4
@schematics/angular             19.1.4
ng-packagr                      19.1.0
rxjs                            7.8.1
typescript                      5.7.3
zone.js                         0.15.0

Anything else relevant?

No response

@alan-agius4 alan-agius4 added the needs: investigation Requires some digging to determine if action is needed label Jan 24, 2025
@mattlewis92
Copy link
Contributor

We are experiencing this issue in our application as well after upgrading to 19.1.4 from 18.2.2

I did some debugging and the root cause is the upgrade of esbuild from 0.24.0 to 0.24.2 (forcing the older version fixes the issue)

Looking at the release notes, I'm guessing it's this change from 0.24.1 which seems like a deliberate change rather than a bug:

Image

So potentially it sounds like the issue should be fixed in @ampproject/remapping

I put together a reproduction of the issue here

As a workaround for other people experiencing the issue, we've applied a patch to wrap the sourcemap remapping code inside of a try catch to silence the error and prevent the build from failing:

outputMap = remapping([transformResult.map as SourceMapInput, map], () => null);

@alan-agius4 alan-agius4 added state: blocked on upstream and removed needs: investigation Requires some digging to determine if action is needed labels Jan 24, 2025
@alan-agius4
Copy link
Collaborator

Thank you for loooking into this, @mattlewis92. We should open an upstream issue to address and resolve it.

@bastienmoulia
Copy link

bastienmoulia commented Feb 4, 2025

An other workaround is to override the version of esbuild in the package.json

"overrides": {
  "vite": {
    "esbuild": "0.24.0"
  },
  "@angular-devkit/build-angular": {
    "esbuild": "0.24.0"
  },
  "@angular/build": {
    "esbuild": "0.24.0"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants