The AMD spec needs require.registry (or require.defined, or require.bikeshed)

128 views
Skip to first unread message

Devin Torres

unread,
Aug 14, 2013, 3:20:01 PM8/14/13
to amd-im...@googlegroups.com
I'm going to be really bad at this, but please hear me out:

The AMD spec currently specifies no way to get a list of all the currently `define`d modules.

For our use cases with Ember.js, we need a way to check if the module has been `define`d before we require it. It is unacceptable to wrap the the require in a try/catch block for reasons I hope are obvious. We would like a user to be able to use any AMD compatible loader be it Almond/RequireJS/whatever and not depend on loader specific behaviour, thus we hope all AMD implementers can agree that this needs to be part of the spec.

Context:


John Hann

unread,
Aug 14, 2013, 9:33:34 PM8/14/13
to amd-im...@googlegroups.com
Hey Devin,

I can certainly understand why you'd want a feature like this.  At one point, I thought it was a necessary feature.  However, as James pointed out in the almond.js PR, it's problematic for the more advanced environments / loaders and it's a dangerous feature for end users.  

Ember isn't the first framework / toolkit to want this feature.  It took the dojo toolkit team over a year to finally figure out how to remove proprietary functions very similar to what you're suggesting out of their codebase.  We, the cujoJS toolkit team, also struggled with it for a short time.  However, we all (dojo and cujoJS) discovered that it was our mental model and code that were flawed, not the spec.  

In summary, what you're asking for would be disastrous and cause more problems than it would fix since devs would start using it in *application code*.  

Sorry if this wasn't the answer you were looking for, but I think the Ember team needs to take another look at its architecture if it wants to work with async modules.  In a 100% async architecture, there is no need to synchronously check for a module.

Regards,

-- John




--
You received this message because you are subscribed to the Google Groups "amd-implement" group.
To unsubscribe from this group and stop receiving emails from it, send an email to amd-implemen...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages