Skip to content

Commit

Permalink
chore(docs): update readme with ng-annotate msg
Browse files Browse the repository at this point in the history
Adds message about ng-annotate
Also updates the module list included with the generator
  • Loading branch information
eddiemonge committed Nov 7, 2014
1 parent dfbfd1f commit 08a252e
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,30 +204,13 @@ To output JavaScript files, even if CoffeeScript files exist (the default is to

### Minification Safe

**Removed**

[Related Issue #452](https://github.com/yeoman/generator-angular/issues/452): This option has been removed from the generator. Initially it was needed as ngMin was not entirely stable. As it has matured, the need to keep separate versions of the script templates has led to extra complexity and maintenance of the generator. By removing these extra burdens, new features and bug fixes should be easier to implement. If you are dependent on this option, please take a look at ngMin and seriously consider implementing it in your own code. It will help reduce the amount of typing you have to do (and look through) as well as make your code cleaner to look at.
**tl;dr**: You don't need to write annotated code as the build step will
handle it for you.

By default, generators produce unannotated code. Without annotations, AngularJS's DI system will break when minified. Typically, these annotations that make minification safe are added automatically at build-time, after application files are concatenated, but before they are minified. The annotations are important because minified code will rename variables, making it impossible for AngularJS to infer module names based solely on function parameters.

The recommended build process uses `ngmin`, a tool that automatically adds these annotations. However, if you'd rather not use `ngmin`, you have to add these annotations manually yourself. **One thing to note is that `ngmin` does not produce minsafe code for things that are not main level elements like controller, services, providers, etc.:

```javascript
resolve: {
User: function(myService) {
return MyService();
}
}
```

will need to be manually done like so:
```javascript
resolve: {
User: ['myService', function(myService) {
return MyService();
}]
}
```
The recommended build process uses `ng-annotate`, a tool that automatically adds these annotations. However, if you'd rather not use it, you have to add these annotations manually yourself. Why would you do that though? If you find a bug
in the annotated code, please file an issue at [ng-annotate](https://github.com/olov/ng-annotate/issues).


### Add to Index
Expand All @@ -253,8 +236,10 @@ The following packages are always installed by the [app](#app) generator:

The following additional modules are available as components on bower, and installable via `bower install`:

* angular-animate
* angular-aria
* angular-cookies
* angular-loader
* angular-messages
* angular-resource
* angular-sanitize

Expand Down

0 comments on commit 08a252e

Please sign in to comment.