DecCF./ˈdɛk.ɛf/

Split a model into JavaScript files

In the calculation model editor, use Add file to create a named .js file. The main model still returns defineModel(...). Other files export inputs, sections or helper calculations for the main model to import.

A new file includes a small working export example. For example, a file named section1.js can contain:

const { input } = deccf;

export const section1 = input.section({
  name: input.str("Anna"),
  amount: input.money(100, deccf.currencies.SEK),
});

Import that section in the main model and register it in preconditions:

import { section1 } from "./section1.js";
const { input, currencies, periods, defineModel } = deccf;

return defineModel({
  currency: currencies.SEK,
  timeline: periods.monthly({ from: "2026-01", count: 12 }),
  preconditions: input.domain({ section1 }),
});

These are ordinary JavaScript import and export declarations. You can also use export { section1 }, export default section1, or import * as pages from "./section1.js". Each file has its own variables; export declarations that other files need. Files may import other files in the same model. Use named .js files without folders and avoid circular imports.

Type / and choose Import another model file for an import example. In a child file, Export input page inserts a section export. The main editor's Two input pages starter demonstrates two pages with two fields each.

The file tabs preserve your draft and cursor while you switch between them. Rename file and Delete file manage the selected file; update any imports that refer to its old name before running. Saving the app saves every model file, and execution history restores the files together with the main model.

If a file contains an error, the preview shows the error without stale inputs or results. Select its line and column to return to that position in the file.

See Organize input pages for sections and aspects, or Create scenarios to select individual fields.