Do AMD loaders need the ability to initiate a module resolution other than "define?"

In a discussion of the tangential aspect of the AMD minimum bootloader that I am working on, James Burke wrote:

There must be some way to let go of the resolution of the modules besides just define (). define () themselves should simply register the existence of a module definition, but not immediately execute the factory function. This will more closely meet people's expectations from other loaders and the way they more closely correspond to the behavior of dynamically loaded modules, factory functions are called only because they are part of the top-level load dependency tree.

If anyone knows about AMD, this is that guy. However, I wonder if he can misunderstand how my loader works. It does not immediately execute the factory, but immediately begins to resolve dependencies when called define.

Essentially, my loader uses definefor the very same thing that RequireJS uses global requirefor, which makes sense to me, given that the functions perform very similar things, and their signatures are almost identical.


To a new thread on the AMD Developers mailing list, I replied:

AMD, , . API - define. define, ( ). , factory.

, - , ? , , , , , ?


, . , AMD. - define , ? , , , , - , .

:

  • define, ( ).

  • ( ), factory.

  • API require.

( ) , , - RequireJS?


: thread , . - . , , .


downvotes : , , , . , ; - , , - , , , , .

+4
1

, , , , ?

, , . define , require .

AMD , . :

require() - , scope, define(). a global require, , require require(), : [...]

API, , ; , require() .

.

+2

Source: https://habr.com/ru/post/1548316/


All Articles