amdjs / amdjs-api

Houses the Asynchronous Module Definition API
https://groups.google.com/group/amd-implement
4.31k stars 499 forks source link

why is `id` optional? define(id?, dependencies?, factory); #10

Closed tlindig closed 11 years ago

tlindig commented 11 years ago

Is there a cogent reason that parameter id is optional?

I would prefer, that it would be required.

If so, the implementation of define could be run free of file specific context and would be easy and resource load could be done with better performance.

If not, define have to get the default id from the requested script filename and so it needs for every loaded module a own context.

jrburke commented 11 years ago

Anonymous define calls are important to allow code to be moved around to different file names/directories and still work. There are no plans to force the id argument, as the anonymous modules have been very useful in practice.

unscriptable commented 11 years ago

Just adding more useful and relevant (imho) info for @tlindig: ES6 allows modules to be anonymous (no id). CommonJS only has anonymous modules.