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