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

Simplify modules like Array to not export the global object. #576

Open
andrewplummer opened this issue Jan 15, 2017 · 0 comments
Open

Simplify modules like Array to not export the global object. #576

andrewplummer opened this issue Jan 15, 2017 · 0 comments
Labels

Comments

@andrewplummer
Copy link
Owner

Sugar currently allows requiring by "module", however all modules return the global object:

require('sugar');
require('sugar/array');
require('sugar/enumerable');

All of the above return simply the root Sugar object. The reason for this is that modules are simply packages for convenience, and may define methods for different types. For example, the enumerable package defines methods on both Array and Object that share common code. Other modules are es5, es6, and es7, which define polyfills, as well as inflections and language, which define extra methods on String that are complex, and not desirable in most contexts.

The proposal here is to simplify this so that require('sugar/array') would return Sugar.Array instead of Sugar. This would unfortunately mean that sugar/enumerable would either have to not exist any more, or continue to return the global Sugar object, which could be confusing. Alternatively, modules could continue to exist, but simply as their npm package names (sugar-enumerable, etc), and just be collections of like methods, but no longer carry any meaning in Sugar itself.

I'm considering different approaches and open to input here.

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

No branches or pull requests

1 participant