IClientSideComponentLoaderConfiguration interface

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

This interface describes how a client-side component is to be loaded and initialized by a SharePoint client framework. It contains all data for loading an entrypoint script and its dependency scripts.

Properties

entryModuleId

This is the ID of one of the entries in the "scriptResources" dictionary.

exportName

The module referenced by the "entryModuleId" field may export an object with several fields.

internalModuleBaseUrls

This is an array of fully-qualified paths to be prepended to each of the script resource paths with the "internal" or "localized" type. If one fails to load, the loader will attempt to load from the next until there are no base paths remaining.

scriptResources

This is a dictionary of named script resources. path and localizedPath modules may reference each other and manifest modules are expected to be provided by the framework runtime. The resource named in the entryModuleId must contain the component's exported object.

Property Details

entryModuleId

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

This is the ID of one of the entries in the "scriptResources" dictionary.

entryModuleId: string;

Property Value

string

Remarks

The loader will download and evaluate the script resource referenced in this field, resolve all dependencies against the keys in the "scriptResources", and return the exported object to the loader's calling function. The entry referenced in the "scriptResources" dictionary must be of the "internal" or the "localized" type.

Supported values: An entry in the "scriptResources" dictionary that defines the base exported module of the component.

Example: "myApplication.bundle"

exportName

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

The module referenced by the "entryModuleId" field may export an object with several fields.

exportName?: string;

Property Value

string

Remarks

This value optionally references the name of a field on the object exported by the module referenced by the entryModuleId field. When this field has a value, the value of the referenced field on the object exported by the module referenced by the entryModuleId field is returned when this manifest is loaded instead of the base exported object. For example, if entryModuleId refers to a module with with a top-level export of { foo: 'bar', baz: 123 } and:

  • if this field is unset, the value returned by the module loader is { foo: 'bar', baz: 123 }

  • if this field is set to foo, the value returned by the module loader is bar

  • if this field is set to bar, the value returned by the module loader is undefined (as bar is not a key in the top-level export).

Example: mySpWebpart

internalModuleBaseUrls

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

This is an array of fully-qualified paths to be prepended to each of the script resource paths with the "internal" or "localized" type. If one fails to load, the loader will attempt to load from the next until there are no base paths remaining.

internalModuleBaseUrls: string[];

Property Value

string[]

Remarks

All "internal" and "localized" script resources that do not have fully-qualified URLs as their "path" field values must be hosted under each of the paths listed in this property. For example, if an internal module's "path" field value is "master_2015-04-20/my-application.bundle_1928f8a0.js" and this field's value is [ "https://contoso.akamaihd.net/files/", "https://contoso.msecnd.net/files/" ], the loader will first attempt to load this script resource from the URL "https://contoso.akamaihd.net/files/master_2015-04-20/my-application.bundle_1928f8a0.js". If loading from that URL fails, the loader will then attempt to load this script resource from "https://contoso.msecnd.net/files/master_2015-04-20/my-application.bundle_1928f8a0.js". If that URL fails to load, the component will fail to load and an error will be returned. It is important to note that the support for multiple base URLs is purely for failover support. This means that all files must be present on all hosts listed in this field.

Usage: Base URLs for script resources with the "internal" or "localized" type.

Supported values: Any URL that contains all internal scripts referenced in the "scriptResources" dictionary.

Example: [ "https://contoso.akamaihd.net/files/", "https://contoso.msecnd.net/files/" ]

scriptResources

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

This is a dictionary of named script resources. path and localizedPath modules may reference each other and manifest modules are expected to be provided by the framework runtime. The resource named in the entryModuleId must contain the component's exported object.

scriptResources: {
        [name: string]: IModuleConfiguration;
    };

Property Value

{ [name: string]: IModuleConfiguration; }

Remarks

Supported values: A dictionary of named script resources.

Example:

 {
   "myApplication.bundle": {
     "type": "path",
     "path": "master_2015-04-20/my-application.bundle_1928f8a0.js"
   },
   "@microsoft/sp-client-base": {
     "type": "component",
     "id": "af59c2b3-2da7-41fd-8b72-3939817960af",
     "version": "latest"
   },
   "@microsoft/sp-client-preview": {
     "type": "component",
     "id": "4d5eb168-6729-49a8-aec7-0e397f486b6e",
     "version": "latest"
   },
   "jQuery": {
     "type": "component",
     "id": "00000000-0000-0000-0000-000000000000",
     "version": "2.2.4",
     "path": "https://code.jquery.com/jquery-2.2.4.min.js"
   },
   "myApplication_strings": {
     "type": "localizedPath",
     "defaultPath": "master_2015-04-20/my-application_strings_default_af378e0d.js",
     "paths": {
       "en-us": "master_2015-04-20/my-application_strings_en-us_d38ff012.js",
       "fr-fr": "master_2015-04-20/my-application_strings_fr-fr_138af7e4.js"
     }
   }
 }