0

I have written a self contained angular js module using browserify in order to make use of the commonJS/Node style syntax.

The module works fantastic when tested by itself, so I then use gulp to minify and host that on GitHub.

I've then imported that into another app that is also using browserify. When I run browserify it seems to try and rebrowserify the module and causes no end of problems.

I believe this is because the module requires angular and jquery and qtip2. So it's obviously trying to re parse these.

Is there a standard to not parse modules, or is there a way to exclude the browserifying of the modules? Or is it best to not include things like angular and jquery within your modules? I was trying to make them perfectly stand alone, maybe that's unwise?

Many thanks!

James Woodley
  • 501
  • 1
  • 4
  • 18
  • *"Or is it best to not include things like angular and jquery within your modules"* This. If it's being included in another angular app, why would you want it to include it's own angular... that makes it less reuseable, not more. – Kevin B May 28 '15 at 18:23
  • I agree to an extent but what if the consumer isn't using angular? Am I being too broad? Should you always insist on frameworks being available from the consumer? – James Woodley May 28 '15 at 18:26
  • Yes, otherwise you make your code impossible to use for developers who already have the frameworks in place. (impossible, or just **very** inefficient.) – Kevin B May 28 '15 at 18:29
  • You could always make both options available to your users. – Kevin B May 28 '15 at 18:31
  • 2 versions. That's a thought. Thanks for your responses if you put the 2 versions as an answer I'll mark it – James Woodley May 28 '15 at 20:04

1 Answers1

0

I would suggest providing both options, if it is important for you to have a standalone version that includes angular. This will provide people using your code with a total of three ways of using your code: Using the standalone version, the version that only includes the module, and cloning the repository directly and including the source files as part their build process.

I generally use the third option, but people who don't have build processes will likely prefer the first or second.

Kevin B
  • 94,570
  • 16
  • 163
  • 180