ForbesLindesay / browserify-middleware

express middleware for browserify, done right
http://browserify.org
MIT License
381 stars 66 forks source link

Support different basedir per browserify() call #18

Closed afbobak closed 10 years ago

afbobak commented 11 years ago

NOTE: Created pull request https://github.com/ForbesLindesay/browserify-middleware/pull/19 for this issue. Should have done that first... sorry.

I have an application structure where the express server is being instantiated in a different module from the handlers and the handlers are injected. Basically something like this:

+--app
    \
     +--http-server
     |  \
     |   +--express 
     +--handler
        \
         +--dependencies

Because the module search is relative to __dirname of the caller (which in fact is the module that creates the express-app) browserify-middleware isn't able to pull in the browser dependencies from the other branch.

A "basedir"-option on the browserify() call would solve that problem, e.g.:

app.use("/js/base.js", browserify(["dependency1", "dependency2"], {
    basedir : __dirname
  });
ForbesLindesay commented 10 years ago

See pr