Alpha: this compiler is under active development and updates will break your projects. Not recommended for real use yet.
Skip to content

Build options ​

Build options change how helix writes the pack, not what it does: optimizer passes and debug helpers.

ts
// helix.config.ts
export default defineConfig({
  name: "game",
  version: v26_3,
  entry: "src/pack.ts",
  out: { datapack: "out" },
  debug: { comments: true },
  optimize: { inline: false },
});
OptionDefaultDoes
debug.sourcesoffMaps each command to the TS line that emitted it
debug.commentsoffAlso writes # <file>:<line> above commands. Implies sources
optimize.inlineonFolds one-command private functions, and ones called from a single plain function line, into their callers
optimize.unrollonWrites fixed-count loops out in place when the copies are small
optimize.grouponMoves lines sharing an execute prefix into one call
optimize.reorderForksonLets grouping run a forked prefix whole per entity
optimize.inferTypesonAdds type= to selectors whose tags only one entity type gets
optimize.internReadsonInterns /compute score reads used more than once
optimize.dedupeonMerges private functions with identical bodies into one file
optimize.splitChainsonSearches an if/elif chain of 16+ branches on one score by range
layout"split"Private functions under zzzprivate/, or "beside" their owner

TIP

dp.keep(fn) keeps one function out of inlining, so it stays a file you can find by name in reports and profiles.

Find the line behind a command ​

debug.comments writes the source line above each run of commands.

text
# src/pack.ts:12
scoreboard players add @s game 1
# src/pack.ts:13
say tick!

debug.sources alone keeps the files clean. helix report then shows a ↳ line under each warning, and the build writes helix-sources.json next to the pack.

TIP

In helix.config.ts, debug applies to dev builds only, so helix build --prod always ships without comments.

Turn an optimization off ​

Turn a pass off to see what it changed, or to rule it out when output looks wrong.

ts
import { Datapack, v26_2, Selector } from "helix";

const dp = new Datapack("game", v26_2, undefined, {
  optimize: { inline: false, group: false },
});

dp.createFunction("tick").build(() => {
  Selector.allPlayers().forEach((p) => p.say("hi"));
});

Open in playground

Compiled output - the real files helix emits for the code above:

txt
execute as @a at @s run say hi
json
{
  "values": [
    "game:tick"
  ]
}
txt
{
  "pack": {
    "description": "game\nCreated using Helix",
    "min_format": [
      107,
      1
    ],
    "max_format": [
      107,
      1
    ]
  }
}

WARNING

reorderForks assumes no entity depends on another's order inside a forked execute. Turn it off if your per-entity lines read each other's state.

Long if/elif chains ​

An if/elif chain checks its branches in order and stops at the first match, so the last of 100 branches costs 100 checks. When every branch tests the same score and no two ranges overlap, splitChains searches by range instead: check the half, then the half of that, down to 8 branches per function.

text
# f.mcfunction
execute if score #x o matches 0..49 run return run function p:zzzprivate/f/if_0_split_14
execute if score #x o matches 50..99 run return run function p:zzzprivate/f/if_0_split_29
Matching branch of 100Flat chainSplit
99th27 us4 us
50th14 us3 us
3rd1.5 us3 us

Times are per call, on a 26.3 server. Chains under 16 branches stay flat, since they're as fast that way. Turn it off if nearly every call matches one of the first few branches.

Set them without a config ​

Pass the same options as the fourth Datapack argument: new Datapack(name, version, target, { debug, optimize, layout }).

Try them in the playground ​

The playground's build menu toggles debug.comments and each optimize pass. There, comments show as line N labels; click one to jump to its line.

See also ​

Released under the MIT License · Credits
These docs were written with AI; the layout and every page have been reviewed by a human.