Hacker News new | ask | show | jobs
by z3t4 3802 days ago
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.

1 comments

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