This page demonstrates the various methods of compiling and distributing Saito applications, including compiling and serving directly from an Application (serving) Full Node, or dynamically compiled standalone bundles which users can drag-and-drop install onto their clients.
Even if you plan to use dynamically compiled standalone bundles, it is useful to follow the Application Node Compile steps below and run apps locally to quickly test and debug them.
When building applications with the Saito-Lite-Rust software, Javascript must first be compiled before it can ran on a core-client or served to lite-clients (like browsers).
The core-client is a full node and more specifically, an application node. This software is responsible for compiling and serving compiled applications to lite-clients which can be seen in action when using the apps on Saito.io.
Your application won't be compiled until the compile configuration lists it.
Open the file /saito-lite-rust/config/modules.config.js
.
Add myApp/myApp.js
to core
, lite
or both.
core [
'myApp/myApp.js',
...
lite: [
'myApp/myApp.js',
...
Then navigate to /saito-lite-rust
and compile the Javascript bundle:
> npm run nuke
If this is not your first time compiling the software you can run npm run compile
instead. Once compilation finishes, start Saito by running:
> npm start
Dynamic Module Compilation can be used to compile modules into standalone bundles users can drag-and-drop to install into their browser. This precludes the need for developers to run infrastructure which serves the application bundles.
The following section shows how to compile applications into this format.
Make sure your local Saito node is compiled with both CORE and LITE support of the devtools
module, and then start your server and visit /devtools
in your browser. You will see a drag-and-drop target.
Provide ZIP file of your module directory and a popup will appear confirming the details of the application. If there is an issue reading the .zip file you likely have a problem with the application -- make sure it compiles and runs locally before you attempt to compile for remote installation. Otherwise click the button to generate the application.
Once you click the button, it may take a short while, but your machine will compile your module into a standalone file and download it to your machine. Find that file - this is the application-file that browsers will be able to install.
To install these standalone application packages, click on the top-right menu in any Saito application and click on the Account button below your wallet balance. On the overlay that appears, look for the "+" button that shows up on the top-right of your installed modules.
Click on the add button and you'll get another drag-and-drop target. Drag the application package that you previously compiled into this window.
A popup will appear to confirm installation. Confirm that you want to install this application and click "Install" if so.
Your browser will unpack the application, save it in your wallet and refresh. Once your browser reloads it will load the application you have just installed along with all other modules. You can now toggle it on-or-off like any other module.
npm run compile