Packer's -var-file support is useful for keeping environment values out of templates, but every file currently has to repeat the complete variable set. Add composition support to the existing JSON variable-file loader exposed by FlagJSON.Set.
A variable file may contain a reserved _packer_include member. A string value includes one file; an array of strings includes those files in listed order. Includes are recursive, and relative include paths are resolved relative to the file that declares them, not the process working directory or the original root file. Load included files depth-first. Later files in an include list override earlier ones, then ordinary variables in the including file override every included value. _packer_include is metadata and must never appear in the resulting variables.
Preserve command-line ordering: each successful Set merges into the receiver, retains keys not mentioned by the new file, and lets the newly loaded values override existing ones. Reaching the same shared file from separate include branches is valid. A file may not include itself directly or indirectly, however; detect cycles using absolute, cleaned paths so aliases such as nested/../file.json cannot bypass detection. A cycle error must identify the involved file and describe the problem as a cycle.
Treat every root or included file as one strict variable document: it must contain exactly one top-level JSON object with no trailing JSON, duplicate member names are invalid, and every ordinary variable value must be a JSON string. The include member must be either a string or an array containing only strings. Numbers, booleans, nulls, objects, and arrays remain invalid as ordinary variable values.
Loading is transactional across the whole include graph. If any file is missing or malformed, a cycle is found, or any document/value rule fails, Set returns an error and leaves the receiver exactly as it was before the call, including when earlier includes were valid. Errors must identify the file whose read or contents caused the failure.