Releasing for the Web

These instructions assume your WhaleJS project is located in $PROJECT directory.

  1. Install Python 3.

  2. Install Emscripten.

  3. Download and extract WhaleJS Emscripten build. Let’s assume extracted files are located in $WHALE directory.

  4. Activate Emscripten in your shell.

    $ source emsdk_env.sh
    
  5. Package your files with file_packager.py.

    $ python3 $EMSDK/upstream/emscripten/tools/file_packager.py \
        my_project.data \
        --preload $PROJECT@/my_project \
        --js-output=my_project.js
    

    This will create two files:

    • my_project.data - File containing all packaged files from the project directory.

    • my_project.js - Script loading packaged files. It places them in /my_project directory of Emscripten virtual filesystem.

  6. Gather files generated in step 5 and the following files in a single directory:

    • $WHALE/bin/index.html

    • $WHALE/bin/whalejs.js

    • $WHALE/bin/whalejs.wasm

  7. Edit index.html to load your project.

          canvas: canvasElement,
          // Select directory with your project files in filesystem package.
          arguments: ['demo']
        };
      </script>
      <script async type="text/javascript" src="whalejs.js"></script>
      <!-- Select filesystem package with your project files. -->
      <script async type="text/javascript" src="demo.js"></script>
    </body>
    

    In above fragment change all occurrences of demo to my_project.

The newly created project directory is now ready for deployment.