HN2new | past | comments | ask | show | jobs | submitlogin

A module is already scoped in node.js. It would be nice to have scoped require in the browser too, instead of just global import.

Splitting up a program, or module, into (more) modules does not make it simpler, rather contrary, it makes it more complex! Unless it's a fully decoupled abstraction reusable in other projects.

An example of require-ing within individual functions: A function to send notifications to e-mail or SMS ... It makes more sense to require the SMTP or SMS module in those functions, then somewhere else.



ES6 modules do get their own scope in the browser. That's kind of the point of them.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: