Coming from RESTApps 1
RESTApps 2 introduces a few changes. If you have worked with RESTApps 1 there are a few differences you should know about.
Loop protection
Sitevision will transform bundled apps (WebApps 2 and RESTApps 2) to protect against infinite loops. The protection process takes place when a bundled app is deployed, as opposed to runtime in RESTApps 1. This may take a couple of seconds depending on the size of the bundled app. A bundled app will not respond to requests before the protection process is complete. Hence, it is not recommended to force-deploy a bundled app in a production environment.
Structure and importing
Structure of RESTApps 1 and 2 are very similar but RESTApps 2 is less rigid. If you needed to create utilities for separating your code it had to be done in the module folder. This is no longer the case.
Imports are no longer done by the require function. Instead, use the import statement and let webpack bundle your app.
Inaccessible requireables
Given the architecture of a bundled app, some app-requireables are inaccessible during render due to no longer being needed or no longer supported:
- require('/module/*')
New properties in manifest.json
The app's manifest.json now accepts two new properties:
- requiredLibs. Specify which libraries Sitevision should provide for an app (React is currently the only library supported). When using Create Sitevision App, React will not be included in the client bundle, instead Sitevision's provided React will be used to avoid multiple instances of React on a single page.(React is only of use to WebApps/Widgets and not to RESTApps).
- bundled. Boolean to tell Sitevision whether this is a bundled app or not.