angular / angular-hint

run-time hinting for AngularJS applications
362 stars 45 forks source link

feat: warn when a module is created, but never added to an app #1

Closed btford closed 10 years ago

ealtenho commented 10 years ago

@caguillen214 is looking into this as it is somewhat close to his logic for checking for different directives.

caguillen214 commented 10 years ago

So after doing a little investigation, I figured out that the way to get the directives loaded/created isn't as similar to how we can get the modules loaded/created as we first imagined.

I came up with the approach below, which is significantly simpler than what has to be used in the directives. Essentially by checking the dependencies of all modules created, we know which modules are eventually going to be loaded. Keeping track of the modules created and the ones to be loaded, allows us to then compare the two sets and find out which modules were created but _not_ loaded


angular.module = function() {
  var module = llLib.originalAngularModule.apply(this,arguments);
  if(module.requires.length) { // if the module has dependencies
    llLib.storeDependencies(module); //store those dependencies as modules that will be loaded
  }
  llLib.createdModules[module.name] = module; //store the module as one that has been created
  return module;
};

However, this approach is limited in the sense that the only modules that it knows are going to be loaded are ones declared as dependencies for other modules. If there is in fact a way to load in a module aside from doing it as dependency in another module, this approach will not work for those cases. Thoughts? Are there other ways to load modules besides as dependencies, @btford?

caguillen214 commented 10 years ago

This is being addressed temporarily at: https://github.com/caguillen214/loading-loader

It's in a good place to be transferred over to angular-hint. Can we make a repo and come up with a name for this one? @btford

btford commented 10 years ago

Mostly just not sure what to call this :/

btford commented 10 years ago

Added: https://github.com/angular/angular-hint-modules

caguillen214 commented 10 years ago

This is closed. It will be tracked further in the repo mentioned above.