Skip to main content

Overview

The part-main schematic reads the .nanoforge/{part}.save.json file produced by part-base and generates a fully wired main.ts (or main.js) entry point. It registers all libraries, components, systems, and entities declared in the save file.

Usage

Options

Output path resolution

The generated file is placed at one of the following paths, in priority order:
  1. outFile — if provided explicitly
  2. .nanoforge/editor/{part}/main.{language} — if editor: true
  3. {part}/main.{language} — default

How it works

part-main reads {directory}/.nanoforge/{part}.save.json, builds the full application bootstrap code, then writes the result as the entry point. Every time you add a component, system, or entity through the NanoForge CLI or editor, regenerating part-main keeps the entry point in sync with the save file.

Examples

Generate a client main file:
Generate a server main file with init hooks:
Generate with a custom save file and output path:
Regenerate the editor entry point: