{"record":{"id":"ceadd585c23c99a8","repo":"gatsbyjs/gatsby","slug":"cflag-is-not-part-of-the-available-compiler-fla","errorCode":null,"errorMessage":"${cFlag} is not part of the available compiler flags.","messagePattern":"(.+?) is not part of the available compiler flags\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/babel-preset-gatsby-package/lib/babel-transform-compiler-flags.js","lineNumber":59,"sourceCode":"       * @param {PluginPass} state\n       */\n      Identifier(\n        nodePath,\n        state\n      ) {\n        const identifier = /** @type {Identifier} */ (nodePath.node)\n        const flags = /** @type {IPluginOptions} */ (state.opts).flags\n        const availableFlags = /** @type {IPluginOptions} */ (state.opts).availableFlags\n\n        if (\n          identifier.name === `_CFLAGS_` &&\n          t.isMemberExpression(nodePath.parent)\n        ) {\n          const parentNode = /** @type {MemberExpression} */ (nodePath.parent)\n          const cFlag = /** @type {Identifier} */ (parentNode.property).name\n\n          if (!availableFlags.includes(cFlag)) {\n            throw new Error(\n              `${cFlag} is not part of the available compiler flags.`\n            )\n          }\n\n          nodePath.parentPath.replaceWith(\n            t.stringLiteral(flags[cFlag] ? flags[cFlag] : ``)\n          )\n        }\n      },\n    },\n  }\n}\n","sourceCodeStart":41,"sourceCodeEnd":72,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/babel-preset-gatsby-package/lib/babel-transform-compiler-flags.js#L41-L72","documentation":"Thrown by the Identifier visitor of `babel-transform-compiler-flags` (babel-transform-compiler-flags.js:59). When source code references `_CFLAGS_.<cFlag>`, the plugin checks `availableFlags.includes(cFlag)`; if the accessed flag name is not on the whitelist, the build aborts to prevent silently replacing it with an empty string.","triggerScenarios":"Source code contains `_CFLAGS_.NEW_THING` but `NEW_THING` is not listed in `availableFlags`; renaming a flag in code but not in the build config; copy-pasting code that references a flag the build does not know about.","commonSituations":"Adding a new compiler flag to source without updating the preset's `availableFlags` list; using a flag only defined in a different build configuration; typos in the flag name on either side.","solutions":["Add the missing flag name to the `availableFlags` array in the plugin/preset options.","Check for typos: the name after `_CFLAGS_.` must exactly match an entry in `availableFlags`.","Remove the `_CFLAGS_.<flag>` reference if the flag is no longer used."],"exampleFix":"// before\n// source: if (_CFLAGS_.ENABLE_X) { ... }\n// config: availableFlags: ['PRESERVE_FILE_DOWNLOADS']\n\n// after\n// config:\navailableFlags: ['PRESERVE_FILE_DOWNLOADS', 'ENABLE_X']","handlingStrategy":"validation","validationCode":"function allCflagRefsAreListed(sourceFiles, availableFlags) {\n  const used = new Set()\n  for (const src of sourceFiles) {\n    for (const m of src.matchAll(/_CFLAGS_\\.([A-Za-z0-9_]+)/g)) used.add(m[1])\n  }\n  return [...used].filter(f => !availableFlags.includes(f))\n}","typeGuard":"function isKnownFlag(flagName, availableFlags) {\n  return Array.isArray(availableFlags) && availableFlags.includes(flagName)\n}","tryCatchPattern":null,"preventionTips":["Keep the availableFlags array in sync with `_CFLAGS_.*` references in source.","Generate availableFlags from a single source of truth.","Add a pre-build check that greps for unknown flags."],"tags":["babel","flags","compiler","whitelist"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}