{"record":{"id":"c84d8ef05b4e3a34","repo":"vuejs/core","slug":"enum-cache-needs-to-be-initialized-before-creating","errorCode":null,"errorMessage":"enum cache needs to be initialized before creating plugin","messagePattern":"enum cache needs to be initialized before creating plugin","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/inline-enums.js","lineNumber":221,"sourceCode":"  /** @type {EnumData} */\n  const enumData = {\n    declarations,\n    defines,\n  }\n\n  writeFileSync(ENUM_CACHE_PATH, JSON.stringify(enumData))\n\n  return () => {\n    rmSync(ENUM_CACHE_PATH, { force: true })\n  }\n}\n\n/**\n * @returns {[import('rollup').Plugin, Record<string, string>]}\n */\nexport function inlineEnums() {\n  if (!existsSync(ENUM_CACHE_PATH)) {\n    throw new Error('enum cache needs to be initialized before creating plugin')\n  }\n  /**\n   * @type {EnumData}\n   */\n  const enumData = JSON.parse(readFileSync(ENUM_CACHE_PATH, 'utf-8'))\n\n  // 3. during transform:\n  //    3.1 files w/ enum declaration: rewrite declaration as object literal\n  //    3.2 files using enum: inject into esbuild define\n  /**\n   * @type {import('rollup').Plugin}\n   */\n  const plugin = {\n    name: 'inline-enum',\n    transform(code, id) {\n      /**\n       * @type {MagicString | undefined}\n       */","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/vuejs/core/blob/a2b40db9a83b36ed9da3a16403cf8f040262d73f/scripts/inline-enums.js#L203-L239","documentation":"Thrown by inlineEnums() in Vue's internal build script (scripts/inline-enums.js). The plugin reads an enum cache file (ENUM_CACHE_PATH) that a prior build phase must write; if it does not exist, line 221 throws. This is build-tooling plumbing for inlining const enums during the Vue release build, not user-facing runtime code.","triggerScenarios":"Calling inlineEnums() before the cache-generating phase (the prepare/extract step that writes ENUM_CACHE_PATH via writeFileSync). Running only part of the Vue release build pipeline; invoking the rollup config out of order.","commonSituations":"Editing the Vue release scripts and reordering plugins; running a partial build locally; the cleanup callback (rmSync of the cache) running before a second plugin instance is created.","solutions":["Run the cache-initialization phase (the function that writes ENUM_CACHE_PATH) before instantiating the inlineEnums plugin.","Follow the canonical build order in scripts/build.js / rollup config so prepare runs first.","If the cache was removed mid-build, re-run the full build rather than reusing a stale rollup invocation.","Only Vue release maintainers should hit this — verify you are running the documented build entry point."],"exampleFix":"// before\nconst plugin = inlineEnums() // cache not yet written\n\n// after\nconst cleanup = prepareAndWriteEnumCache()\nconst plugin = inlineEnums() // cache exists now\n// ... later: cleanup()","handlingStrategy":"validation","validationCode":"// (Vue release maintainers only) ensure the cache exists before inlineEnums().\nimport { existsSync } from 'fs'\nfunction safeInlineEnums() {\n  if (!existsSync(ENUM_CACHE_PATH)) {\n    throw new Error('Run the enum-cache prepare step before inlineEnums()')\n  }\n  return inlineEnums()\n}","typeGuard":"function enumCacheReady(): boolean {\n  return existsSync(ENUM_CACHE_PATH)\n}","tryCatchPattern":null,"preventionTips":["Run the full Vue release build pipeline in order; do not instantiate inlineEnums() before the prepare phase.","If the cleanup callback ran mid-build, start a fresh build instead of reusing the pipeline.","Only Vue maintainers should touch this; use the documented build entry points."],"tags":["vue","build-tooling","rollup","internal-scripts","const-enum"],"backgroundTag":null,"analyzedSha":"a2b40db9a83b36ed9da3a16403cf8f040262d73f","analyzedAt":"2026-08-12T14:21:14.989Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}