On Wednesday, January 21, 2015 at 7:52:11 AM UTC-5, Daniel Lidström wrote:
>
> Hi Adam
>
> May I ask what problems you are solving with RequireJS and putting each 
> file in its own Angular module? Even 170 source files could be bundled, 
> minimized, compressed, and loaded up front, don't you think? And why so 
> many modules? I'm just being curious.
>

I will give my two cents on this. Some the same as Adam's response.

Ben Clinkinbeard (author of this PR) has been promoting a style of Angular 
development which I have a adopted to great effect in my larger projects. 
Like other style guides (John Papa, Todd Motta) I have subdirectories for 
each component (e.g. src/auth) rather than each Angular concept (e.g. 
src/controllers). Each of these component is its own Angular module. But 
each are also standalone CommonJS/NodeJS modules with an index.js to setup 
the component. Each file in the component has a require() for its 
dependencies. browserify can then walk the tree and bundle everything up.

The fun part, though, is that Angular only appears in the component's 
index.js file. My services, controllers, etc. don't do anything like 
angular.module('my component').service('MyService', MyService). They are 
pure NodeJS files. I can then test them with Mocha, use require() for 
dependencies. Basically, future-proof them and gain a tremendous 
productivity speedup. By breaking things up like this, and *especially* by 
not hauling in Angular, mocking the $injector and module() in my unit 
tests, and running through Karma, I feel like I am not squashed by the 
magic.

There are some unit tests that still need Angular, though. Like directives, 
or the wiring in index.js, or my ui-router states. Ben's angular-node npm 
package tries to address this by using jsdom when you are in a NodeJS 
context.

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to