TypeError: Cannot read properties of undefined (reading 'endsWith') #23717
Labels
area: @angular-devkit/build-angular
freq1: low
Only reported by a handful of users who observe it rarely
severity5: regression
type: bug/fix
🐞 Bug report
Command (mark with an
x
)Is this a regression?
Yes, the previous version in which this bug was not present was: Angular Version 9Description
After updating Angular from version 9 to 14, the build no longer works because a property is now undefined. I use the "@angular-builders/custom-webpack" with the Webpack CompressionPlugin, because i want my build files being compressed. To not have the compressed and uncompressed files in the dist directory, the 'deleteOriginalAssets' property is set to true. But the @angular-devkit/build-angular module wants to calculate the statistics and needs the deleted files. In version 9 it just returns 0 for the sizes. Now the build process breaks because in line 175 in the file @angular-devkit/build-angular/src/webpack/plugins/analytics.js the property firstFile is undefined.
🔬 Minimal Reproduction
ng new repro-app
@angular-builders/custom-webpack:browser
npm i
npm run build
-> you will see an error🔥 Exception or Error
An unhandled exception occurred: Cannot read properties of undefined (reading 'endsWith')
Anything else relevant?
For a quick fix i just changed the line 175 in node_modules/@angular-devkit/build-angular/src/webpack/plugins/analytics.js from this:
if (firstFile.endsWith('.css')) {
to this:
if (firstFile && firstFile.endsWith('.css')) {
The text was updated successfully, but these errors were encountered: