AMD is asynchronous module definition, Chinese is the meaning of "asynchronous module definition".
The AMD specification defines the rules for defining modules so that the dependencies of modules and modules can be loaded asynchronously.
The AMD specification defines only one function and is a global variable: define (id?,dependencies?,factory)
Here we mainly organize the naming rules of the ID.
ID A string that defines the name of the module, which is optional. If this parameter is not provided, the module name should default to the specified script name requested by the module loader. If the parameter is provided, it must be top-level or relative .
AMD's module naming specification is a superset of the COMMONJS module name specification. The references are as follows:
- The module name is a string made up of one or more forward slashes (/) as delimiters;
- The word must be in camel form or ".", "..." ;
- The module name does not allow the form of a file extension, such as. js;
- The module name can be relative or top-level. If the first letter is "." or ".." is relative;
- The top-level module names are parsed from the conceptual module of the root namespace;
- The relative module name is parsed from the require writing and calling module.
Example of relative module name resolution:
- If the module "A/B/C" Request ": /d ", then resolves to" A/d "
- If the module "A/B/C" Requests "./e", it resolves to "a/b/e"
requireAPI
Description: Https://github.com/amdjs/amdjs-api/wiki/require
AMD specification Chinese version: https://github.com/amdjs/amdjs-api/wiki/amd-(%e4%b8%ad%e6%96%87%e7%89%88)
Currently, the implementation of AMD's library is available RequireJS 、curl 、Dojo 、Nodules
.
Naming rules for module IDs in the AMD specification