marklagendijk / ui-router.stateHelper

A helper module for AngularUI Router, which allows you to define your states as an object tree.
MIT License
235 stars 40 forks source link

Change provider injection for minification parity #1

Closed synthsym closed 10 years ago

synthsym commented 10 years ago

If the js is minified by another system, the parameter specifying $stateprovider would be converted to single character, thus breaking the injector.

marklagendijk commented 10 years ago

Thanks for your pull request. However, I do not agree that this is a good idea. There exist good modules which can make your Angular code 'minify proof'. I consider it bad practice to not use such tools.

This module already provides a minified version. Whenever you use libraries which already provide a minified version you should not try to re-minify it yourself.

synthsym commented 10 years ago

I'm not aware of any modules that make code "minification-proof" apart from ngmin, which converts it to the same array style injection. This is already specified as good practise in the AngularJS docs, so why aren't we following that good practise?

synthsym commented 10 years ago

Besides, you yourself made such changes to the angular-kendo project to fix the same issue that is experienced here.

marklagendijk commented 10 years ago

You are right that I did fix such issue, quite a while ago, on angular-kendo. I also agree that using the array style injection is good practice. I just think that using gulp or grunt with ngmin to automatically provide this, is even better practice. It:

  1. Is easier to maintain.
  2. Prevents bugs where only the minified version of the library is broken (which is especially annoying if the minified version isn't also automatically tested). This is the reason that I prefer this approach, and am using it on all my modules.

This would only cause problems when people are doing two things, which both are quite wrong:

  1. Re-minify third-party libraries which already come with a minified version.
  2. Minify Angular modules in a wrong way (without using ngmin).
sudodoki commented 9 years ago

I just think that using gulp or grunt with ngmin to automatically provide this, is even better practice.

I had worked on the project that was using array style injections and uglifying the output. For development purposes, you always included full version of the code & minified everything on build step (we didn't use ngmin or anything similar).

This has several advantages:

  1. You get to debug nice code (yes, there're source maps, but they are not always an option).
  2. You can minify it on your build step. In theory, this brings better compression than bringing in minified version and minifying that.