QwikDev / qwik

Instant-loading web apps, without effort
https://qwik.dev
MIT License
20.84k stars 1.31k forks source link

[🐞] SSG with empty appdoesn't work #5932

Closed allevo closed 8 months ago

allevo commented 8 months ago

Which component is affected?

Qwik Runtime

Describe the bug

The output of npm run build.server is:

% npm run build.server                                                                                                                                                      on main  -1-

> build.server
> vite build -c adapters/static/vite.config.ts

vite v5.1.4 building SSR bundle for production...
✓ 14 modules transformed.
server/@qwik-city-plan.js   0.20 kB
server/entry.ssr.js        33.75 kB
server/q-BSB6CXrI.js       71.17 kB
✓ built in 1.28s

Starting Qwik City SSG...
Missing client manifest, loading symbols in the client might 404. Please ensure the client build has run and generated the manifest for the server build.

Error during SSG
Ne is not iterable (cannot read property Symbol(Symbol.iterator))
  Pathname: /
  Plugin: qwik-ssg
  File: /Users/allevo/repos/qwik-app/server/entry.ssr.js:274:2913
  272|      })(document);
  273|  })();`;function Be(t={}){return Array.isArray(t.events)&&t.events.length>0?(t.debug?Qe:Me).replace("window.qEvents",JSON.stringify(t.events)):t.debug?ze:We}function He(t,e,n){if(!n)return[];const s=e.prefetchStrategy,r=he(e);if(s!==null){if(!s||!s.symbolsToPrefetch||s.symbolsToPrefetch==="auto")return Je(t,n,r);if(typeof s.symbolsToPrefetch=="function")try{return s.symbolsToPrefetch({manifest:n.manifest})}catch(o){console.error("getPrefetchUrls, symbolsToPrefetch()",o)}}return[]}function Je(t,e,n){const s=[],r=t==null?void 0:t.qrls,{mapper:o,manifest:c}=e,i=new Map;if(Array.isArray(r))for(const a of r){const d=a.getHash(),u=o[d];u&&ye(c,i,s,n,u[1])}return s}function ye(t,e,n,s,r){const o=s+r;let c=e.get(o);if(!c){c={url:o,imports:[]},e.set(o,c);const i=t.bundles[r];if(i&&Array.isArray(i.imports))for(const a of i.imports)ye(t,e,c.imports,s,a)}n.push(c)}function Ke(t){if(t!=null&&t.mapping!=null&&typeof t.mapping=="object"&&t.symbols!=null&&typeof t.symbols=="object"&&t.bundles!=null&&typeof t.bundles=="object")return t}function J(){let r=`const w=new Worker(URL.createObjectURL(new Blob(['onmessage=(e)=>{Promise.all(e.data.map(u=>fetch(u))).finally(()=>{setTimeout(postMessage({}),9999)})}'],{type:"text/javascript"})));`;return r+="w.postMessage(u.map(u=>new URL(u,origin)+''));",r+="w.onmessage=()=>{w.terminate()};",r}function Ve(t){const e={bundles:W(t).map(n=>n.split("/").pop())};return`document.dispatchEvent(new CustomEvent("qprefetch",{detail:${JSON.stringify(e)}}))`}function W(t){const e=[],n=s=>{if(Array.isArray(s))for(const r of s)e.includes(r.url)||(e.push(r.url),n(r.imports))};return n(t),e}function Ye(t){const e=new Map;let n=0;const s=(i,a)=>{if(Array.isArray(i))for(const d of i){const u=e.get(d.url)||0;e.set(d.url,u+1),n++,a.has(d.url)||(a.add(d.url),s(d.imports,a))}},r=new Set;for(const i of t)r.clear(),s(i.imports,r);const o=n/e.size*2,c=Array.from(e.entries());return c.sort((i,a)=>a[1]-i[1]),c.slice(0,5).filter(i=>i[1]>o).map(i=>i[0])}function Ze(t,e,n){const s=nt(t==null?void 0:t.implementation),r=[];return s.prefetchEvent==="always"&&Xe(r,e,n),s.linkInsert==="html-append"&&Ge(r,e,s),s.linkInsert==="js-append"?et(r,e,s,n):s.workerFetchInsert==="always"&&tt(r,e,n),r.length>0?_(U,{children:r}):null}function Xe(t,e,n){const s=Ye(e);for(const r of s)t.push(_("link",{rel:"modulepreload",href:r,nonce:n}));t.push(_("script",{"q:type":"prefetch-bundles",dangerouslySetInnerHTML:Ve(e)+";document.dispatchEvent(new CustomEvent('qprefetch', {detail:{links: [location.pathname]}}))",nonce:n}))}function Ge(t,e,n){const s=W(e),r=n.linkRel||"prefetch";for(const o of s){const c={};c.href=o,c.rel=r,(r==="prefetch"||r==="preload")&&o.endsWith(".js")&&(c.as="script"),t.push(_("link",c,void 0))}}function et(t,e,n,s){const r=n.linkRel||"prefetch";let o="";n.workerFetchInsert==="no-link-support"&&(o+="let supportsLinkRel = true;"),o+=`const u=${JSON.stringify(W(e))};`,o+="u.map((u,i)=>{",o+="const l=document.createElement('link');",o+='l.setAttribute("href",u);',o+=`l.setAttribute("rel","${r}");`,n.workerFetchInsert==="no-link-support"&&(o+="if(i===0){",o+="try{",o+=`supportsLinkRel=l.relList.supports("${r}");`,o+="}catch(e){}",o+="}"),o+="document.body.appendChild(l);",o+="});",n.workerFetchInsert==="no-link-support"&&(o+="if(!supportsLinkRel){",o+=J(),o+="}"),n.workerFetchInsert==="always"&&(o+=J()),t.push(_("script",{type:"module","q:type":"link-js",dangerouslySetInnerHTML:o,nonce:s}))}function tt(t,e,n){let s=`const u=${JSON.stringify(W(e))};`;s+=J(),t.push(_("script",{type:"module","q:type":"prefetch-worker",dangerouslySetInnerHTML:s,nonce:n}))}function nt(t){return{...rt,...t}}var rt={linkInsert:null,linkRel:null,workerFetchInsert:null,prefetchEvent:"always"},st="<!DOCTYPE html>";async function ot(t,e){var x;let n=e.stream,s=0,r=0,o=0,c=0,i="",a;const d=((x=e.streaming)==null?void 0:x.inOrder)??{strategy:"auto",maximunInitialChunk:5e4,maximunChunk:3e4},u=e.containerTagName??"html",m=e.containerAttributes??{},w=n,C=B(),q=he(e),v=it(e.manifest);function f(){i&&(w.write(i),i="",s=0,o++,o===1&&(c=C()))}function y(b){const h=b.length;s+=h,r+=h,i+=b}switch(d.strategy){case"disabled":n={write:y};break;case"direct":n=w;break;case"auto":let b=0,h=!1;const Z=d.maximunChunk??0,z=d.maximunInitialChunk??0;n={write(D){D==="<!--qkssr-f-->"?h||(h=!0):D==="<!--qkssr-pu-->"?b++:D==="<!--qkssr-po-->"?b--:y(D),b===0&&(h||s>=(o===0?z:Z))&&(h=!1,f())}};break}u==="html"?n.write(st):(n.write("<!--cq-->"),e.qwikLoader?(e.qwikLoader.include===void 0&&(e.qwikLoader.include="never"),e.qwikLoader.position===void 0&&(e.qwikLoader.position="bottom")):e.qwikLoader={include:"never"},e.qwikPrefetchServiceWorker||(e.qwikPrefetchServiceWorker={}),e.qwikPrefetchServiceWorker.include||(e.qwikPrefetchServiceWorker.include=!1),e.qwikPrefetchServiceWorker.position||(e.qwikPrefetchServiceWorker.position="top")),e.manifest||console.warn("Missing client manifest, loading symbols in the client might 404. Please ensure the client build has run and generated the manifest for the server build."),await $e(e,v);const g=v==null?void 0:v.manifest.injections,l=g?g.map(b=>_(b.tag,b.attributes??{})):void 0,p=B(),S=[];let j=0,N=0;await ke(t,{stream:n,containerTagName:u,containerAttributes:m,serverData:e.serverData,base:q,beforeContent:l,beforeClose:async(b,h,Z,z)=>{var te,ne,re,se,oe,ie,ae;j=p();const D=B();a=await Ee(b,h,void 0,z);const T=[];if(e.prefetchStrategy!==null){const k=He(a,e,v);if(k.length>0){const ce=Ze(e.prefetchStrategy,k,(te=e.serverData)==null?void 0:te.nonce);ce&&T.push(ce)}}const Se=JSON.stringify(a.state,void 0,void 0);T.push(_("script",{type:"qwik/json",dangerouslySetInnerHTML:at(Se),nonce:(ne=e.serverData)==null?void 0:ne.nonce})),a.funcs.length>0&&T.push(_("script",{"q:func":"qwik/json",dangerouslySetInnerHTML:ut(a.funcs),nonce:(re=e.serverData)==null?void 0:re.nonce}));const _e=!a||a.mode!=="static",X=((se=e.qwikLoader)==null?void 0:se.include)??"auto",G=X==="always"||X==="auto"&&_e;if(G){const k=Be({events:(oe=e.qwikLoader)==null?void 0:oe.events,debug:e.debug});T.push(_("script",{id:"qwikloader",dangerouslySetInnerHTML:k,nonce:(ie=e.serverData)==null?void 0:ie.nonce}))}const ee=Array.from(h.$events$,k=>JSON.stringify(k));if(ee.length>0){let k=`window.qwikevents.push(${ee.join(", ")})`;G||(k=`window.qwikevents||=[];${k}`),T.push(_("script",{dangerouslySetInnerHTML:k,nonce:(ae=e.serverData)==null?void 0:ae.nonce}))}return ct(S,b),N=D(),_(U,{children:T})},manifestHash:(v==null?void 0:v.manifest.manifestHash)||"dev"}),u!=="html"&&n.write("<!--/cq-->"),f();const P=a.resources.some(b=>b._cache!==1/0);return{prefetchResources:void 0,snapshotResult:a,flushes:o,manifest:v==null?void 0:v.manifest,size:r,isStatic:!P,timing:{render:j,snapshot:N,firstFlush:c},_symbols:S}}function it(t){if(t){if("mapper"in t)return t;if(t=Ke(t),t){const e={};return Object.entries(t.mapping).forEach(([n,s])=>{e[H(n)]=[n,s]}),{mapper:e,manifest:t}}}}var at=t=>t.replace(/<(\/?script)/gi,"\\x3C$1");function ct(t,e){var n;for(const s of e){const r=(n=s.$componentQrl$)==null?void 0:n.getSymbol();r&&!t.includes(r)&&t.push(r)}}var lt='document.currentScript.closest("[q\\\\:container]").qFuncs=';function ut(t){return lt+`[${t.join(`,
  274|  `)}]`}const dt=null,ft='((i,a,r,s)=>{r=e=>{const t=document.querySelector("[q\\\\:base]");t&&a.active&&a.active.postMessage({type:"qprefetch",base:t.getAttribute("q:base"),...e})},document.addEventListener("qprefetch",e=>{const t=e.detail;a?r(t):i.push(t)}),navigator.serviceWorker.register("/service-worker.js").then(e=>{s=()=>{a=e,i.forEach(r),r({bundles:i})},e.installing?e.installing.addEventListener("statechange",t=>{t.target.state=="activated"&&s()}):e.active&&s()}).catch(e=>console.error(e))})([])',mt=R("qc-s"),pt=R("qc-c"),be=R("qc-ic"),we=R("qc-h"),ge=R("qc-l"),vt=R("qc-n"),ht=R("qc-a"),yt=R("qc-ir"),bt=t=>{const e=window,n=location.pathname+location.search,s="_qCitySPA",r="_qCityHistoryPatch",o="_qCityBootstrap",c="_qCityInitPopstate",i="_qCityInitAnchors",a="_qCityInitVisibility",d="_qCityInitScroll",u="_qCityScrollEnabled",m="_qCityScrollDebounce",w="_qCityScroll",C=f=>{f&&e.scrollTo(f.x,f.y)},q=()=>{const f=document.documentElement;return{x:f.scrollLeft,y:f.scrollTop,w:Math.max(f.scrollWidth,f.clientWidth),h:Math.max(f.scrollHeight,f.clientHeight)}},v=f=>{const y=history.state||{};y[w]=f||q(),history.replaceState(y,"")};if(!e[s]&&!e[c]&&!e[i]&&!e[a]&&!e[d]){if(v(),e[c]=()=>{var f;if(!e[s]){if(e[u]=!1,clearTimeout(e[m]),n!==location.pathname+location.search){const g=t.closest("[q\\:container]").querySelector('a[q\\:key="AD_1"]');if(g){const l=g.closest("[q\\:container]"),p=g.cloneNode();p.setAttribute("q:nbs",""),p.style.display="none",l.appendChild(p),e[o]=p,p.click()}else location.reload()}else if(history.scrollRestoration==="manual"){const y=(f=history.state)==null?void 0:f[w];C(y),e[u]=!0}}},!e[r]){e[r]=!0;const f=history.pushState,y=history.replaceState,g=l=>(l===null||typeof l>"u"?l={}:(l==null?void 0:l.constructor)!==Object&&(l={_data:l}),l._qCityScroll=l._qCityScroll||q(),l);history.pushState=(l,p,S)=>(l=g(l),f.call(history,l,p,S)),history.replaceState=(l,p,S)=>(l=g(l),y.call(history,l,p,S))}e[i]=f=>{if(e[s]||f.defaultPrevented)return;const y=f.target.closest("a[href]");if(y&&!y.hasAttribute("preventdefault:click")){const g=y.getAttribute("href"),l=new URL(location.href),p=new URL(g,l),S=p.origin===l.origin,j=p.pathname+p.search===l.pathname+l.search;if(S&&j)if(f.preventDefault(),p.href!==l.href&&history.pushState(null,"",p),!p.hash)p.href.endsWith("#")?window.scrollTo(0,0):(e[u]=!1,clearTimeout(e[m]),v({...q(),x:0,y:0}),location.reload());else{const N=p.hash.slice(1),P=document.getElementById(N);P&&P.scrollIntoView()}}},e[a]=()=>{!e[s]&&e[u]&&document.visibilityState==="hidden"&&v()},e[d]=()=>{e[s]||!e[u]||(clearTimeout(e[m]),e[m]=setTimeout(()=>{v(),e[m]=void 0},200))},e[u]=!0,setTimeout(()=>{addEventListener("popstate",e[c]),addEventListener("scroll",e[d],{passive:!0}),document.body.addEventListener("click",e[i]),e.navigation||document.addEventListener("visibilitychange",e[a],{passive:!0})},0)}},wt=A(bt,"s_DyVc0YBIqQU"),gt=()=>{{const[t,e]=Ne().chunkForSymbol(wt.getSymbol(),null),n=Pe+"build/"+e;return`(${qt.toString()})('${n}','${t}');`}},qt=async(t,e)=>{var n;if(!window._qcs&&history.scrollRestoration==="manual"){window._qcs=!0;const s=(n=history.state)==null?void 0:n._qCityScroll;s&&window.scrollTo(s.x,s.y);const r=document.currentScript;(await import(t))[e](r)}},St=()=>{const t=gt();Ce();const e=K("nonce"),n=V(be);if(n.value&&n.value.length>0){const s=n.value.length;let r=null;for(let o=s-1;o>=0;o--)n.value[o].default&&(r=L(n.value[o].default,{children:r},1,"zl_0"));return L(U,{children:[r,E("script",{dangerouslySetInnerHTML:t},{nonce:e},null,3,null)]},1,"zl_1")}return Ie},_t=$(A(St,"s_e0ssiDXoeAM")),kt=(t,e)=>new URL(t,e.href),Et=(t,e)=>t.origin===e.origin,ue=t=>t.endsWith("/")?t:t+"/",Lt=({pathname:t},{pathname:e})=>{const n=Math.abs(t.length-e.length);return n===0?t===e:n===1&&ue(t)===ue(e)},Ct=(t,e)=>t.search===e.search,It=(t,e)=>Ct(t,e)&&Lt(t,e),At=t=>t&&typeof t.then=="function",Rt=(t,e,n,s)=>{const r=qe(),c={head:r,withLocale:i=>le(s,i),resolveValue:i=>{const a=i.__id;if(i.__brand==="server_loader"&&!(a in t.loaders))throw new Error("You can not get the returned data of a loader that has not been executed for this request.");const d=t.loaders[a];if(At(d))throw new Error("Loaders returning a promise can not be resolved for the head function.");return d},...e};for(let i=n.length-1;i>=0;i--){const a=n[i]&&n[i].head;a&&(typeof a=="function"?de(r,le(s,()=>a(c))):typeof a=="object"&&de(r,a))}return c.head},de=(t,e)=>{typeof e.title=="string"&&(t.title=e.title),F(t.meta,e.meta),F(t.links,e.links),F(t.styles,e.styles),F(t.scripts,e.scripts),Object.assign(t.frontmatter,e.frontmatter)},F=(t,e)=>{if(Array.isArray(e))for(const n of e){if(typeof n.key=="string"){const s=t.findIndex(r=>r.key===n.key);if(s>-1){t[s]=n;continue}}t.push(n)}},qe=()=>({title:"",meta:[],links:[],styles:[],scripts:[],frontmatter:{}});let fe;(function(t){t[t.EOL=0]="EOL",t[t.OPEN_BRACKET=91]="OPEN_BRACKET",t[t.CLOSE_BRACKET=93]="CLOSE_BRACKET",t[t.DOT=46]="DOT",t[t.SLASH=47]="SLASH"})(fe||(fe={}));const xt=()=>V(we),Tt=()=>V(ge),Nt=()=>pe(K("qwikcity")),Pt=":root{view-transition-name:none}",Dt=async(t,e)=>{const[n,s,r,o]=ve(),{type:c="link",forceReload:i=t===void 0,replaceState:a=!1,scroll:d=!0}=typeof e=="object"?e:{forceReload:e},u=r.value.dest,m=t===void 0?u:kt(t,o.url);if(Et(m,u)&&!(!i&&It(m,u)))return r.value={type:c,dest:m,forceReload:i,replaceState:a,scroll:d},n.value=void 0,o.isNavigating=!0,new Promise(w=>{s.r=w})},jt=({track:t})=>{const[e,n,s,r,o,c,i,a,d,u,m]=ve();async function w(){const[q,v]=t(()=>[u.value,e.value]),f=De(""),y=m.url,g=v?"form":q.type;q.replaceState;let l,p,S=null;if(l=new URL(q.dest,m.url),S=o.loadedRoute,p=o.response,S){const[j,N,P,Y]=S,x=P,b=x[x.length-1];m.prevUrl=y,m.url=l,m.params={...N},u.untrackedValue={type:g,dest:l};const h=Rt(p,m,x,f);n.headings=b.headings,n.menu=Y,s.value=pe(x),r.links=h.links,r.meta=h.meta,r.styles=h.styles,r.scripts=h.scripts,r.title=h.title,r.frontmatter=h.frontmatter}}return w()},Ot=t=>{Ae(A(Pt,"s_RPDJAz33WLA"));const e=Nt();if(!(e!=null&&e.params))throw new Error("Missing Qwik City Env Data");const n=K("url");if(!n)throw new Error("Missing Qwik URL Env Data");const s=new URL(n),r=O({url:s,params:e.params,isNavigating:!1,prevUrl:void 0},{deep:!1}),o={},c=Re(O(e.response.loaders,{deep:!1})),i=M({type:"initial",dest:s,forceReload:!1,replaceState:!1,scroll:!0}),a=O(qe),d=O({headings:void 0,menu:void 0}),u=M(),m=e.response.action,w=m?e.response.loaders[m]:void 0,C=M(w?{id:m,data:e.response.formData,output:{result:w,status:e.response.status}}:void 0),q=A(Dt,"s_fX0bDjeJa0E",[C,o,i,r]);return I(pt,d),I(be,u),I(we,a),I(ge,r),I(vt,q),I(mt,c),I(ht,C),I(yt,i),xe(A(jt,"s_02wMImzEAbk",[C,d,u,a,e,q,c,o,t,i,r])),L(Te,null,3,"qY_0")},Ft=$(A(Ot,"s_TxCFOy819ag")),Ut=t=>E("script",{nonce:me(t,"nonce")},{dangerouslySetInnerHTML:ft},null,3,"1Z_0"),$t=()=>{const t=xt(),e=Tt();return L(U,{children:[E("title",null,null,t.title,1,null),E("link",null,{href:je(n=>n.url.href,[e],"p0.url.href"),rel:"canonical"},null,3,null),E("meta",null,{content:"width=device-width, initial-scale=1.0",name:"viewport"},null,3,null),E("link",null,{href:"/favicon.svg",rel:"icon",type:"image/svg+xml"},null,3,null),t.meta.map(n=>Q("meta",{...n},null,0,n.key)),t.links.map(n=>Q("link",{...n},null,0,n.key)),t.styles.map(n=>Q("style",{...n.props,dangerouslySetInnerHTML:me(n,"style")},null,0,n.key))]},1,"0D_0")},Wt=$(A($t,"s_0vphQYqOdZI")),zt=()=>L(Ft,{children:[E("head",null,null,[E("meta",null,{charSet:"utf-8"},null,3,null),E("link",null,{href:"/manifest.json",rel:"manifest"},null,3,null),L(Wt,null,3,"vp_0")],1,null),E("body",null,{lang:"en"},[L(_t,null,3,"vp_1"),L(Ut,null,3,"vp_2")],1,null)]},1,"vp_3"),Mt=$(A(zt,"s_tntnak2DhJ8"));function Bt(t){return ot(L(Mt,null,3,"Qb_0"),{manifest:dt,...t,containerAttributes:{lang:"en-us",...t.containerAttributes}})}export{Bt as default};
     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ^
  275|  
      at gt (file:///Users/allevo/repos/qwik-app/server/entry.ssr.js:274:2913)
      at AsyncFunction.St (file:///Users/allevo/repos/qwik-app/server/entry.ssr.js:274:3262)
      at AsyncFunction.Ao (file:///Users/allevo/repos/qwik-app/server/q-BSB6CXrI.js:10:5538)
      at AsyncFunction.Q (file:///Users/allevo/repos/qwik-app/server/q-BSB6CXrI.js:10:5472)
      at file:///Users/allevo/repos/qwik-app/server/q-BSB6CXrI.js:11:10238
      at q (file:///Users/allevo/repos/qwik-app/server/q-BSB6CXrI.js:7:1510)
      at file:///Users/allevo/repos/qwik-app/server/q-BSB6CXrI.js:11:10107
      at file:///Users/allevo/repos/qwik-app/server/q-BSB6CXrI.js:8:4615
      at we (file:///Users/allevo/repos/qwik-app/server/q-BSB6CXrI.js:7:1430)
      at oe (file:///Users/allevo/repos/qwik-app/server/q-BSB6CXrI.js:8:4608)
dist/index.html
error during build:
undefined

Instead, I'm expect that works fine.

Reproduction

https://stackblitz.com/edit/qwik-starter-2umwzq?file=package.json

Steps to reproduce

System Info

System:
    OS: macOS 14.3.1
    CPU: (12) arm64 Apple M2 Pro
    Memory: 45.08 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
    Yarn: 1.22.21 - ~/Library/pnpm/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
    pnpm: 8.14.0 - ~/Library/pnpm/pnpm
    bun: 1.0.26 - ~/Library/pnpm/bun
  Browsers:
    Chrome: 122.0.6261.94
    Safari: 17.3.1
  npmPackages:
    @builder.io/qwik: ^1.4.5 => 1.4.5 
    @builder.io/qwik-city: ^1.4.5 => 1.4.5 
    undici: * => 6.7.0 
    vite: ^5.0.12 => 5.1.4 


### Additional Information

The reproduction url refers to a different app, but the issue is the same
wmertens commented 8 months ago

I tried your starter, set the qwik versions to 1.5.0 and could run pnpm build without issues including the SSG build.

Closing because the issue seems fixed, feel free to add comments if not.

allevo commented 8 months ago

This is not fixed with 1.5.0.

This is the output:

% npm run build.server                                                                                                                                                                                                                     on main

> build.server
> vite build -c adapters/static/vite.config.ts

vite v5.1.5 building SSR bundle for production...
transforming (1) @qwik-city-plan[vite-plugin-qwik](warn): useVisibleTask$() runs eagerly and blocks the main thread, preventing user interaction until the task is finished. Consider using useTask$(), useOn(), useOnDocument(), or useOnWindow() instead. If you have to use a useVisibleTask$(), you can disable the warning with a '// eslint-disable-next-line qwik/no-use-visible-task' comment.

  /Users/allevo/repos/qwik-app/src/routes/demo/flower/index.tsx:19:3

✓ 35 modules transformed.
server/build/q-YWg4fP5u.css    3.68 kB
server/entry.ssr.js           18.51 kB
server/@qwik-city-plan.js     21.21 kB
server/q-BRlvjEAg.js         137.37 kB
✓ built in 2.08s

Starting Qwik City SSG...
Missing client manifest, loading symbols in the client might 404. Please ensure the client build has run and generated the manifest for the server build.

Error during SSG
zn is not iterable (cannot read property Symbol(Symbol.iterator))
  Pathname: /
  Plugin: qwik-ssg
  File: /Users/allevo/repos/qwik-app/server/q-BRlvjEAg.js:11:71283

// skip output....

  13 |      This is because the routeLoader$ was not exported in a 'layout.tsx' or 'index.tsx' file of the existing route.
      at od (file:///Users/allevo/repos/qwik-app/server/q-BRlvjEAg.js:11:71283)
      at AsyncFunction.ad (file:///Users/allevo/repos/qwik-app/server/q-BRlvjEAg.js:11:71713)
      at AsyncFunction.Qa (file:///Users/allevo/repos/qwik-app/server/q-BRlvjEAg.js:10:5887)
      at AsyncFunction.te (file:///Users/allevo/repos/qwik-app/server/q-BRlvjEAg.js:10:5821)
      at file:///Users/allevo/repos/qwik-app/server/q-BRlvjEAg.js:11:10533
      at L (file:///Users/allevo/repos/qwik-app/server/q-BRlvjEAg.js:7:1606)
      at file:///Users/allevo/repos/qwik-app/server/q-BRlvjEAg.js:11:10400
      at file:///Users/allevo/repos/qwik-app/server/q-BRlvjEAg.js:8:4732
      at Un (file:///Users/allevo/repos/qwik-app/server/q-BRlvjEAg.js:7:1526)
      at hn (file:///Users/allevo/repos/qwik-app/server/q-BRlvjEAg.js:8:4725)
dist/demo/flower/index.html
error during build:
undefined

The package.json

{
  "name": "my-qwik-basic-starter",
  "description": "Demo App with Routing built-in (recommended)",
  "engines": {
    "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
  },
  "engines-annotation": "Mostly required by sharp which needs a Node-API v9 compatible runtime",
  "private": true,
  "trustedDependencies": [
    "sharp"
  ],
  "trustedDependencies-annotation": "Needed for bun to allow running install scripts",
  "type": "module",
  "scripts": {
    "build": "qwik build",
    "build.client": "vite build",
    "build.preview": "vite build --ssr src/entry.preview.tsx",
    "build.server": "vite build -c adapters/static/vite.config.ts",
    "build.types": "tsc --incremental --noEmit",
    "deploy": "echo 'Run \"npm run qwik add\" to install a server adapter'",
    "dev": "vite --mode ssr",
    "dev.debug": "node --inspect-brk ./node_modules/vite/bin/vite.js --mode ssr --force",
    "fmt": "prettier --write .",
    "fmt.check": "prettier --check .",
    "lint": "eslint \"src/**/*.ts*\"",
    "preview": "qwik build preview && vite preview --open",
    "start": "vite --open --mode ssr",
    "qwik": "qwik"
  },
  "devDependencies": {
    "@builder.io/qwik": "^1.5.0",
    "@builder.io/qwik-city": "^1.5.0",
    "@types/eslint": "^8.56.5",
    "@types/node": "^20.11.24",
    "@typescript-eslint/eslint-plugin": "^7.1.0",
    "@typescript-eslint/parser": "^7.1.0",
    "eslint": "^8.57.0",
    "eslint-plugin-qwik": "^1.5.0",
    "prettier": "^3.2.5",
    "typescript": "5.3.3",
    "undici": "*",
    "vite": "^5.1.4",
    "vite-tsconfig-paths": "^4.2.1"
  }
}
wmertens commented 8 months ago

Your output suggests a different codebase than what you posted as stackblitz?

allevo commented 8 months ago

As mentioned in the additional information, the stackblitz doens't allow me to use the Basic App (Qwik City + Qwik) (Demo App with Routing built-in (recommended)) provided by the CLI. No change is made to the code.

I'm not an expert of stackblitz and I don't know how to "upload" the code there.

wmertens commented 8 months ago

@allevo do you have a repo? Stackblitz can load that as is

allevo commented 8 months ago

Yes: https://github.com/allevo/qwik-ssg

the steps:

rerelurelu commented 8 months ago

@allevo I had the same problem as you, but I got it to work by running pnpm build.client before running pnpm build.server!

PatrickJS commented 8 months ago

@wmertens yeah the errors could be better. for SSG you need to have build.client first

PipocaZalas commented 7 months ago

@PatrickJS I believe this issue should remain open since it is not resolved; you have only implemented a workaround. It appears this way because the documentation does not mention the necessity of running build.client first.

By the way, I am experimenting the same issue even with the last version 1.5.2