{"id":25986,"library":"ngast","title":"ngast","description":"ngast is a library providing a user-friendly API for parsing Angular projects by abstracting over the Angular compiler. The current stable version is 0.6.2, built on top of Ivy (ngtsc) and requiring TypeScript ~4.0.0. Key differentiators: it offers a high-level interface to analyze Angular workspaces, methods like getAllComponents() and getAllModules(), and integrates with tools like ngrev and codelyzer. The analysis is slow (>10 sec for small projects). Release cadence is low; previous version 0.4.0 used the older ViewEngine.","status":"active","version":"0.6.2","language":"javascript","source_language":"en","source_url":"https://github.com/ng-ast/ngast","tags":["javascript","AST","Angular","Parser","Compiler","typescript"],"install":[{"cmd":"npm install ngast","lang":"bash","label":"npm"},{"cmd":"yarn add ngast","lang":"bash","label":"yarn"},{"cmd":"pnpm add ngast","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required to parse Angular decorators and components.","package":"@angular/core","optional":false},{"reason":"Required to compile and understand Angular templates.","package":"@angular/compiler","optional":false},{"reason":"Required to use Ivy and ngtsc analysis.","package":"@angular/compiler-cli","optional":false},{"reason":"Peer dependency for runtime helpers in compiled TypeScript.","package":"tslib","optional":false},{"reason":"Peer dependency needed for TypeScript AST manipulation (version ~4.0.0).","package":"typescript","optional":false}],"imports":[{"note":"ESM import is required; ngast ships TypeScript definitions and uses ES modules internally.","wrong":"const WorkspaceSymbols = require('ngast');","symbol":"WorkspaceSymbols","correct":"import { WorkspaceSymbols } from 'ngast'"}],"quickstart":{"code":"import { join } from 'path';\nimport { WorkspaceSymbols } from 'ngast';\n\nconst tsconfigPath = join(process.cwd(), 'tsconfig.json');\nconst workspace = new WorkspaceSymbols(tsconfigPath);\n\n// Wait for first analysis (could take minutes)\nconst modules = workspace.getAllModules();\nconsole.log('Modules found:', modules.length);\n\nconst components = workspace.getAllComponents();\nconsole.log('Components found:', components.length);\n\nconst directives = workspace.getAllDirectives();\nconsole.log('Directives found:', directives.length);\n\nconst injectables = workspace.getAllInjectable();\nconsole.log('Injectable found:', injectables.length);\n\nconst pipes = workspace.getAllPipes();\nconsole.log('Pipes found:', pipes.length);","lang":"typescript","description":"Shows how to initialize WorkspaceSymbols with a tsconfig path and retrieve all Angular decorated classes (modules, components, directives, injectables, pipes) from the workspace."},"warnings":[{"fix":"Upgrade your Angular project to use Ivy and run ngcc before using ngast 0.5+.","message":"Version 0.5+ is built on Ivy (ngtsc) and is incompatible with ViewEngine (ngc). Previous version 0.4.0 used ViewEngine.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Be patient; consider using a progress indicator. Avoid calling getAll* multiple times unnecessarily.","message":"First analysis is very slow: >10 seconds for small projects, >2 minutes for large projects. Subsequent calls are cached but still slow.","severity":"gotcha","affected_versions":">=0.5.0"},{"fix":"Ensure your project uses TypeScript 4.0.x and tslib 2.x.","message":"Requires TypeScript ~4.0.0 and tslib ^2.0.0 as peer dependencies. Using a different TypeScript version may cause errors.","severity":"gotcha","affected_versions":">=0.5.0"},{"fix":"Update to ngast 0.6.2 and upgrade Angular to version 9+ with Ivy enabled.","message":"ngast 0.4.0 (ViewEngine) is deprecated and no longer maintained. Users on Angular versions prior to Ivy should stay on that version.","severity":"deprecated","affected_versions":"=0.4.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"npm install @angular/compiler --save","cause":"Missing @angular/compiler as a dependency.","error":"Error: Can't resolve '@angular/compiler'"},{"fix":"Use 'import { WorkspaceSymbols } from 'ngast' instead of require.","cause":"Using require instead of import for the ES module.","error":"TypeError: ngast_1.WorkspaceSymbols is not a constructor"},{"fix":"Use workspace.getAllComponents().","cause":"Calling getUserComponents() or similar wrong method name.","error":"Error: getAllComponents is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}