-
Notifications
You must be signed in to change notification settings - Fork 27
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
Requiring nconf prevents using browserify to "flatten" this module. #1
Comments
@emilyrose Ideally, it's be nice to have a module that works in both the browser and nodejs. Here's a pretty good article on that: http://www.richardrodger.com/2013/09/27/how-to-make-simple-node-js-modules-work-in-the-browser/#.VdH8hHUVhBc Here are some of the issues I've found trying to port (okay, hack) this into the browser:
Regarding "nconf": honestly, I think the read-config-from-file feature can be dropped. It's easy for developers to add this feature themselves, they probably have their own "master" config file anyway, and it causes issues in the browser. If your target audience includes non-developers then command line options might work, but you'll probably want to conditionally exclude that feature when not running in node. I don't see a way to get the "tcp" protocol to ever work in the browser w/o Photon support for websockets (this is what "net-browserify" uses). The TCP API will only work in nodejs and needs to be excluded in the browser version. Maybe drop the protocol altogether once the HTTP API is implemented in the Photon?? This would simplify things... one protocol to rule-them-all. At a minimum I think you have to detect if you're running in node (see above link) and not execute any of that code. Other options I can see:
For the record, I think this module is written well and I'm thankful it's available. Your audience may be broader than developers like myself, but here's what I care about:
This is just the perspective of one developer. Anyways, until the HTTP API is available, it's a moot point. (: Cheers! |
Thank you for taking the time to give such a thorough description! I really appreciate your feedback on this. I think you bring up several very compelling points, and it seems like @lourd has some similar thoughts as well. Perhaps we should continue the discussion over on #2? I agree with you specifically about breaking things up into several modules, and also the filesystem/environment stuff is probably overkill for most people anyway, so that defeats most of the benefit of nconf. |
a simple question from an amateur (non-developer trying to develop something): |
Hi @kefir135, No, this package isn't ready for use in the browser yet. |
This is now fixed! thanks @brewnerd! |
Browserify is a popular solution for converting node modules into a single js file to include in the browser. In my case, I want to include this code in my HTML (Sencha Touch) based mobile app for iPhone/Android.
The "nconf" package is used in one small place in this code, and it causes errors in the browser. Specifically, "Uncaught TypeError: fs.readdirSync is not a function"
There's already a request for nconf to be browserify-friendly (indexzero/nconf#130) but it'd be nice if this project wouldn't use it.
The text was updated successfully, but these errors were encountered: