Bunyk Bunyk - 4 months ago 11
Node.js Question

Pass browserify a module, or get module path in node.js

I have two front-end application on Angular. And I made some common library for them. Before I used git submodules, but I want to move to npm. I rewritten that library as node package, and installing it with npm from github repo.

Then I want to pipe it through browserify and integrate with the rest of my Angular code. I am able to

require('MyUtils')
, but then I don't know how to get file of that module to pass to browserify. Is there some property like
__file__
in python? Or is browserify able to take module instead of filename?

Answer

If your apps call require('MyUtils'), Browserify will automatically include the contents of the MyUtils package (and all of its dependencies) in the bundle it outputs.