Ship only enabled features
A Task runs only when its enabled returns true. Otherwise it’s skipped — run.fn never executes.
But a skipped Task still ships its code. Static imports go into the bundle whether the Task runs or not.
Load a feature’s code with a dynamic import() inside run.fn, and the bundler emits it as a separate chunk. The browser fetches it only when the Task runs.
Disable the Task, and the chunk never loads.
import { compose, createTask } from "@grlt-hub/app-compose"import { themeSelectFeature } from "./theme-select"
const themeSelect = createTask({ name: "theme-select", run: { fn: () => themeSelectFeature() }, // Task is disabled — but the static import above already loaded the module enabled: { fn: () => false },})
const languageSelect = createTask({ name: "language-select", run: { fn: async () => { const { languageSelectFeature } = await import("./language-select") languageSelectFeature() }, }, // Task is disabled — the dynamic import never runs, so the module never loads enabled: { fn: () => false }, // 👇 uncomment to enable — the module will load // enabled: { fn: () => true },})
compose().step([themeSelect, languageSelect]).run()