0

Seeing a strange error message when building an Angular 17 site when aot is enabled. When aot is disabled the site builds without issue.

The error message identifies a line in one of our own custom npm libraries which the site consumes.

 [ERROR] Expected ";" but found "-"

    node_modules/@mycompany/angular-common/fesm2022/angular-common-library.mjs:1776:16:
      1776 │       let tmp_4_-1;

I understand that there is some particular syntax being used in the dependency which the aot compiler does not like, but I cannot seem to find the actual offending line in the file referenced. Line 1776 does not remotely resemble this. I have even gone through the mjs file and removed every line that ends in -1; and the error persists.

Is there any way to see the actual file in memory that ng build is working with when it encounters this syntax issue? Even if I could just see a bit more context of the lines around this one I might be able to identify the issue, but as it stands this message tells me nothing about where the error actually originates.

Don't really need aot on this site, so disabling it is a viable option in this case, but would still like to know what the problem here is.

4
  • 1
    Is this library built with "strictMetadataEmit" : true? Commented Apr 3, 2024 at 21:26
  • It was not, but I just rebuilt with this option set. Still getting the same error. Not fully clear on what this setting does so I am curious as to why you suggested. Thank you for the response. Commented Apr 4, 2024 at 13:00
  • This option (in conjuction with some others) makes the compiler to report errors. Without it the library may succesfully build even when it has errors, and those errors then are reported during consumer app build. I just wanted to make sure it is not your case. It should be set as true fornlibs by default and as it was not please check other related options in the docs Commented Apr 4, 2024 at 13:17
  • Thanks for the clarification. These are the options now set in the library's tsconfig: "angularCompilerOptions": { "enableI18nLegacyMessageIdFormat": false, "strictInjectionParameters": true, "strictInputAccessModifiers": true, "strictTemplates": true, "strictMetadataEmit": true } Commented Apr 4, 2024 at 13:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.