Naming rules for module IDs in the AMD specification

Source: Internet
Author: User

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"

requireAPIDescription: 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.