update reference docs
Opened this issue · 1 comments
dyoder commented
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:
-
Create a directory for your modular JS/CS code under
assets/js
, beginning with and underscore (_
):mkdir -p assets/js/_mymodule
-
Create a
package.json
file, and give this module a name. The code in this directory will be compiled toassets/js/#{name}.js
.{ "name": "mymodule", "dependencies": { } }
-
Now you can
require
code from other files (inassets/js/_mymodule/somefile.js
):thing = require("./thing.js")
You can also require
npm modules:
-
Install the npm module:
cd assets/js/_mymodule npm install --save request
-
Require it in your code (in
assets/js/_mymodule/somefile.js
):request = require("request")