Dependencies

This topic applies to

Applies to

SuiteCommerce Advanced

Every JavaScript file in the SCA source contains the same general structure that corresponds to Asynchronous Module Definition (AMD) API. RequireJS uses the AMD API to asynchronously load modules within the application. The following shows the general structure of each file:

define('<module_name>'
,
   [   '<dependency_1>'
   ,
      '<dependency_2>'.
      ...
   ]

   function (
      <module_1>
   ,   <module_2>
      ...
   )

)
{
      <module code>
}

All files within a module contain one define function which occurs at the beginning of the file and uses the following syntax:

define(module_id, [dependencies], function)
  • module_id — a string defining the name of the module.

  • dependencies — an array containing the names of the dependencies. In SCA, this is generally the name of a module, a component within a module, or a core dependency.

  • function — defines a function that instantiates the module.

By following this structure consistently, the developer tools can compile the application into a single JavaScript file by calculating the cascading dependencies starting with the root level application modules down to each lower-level feature and utility modules. See Core SuiteCommerce Advanced Developer Tools for more information.