Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aliasing node module with require target seems broken #938

Closed
danielkcz opened this issue Oct 7, 2014 · 2 comments
Closed

Aliasing node module with require target seems broken #938

danielkcz opened this issue Oct 7, 2014 · 2 comments

Comments

@danielkcz
Copy link

Or am I doing something wrong? Simple example, eg. I would like to alias debug/browser.js file so I can call require('dbg').

browserify -r 'debug/browser.js:dbg' -e index.js

The file index.js has only single line with require('dbg'). After running this, you can check out the result there and as you can see at the top, it didn't aliased this thing properly. Although correct file is included in the bundle...

{1:[function(require,module,exports){
    require('dbg')
},{"dbg":undefined}]}

I tried running the command with the --deps argument. Here is the result and everything looks great in there, so it might be some issue in browser-pack?

I am running browserify 5.9.1

@danielkcz
Copy link
Author

Well, I have updated browserify to 6.0.2 and it's broken even more now...

$ browserify -r 'debug/browser.js:dbg' -e index.js -o out.js

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: Cannot find module 'dbg' from 'c:\workspace\test' 
    at c:\Users\Fredy\AppData\Roaming\npm\node_modules\browserify\node_modules\resolve\lib\async.js:50:17
    at process (c:\Users\Fredy\AppData\Roaming\npm\node_modules\browserify\node_modules\resolve\lib\async.s:119:43)

Edit: I've just noticed that debug module uses browser field in package.json, so this should be working, but produces same error as above...

$ browserify -r 'debug:dbg' -e index.js -o out.js

@nathanbowser
Copy link

This might be a duplicate of #850. I'm still on browserify 4.x because of this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants