4

I have been developing a large AngularJS application inside of a .NET MVC Website. I've gone way to long without testing if it will sucesfully minifiy using the Bundle Optimiazation Features?

BundleTable.EnableOptimizations = True

And of Course, it fails. I've been playing with the Order I bundle my scripts, and ensuring I am using String Literals for my Controller Names (I wasn't, and that is a lot of re-factoring that I will have to do).

But I can not get my Core Scripts to Minifiy without the angular "Unknown Provider" error.

Here is the exact Error: Uncaught Error: [$injector:modulerr] [http://errors.angularjs.org/1.3.14/$injector/modulerr?p0=ppAccount&p1=Error…redScripts%3Fv%3DknV3wkCOg32ajaw4GwiRSrTXdo8Ue7MRIn65CPYa1b81%3A1%3A379851)]1

Here is my bundle config that is failing:

            bundles.Add(new ScriptBundle("~/bundles/PilotPartnerRequiredScripts")
      .Include(
          "~/UI/js/jquery/jquery-2.1.3.js",
          "~/UI/js/plugins/jquery-ui/jquery-ui.js",
          "~/UI/js/bootstrap/bootstrap.js",
          "~/UI/js/plugins/pace/pace.min.js",
          "~/UI/js/plugins/slimscroll/jquery.slimscroll.js",
          "~/UI/js/inspinia.js",
          "~/UI/js/angular/angular.js",
          "~/UI/js/ui-router/angular-ui-router.js",
          "~/UI/js/bootstrap/ui-bootstrap-tpls-0.12.1.js",
          "~/UI/js/angular/angular-resource.js",
          "~/UI/js/angular/angular-sanitize.js",
          "~/UI/js/angular/angular-route.js",
          "~/UI/js/plugins/switchery/switchery.js",
           "~/UI/js/plugins/angular-ui-switch/angular-ui-switch.js",
           "~/UI/js/plugins/angularLocalStorage/angular-local-storage.js",
           "~/UI/js/plugins/ngDialog/ngDialog.js",
           "~/Scripts/ngTags/ng-tags-input.js",
           "~/Scripts/uiSortable/sortable.js",
           "~/Scripts/kendo/2014.3.1119/kendo.all.min.js",
           "~/Scripts/xeditable/xeditable.js"

For the life of me, I can't figure out which dependency isn't being resolved. I feel that if I can narrow it down to a specific dependency I know I can solve the issue.

Is there any way to track down the specific Module that is causing the issue?

Any suggestions on how to make this work?

Thank you for your help.

1
  • Are your injections min-safe in Angular? Commented Apr 17, 2015 at 17:08

1 Answer 1

6

You should always follow strict di while injecting dependency (Array notation)

Angualar Doc has mentioned that, Do follow strict DI while doing minification, otherwise it could break you app

Eg.(Code)

angular.module('myModule', [])
.factory('serviceId', ['depService', function(depService) {
  // ...
}])
.directive('directiveName', ['depService', function(depService) {
  // ...
}])
.filter('filterName', ['depService', function(depService) {
  // ...
}]);

In above snippet I followed inline array notation of DI, it has been applied on various angular component just to demonstrate it. You should make sure that you follow it wherever you're injecting dependency.

Sign up to request clarification or add additional context in comments.

2 Comments

I wasn't doing that and when it was failing that was the first thing I started to try. I went through an entire AngularJS application (I have multiple in my entire app) and swapped it out. No Luck so far. It is possible I missed one though. I am going to keep on it. But it seems that Angular-Animate is causing me issues too. It keeps failing to minimize.
Did some more digging. It was exactly that. I found my App.config was not using strict-DI and that was causing the issue. This is where I was setting up my $routeProvider.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.