Skip to content
This repository was archived by the owner on Mar 26, 2018. It is now read-only.

Commit c24e250

Browse files
committed
feat(app): remove minsafe options
Remove the minsafe templates, documentation and options from the generator. Closes #452 BREAKING CHANGE: Removes the --minsafe from the generator. See the readme for more information about this change
1 parent 51e4645 commit c24e250

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+19
-411
lines changed

app/USAGE

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Description:
22
Creates a default AngularJS app
33

44
Example:
5-
yo angular [--coffee] [--minsafe]
5+
yo angular [--coffee]
66

77
This will create:
88
Gruntfile.js

app/index.js

+2-11
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ var Generator = module.exports = function Generator(args, options) {
4747
this.env.options.coffee = this.options.coffee;
4848
}
4949

50-
if (typeof this.env.options.minsafe === 'undefined') {
51-
this.option('minsafe', {
52-
desc: 'Generate AngularJS minification safe code'
53-
});
54-
this.env.options.minsafe = this.options.minsafe;
55-
args.push('--minsafe');
56-
}
57-
5850
this.hookFor('angular:common', {
5951
args: args
6052
});
@@ -118,11 +110,10 @@ Generator.prototype.welcome = function welcome() {
118110
'Out of the box I include Bootstrap and some AngularJS recommended modules.\n'
119111
);
120112

121-
// Deprecation notice for minsafe
113+
// Removed notice for minsafe
122114
if (this.options.minsafe) {
123115
console.warn(
124-
'\n** The --minsafe flag is being deprecated in 0.7.0 and removed in ' +
125-
'0.8.0. For more information, see ' +
116+
'\n** The --minsafe flag has been removed. For more information, see ' +
126117
'https://github.com/yeoman/generator-angular#minification-safe. **\n'
127118
);
128119
}

constant/USAGE

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Description:
33
Docs: http://docs.angularjs.org/guide/dev_guide.services.creating_services
44

55
Example:
6-
yo angular:constant thing [--coffee] [--minsafe]
6+
yo angular:constant thing [--coffee]
77

88
This will create:
99
app/scripts/services/thing.js

controller/USAGE

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Description:
22
Creates a new Angular controller
33

44
Example:
5-
yo angular:controller Thing [--coffee] [--minsafe]
5+
yo angular:controller Thing [--coffee]
66

77
This will create:
88
app/scripts/controllers/thing-ctrl.js

directive/USAGE

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Description:
22
Creates a new Angular directive
33

44
Example:
5-
yo angular:directive thing [--coffee] [--minsafe]
5+
yo angular:directive thing [--coffee]
66

77
This will create:
88
app/scripts/directives/thing.js

factory/USAGE

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Description:
33
Docs: http://docs.angularjs.org/guide/dev_guide.services.creating_services
44

55
Example:
6-
yo angular:factory thing [--coffee] [--minsafe]
6+
yo angular:factory thing [--coffee]
77

88
This will create:
99
app/scripts/services/thing.js

filter/USAGE

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Description:
22
Creates a new AngularJS filter
33

44
Example:
5-
yo angular:filter thing [--coffee] [--minsafe]
5+
yo angular:filter thing [--coffee]
66

77
This will create:
88
app/scripts/filters/thing.js

provider/USAGE

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Description:
33
Docs: http://docs.angularjs.org/guide/dev_guide.services.creating_services
44

55
Example:
6-
yo angular:provider thing [--coffee] [--minsafe]
6+
yo angular:provider thing [--coffee]
77

88
This will create:
99
app/scripts/services/thing.js

readme.md

