Module isolation

David Herman dherman at
Mon Jan 18 12:47:04 PST 2010

[Removed Mark's address from Cc to stop my stmp server from complaining]

On Jan 18, 2010, at 12:14 PM, Brendan Eich wrote:

> Copy and paste. I copy prototype- into mybigfatmodule.js, add my special sauce which makes good use of Prototype's extensions to primordials such as Array.prototype, and then purvey it to the world.

I think I mentioned before at a meeting-- I think we should address modules and isolation as separate concerns and likely separate constructs.

If you do that, you can construct new contexts and control explicitly which contexts modules get instantiated in. That way you don't have your modules tightly coupled with instantiations of e.g. the primordials (and there's no reason to limit this to just the primordials). This would also allow explicit control over multiple modules *sharing* contexts -- you don't just want isolation, you also want the ability to control when /not/ to isolate.

Of course, you also want sensible and convenient defaults, both for back-compat and to avoid infecting all code with the general case.

But say you want to use Prototype and a 3rd-party Prototype-based widget, but you also want to use a couple other libraries that expect the primordials to be left alone. You create a separate context for the former two modules & let 'em go to town.


PS I'm not claiming we should prevent people from copying and pasting a bunch of modules into one fat one, if that's what they want/need to do, but we also shouldn't prevent people from using separate modules separately & still controlling isolation. Separating modularity and isolation is a way to do that.

More information about the es-discuss mailing list