A command line tool to help with the code on demand

Usage no npm install needed!

<script type="module">
  import focusonCod from 'https://cdn.skypack.dev/@focuson/cod';


Code on Demand CLI

This is a cli tool to help with the Code On Demand project. It transpiles normal react components suitable for use as code on demand components


npm i --global  @focuson/cod

To validate it worked: the following should give a 'usage message'



Currently there is only cod build

cod build

  -src, --source <source>             directory having components to build (default: "src/render")
  -dsrc, --datasource <datasource>    directory having JSON data (default: "src/json")
  -dest, --destination <destination>  directory for saving files after build (default: "public/created")
  -d, --debug                         If specified some commands output more information about how they are working
                                      (default: false)
  -f, --force                         To create destination directory if not found
  • The components to be transpiled should be in the --source directory.
  • Any json files that will be used to load and display the componets are in the --datasource directory
  • The created files are put in the --destination directory

json syntax

If you have a file in src/render called 'Game.tsx' then the following will be replaced by the correct details for the Game component

  "_links":  {
    "game1": {"href": "created/gameJson1.json"}
  "_render": {"_self": "#Game/render#"}