+4-35
Original file line numberDiff line numberDiff line change
@@ -193,45 +193,14 @@ To output JavaScript files, even if CoffeeScript files exist (the default is to
193193

194194
### Minification Safe
195195

196-
**Deprecated**
196+
**Removed**
197197

198-
[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.
198+
[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.
199199

200-
201-
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.
202-
203-
#### Example
204-
```bash
205-
yo angular:controller user --minsafe
206-
```
207-
208-
Produces `app/controller/user.js`:
209-
```javascript
210-
angular.module('myMod').controller('UserCtrl', ['$scope', function ($scope) {
211-
// ...
212-
}]);
213-
```
214-
215-
#### Background
216-
Unannotated:
217-
```javascript
218-
angular.module('myMod').controller('MyCtrl', function ($scope, $http, myService) {
219-
// ...
220-
});
221-
```
222-
223-
Annotated:
224-
```javascript
225-
angular.module('myMod').controller('MyCtrl',
226-
['$scope', '$http', 'myService', function ($scope, $http, myService) {
227-
228-
// ...
229-
}]);
230-
```
231-
232-
The annotations are important because minified code will rename variables, making it impossible for AngularJS to infer module names based solely on function parameters.
200+
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.
233201

234202
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.:
203+
235204
```javascript
236205
resolve: {
237206
User: function(myService) {

route/USAGE

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Description:
22
Creates a new AngularJS route
33

44
Example:
5-
yo angular:route thing [--coffee] [--minsafe]
5+
yo angular:route thing [--coffee]
66

77
This will create:
88
app/scripts/controllers/thing.js

script-base.js

-9
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ var Generator = module.exports = function Generator() {
4646
this.env.options.coffee = this.options.coffee;
4747
}
4848

49-
if (typeof this.env.options.minsafe === 'undefined') {
50-
this.option('minsafe');
51-
this.env.options.minsafe = this.options.minsafe;
52-
}
53-
5449
var sourceRoot = '/templates/javascript';
5550
this.scriptSuffix = '.js';
5651

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

62-
if (this.env.options.minsafe) {
63-
sourceRoot += '-min';
64-
}
65-
6657
this.sourceRoot(path.join(__dirname, sourceRoot));
6758
};
6859

service/USAGE

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Description:
33
Docs: http://docs.angularjs.org/guide/dev_guide.services.creating_services
44

55
Example:
6-
yo angular:service thing [--coffee] [--minsafe]
6+
yo angular:service thing [--coffee]
77

88
This will create:
99
app/scripts/services/thing.js

templates/coffeescript-min/app.coffee

-12
This file was deleted.

templates/coffeescript-min/controller.coffee

-10
This file was deleted.

templates/coffeescript-min/decorator.coffee

-7
This file was deleted.

templates/coffeescript-min/directive.coffee

-9
This file was deleted.

templates/coffeescript-min/filter.coffee

-7
This file was deleted.

templates/coffeescript-min/service/constant.coffee

-4
This file was deleted.

templates/coffeescript-min/service/factory.coffee

-15
This file was deleted.

templates/coffeescript-min/service/provider.coffee

-21
This file was deleted.

templates/coffeescript-min/service/service.coffee

-5
This file was deleted.

templates/coffeescript-min/service/value.coffee

-4
This file was deleted.

templates/coffeescript-min/spec/controller.coffee

-19
This file was deleted.

templates/coffeescript-min/spec/directive.coffee

-16
This file was deleted.

templates/coffeescript-min/spec/filter.coffee

-15
This file was deleted.

templates/coffeescript-min/spec/service.coffee

-14
This file was deleted.

templates/common/Gruntfile.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,9 @@ module.exports = function (grunt) {
288288
}
289289
},
290290

291-
// Allow the use of non-minsafe AngularJS files. Automatically makes it
292-
// minsafe compatible so Uglify does not destroy the ng references
291+
// ngmin tries to make the code safe for minification automatically by
292+
// using the Angular long form for dependency injection. It doesn't work on
293+
// things like resolve or inject so those have to be done manually.
293294
ngmin: {
294295
dist: {
295296
files: [{

templates/javascript-min/app.js

-13
This file was deleted.

templates/javascript-min/controller.js

-10
This file was deleted.

0 commit comments

Comments
 (0)