-
Notifications
You must be signed in to change notification settings - Fork 20
Developer Guide
This page is for contributors who want to change the SW5e Module itself, not just use it.
If you are trying to understand where code lives, how the module hooks into Foundry and DND5e, where to make a change, how compendium data is built, or how to test your work without creating a mess, start here.
Use this page if you want to:
- understand the repo structure before editing anything
- find the right file or layer for a change
- build or rebuild compendium content safely
- test changes in a local Foundry environment
- avoid breaking compatibility, migration paths, or generated content
If you only want to create custom content inside the module’s existing workflows, use Homebrew and Content Authoring instead.
The SW5e Module is a module layered on top of DND5e, not a standalone replacement system.
That means most changes live at the boundary between:
- FoundryVTT core
- the DND5e system
- SW5e-specific patches, templates, styles, localization, and content
When you start a change, do not ask only “what file should I open?” Ask:
- is this a runtime behavior problem?
- a sheet or template problem?
- a style or theme problem?
- a localization problem?
- a migration or normalization problem?
- a compendium source-data problem?
If you answer that first, you will usually save yourself a lot of wasted time.
These are the main layers contributors touch most often:
-
scripts/: runtime hooks, feature logic, custom apps, migrations, and patch layers -
scripts/patch/: DND5e-to-SW5E behavior integration points -
templates/: Handlebars UI structure for sheets and apps -
styles/: LESS and built CSS for module presentation -
languages/: localization strings -
packs/_source/: editable compendium source data -
packs/: generated compendium output -
utils/: helper scripts such as pack tooling and style builds
The most important source-of-truth rule is simple:
- edit
packs/_source/ - build into
packs/
At a high level:
-
scripts/module.mjsis the main runtime entrypoint - feature-specific behavior is usually registered through
scripts/patch/*or nearby runtime files - templates and styles support the runtime layer rather than replacing it
That means a visible UI bug is not always “just a template bug.” It may be:
- a template problem
- a bad render context
- a runtime-prep problem upstream
- or a style scoping problem
If you are working on one of the most support-heavy 1.3.8 systems, start with these file groups.
Start here:
scripts/patch/blaster-reload.mjsscripts/patch/blaster-ammo-ux.mjs
This is the right area when the question involves:
- the Reload control on weapon rows
- private Reload cards
- out-of-ammo or not-enough-ammo interception
- managed blaster magazine behavior
Start here:
scripts/patch/power-bonuses.mjsscripts/powercasting-overrides.mjsscripts/power-casting-ability-config.mjs
This is the right area when the question involves:
- Force or Tech power attack bonuses
- power save DC bonus handling
- save-target DC bonus logic
- Configure Powercasting behavior
- actor override flags for Force-school casting
Start here:
scripts/starship-system-damage.mjsscripts/starship-destruction-saves.mjsscripts/starship-conditions.mjsscripts/starship-token-status.mjsscripts/patch/starship-sheet.mjs
This is the right area when the question involves:
- System Damage
- Destruction Saves
- starship conditions
- Used or Slowed state
- token HUD status sync
- the current
Core | Inventory | Features | Effects | Descriptionworkflow
Start here:
- Themes and Appearance for the current appearance model
- starship and sheet LESS/CSS that still support functional layout and branding
This is the right area when the question involves:
- retained Pause / lightsaber / logo branding after selectable themes were removed in the 1.4.0 feature set
- dialog styling or scope application that still uses module CSS
- icon contrast or control regressions on stock Foundry chrome
Note: scripts/theme.mjs and theme-mode LESS paths described in older notes are removed with the selectable theme system.
Here is the practical version of “where should this change go?”
Check:
languages/en.json- relevant templates
- any prep code that supplies labels or localized summaries
Check:
-
templates/first - then the runtime layer that prepares the template context
Check:
scripts/patch/*- feature-specific runtime files
- data preparation paths
Check:
styles/less/*scripts/theme.mjs- any app-specific theme scope hook
Check:
- migration and normalization paths
- whether the older item needs refresh or re-import
- whether the change belongs to source content rather than runtime code
Check:
packs/_source/- any related normalization or pack-build helper
If you are editing this module, you need to respect migration.
Before calling a change “done,” ask:
- what happens to older world content?
- what happens to copied items?
- what happens to starships created before the current workflow?
- what happens to existing compendium references or old module IDs?
If you skip those questions, you are usually solving only half the problem.
Avoid reintroducing hardcoded assumptions about older module IDs or paths.
If a helper already exists for:
- module ID resolution
- compendium path normalization
- legacy reference cleanup
use the helper instead of introducing a new raw string assumption.
The content workflow is source-first.
That means:
- edit
packs/_source/ - do not hand-edit generated
packs/ - rebuild packs through the documented scripts
If a content change is only visible in source JSON and not in Foundry, the pack build step is probably the missing piece.
A safe workflow looks like this:
- identify the feature area and likely layer first
- confirm whether the change belongs in code, templates, styles, localization, migration, or source content
- edit the source-of-truth location, not a generated artifact
- rebuild what actually needs rebuilding
- test in a local Foundry environment that matches the supported versions
- test the obvious success case and at least one nearby edge case
- call out anything legacy-sensitive, version-sensitive, or still untested
The right test depends on the layer you changed.
Examples:
- patch logic: verify real in-play behavior, not just data prep
- template work: verify both read mode and edit mode
- theme work: verify visibility, icons, and control contrast on the affected surfaces
- source content: verify the built result in Foundry, not just the JSON diff
- migration-sensitive work: compare fresh content and older content when possible
Use Testing & Contribution for more detailed regression checklists.
Use these pages next depending on what you need:
- Developer Reference for fast lookup while you are already coding
- Local Setup and Workflow for rebuild and reload rules
- Testing & Contribution for regression mindset and contribution discipline
- Active Effect Keys if the change involves actor effect paths
If you want the shortest useful summary of this page, it is this:
- figure out the layer before you edit
- treat
scripts/,templates/,styles/,languages/, andpacks/_source/as different kinds of source-of-truth - use the 1.3.8 feature hotspots above when the bug is in blasters, powercasting, starships, or themes
- do not ignore migration or older copied content
- rebuild and retest the layer you actually changed
SW5e Module Wiki
Start here: Home · Getting Started · Feature Overview · Sheets & Features
Popular topics: Blaster Reload and Ammo Use · Themes and Appearance · Starship Sheet Guide · Powercasting Configuration and Overrides
Need help? Troubleshooting · FAQ · Compatibility & Limitations
Working on the module? Developer Guide · Developer Reference · Local Setup and Workflow · Testing & Contribution
For general FoundryVTT help, please use the Foundry VTT Discord, Baileywiki’s Foundry VTT playlist, or Encounter Library’s Foundry VTT Basics playlist.