[{"data":1,"prerenderedAt":572},["ShallowReactive",2],{"navigation":3,"-guide-bundler":51,"-guide-bundler-surround":567},[4],{"title":5,"path":6,"stem":7,"children":8,"icon":10},"Getting Started","/guide","1.guide/1.index",[9,11,16,21,26,31,36,41,46],{"title":5,"path":6,"stem":7,"icon":10},"ph:book-open-duotone",{"title":12,"path":13,"stem":14,"icon":15},"Fetch Handler","/guide/handler","1.guide/2.handler","i-fluent:target-24-regular",{"title":17,"path":18,"stem":19,"icon":20},"Server Instance","/guide/server","1.guide/3.server","radix-icons:component-instance",{"title":22,"path":23,"stem":24,"icon":25},"Middleware","/guide/middleware","1.guide/4.middleware","clarity:plugin-line",{"title":27,"path":28,"stem":29,"icon":30},"Server Options","/guide/options","1.guide/5.options","ri:settings-3-line",{"title":32,"path":33,"stem":34,"icon":35},"Bundler Usage","/guide/bundler","1.guide/6.bundler","clarity:bundle-line",{"title":37,"path":38,"stem":39,"icon":40},"Node.js Support","/guide/node","1.guide/7.node","akar-icons:node-fill",{"title":42,"path":43,"stem":44,"icon":45},"AWS Lambda","/guide/aws-lambda","1.guide/8.aws-lambda","clarity:cloud-traffic-line",{"title":47,"path":48,"stem":49,"icon":50},"Using CLI","/guide/cli","1.guide/9.cli","garden:terminal-cli-stroke-12",{"id":52,"title":32,"body":53,"description":561,"extension":562,"meta":563,"navigation":564,"path":33,"seo":565,"stem":34,"__hash__":566},"content/1.guide/6.bundler.md",{"type":54,"value":55,"toc":554,"icon":35},"minimark",[56,65,97,108,114,119,125,199,203,221,226,238,372,375,379,382,547,550],[57,58,59,60,64],"p",{},"Typically ",[61,62,63],"code",{},"srvx"," is to be imported like this.",[66,67,72],"pre",{"className":68,"code":69,"language":70,"meta":71,"style":71},"language-js shiki shiki-themes github-light github-dark github-dark","import { serve } from \"srvx\";\n","js","",[61,73,74],{"__ignoreMap":71},[75,76,79,83,87,90,94],"span",{"class":77,"line":78},"line",1,[75,80,82],{"class":81},"so5gQ","import",[75,84,86],{"class":85},"slsVL"," { serve } ",[75,88,89],{"class":81},"from",[75,91,93],{"class":92},"sfrk1"," \"srvx\"",[75,95,96],{"class":85},";\n",[57,98,99,100,107],{},"The import above automatically resolves the the correct entrypoint for each runtime. Node.js, Deno, Cloudflare, and Bun use ",[101,102,106],"a",{"href":103,"rel":104},"https://nodejs.org/api/esm.html#resolution-algorithm-specification",[105],"nofollow","ESM conditions"," to resolve the correct entrypoint.",[57,109,110,111,113],{},"Normally, when you are directly using ",[61,112,63],{}," in your project without bundling it should work as expected.",[115,116,118],"h2",{"id":117},"using-explicit-imports","Using Explicit Imports",[57,120,121,122,124],{},"Instead of depending on ESM conditions, you can explicitly import ",[61,123,63],{}," for specific runtime:",[66,126,128],{"className":68,"code":127,"language":70,"meta":71,"style":71},"import { serve } from \"srvx/node\";\nimport { serve } from \"srvx/deno\";\nimport { serve } from \"srvx/bun\";\nimport { serve } from \"srvx/bunny\";\nimport { serve } from \"srvx/cloudflare\";\n",[61,129,130,143,157,171,185],{"__ignoreMap":71},[75,131,132,134,136,138,141],{"class":77,"line":78},[75,133,82],{"class":81},[75,135,86],{"class":85},[75,137,89],{"class":81},[75,139,140],{"class":92}," \"srvx/node\"",[75,142,96],{"class":85},[75,144,146,148,150,152,155],{"class":77,"line":145},2,[75,147,82],{"class":81},[75,149,86],{"class":85},[75,151,89],{"class":81},[75,153,154],{"class":92}," \"srvx/deno\"",[75,156,96],{"class":85},[75,158,160,162,164,166,169],{"class":77,"line":159},3,[75,161,82],{"class":81},[75,163,86],{"class":85},[75,165,89],{"class":81},[75,167,168],{"class":92}," \"srvx/bun\"",[75,170,96],{"class":85},[75,172,174,176,178,180,183],{"class":77,"line":173},4,[75,175,82],{"class":81},[75,177,86],{"class":85},[75,179,89],{"class":81},[75,181,182],{"class":92}," \"srvx/bunny\"",[75,184,96],{"class":85},[75,186,188,190,192,194,197],{"class":77,"line":187},5,[75,189,82],{"class":81},[75,191,86],{"class":85},[75,193,89],{"class":81},[75,195,196],{"class":92}," \"srvx/cloudflare\"",[75,198,96],{"class":85},[115,200,202],{"id":201},"using-bundlers","Using Bundlers",[57,204,205,206,211,212,217,218,220],{},"If srvx is being bundled (e.g. by ",[101,207,210],{"href":208,"rel":209},"https://rollupjs.org/",[105],"Rollup"," or ",[101,213,216],{"href":214,"rel":215},"https://esbuild.github.io/",[105],"esbuild","),\nthe bundler also has to run the ESM resolution algorithm during bundling.\nThis means the ",[61,219,63],{}," in the bundle will only work with one specific runtime (usually Node.js).",[222,223,225],"h3",{"id":224},"external-dependency","External Dependency",[57,227,228,229,231,232,237],{},"The simplest way to avoid this is to set ",[61,230,63],{}," as an ",[101,233,236],{"href":234,"rel":235},"https://rollupjs.org/configuration-options/#external",[105],"external dependency"," in your bundler.",[239,240,241,279,340],"code-group",{},[66,242,244],{"className":68,"code":243,"filename":210,"language":70,"meta":71,"style":71},"export default {\n  //...\n  external: [\"srvx\"],\n};\n",[61,245,246,257,263,274],{"__ignoreMap":71},[75,247,248,251,254],{"class":77,"line":78},[75,249,250],{"class":81},"export",[75,252,253],{"class":81}," default",[75,255,256],{"class":85}," {\n",[75,258,259],{"class":77,"line":145},[75,260,262],{"class":261},"sCsY4","  //...\n",[75,264,265,268,271],{"class":77,"line":159},[75,266,267],{"class":85},"  external: [",[75,269,270],{"class":92},"\"srvx\"",[75,272,273],{"class":85},"],\n",[75,275,276],{"class":77,"line":173},[75,277,278],{"class":85},"};\n",[66,280,284],{"className":281,"code":282,"filename":216,"language":283,"meta":71,"style":71},"language-ts shiki shiki-themes github-light github-dark github-dark","import { build } from \"esbuild\";\n\nawait build({\n  //...\n  external: [\"srvx\"], // Add this\n});\n","ts",[61,285,286,300,306,318,322,334],{"__ignoreMap":71},[75,287,288,290,293,295,298],{"class":77,"line":78},[75,289,82],{"class":81},[75,291,292],{"class":85}," { build } ",[75,294,89],{"class":81},[75,296,297],{"class":92}," \"esbuild\"",[75,299,96],{"class":85},[75,301,302],{"class":77,"line":145},[75,303,305],{"emptyLinePlaceholder":304},true,"\n",[75,307,308,311,315],{"class":77,"line":159},[75,309,310],{"class":81},"await",[75,312,314],{"class":313},"shcOC"," build",[75,316,317],{"class":85},"({\n",[75,319,320],{"class":77,"line":173},[75,321,262],{"class":261},[75,323,324,326,328,331],{"class":77,"line":187},[75,325,267],{"class":85},[75,327,270],{"class":92},[75,329,330],{"class":85},"], ",[75,332,333],{"class":261},"// Add this\n",[75,335,337],{"class":77,"line":336},6,[75,338,339],{"class":85},"});\n",[66,341,346],{"className":342,"code":343,"filename":344,"language":345,"meta":71,"style":71},"language-bash shiki shiki-themes github-light github-dark github-dark","esbuild main.ts \\\n    # ...\n    --external:srvx # Add this\n","esbuild (CLI)","bash",[61,347,348,359,364],{"__ignoreMap":71},[75,349,350,352,355],{"class":77,"line":78},[75,351,216],{"class":313},[75,353,354],{"class":92}," main.ts",[75,356,358],{"class":357},"suiK_"," \\\n",[75,360,361],{"class":77,"line":145},[75,362,363],{"class":261},"    # ...\n",[75,365,366,369],{"class":77,"line":159},[75,367,368],{"class":313},"    --external:srvx",[75,370,371],{"class":261}," # Add this\n",[57,373,374],{},"By doing this, srvx won't be included in the final bundle, it needs to be available at runtime.",[222,376,378],{"id":377},"conditions","Conditions",[57,380,381],{},"Another approach is to set the ESM condition manually at bundle time.",[239,383,384,474,522],{},[66,385,387],{"className":68,"code":386,"filename":210,"language":70,"meta":71,"style":71},"import resolve from \"@rollup/plugin-node-resolve\";\n\nexport default {\n  //...\n  plugins: [\n    resolve({\n      preferBuiltins: true,\n      conditions: [\"node\"], // or \"deno\", \"bun\", \"workerd\", etc.\n    }),\n  ],\n};\n",[61,388,389,403,407,415,419,424,431,443,457,463,469],{"__ignoreMap":71},[75,390,391,393,396,398,401],{"class":77,"line":78},[75,392,82],{"class":81},[75,394,395],{"class":85}," resolve ",[75,397,89],{"class":81},[75,399,400],{"class":92}," \"@rollup/plugin-node-resolve\"",[75,402,96],{"class":85},[75,404,405],{"class":77,"line":145},[75,406,305],{"emptyLinePlaceholder":304},[75,408,409,411,413],{"class":77,"line":159},[75,410,250],{"class":81},[75,412,253],{"class":81},[75,414,256],{"class":85},[75,416,417],{"class":77,"line":173},[75,418,262],{"class":261},[75,420,421],{"class":77,"line":187},[75,422,423],{"class":85},"  plugins: [\n",[75,425,426,429],{"class":77,"line":336},[75,427,428],{"class":313},"    resolve",[75,430,317],{"class":85},[75,432,434,437,440],{"class":77,"line":433},7,[75,435,436],{"class":85},"      preferBuiltins: ",[75,438,439],{"class":357},"true",[75,441,442],{"class":85},",\n",[75,444,446,449,452,454],{"class":77,"line":445},8,[75,447,448],{"class":85},"      conditions: [",[75,450,451],{"class":92},"\"node\"",[75,453,330],{"class":85},[75,455,456],{"class":261},"// or \"deno\", \"bun\", \"workerd\", etc.\n",[75,458,460],{"class":77,"line":459},9,[75,461,462],{"class":85},"    }),\n",[75,464,466],{"class":77,"line":465},10,[75,467,468],{"class":85},"  ],\n",[75,470,472],{"class":77,"line":471},11,[75,473,278],{"class":85},[66,475,477],{"className":281,"code":476,"filename":216,"language":283,"meta":71,"style":71},"import { build } from \"esbuild\";\n\nawait build({\n  //...\n  conditions: [\"node\"], // or \"deno\", \"bun\", \"workerd\", etc.\n});\n",[61,478,479,491,495,503,507,518],{"__ignoreMap":71},[75,480,481,483,485,487,489],{"class":77,"line":78},[75,482,82],{"class":81},[75,484,292],{"class":85},[75,486,89],{"class":81},[75,488,297],{"class":92},[75,490,96],{"class":85},[75,492,493],{"class":77,"line":145},[75,494,305],{"emptyLinePlaceholder":304},[75,496,497,499,501],{"class":77,"line":159},[75,498,310],{"class":81},[75,500,314],{"class":313},[75,502,317],{"class":85},[75,504,505],{"class":77,"line":173},[75,506,262],{"class":261},[75,508,509,512,514,516],{"class":77,"line":187},[75,510,511],{"class":85},"  conditions: [",[75,513,451],{"class":92},[75,515,330],{"class":85},[75,517,456],{"class":261},[75,519,520],{"class":77,"line":336},[75,521,339],{"class":85},[66,523,525],{"className":342,"code":524,"filename":344,"language":345,"meta":71,"style":71},"esbuild main.ts \\\n    # ...\n    --conditions:node # or deno, bun, workerd, etc.\n",[61,526,527,535,539],{"__ignoreMap":71},[75,528,529,531,533],{"class":77,"line":78},[75,530,216],{"class":313},[75,532,354],{"class":92},[75,534,358],{"class":357},[75,536,537],{"class":77,"line":145},[75,538,363],{"class":261},[75,540,541,544],{"class":77,"line":159},[75,542,543],{"class":313},"    --conditions:node",[75,545,546],{"class":261}," # or deno, bun, workerd, etc.\n",[57,548,549],{},"By doing this, the bundler will resolve the correct version on srvx for your runtime.",[551,552,553],"style",{},"html pre.shiki code .so5gQ, html code.shiki .so5gQ{--shiki-light:#D73A49;--shiki-default:#F97583;--shiki-dark:#F97583}html pre.shiki code .slsVL, html code.shiki .slsVL{--shiki-light:#24292E;--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8}html pre.shiki code .sfrk1, html code.shiki .sfrk1{--shiki-light:#032F62;--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sCsY4, html code.shiki .sCsY4{--shiki-light:#6A737D;--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .shcOC, html code.shiki .shcOC{--shiki-light:#6F42C1;--shiki-default:#B392F0;--shiki-dark:#B392F0}html pre.shiki code .suiK_, html code.shiki .suiK_{--shiki-light:#005CC5;--shiki-default:#79B8FF;--shiki-dark:#79B8FF}",{"title":71,"searchDepth":145,"depth":145,"links":555},[556,557],{"id":117,"depth":145,"text":118},{"id":201,"depth":145,"text":202,"children":558},[559,560],{"id":224,"depth":159,"text":225},{"id":377,"depth":159,"text":378},"Tips for using srvx with bundlers.","md",{"icon":35},{"icon":35},{"title":32,"description":561},"3BGNkqncTy0BEX584R8cccJ_X3z0mVflt0i8jjm-k-Q",[568,570],{"title":27,"path":28,"stem":29,"description":569,"icon":30,"children":-1},"Provide additional options to customize listening server.",{"title":37,"path":38,"stem":39,"description":571,"icon":40,"children":-1},"Learn more about Node.js compatibility with srvx.",1771317514429]