ng-annotate-patched (v1.15.0) is a maintained fork of the now-unmaintained ng-annotate library. It adds and removes AngularJS dependency injection annotations, supporting modern JavaScript syntax (ES2020, classes, arrow functions, dynamic import, export) that the original cannot parse. Key updates include a newer acorn parser and acornOptions for customization. It is the recommended choice over ng-annotate for projects using modern JS.
npm install ng-annotate-patchedNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates adding AngularJS DI annotations to a controller function using the ng-anotate-patched library API.
npm install ng-annotate-patched && const ngAnnotate = require('ng-annotate-patched');Use const result = ngAnnotate(src, options);
Prefer calling ngAnnotate(src, options) directly.
Add a post-processing step: result.src.replace(/["']ngInject["'];*/g, '');
Use explicit 'ngInject' pragma or enable 'ng-strict-di' in AngularJS.
npm install ng-annotate-patched && const ngAnnotate = require('ng-annotate-patched');Use ngAnnotate(src, options) directly instead of ngAnnotate.annotate(src, options).
Switch to ng-annotate-patched which supports ES2020 syntax via updated acorn parser.
ng-annotate -a path/to/source.js