Skip to content

Prevent angular from being required explicitly #164

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

Closed
wants to merge 1 commit into from

Conversation

piotrd
Copy link

@piotrd piotrd commented Dec 8, 2015

Similar to the following PR: videogular/bower-videogular#9. Placing angular as a dependency in index.js causes WARNING: Tried to load angular more than once..

Similar to the following PR: videogular/bower-videogular#9. Placing angular as a dependency in `index.js` causes `WARNING: Tried to load angular more than once. Angular JS`.
@oblador
Copy link
Owner

oblador commented Dec 8, 2015

If you are not using angular as an npm module with browserify there are shims to get it from the window object instead. If you don't want to do that then I'd suggest you'd do require('angular-scroll/angular-scroll'); instead.

@piotrd
Copy link
Author

piotrd commented Dec 8, 2015

I am using browserify-shim to get angular, just like you described. The problem is that if I do require('angular-scroll) I get Tried to load angular more than once. Why not allow people require angular where they want, instead of requiring it in your package?

@oblador
Copy link
Owner

oblador commented Dec 8, 2015

Because it's against the whole point of browserify :-) It sounds like your browserify-shim setup is wrong somehow, if you can't/won't fix that just use require('angular-scroll/angular-scroll'); instead like I suggested.

Thanks for your contribution though, much appreciated! 👍 💯

@oblador oblador closed this Dec 8, 2015
@piotrd
Copy link
Author

piotrd commented Dec 9, 2015

The setup is fine, it's just a long story ;) Thanks for the tip, will use your method.

@piotrd
Copy link
Author

piotrd commented Dec 9, 2015

@oblador: I think this leans toward not using explicit require('angular'); in modules: angular/angular.js#10732 (comment)

At least dozens of modules I use don't do that. I must say yours is an exception.

@oblador
Copy link
Owner

oblador commented Dec 9, 2015

@piotrd: no it means they will use the same the same technique as this module actually :-)

@oblador
Copy link
Owner

oblador commented Dec 9, 2015

Suggested usage, copy pasted from the comment:

var angular = require('angular');
angular.module('myMod', [
  require('angular-animate'),
  require('angular-mocks/ngMock')
  require('angular-mocks/ngAnimateMock')
]);

@piotrd
Copy link
Author

piotrd commented Dec 10, 2015

Yeah, I've read that, but I looked at it in a different way. On a second thought it seams like your way is the correct one ;) And, what's more, it seems like all other packages should get their index.js updated to include require('angular');.

Thanks again.

@piotrd piotrd deleted the patch-1 branch December 10, 2015 08:23
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

Successfully merging this pull request may close these issues.

2 participants