How do I get started writing a module? Where do I put everything?

Author: Heliomance

So, how do I get started writing a module? I’m an experience JS developer, and I’ve got my project set up in WebStorm, but I have no idea what needs to go where for Foundry to run a module!

Author: zeel

All modules are stored in the [user data]/Data/modules/ folder.
Each module needs a module.json file in its folder, which describes to Foundry what the module is and does.
The module.json is referred to as the manifest.
The module.json is referred to as the manifest.
Whenever a new module manifest is created manually, or modified manually, you will need to reload the Foundry server to refresh those changes.
The manifest will tell Foundry what scripts, stylesheets, languages, etc. to load.
Beyond that, it heavily depends on what you want to do. A simple module like has very little, it’s just a manifest and one single .js file. Foundry will load all the scripts specified in the manifest, if you need to use things like import you will specify those scripts under esmodules otherwise they can be specified under scripts in the manifest.

Most modules will typically begin with one or more Hooks bindings. Unfortunately Hooks aren’t super well documented yet, but we’re working on that.

The most basic usage though, is similar to using event listeners in JS:

Hooks.on('hook', (args) => {
  // Stuff to do

There is also Hooks.once.