Smarter Module Instance Object

Matthew Robb matthewwrobb at
Mon Aug 18 09:17:24 PDT 2014

So today I was thinking about the possibility of having the module instance
object be a function. If it were a function with fairly simple code to
check if the default exports is also a function and if so then apply-invoke
it then you would have a much more useful module instance object.

If you were to do this then either changing it so the unnamed import
returned the module instance object/function instead of the default export
OR using the new `import * as mod from "module"` syntax would get you what
you want much more often than previously.

Here's a gist with kind of what I am saying:

There are a few limitations to this like some of the non-configurables of
functions but it's possible it could instead be a proxy that supports a
call trap or what have you.

Just a thought and I'm sure there are good reasons it's a stupid thought,
just figured I'd rather know why than say nothing.

- Matthew Robb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list