Skip to content
This repository was archived by the owner on Mar 26, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/USAGE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Description:
Creates a default AngularJS app

Example:
yo angular [--coffee] [--minsafe]
yo angular [--coffee]

This will create:
Gruntfile.js
Expand Down
13 changes: 2 additions & 11 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ var Generator = module.exports = function Generator(args, options) {
this.env.options.coffee = this.options.coffee;
}

if (typeof this.env.options.minsafe === 'undefined') {
this.option('minsafe', {
desc: 'Generate AngularJS minification safe code'
});
this.env.options.minsafe = this.options.minsafe;
args.push('--minsafe');
}

this.hookFor('angular:common', {
args: args
});
Expand Down Expand Up @@ -118,11 +110,10 @@ Generator.prototype.welcome = function welcome() {
'Out of the box I include Bootstrap and some AngularJS recommended modules.\n'
);

// Deprecation notice for minsafe
// Removed notice for minsafe
if (this.options.minsafe) {
console.warn(
'\n** The --minsafe flag is being deprecated in 0.7.0 and removed in ' +
'0.8.0. For more information, see ' +
'\n** The --minsafe flag has been removed. For more information, see ' +
'https://github.com/yeoman/generator-angular#minification-safe. **\n'
);
}
Expand Down
2 changes: 1 addition & 1 deletion constant/USAGE
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Description:
Docs: http://docs.angularjs.org/guide/dev_guide.services.creating_services

Example:
yo angular:constant thing [--coffee] [--minsafe]
yo angular:constant thing [--coffee]

This will create:
app/scripts/services/thing.js
2 changes: 1 addition & 1 deletion controller/USAGE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Description:
Creates a new Angular controller

Example:
yo angular:controller Thing [--coffee] [--minsafe]
yo angular:controller Thing [--coffee]

This will create:
app/scripts/controllers/thing-ctrl.js
2 changes: 1 addition & 1 deletion directive/USAGE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Description:
Creates a new Angular directive

Example:
yo angular:directive thing [--coffee] [--minsafe]
yo angular:directive thing [--coffee]

This will create:
app/scripts/directives/thing.js
2 changes: 1 addition & 1 deletion factory/USAGE
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Description:
Docs: http://docs.angularjs.org/guide/dev_guide.services.creating_services

Example:
yo angular:factory thing [--coffee] [--minsafe]
yo angular:factory thing [--coffee]

This will create:
app/scripts/services/thing.js
2 changes: 1 addition & 1 deletion filter/USAGE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Description:
Creates a new AngularJS filter

Example:
yo angular:filter thing [--coffee] [--minsafe]
yo angular:filter thing [--coffee]

This will create:
app/scripts/filters/thing.js
2 changes: 1 addition & 1 deletion provider/USAGE
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Description:
Docs: http://docs.angularjs.org/guide/dev_guide.services.creating_services

Example:
yo angular:provider thing [--coffee] [--minsafe]
yo angular:provider thing [--coffee]

This will create:
app/scripts/services/thing.js
39 changes: 4 additions & 35 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,45 +193,14 @@ To output JavaScript files, even if CoffeeScript files exist (the default is to

### Minification Safe

**Deprecated**
**Removed**

[Related Issue #452](https://github.com/yeoman/generator-angular/issues/452): This option is being removed in future versions of 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.
[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.


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. By providing the `--minsafe` option, the code generated will out-of-the-box be ready for minification. The trade-off is between amount of boilerplate, and build process complexity.

#### Example
```bash
yo angular:controller user --minsafe
```

Produces `app/controller/user.js`:
```javascript
angular.module('myMod').controller('UserCtrl', ['$scope', function ($scope) {
// ...
}]);
```

#### Background
Unannotated:
```javascript
angular.module('myMod').controller('MyCtrl', function ($scope, $http, myService) {
// ...
});
```

Annotated:
```javascript
angular.module('myMod').controller('MyCtrl',
['$scope', '$http', 'myService', function ($scope, $http, myService) {

// ...
}]);
```

The annotations are important because minified code will rename variables, making it impossible for AngularJS to infer module names based solely on function parameters.
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) {
Expand Down
2 changes: 1 addition & 1 deletion route/USAGE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Description:
Creates a new AngularJS route

Example:
yo angular:route thing [--coffee] [--minsafe]
yo angular:route thing [--coffee]

This will create:
app/scripts/controllers/thing.js
Expand Down
9 changes: 0 additions & 9 deletions script-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ var Generator = module.exports = function Generator() {
this.env.options.coffee = this.options.coffee;
}

if (typeof this.env.options.minsafe === 'undefined') {
this.option('minsafe');
this.env.options.minsafe = this.options.minsafe;
}

var sourceRoot = '/templates/javascript';
this.scriptSuffix = '.js';

Expand All @@ -59,10 +54,6 @@ var Generator = module.exports = function Generator() {
this.scriptSuffix = '.coffee';
}

if (this.env.options.minsafe) {
sourceRoot += '-min';
}

this.sourceRoot(path.join(__dirname, sourceRoot));
};

Expand Down
2 changes: 1 addition & 1 deletion service/USAGE
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Description:
Docs: http://docs.angularjs.org/guide/dev_guide.services.creating_services

Example:
yo angular:service thing [--coffee] [--minsafe]
yo angular:service thing [--coffee]

This will create:
app/scripts/services/thing.js
12 changes: 0 additions & 12 deletions templates/coffeescript-min/app.coffee

This file was deleted.

10 changes: 0 additions & 10 deletions templates/coffeescript-min/controller.coffee

This file was deleted.

7 changes: 0 additions & 7 deletions templates/coffeescript-min/decorator.coffee

This file was deleted.

9 changes: 0 additions & 9 deletions templates/coffeescript-min/directive.coffee

This file was deleted.

7 changes: 0 additions & 7 deletions templates/coffeescript-min/filter.coffee

This file was deleted.

4 changes: 0 additions & 4 deletions templates/coffeescript-min/service/constant.coffee

This file was deleted.

15 changes: 0 additions & 15 deletions templates/coffeescript-min/service/factory.coffee

This file was deleted.

21 changes: 0 additions & 21 deletions templates/coffeescript-min/service/provider.coffee

This file was deleted.

5 changes: 0 additions & 5 deletions templates/coffeescript-min/service/service.coffee

This file was deleted.

4 changes: 0 additions & 4 deletions templates/coffeescript-min/service/value.coffee

This file was deleted.

19 changes: 0 additions & 19 deletions templates/coffeescript-min/spec/controller.coffee

This file was deleted.

16 changes: 0 additions & 16 deletions templates/coffeescript-min/spec/directive.coffee

This file was deleted.

15 changes: 0 additions & 15 deletions templates/coffeescript-min/spec/filter.coffee

This file was deleted.

14 changes: 0 additions & 14 deletions templates/coffeescript-min/spec/service.coffee

This file was deleted.

5 changes: 3 additions & 2 deletions templates/common/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,9 @@ module.exports = function (grunt) {
}
},

// Allow the use of non-minsafe AngularJS files. Automatically makes it
// minsafe compatible so Uglify does not destroy the ng references
// ngmin tries to make the code safe for minification automatically by
// using the Angular long form for dependency injection. It doesn't work on
// things like resolve or inject so those have to be done manually.
ngmin: {
dist: {
files: [{
Expand Down
13 changes: 0 additions & 13 deletions templates/javascript-min/app.js

This file was deleted.

10 changes: 0 additions & 10 deletions templates/javascript-min/controller.js

This file was deleted.

Loading