Is there any concrete reason why you consider exporting a string as the
better alternative to exporting the actual Angular module?
I've been wrapping Angular modules up in CommonJS for quite some time with
Webpack. To register a dependency on another module is as easy as:
Angular.module("myModule", [ require("angular-animate").name ]);
This is the approach I took because within my own code, there are cases
where I might want to add additional services, directives, etc to an
already-defined module. If I can require() that module and be returned the
actual module instance, this is quite clear and intuitive. However, if
instead every require needed to instead be: var myExistingModule =
angular.module(require("myExistingModule")) that seems to be an extra step
of unnecessary indirection.
Here is a gist of the approach I use for packaging modules in Webpack for
those who are
curious: https://gist.github.com/ggoodman/149751343c22892b9871 Skip through
to 'why go through the hassle' for an example of code using this approach.
You will also note that I developed a very simple loader for Webpack to
allow me to make this approach work with modules not otherwise designed
like this: https://github.com/filearts/ng-loader/blob/master/index.js
Geoff
On Tuesday, January 13, 2015 at 11:01:54 PM UTC-5, Ben Clinkinbeard wrote:
>
> It would use the existing packages, but it doesn't affect any existing use
> cases. It is simply adding support for `require()` via Browserify and
> webpack.
>
--
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.