ForbesLindesay / browserify-middleware

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

Alias modules? #36

Closed porkchop closed 10 years ago

porkchop commented 10 years ago

Hi :) Is there a way to rename a bundled module? I see that the ability exists in the straight browserify command line docs like so:

browserify -r ./my-file.js:my-module > bundle.js

which (I am pretty sure) allows us to do this client side:

require('my-module')

I can't seem to find the equivalent via api that might work for browserify-middleware? Like something along the lines of

app.get('bundle.js', browserify('./path/to/some-module', {alias: 'newName'}))

allowing this client side:

require('newName')

Thanks for any advice, Aaron

porkchop commented 10 years ago

FWIW everybody, I found an alternate solution to by applying the aliasify transform on my requires to match the name of my dynamcally browserified package.

ForbesLindesay commented 10 years ago

https://github.com/ForbesLindesay/browserify-middleware#browserifymodule-d-expose-dee-options lets you add the "expose" option: https://github.com/substack/node-browserify#brequirefile-opts

You probably should just use the actual name of the module though wherever possible. A lot of things become easier to work with, and it's easier to read the source code and work out where modules come from.

porkchop commented 10 years ago

Thanks Forbes. I'll take a look at that :)