linemanjs / lineman-angular

A Lineman plugin for Angular projects (for a quickstart, see lineman-angular-template)
8 stars 5 forks source link

uglify:js breaks angular code. :( #3

Closed markbates closed 10 years ago

markbates commented 10 years ago

Because of the way Angular uses dependency inject mangling code, using something like uglify breaks Angular. There are two ways to get around this. The first way is to write your Angular code like this:

FooController = ["$scope", function($scope) {}];

Which, personally, I find ugly (no pun intended).

The second way to get around this problem is just not uglify the code. Unfortunately there appears to not be a way to shut off this 'feature'. It would be nice if there were some flag, or line that could be commented out, that would prevent this task from running.

searls commented 10 years ago

The lineman-angular plugin adds ngmin to the process, I thought that either replaced uglify or addressed this problem. Hmm. @davemo?

On Thu, Feb 13, 2014 at 9:56 PM, Mark Bates notifications@github.com wrote:

Because of the way Angular uses dependency inject mangling code, using something like uglify breaks Angular. There are two ways to get around this. The first way is to write your Angular code like this:

FooController = ["$scope", function($scope) {}];

Which, personally, I find ugly (no pun intended).

The second way to get around this problem is just not uglify the code. Unfortunately there appears to not be a way to shut off this 'feature'. It would be nice if there were some flag, or line that could be commented out, that would prevent this task from running.

Reply to this email directly or view it on GitHub: https://github.com/linemanjs/lineman-angular/issues/3

jraede commented 10 years ago

This is an angular issue rather than a lineman issue. The most used fix for this is the array method that you described. Unfortunately with the way angular's dependency injection works that's what you have to do if you want minified code. — Sent from Mailbox for iPhone

On Thu, Feb 13, 2014 at 6:56 PM, Mark Bates notifications@github.com wrote:

Because of the way Angular uses dependency inject mangling code, using something like uglify breaks Angular. There are two ways to get around this. The first way is to write your Angular code like this:

FooController = ["$scope", function($scope) {}];

Which, personally, I find ugly (no pun intended).

The second way to get around this problem is just not uglify the code. Unfortunately there appears to not be a way to shut off this 'feature'. It would be nice if there were some flag, or line that could be commented out, that would prevent this task from running.

Reply to this email directly or view it on GitHub: https://github.com/linemanjs/lineman-angular/issues/3

jraede commented 10 years ago

Edit: aside from ng-min of course, I forgot about that. — Sent from Mailbox for iPhone

On Thu, Feb 13, 2014 at 7:00 PM, Justin Searls notifications@github.com wrote:

The lineman-angular plugin adds ngmin to the process, I thought that either replaced uglify or addressed this problem. Hmm. @davemo? On Thu, Feb 13, 2014 at 9:56 PM, Mark Bates notifications@github.com wrote:

Because of the way Angular uses dependency inject mangling code, using something like uglify breaks Angular. There are two ways to get around this. The first way is to write your Angular code like this:

FooController = ["$scope", function($scope) {}];

Which, personally, I find ugly (no pun intended).

The second way to get around this problem is just not uglify the code. Unfortunately there appears to not be a way to shut off this 'feature'. It would be nice if there were some flag, or line that could be commented out, that would prevent this task from running.

Reply to this email directly or view it on GitHub:

https://github.com/linemanjs/lineman-angular/issues/3

Reply to this email directly or view it on GitHub: https://github.com/linemanjs/lineman-angular/issues/3#issuecomment-35051355

markbates commented 10 years ago

What I was looking for was a way to turn off uglify. I've found it, but it could probably do with some documenting.

In the config/application.js file you can add the following:

removeTasks: {
  dist: ['uglify']
}

That removes the uglify task.

This issue can be closed, but I would recommend a doc update for others who also want to remove this task.

searls commented 10 years ago

In fact @markbates, this same thing stood out to me yesterday and I didn't do anything about it because I was sure I must be wrong. In fact, I was convinced this plugin was already disabling uglify and apparently—whether or not it was—it isn't. Instead of documenting, I propose we add that behavior to the plugin.

markbates commented 10 years ago

This is connected to #5 in that if I remove the uglify task, then my dist folder gets no JS output at all. :(

davemo commented 10 years ago

This seems like a regression; pre extraction to lineman-angular, the lineman-angular-template worked with both uglify and ngmin.

davemo commented 10 years ago

Looking into this now @markbates

searls commented 10 years ago

Whelp, I'm dumb. Everyone, disregard my previous advice. This lineman+angular workflow always incorporated uglify. grunt-ngmin has only ever been used here as a pre-uglify massage to the concatenated generated/app.js file to prep it for uglification.

I think I tackled the root issue Mark experienced here: https://github.com/markbates/lineman-metacast/pull/1