Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem initializing module with Browserify dependency management #42

Open
bencpeters opened this issue Apr 14, 2015 · 0 comments
Open

Comments

@bencpeters
Copy link

When using Browserify to load in angular-dc, I'm getting a "cannot read property 'module' of undefined" error. I'm loading angular-dc as follows:

require('angular-dc');

var app = angular.module('MyApp', ['angularDc']);

The issue is, with Browerify-style imports, we get into this branch of the module logic at the beginning of angular-dc.js:

    } else if (typeof exports === 'object') {
        // Node. Does not work with strict CommonJS, but
        // only CommonJS-like enviroments that support module.exports,
        // like Node.
        module.exports = factory();

This calls the factory function with no arguments, so angular, dc, _, and d3 are all undefined.

It should be fixable by changing to module.exports = factory; (don't call factory, just export the function). Then we could load the module using browserify as follows:

require('angular');

var _ = require('underscore')
  , d3 = require('d3')
  , dc = require('dcjs');

require('angular-dc')(angular, dc, _, d3);

var app = angular.module('MyApp', ['angularDc']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant