ericclemmons / grunt-angular-templates

Grunt build task to concatenate & pre-load your AngularJS templates
MIT License
710 stars 107 forks source link

Script hangs? New to grunt #43

Closed cm325 closed 11 years ago

cm325 commented 11 years ago

Not sure if this is an issue with the library (I assume it isn't), but maybe it will still help someone down the line. I installed the plugin, and I run grunt myawesomecompiletask and this is the output I get:

....all the setup and then Running "ngtemplates:app" (ngtemplates) task Verifying property ngtemplates.app exists in config...OK Files: partials/angular_ui_modal_lightbox_carousel.html, partials/siteexplorer_container_partial.html, partials/siteexplorer_featuredsites_list.html, partials/siteexplorer_sites_detail.html, partials/siteexplorer_sites_habitat_list.html, partials/siteexplorer_sites_list.html, partials/ym_photo_gallery.html, partials/ym_site_badges_list.html -> dist/siteexplorer.templates.js Options: angular="angular", bootstrap=undefined, concat=null, htmlmin={}, module="app", source=undefined, standalone=false, url=undefined Reading partials/angular_ui_modal_lightbox_carousel.html...OK Reading partials/siteexplorer_container_partial.html...OK Reading partials/siteexplorer_featuredsites_list.html...OK Reading partials/siteexplorer_sites_detail.html...OK Reading partials/siteexplorer_sites_habitat_list.html...OK Reading partials/siteexplorer_sites_list.html...OK Reading partials/ym_photo_gallery.html...OK Reading partials/ym_site_badges_list.html...OK

and then the script just hangs. For at least 5 minutes, I've tried several times, it never seems to complete :'(

cm325 commented 11 years ago

The node process is also pegged at 100%. Here's some other environment info as well node v0.10.18 grunt-cli v0.1.9

MylesBorins commented 11 years ago

I am experiencing the exact same problem. Works fine for single files but explodes on lists

ericclemmons commented 11 years ago

Wow, I had no idea! I'll try to replicate it, but heads up, I may need some immediate help setting up a failing test case.

If you can do that (or point me to your code), this will be muuuucho easier!

cm325 commented 11 years ago

well, here's the gruntfile, but are you also wanting the angular javascript files too?

module.exports = function(grunt) {

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    concat: {
      options: {
        separator: ';'
      },
      dist: {
        src: ['lib/angularextensions/*.js','lib/angularui/*.js','js/*.js','js/**/*.js'],
        dest: 'dist/<%= pkg.name %>.js'
      }
    },
    ngtemplates:{
      app:        {
        /*cwd:      'src/app',*/
        src:      'partials/**.html',
        dest:     'dist/siteexplorer.templates.js',
        options:    {
          htmlmin:  { collapseWhitespace: true}
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-angular-templates');

  grunt.registerTask('default', ['concat']);
  grunt.registerTask('compileAngularTemplates', ['ngtemplates']);

};
cm325 commented 11 years ago

Any updates on this one?

sidwood commented 11 years ago

I'm getting this too. It seems to be a parse error when encountering custom tag-based directives.

sidwood commented 11 years ago

I've gotta say I'm a bit bewildered by some of the choices made in 0.4. We seem to have departed from a simple html to angular template converter to All Of The Things. HTML min? Why can't people do that using other grunt plugins prior to using grunt-angular-template?

cm325 commented 11 years ago

Interesting, I'm not using any custom tag types in my templates, I prefer to keep the markup valid by todays standards, so I've been using data-* attributes. Would love to use this, getting near production deployment-

ericclemmons commented 11 years ago

So the bug here is that HTMLMinification is optional, but the its still going through the minifier which is supposed to ignore it, but apparently it does not!

@sidwood It's still the same converter, but with massive cleanup of code. HTMLMinification is a necessary step with a large amount of templates, as JSminifiers won't touch anything within the quoted strings. I bumped from 0.3 to 0.4 because these were significant breaking changes, but really need others help (such as @cm325 with this great issue!) to nail down the bugs.

I'm really hoping to appease both sides, but avoid going the route that 0.3 went where we had tons of options that led to tons of spaghetti code.

I'll be clearing out issues soon, but with recent layoffs and life in general, I have to take care of family first.

cm325 commented 11 years ago

As I said earlier, I'm brand new to Grunt, but maybe this is something I can take a stab at. So are you saying that even if you set all the htmlmin settings to false, its still going through there, and thats where the problem is?

ericclemmons commented 11 years ago

Exactly, but it's pretty easy to wrap up. If I don't have it done today, feel free to stab at it, cap'n!

sidwood commented 11 years ago

Ok, I can see that htmlmin was introduced at 0.3.11 so its not really a 0.4 thing. However, I'm still struggling to see the need for it. HTML minification should occur before grunt-angular-template in the 'grunt stack'. I've been happily using minified HTML with grunt-angular-template prior to 0.3.11.

Sorry to harp on about this but it just feels like the responsibility of this plugin has swelled to include minification and as a result we have complexity, bugs, etc.

v0.3.9 works great so I'll be sticking with that. Thanks for all your efforts just the same though Eric! :o)

ericclemmons commented 11 years ago

htmlmin was introduced in 0.3.11, and is in ~0.4. The difference is a bug that's always running htmlmin.

As for when to perform it, I use htmlmin only through this plugin, which is much easier than doing a double-compile and tracking resources across multiple grunt tasks.

Take a look @ the difference in the code for 0.4 & 0.3, Sid, and you'll see why I rewrote everything for 0.4. It was pure crap before then.

This is a bug, not an architectural problem, so don't write off the this minor release because of a bug, whereas 0.3 still has plenty.

cm325 commented 11 years ago

any word on this? time for me to start stabbing at it?

ericclemmons commented 11 years ago

Fixed it in #54. I'll merge that soon, but wanted to give the option for feedback first!

cm325 commented 11 years ago

With that fix, removing the htmlmin option lets everything work normally. but if I leave the htmlmin option in there, everything still hangs. Should that work now?

ericclemmons commented 11 years ago

It sounds like the root problem then is with htmlmin trying to minify your HTML and hanging as a result, not this plugin.

If you can post your HTML that's causing the hang, that'll at least help me prove the point.

ericclemmons commented 11 years ago

htmlmin works successfully on other plugins, but I guess it just hates certain markup =/

cm325 commented 11 years ago

Right, I figured as much, ok, thanks for the fix, at least I have a nice file for production now! Thanks again-

joshuacc commented 11 years ago

@cm325 You could also try running your HTML through grunt-htmlcompressor. It uses a different minifier that might work better for your HTML.

You can then just feed the output of grunt-htmlcompressor into grunt-angular-templates. It's a little more setup, but it has been working very well for me. (I haven't yet upgraded to the built-in minification.)

ericclemmons commented 11 years ago

I originally (#32) looked at that one too, but decided against it because of the .jar dependency. Seeing how grunt-usemin has to seemingly apologize for the one we're both using now, maybe it's worth switching...

statico commented 10 years ago

FWIW, I ran into this with the following incorrect HTML. The extra quotes in the attribute caused the hang:

<img src="John "Q" Taxpayer"/>
ericclemmons commented 10 years ago

@statico That htmlmin project is a piece of work =/