I am developing library A and library B, B depending on A. I would like, using a browser, to combine them myself, so in my browser I could do:
var A = require("A"); var B = require("B");
I would like to link them myself, since I am also developing a C library that depends only on A and if A is included in B, then C will not be available, and if A is in B and C, I have duplicates.
So, I start with the Browning Library A:
browserify -r ./src/A.js:A -o build/A.js
Which works fine, I can distribute A, and other people can develop their applications with it.
Then I look at library B:
browserify -r ./src/B.js:B -o build/B.js
But I now have A twice, A loads independently in the browser and is again packaged with B. So I use the -i option from the browser to prevent it from turning on:
browserify -r ./src/B.js -o build/B.js -i A
But then, when B requires A, it gets an empty object {} instead of a library. Library A, although still accessible from a global area, requiring ("A").
I tried the external thing with -x, but then I can no longer require my library from the global scope.
I managed to get the behavior that I wanted by hacking the generated output of B, forcing the module permission to get A from the previous requirement, which makes me think that there may be a simple solution, but I can not find it.
I am using browser 2.18.1