Registry / http-networking / ngast
library0.6.2jsnpmunverified

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.

npm install ngast
INSTALL
IMPORT
SIG · NGAST
N
ngast
http-networkingjavascriptv0.6.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

WorkspaceSymbols
import { WorkspaceSymbols } from 'ngast'
const WorkspaceSymbols = require('ngast');
ESM import is required; ngast ships TypeScript definitions and uses ES modules internally.

Shows how to initialize WorkspaceSymbols with a tsconfig path and retrieve all Angular decorated classes (modules, components, directives, injectables, pipes) from the workspace.

import { join } from 'path'; import { WorkspaceSymbols } from 'ngast'; const tsconfigPath = join(process.cwd(), 'tsconfig.json'); const workspace = new WorkspaceSymbols(tsconfigPath); // Wait for first analysis (could take minutes) const modules = workspace.getAllModules(); console.log('Modules found:', modules.length); const components = workspace.getAllComponents(); console.log('Components found:', components.length); const directives = workspace.getAllDirectives(); console.log('Directives found:', directives.length); const injectables = workspace.getAllInjectable(); console.log('Injectable found:', injectables.length); const pipes = workspace.getAllPipes(); console.log('Pipes found:', pipes.length);
Debug
Known issues
breakingVersion 0.5+ is built on Ivy (ngtsc) and is incompatible with ViewEngine (ngc). Previous version 0.4.0 used ViewEngine.
fix
Upgrade your Angular project to use Ivy and run ngcc before using ngast 0.5+.
affects: >=0.5.0
gotchaFirst analysis is very slow: >10 seconds for small projects, >2 minutes for large projects. Subsequent calls are cached but still slow.
fix
Be patient; consider using a progress indicator. Avoid calling getAll* multiple times unnecessarily.
affects: >=0.5.0
gotchaRequires TypeScript ~4.0.0 and tslib ^2.0.0 as peer dependencies. Using a different TypeScript version may cause errors.
fix
Ensure your project uses TypeScript 4.0.x and tslib 2.x.
affects: >=0.5.0
deprecatedngast 0.4.0 (ViewEngine) is deprecated and no longer maintained. Users on Angular versions prior to Ivy should stay on that version.
fix
Update to ngast 0.6.2 and upgrade Angular to version 9+ with Ivy enabled.
affects: =0.4.0
Errors
Common errors & fixes
Error: Can't resolve '@angular/compiler'
Missing @angular/compiler as a dependency.
fix
npm install @angular/compiler --save
TypeError: ngast_1.WorkspaceSymbols is not a constructor
Using require instead of import for the ES module.
fix
Use 'import { WorkspaceSymbols } from 'ngast' instead of require.
Error: getAllComponents is not a function
Calling getUserComponents() or similar wrong method name.
fix
Use workspace.getAllComponents().
Upgrade
Version history
0.6.2latest on npm
Audit
Dependencies
@angular/corerequiredRequired to parse Angular decorators and components.
@angular/compilerrequiredRequired to compile and understand Angular templates.
@angular/compiler-clirequiredRequired to use Ivy and ngtsc analysis.
tslibrequiredPeer dependency for runtime helpers in compiled TypeScript.
typescriptrequiredPeer dependency needed for TypeScript AST manipulation (version ~4.0.0).
Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
ngast — npm install ngast · libregistry