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

Remove requireindex, for browserify support #356

Merged
merged 1 commit into from
Jan 12, 2016

Conversation

deathcap
Copy link
Member

Not the most ideal fix but I couldn't find any other feasible solution unfortunately. Background in deathcap/wsmc#19 (comment) but long story short, this change allows using require('mineflayer') in a browserified environment.

Previously I was using require('mineflayer/lib/block') etc. and not accessing the mineflayer index.js at all, but this changed in ca365c3 so I tried to use require('mineflayer').Block instead but then it runs the unbrowserifiable requireindex module. With this PR, index.js can be browserified.

Another option is to include a separate browser.js listing the modules and keep requireindex in the main index.js, but this means it has to be maintained separately. I think making the change to index.js is the simplest solution, although it does mean that this file will have to be updated when new plugins are added. Open to other suggestions but this is the best I could come up with so far (see deathcap/wsmc#19 (comment))

@deathcap
Copy link
Member Author

For what it's worth, I faced a similar problem with voxel-plugins (which also runs under browserify). Various tricks with require() are possible but it is more straightforward and easier to understand in my opinion to make each require explicit (voxel/voxel-plugins#8).

deathcap added a commit to deathcap/wsmc that referenced this pull request Jan 12, 2016
@rom1504
Copy link
Member

rom1504 commented Jan 12, 2016

Yeah, I think it's a good idea to get rid of dynamic requires in general anyway. It's not really a big effort to add a line in index.js for a new plugin.

rom1504 added a commit that referenced this pull request Jan 12, 2016
Remove requireindex, for browserify support
@rom1504 rom1504 merged commit 3d90455 into PrismarineJS:master Jan 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants