The require function in WebApps

The require function is available in both server-side and client-side context of a WebApp. Though, not all objects are available in both contexts.

Client

Below is an example of objects available client-side via the require function. Note that only client and common modules are available.

// Client context
var
  _              = require('underscore'), // [example](https://underscorejs.org/)
  $              = require('jquery'), // [example](https://https://jquery.com/)
  redux          = require('redux'), // [example](https://redux.js.org/)

  router         = require('router'), // [example](/docs/webapps/sdk#h-router)
  i18n           = require('i18n'), // [example](/docs/webapps/i18n)
  events         = require('events'), // [example](/docs/webapps/component#h-Appandglobalevents)
  app            = require('app'), // [example](/docs/webapps/component#h-Appandglobalevents)
  store          = require('store'), //[example](/docs/webapps/state-management#h-Store)
  requester      = require('requester'), //[example](/docs/webapps/sdk#h-requester)

  Component      = require('Component'), // [example](/docs/webapps/component)
  ListComponent  = require('ListComponent'), // [example](/docs/webapps/component#h-ListComponent)

  MyComponent    = require('/component/NameOfComponent'), // [example](/docs/webapps/component)  

  myTemplate     = require('/template/nameOfTemplate'), // [example](/docs/webapps/template)
  
  myClientModule = require('/module/client/nameOfClientModule'), // [example](/docs/webapps/module)
  myCommonModule = require('/module/common/nameOfCommonModule'); // [example](/docs/webapps/module)

Server

Below is an example of objects available server-side via the require function. Note that only server and common modules are available.

// Server context, e.g. index.js or a server module
var
  _              = require('underscore'), // [example](https://underscorejs.org/)
  
  router         = require('router'), // [example](/docs/webapps/index.js#h-Routing)
  i18n           = require('i18n'), // [example](/docs/webapps/i18n)

  appData        = require('appData'), // [example](/docs/webapps/configuration#AppData)
  appResource    = require('appResource'), // since 4.5.1 [example](/docs/webapps/resource#h-AppResource)
  appInfo        = require('appInfo'), // since 4.5.3 [example](/docs/webapps/require/appinfo)

  Component      = require('Component'), // [example](/docs/webapps/component)
  ListComponent  = require('ListComponent'), // [example](/docs/webapps/component#h-ListComponent)

  MyComponent    = require('/component/NameOfComponent'), // [example](/docs/webapps/component)  

  myTemplate     = require('/template/nameOfTemplate'), // [example](/docs/webapps/template)
  
  myServerModule = require('/module/server/nameOfServerModule'), // [example](/docs/webapps/module)
  myCommonModule = require('/module/common/nameOfCommonModule'); // [example](/docs/webapps/module)

The SiteVision Public API is also accessible server-side. All interfaces, classes and enums that are anotated with the @Requireable annotation is available via the require function.

// Server context, e.g. index.js or a server module
var
  properties             = require('Properties'),  // since 4.5.2
  propertyUtil           = require('PropertyUtil'),
  resourceLocatorUtil    = require('ResourceLocatorUtil'),
  portletContextUtil     = require('PortletContextUtil'),
  permissionUtil         = require('PermissionUtil'),
  publishingUtil         = require('PublishingUtil'),
  versionUtil            = require('VersionUtil'),
  metadataUtil           = require('MetadataUtil'),
  metadataDefinitionUtil = require('MetadataDefinitionUtil'),
  outputUtil             = require('OutputUtil'),  
  userIdentityUtil       = require('UserIdentityUtil'),
  mimeTypeUtil           = require('MimeTypeUtil'),
  nodeIteratorUtil       = require('NodeIteratorUtil'),
  nodeTreeUtil           = require('NodeTreeUtil'),  
  nodeComparatorUtil     = require('NodeComparatorUtil'),
  nodeFilterUtil         = require('NodeFilterUtil'),
  nodeTypeUtil           = require('NodeTypeUtil'),
  localInboundRestApi    = require('RestApi'),
  ...