pandastrike/haiku9

update reference docs

Opened this issue · 1 comments

update reference docs
f1337 commented

Not sure where this belongs. Will happily move to the appropriate destination.

Using modular JS/CS w/ h9 isn't super intuitive. Some documentation would be helpful. Initial notes:

  1. Create a directory for your modular JS/CS code under assets/js, beginning with and underscore (_):

    mkdir -p assets/js/_mymodule
    
  2. Create a package.json file, and give this module a name. The code in this directory will be compiled to assets/js/#{name}.js.

    {
      "name": "mymodule",
      "dependencies": {
      }
    }
    
  3. Now you can require code from other files (in assets/js/_mymodule/somefile.js):

    thing = require("./thing.js")
    

You can also require npm modules:

  1. Install the npm module:

    cd assets/js/_mymodule
    npm install --save request
    
  2. Require it in your code (in assets/js/_mymodule/somefile.js):

    request = require("request")