I am creating a angular shcematics project to propose suggestions to my angular project. I am trying to use the built in angular compiler to parse the code because libraries such as parse5 and htmlparser2 use standardized HTML, so it will provide suggestions such as adding values to template reference variables (e.g. #myInput=""), which will break the project. Now, when I run this code,
import { parseTemplate } from '@angular/compiler'
tree.visit(async (filePath: string, fileEntry) => {
if (fileEntry && filePath.endsWith('.html') && !filePath.includes('node_modules')) {
const parsedTemplate = parseTedmplate(fileEntry.content.toString('utf-8'), filePath)
}
})
I get the error:
[error] Error [ERR_INTERNAL_ASSRETION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals. ...
at assert (node: internal/assert:14:11)
at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:329:5)
at new ModuleJobSync (node:internal/modules/esm/module_job:313:34)
Have you guys faced this issue of trying to parse Angular with packages like parse5 and htmlparser2? Do you guys think I am taking the correct approach or have any suggestions? I'd love to hear your POV. Thanks