{"record":{"id":"27d84a6b510e083e","repo":"parcel-bundler/parcel","slug":"dependency-not-found","errorCode":null,"errorMessage":"Dependency not found","messagePattern":"Dependency not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/core/src/public/MutableBundleGraph.js","lineNumber":86,"sourceCode":"\n  addEntryToBundle(\n    asset: IAsset,\n    bundle: IBundle,\n    shouldSkipDependency?: IDependency => boolean,\n  ) {\n    this.#graph.addEntryToBundle(\n      assetToAssetValue(asset),\n      bundleToInternalBundle(bundle),\n      shouldSkipDependency\n        ? d => shouldSkipDependency(new Dependency(d, this.#options))\n        : undefined,\n    );\n  }\n\n  createBundleGroup(dependency: IDependency, target: Target): IBundleGroup {\n    let dependencyNode = this.#graph._graph.getNodeByContentKey(dependency.id);\n    if (!dependencyNode) {\n      throw new Error('Dependency not found');\n    }\n\n    invariant(dependencyNode.type === 'dependency');\n\n    let resolved = this.#graph.getResolvedAsset(\n      dependencyToInternalDependency(dependency),\n    );\n    if (!resolved) {\n      throw new Error(\n        'Dependency did not resolve to an asset ' + dependency.id,\n      );\n    }\n\n    let bundleGroup: InternalBundleGroup = {\n      target: targetToInternalTarget(target),\n      entryAssetId: resolved.id,\n    };\n","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/core/core/src/public/MutableBundleGraph.js#L68-L104","documentation":"`MutableBundleGraph.createBundleGroup(dependency, target)` looks up the dependency by its content key in the internal graph. If no node with that id exists, the dependency was never added (or has been removed) and creating a bundle group around it is impossible. The same method separately checks that the dependency resolves to an asset.","triggerScenarios":"A custom packager calls `createBundleGroup(dep, target)` with a dependency object whose `id` is not present in the bundle graph (e.g. from a stale reference, a different graph, or before `addDependency`).","commonSituations":"Holding onto a dependency reference across graph rebuilds; constructing a Dependency manually rather than obtaining it from `addDependency`.","solutions":["Obtain the dependency from `asset.addDependency(...)` or the graph's own APIs rather than caching it.","Before calling `createBundleGroup`, verify the dependency is still in the graph.","Re-resolve dependencies after any graph mutation that may have removed nodes."],"exampleFix":"// before\nconst dep = cachedDependency; // may be stale\ngraph.createBundleGroup(dep, target);\n\n// after\nconst dep = graph.getDependencies(asset)[0];\nif (dep) graph.createBundleGroup(dep, target);","handlingStrategy":"validation","validationCode":"// Confirm the dependency exists in the graph before grouping.\nconst node = graph._graph.getNodeByContentKey(dependency.id);\nif (!node) throw new Error(`dependency ${dependency.id} not in graph`);\ngraph.createBundleGroup(dependency, target);","typeGuard":"function dependencyInGraph(graph: any, id: string): boolean {\n  return graph._graph.getNodeByContentKey(id) != null;\n}","tryCatchPattern":null,"preventionTips":["Obtain dependencies from the graph itself, not cached references.","Re-resolve dependencies after graph mutations.","Validate id presence before createBundleGroup in custom packagers."],"tags":["bundler","dependency-graph","plugin"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}