[{"data":1,"prerenderedAt":218},["ShallowReactive",2],{"navigation":3,"-concepts":61,"-concepts-surround":215},[4,19,37,55],{"title":5,"path":6,"stem":7,"children":8,"icon":10},"Compdi","\u002Fguide","1.guide\u002F1.index",[9,11,15],{"title":5,"path":6,"stem":7,"icon":10},"i-lucide-book-open",{"title":12,"path":13,"stem":14,"icon":10},"Quick start","\u002Fguide\u002Fquick-start","1.guide\u002F2.quick-start",{"title":16,"path":17,"stem":18,"icon":10},"Imports and packages","\u002Fguide\u002Fimports","1.guide\u002F3.imports",{"title":20,"path":21,"stem":22,"children":23},"Lifecycles","\u002Fconcepts","2.concepts\u002F1.index",[24,25,29,33],{"title":20,"path":21,"stem":22},{"title":26,"path":27,"stem":28},"Targets, factories, and inference","\u002Fconcepts\u002Ffactories-and-inference","2.concepts\u002F2.factories-and-inference",{"title":30,"path":31,"stem":32},"Scoped dependencies","\u002Fconcepts\u002Fscopes","2.concepts\u002F3.scopes",{"title":34,"path":35,"stem":36},"Application teardown","\u002Fconcepts\u002Fteardown","2.concepts\u002F4.teardown",{"title":38,"path":39,"stem":40,"children":41},"Build-tool integrations","\u002Fintegrations","3.integrations\u002F1.index",[42,43,47,51],{"title":38,"path":39,"stem":40},{"title":44,"path":45,"stem":46},"Vite","\u002Fintegrations\u002Fvite","3.integrations\u002F2.vite",{"title":48,"path":49,"stem":50},"Rollup and Rolldown","\u002Fintegrations\u002Frollup-and-rolldown","3.integrations\u002F3.rollup-and-rolldown",{"title":52,"path":53,"stem":54},"Rspack and esbuild","\u002Fintegrations\u002Frspack-and-esbuild","3.integrations\u002F4.rspack-and-esbuild",{"title":56,"path":57,"stem":58,"children":59},"API","\u002Fapi","4.api\u002F1.index",[60],{"title":56,"path":57,"stem":58},{"id":62,"title":20,"body":63,"description":206,"extension":210,"meta":211,"navigation":212,"path":21,"seo":213,"stem":22,"__hash__":214},"content\u002F2.concepts\u002F1.index.md",{"type":64,"value":65,"toc":205},"minimark",[66,70,176,179,184,193],[67,68,69],"p",{},"Compdi models dependency lifetime explicitly in the macro that defines it.",[71,72,73,89],"table",{},[74,75,76],"thead",{},[77,78,79,83,86],"tr",{},[80,81,82],"th",{},"Need",[80,84,85],{},"Use",[80,87,88],{},"Behavior",[90,91,92,107,120,137,150,163],"tbody",{},[77,93,94,98,104],{},[95,96,97],"td",{},"One value immediately",[95,99,100],{},[101,102,103],"code",{},"createSingleton",[95,105,106],{},"Constructs and exports one shared value.",[77,108,109,112,117],{},[95,110,111],{},"One value behind an accessor",[95,113,114],{},[101,115,116],{},"defineSingleton",[95,118,119],{},"Returns one shared value and supports lazy initialization.",[77,121,122,125,134],{},[95,123,124],{},"A fresh value per operation",[95,126,127,130,131],{},[101,128,129],{},"createTransient"," or ",[101,132,133],{},"defineTransient",[95,135,136],{},"Returns a factory that constructs on every call.",[77,138,139,142,147],{},[95,140,141],{},"A value selected from ambient context",[95,143,144],{},[101,145,146],{},"createScoped",[95,148,149],{},"Returns a stable proxy and lifecycle controller.",[77,151,152,155,160],{},[95,153,154],{},"A value selected by an explicit key",[95,156,157],{},[101,158,159],{},"defineScoped",[95,161,162],{},"Returns a per-context accessor with lifecycle methods.",[77,164,165,168,173],{},[95,166,167],{},"Full-application cleanup",[95,169,170],{},[101,171,172],{},"defineAppTeardown",[95,174,175],{},"Experimental reverse-order disposal; may be removed.",[67,177,178],{},"Use the narrowest lifecycle that represents the ownership of a value. Shared infrastructure such as configuration and database pools is commonly singleton-scoped. Stateful operation objects are usually transient. Request- or tenant-specific state belongs in a scoped dependency.",[180,181,183],"h2",{"id":182},"a-practical-default","A practical default",[67,185,186,187,189,190,192],{},"Start with ",[101,188,103],{}," for shared infrastructure and ",[101,191,129],{}," for stateful work. Introduce a scoped dependency only when the same context must reuse a value and different contexts must remain isolated.",[67,194,195,196,200,201,204],{},"Continue with ",[197,198,199],"a",{"href":27},"targets, factories, and inference",", or go directly to ",[197,202,203],{"href":31},"scoped dependencies",".",{"title":206,"searchDepth":207,"depth":207,"links":208},"",2,[209],{"id":182,"depth":207,"text":183},"md",{},{},{"title":20,"description":206},"IXmYLhU0gCt0eTN2kUYjax-HPfdESwYTAgCxJ51tmpk",[216,217],{"title":16,"path":17,"stem":18,"description":206,"icon":10,"children":-1},{"title":26,"path":27,"stem":28,"description":206,"children":-1},1785705020731]