CommonJS Module Loading
CommonJS-like functionality has now been integrated with Barista.
- Barista now has CommonJS like functionality, there are two global functions available: require(
) and listBundles();
- Require may perform multiple operations, such as adding additional ‘types’ to the current runtime.
- E.g. to use SharePoint functionality in Barista, one will need to write:
var sp = require(“SharePoint”);
The inclusion of require and it’s functionality lets script developers specify the name of the variable that holds the export object, and minimizes the amount of global variables that would otherwise be included by default.
Require also allows for extensibility: an interface, IBundle, can be implemented by types. If a fully-qualified type name is passed as the string parameter, the type will be loaded and the export object returned. This lets additional bundles be deployed separately from Barista.
- listBundles lists all bundles that are available:
This is a breaking change, existing scripts will need to add the require statements at the top of the script