1

I am trying to minify and uglify my angularjs + typescript app using grunt-minified. Currently I am getting an error that my main module for the app is not available when I minify. I know why this is occuring due variable names no longer matching the names of the modules they reference. How would I set up annotation so angular is able to identify my main module after minification?

declare module BB {

}

    module BB.MyModule {

        // initialize the module
        export var module = angular
            // load the dependencies
            .module("MyModule", [
                // dependancies
            ]);

    }

This basic setup is working fine unminified, but MyModule is not defined when I minify it. How would I go about defining for safe minification?

1 Answer 1

1

You have:

declare module BB {

}

Probably BB has been minified to something else. That would make module BB.MyModule be different from BB.

Solution: Your code is already safe for minification if the point where you bootstrap angular https://docs.angularjs.org/api/ng/function/angular.bootstrap is minified through the same pipeline as BB.module is passed through.

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

4 Comments

So your saying to simply drop declare from module BB only and the problem will be resolved?
No. I am saying that your code is already safe for minification if the point where you bootstrap angular docs.angularjs.org/api/ng/function/angular.bootstrap is minified through the same pipeline as BB.module is passed through.
How would I go about determining that angular.bootstrap is being minified on the same pipeline as BB.module? I tried running bootstrap just after initialization of MyModule and loading of controllers, services, directives, etc. No effect though.
but MyModule is not defined when I minify it Run angular.module('MyModule') in the browser. Is it undefined?

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.