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