JSPM

astral-angular-annotate

0.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4552
  • Score
    100M100P100Q132903F
  • License MIT

AngularJS DI annotation pass for astral

Package Exports

  • astral-angular-annotate

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (astral-angular-annotate) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Astral Angular Annotator

A pass for Astral to generate AngularJS [DI annotations](TODO: find docs) automatically.

For a tool CLI, see `[ngmin](TODO: link).

Usage

Below is an example parsing, annotating, and generating JavaScript code. Note that this requires the esprima, escodegen, astral, and astral-angular-annotator npm packages.

var esprima = require('esprima'),
  escodegen = require('escodegen'),
  astral = require('astral')();

// register angular annotator pass
require('astral-angular-annotator')(astral);

var inputCode = "angular.module('myMod').controller('FooCtrl', function ($scope) {" +
"  // ..." +
"});";

var ast = esprima.parse(inputCode, {
  tolerant: true
});

astral.run(ast);

var generatedCode = escodegen.generate(ast, {
  format: {
    indent: {
      style: '  '
    }
  }
});

console.log(generatedCode);

// logs:
//
// angular.module('myMod').controller('FooCtrl', ['$scope', function ($scope) {
//   // ...
// });

API

You can also access each of the individual passes like this:

This might be handy for more fine-tuned control.

License

MIT