Code Monkey home page Code Monkey logo

Comments (6)

mgol avatar mgol commented on July 28, 2024

It's hard to say something based on this information. It seems you have a file that is not annotated, isn't passed to ng-annotate and is passed to a minifier later on. This is basically the only reason why this error may occur.

It's weird, though, that it worked for you with ngmin and didn't work with ng-annotate. Are you sure this works with ngmin? Maybe you changed something else as well?

If you set up a repo with a simple example with ngmin working and ng-annotate not, I could have a look. Otherwise it's hard to help.

I'll close this issue for now as I'm pretty sure it's a simple configuration error but feel free to post updates here.

from grunt-ng-annotate.

ruben-dossantos avatar ruben-dossantos commented on July 28, 2024

The only thing i did was to change my package.json

-    "grunt-ngmin": "0.0.3",
+    "grunt-ng-annotate": "1.0.1",

and then in my gruntfile.js i put

 grunt.loadNpmTasks('grunt-ng-annotate');

then changed what I put on the issue, and finally changed this

grunt.registerTask('build', [
     'clean:dist',
     'wiredep',
     'useminPrepare',
     'concurrent:dist',
     'autoprefixer',
     'concat',
-        'ngmin',
+        'ngAnnotate',
     'copy:dist',
     'removelogging',
     'cssmin',
     'uglify',
     'ngtemplates',
     'filerev',
     'usemin',
     'htmlmin',
     'appcache'
 ]);

It's completely working with grunt-ngmin.. So my only guess is that maybe grunt-ng-annotate may be incompatible with something else or i'm missing some other configuration.. It's an error at angular.js annotated file/minified file, so I don't know what I should do.

from grunt-ng-annotate.

mgol avatar mgol commented on July 28, 2024

Could you (both with ngAnnotate & ngmin) run Grunt with the --verbose
--debug --stack flags and see if both ngmin & ngAnnotate pick up the same
files?

Michał Gołębiowski

from grunt-ng-annotate.

mgol avatar mgol commented on July 28, 2024

I've mixed up the potential reasons - it might be that ngAnnotate doesn't annotate a particular portion of your file because its heuristics don't detect one of the places that need annotatiion. In such cases you need to insert an /* ngInject */ comment. Could you post here part of the file definining ClientGroup? Its dependencies are not annotated for some reason.

from grunt-ng-annotate.

ruben-dossantos avatar ruben-dossantos commented on July 28, 2024

ClientGroup is a service generated with the following code

var addr = location.hostname;
var constants = {
     'serverAddress': addr + '/api/',
     'resources': {
           'ClientGroup': {
                 'endpoint': 'lab/client_group'
           },
      }
};

var service = angular.module('myApp.services', ['ngResource']);

var resourceObjects = constants.resources;

function addResourceFactoryToService(service, resource, resourceEndPoint){
    service.factory(resource, function ($resource, $http, $cookies) {


    return $resource(
            constants.serverAddress + resourceEndPoint + '/:id',
        // Creates a PUT method defined as 'update'
        {   id: '@id'},
        {
            update: {
                method: 'PUT',
                params: {id: '@id'}
            },
            query: {
                method: 'GET',
                isArray: false,
                transformResponse: function(data){
                    var response = angular.fromJson(data);
                    if(response instanceof Array) {
                        var object = { count: response.length, results: []};
                        for(var i=0; i< response.length; i++){
                            object.results[i] = response[i];
                        }
                        return object;
                    }
                    else {
                        return response;
                    }
                }
            },
            get: {
                method: 'GET',
                isArray: false
            }
        }
    );
});
}

for (var resource in resourceObjects) {
    if (resourceObjects.hasOwnProperty(resource)) {
        addResourceFactoryToService(service, resource, resourceObjects[resource].endpoint);
    }
}

from grunt-ng-annotate.

mgol avatar mgol commented on July 28, 2024

I'd guess ng-annotate heuristics can't find the factory definition, you need to annotate it via "ngInject". Read more at https://github.com/olov/ng-annotate.

Anyway, this is related to ng-annotate output so the place to report any potential issues is https://github.com/olov/ng-annotate/issues, this repo is just a Grunt task for this module.

from grunt-ng-annotate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.