Closed jbjhjm closed 1 year ago
Thanks for the detailed issue! Looks like it can be fixed quite easily, so PR is welcome.
@th0r alright, will do as soon as I find some time!
Was going to look into this again and open a PR. But I found that it is working fine again, at least with angular 15. So it was fixed in some way in the meantime, means I'm closing this!
Issue description
Angular production bundles use the encoded ɵ char (\u0275) for Ivy-generated methods. In some cases, acorn parser will falsy detect use of a reserved keyword and throw a SyntaxError. (happens in source code bits like
let \u0275FaqFrontendFeature_BaseFactory
, seems the leading \u0275 makes acorn not detect the variable name, let will be treated as whole statement, which would be erronous.)Technical info
This is stripped down content of an angular chunk file which would make webpack-bundle-analyzer fail because acorn throws an error.
Proposed solution
It is not webpack-bundle-analyzer's task to validate source files. Because of that, I propose to update the configuration of acorn parse runner to tolerate such errors and not throw.
In parseUtils.parseBundle, the acorn.parse options object can be detailed by setting
allowReserved:true
. This will make acorn tolerate reserved keywords and analyzation can continue.