Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(optimizer): let the bundler handle entries #6670

Merged
merged 3 commits into from
Aug 1, 2024

Conversation

wmertens
Copy link
Member

@wmertens wmertens commented Jul 11, 2024

This makes the Qwik rollup plugin behave like a normal plugin, and speeds up dev startup.

  • removes entry creating from optimizer
  • adds manualChunks option that tells Rollup which chunks to put together
  • removes building at buildStart so other plugins can transform before the segment splitting

This comment was marked as outdated.

@wmertens wmertens force-pushed the use-bundler-for-entries branch from 201e461 to 7fdea60 Compare July 11, 2024 12:08
@wmertens wmertens changed the title Use-bundler-for-entries fix(optimizer): let the bundler handle entries Jul 11, 2024
@wmertens wmertens changed the title fix(optimizer): let the bundler handle entries fix(optimizer): let the bundler handle entries Jul 11, 2024
Base automatically changed from fix-dev to main July 11, 2024 12:23
Copy link

pkg-pr-new bot commented Jul 11, 2024

commit: e4777bf

npm i https://pkg.pr.new/@builder.io/qwik@6670
npm i https://pkg.pr.new/@builder.io/qwik-city@6670
npm i https://pkg.pr.new/eslint-plugin-qwik@6670
npm i https://pkg.pr.new/create-qwik@6670

Open in Stackblitz

@wmertens
Copy link
Member Author

I'm hoping that we can get traction on rollup/rollup#5574

@wmertens wmertens force-pushed the use-bundler-for-entries branch from 7fdea60 to 457d46e Compare July 11, 2024 15:11
Copy link

netlify bot commented Jul 11, 2024

Deploy Preview for qwik-insights ready!

Name Link
🔨 Latest commit 457d46e
🔍 Latest deploy log https://app.netlify.com/sites/qwik-insights/deploys/668ff60a056a1d0008890d4c
😎 Deploy Preview https://deploy-preview-6670--qwik-insights.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@maiieul
Copy link
Contributor

maiieul commented Jul 11, 2024

Running preview on Qwik UI I get:

Cannot resolve symbol s_18v77IziTO8 in {
I7VYyNnqcIU: [ 's_I7VYyNnqcIU', 'q-BeMFV_d0.js' ],
eFozFs0DibE: [ 's_eFozFs0DibE', 'q-BAp_77SM.js' ],
uT8wKLJfcsw: [ 's_uT8wKLJfcsw', 'q-DRaTmTo_.js' ],
vl5B6UfwsFM: [ 's_vl5B6UfwsFM', 'q-BkfXex-2.js' ],
'02wMImzEAbk': [ 's_02wMImzEAbk', 'q-DBxyvPKu.js' ],
...
wnQa6FTucwo: [ 's_wnQa6FTucwo', 'q-CwaSgWn9.js' ],
wp5ADZk9oYk: [ 's_wp5ADZk9oYk', 'q-BkmjqsAj.js' ],
xAiX3sf6HQg: [ 's_xAiX3sf6HQg', 'q-IhiBiF9P.js' ],
xCze0oKj7Qg: [ 's_xCze0oKj7Qg', 'q-Bu9f0wjm.js' ],
xErO4Q11Rf0: [ 's_xErO4Q11Rf0', 'q-6KZojwbj.js' ],
xUbRbq5KSaU: [ 's_xUbRbq5KSaU', 'q-Cb7y0jXy.js' ],
xVALwjd0b88: [ 's_xVALwjd0b88', 'q-9a20B2Em.js' ],
zBnSnbjGX8Y: [ 's_zBnSnbjGX8Y', 'q-43FTH_K0.js' ],
zJ9EnFolxZ0: [ 's_zJ9EnFolxZ0', 'q-CIG-ugEf.js' ],
zRXNrC3Egh4: [ 's_zRXNrC3Egh4', 'q-DO68g6uG.js' ]
} undefined
serializeQRL: Cannot resolve symbol s_18v77IziTO8 in null undefined
QWIK ERROR Code(31) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L39 s_18v77IziTO8 Error: Code(31) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L39
at Ir (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:18:3022)
at Er (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:18:2945)
at Qe (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:18:3289)
at ul (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:21:31691)
at Object.$serialize$ (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:22:3042)
at rg (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:22:7160)
at file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:21:31147
at Array.map ()
at tc (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:21:30930)
at ec (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:21:27128)
Error: Code(31) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L39
at Ir (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:18:3022)
at Er (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:18:2945)
at Qe (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:18:3289)
at ul (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:21:31691)
at Object.$serialize$ (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:22:3042)
at rg (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:22:7160)
at file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:21:31147
at Array.map ()
at tc (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:21:30930)
at ec (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:21:27128)
file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:18
The request origin "${o}" does not match the server origin "${l}".)}}function nh(n){return async e=>{if(e.headersSent||e.sharedMap.has(Bo))return;e.request.headers.forEach((b,f)=>b);const l=e.headers;l.has("Content-Type")||l.set("Content-Type","text/html; charset=utf-8");const a=Fr(e),{readable:i,writable:d}=new TextEncoderStream,p=e.getWritableStream(),u=i.pipeTo(p,{preventClose:!0}),m=d.getWriter(),y=e.status();try{const b=wt(e)==="static",f=Hp(e),C=await n({base:e.basePathname+"build/",stream:m,serverData:f,containerAttributes:{"q:render":b?"static":"",...f.containerAttributes}}),D={loaders:At(e),action:e.sharedMap.get(vt),status:y!==200?y:200,href:Va(e.url,a)};typeof C.html=="string"&&await m.write(C.html),e.sharedMap.set("qData",D)}finally{await m.ready,await m.close(),await u}await p.close()}}async function oh(n){if(!n.sharedMap.has(Bo))return;try{await n.next()}catch(i){if(!(i instanceof nt))throw i}if(n.headersSent)return;const o=n.status(),l=n.headers.get("Location");if(o>=301&&o<=308&&l){const i=rh(l);if(i){n.headers.set("Location",i),n.getWritableStream().close();return}else n.status(200),n.headers.delete("Location")}}async function th(n){if(!n.sharedMap.has(Bo)||(await n.next(),n.headersSent||n.exited))return;const o=n.status(),l=n.headers.get("Location"),a=Fr(n);n.request.headers.forEach((m,y)=>m),n.headers.set("Content-Type","application/json; charset=utf-8");const i={loaders:At(n),action:n.sharedMap.get(vt),status:o!==200?o:200,href:Va(n.url,a),redirect:l??void 0},d=n.getWritableStream().getWriter(),u=await n[Dt]._serializeData(i,!0);d.write(Bt.encode(u)),n.sharedMap.set("qData",i),d.close()}function rh(n){if(n.startsWith("/")){const e=Hn,o=new URL(n,"http://localhost");return(o.pathname.endsWith("/")?o.pathname.slice(0,-1):o.pathname)+(e.startsWith("/")?"":"/")+e+o.search}else return}function Wl(){return typeof performance<"u"?performance.now():0}async function rt(n,e,o){const l=Wl();try{return await o()}finally{const a=Wl()-l;let i=n.sharedMap.get("@serverTiming");i||n.sharedMap.set("@serverTiming",i=[]),i.push([e,a])}}function lh(n,...e){var o;const l=((o=n.get("content-type"))==null?void 0:o.split(/;,/,1)[0].trim())??"";return e.includes(l)}async function ah(n,e,o){const{render:l,qwikCityPlan:a,manifest:i,checkOrigin:d}=e,p=n.url.pathname,u=zp(p,a.trailingSlash),m=await ih(a,u,n.request.method,d??!0,l);if(m){const[y,b]=m;return Rp(n,y,b,i,a.trailingSlash,a.basePathname,o)}return null}async function ih(n,e,o,l,a){const{routes:i,serverPlugins:d,menus:p,cacheModules:u}=n,m=await Np(i,p,u,e),y=Vp(d,m,o,l,nh(a));return y.length>0?[m,y]:null}const ch=!0,dh=!1,un=n=>n&&typeof n.nodeType=="number",Ya=n=>n.nodeType===9,mn=n=>n.nodeType===1,gn=n=>{const e=n.nodeType;return e===1||e===111},ph=n=>{const e=n.nodeType;return e===1||e===111||e===3},zs=n=>n.nodeType===111,Sr=n=>n.nodeType===3,Fo=n=>n.nodeType===8,Dn=(n,...e)=>Ir(!1,n,...e),Ga=(n,...e)=>{throw Ir(!1,n,...e)},Er=(n,...e)=>Ir(!0,n,...e),rn=()=>{},hh=n=>n,Ir=(n,e,...o)=>{const l=e instanceof Error?e:new Error(e);return console.error("%cQWIK ERROR","",l.message,...hh(o),l.stack),n&&setTimeout(()=>{throw l},0),l};const Ft=n=>Code(${n}) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L${8+n}`,Qe=(n,...e)=>{const o=Ft(n,...e);return Er(o,...e)},uh=()=>({isServer:ch,importSymbol(n,e,o){{const i=uc(o),d=globalThis.__qwik_reg_symbols?.get(i);if(d)return d}if(!e)throw Qe(31,o);if(!n)throw Qe(30,e,o);const l=mh(n.ownerDocument,n,e).toString(),a=new URL(l);return a.hash="",import(a.href).then(i=>i[o])},raf:n=>new Promise(e=>{requestAnimationFrame(()=>{e(n())})}),nextTick:n=>new Promise(e=>{setTimeout(()=>{e(n())})}),chunkForSymbol:(n,e)=>[n,e??""]}),mh=(n,e,o)=>{const l=n.baseURI,a=new URL(e.getAttribute("q:base")??l,l);return new URL(o,a)};let $r=uh();const Wa=n=>$r=n,St=()=>$r,vs=()=>$r.isServer,So=n=>{const e=Object.getPrototypeOf(n);return e===Object.prototype||e===null},Ys=n=>!!n&&typeof n=="object",Ee=n=>Array.isArray(n),ln=n=>typeof n=="string",ys=n=>typeof n=="function",ns=n=>n&&typeof n.then=="function",Et=(n,e,o)=>{try{const l=n();return ns(l)?l.then(e,o):e(l)}catch(l){return o(l)}},ie=(n,e)=>ns(n)?n.then(e):e(n),Tr=n=>n.some(ns)?Promise.all(n):n,Ln=n=>n.length>0?Promise.all(n):n,Ja=n=>n!=null,gh=n=>new Promise(e=>{setTimeout(e,n)}),Xs=[],ls={},Eo=n=>typeof document<"u"?document:n.nodeType===9?n:n.ownerDocument,yh="q:renderFn",As="q:slot",Za="q:s",It="q:style",bh="q:sstyle",ei="q:instance",si=(n,e)=>n["qFuncs"+e]||[],fh="q:id",ar=Symbol("proxy target"),Rn=Symbol("proxy flags"),Ls=Symbol("proxy manager"),t=Symbol("IMMUTABLE"),$t="qc",Ds=(n,e,o)=>n.setAttribute(e,o),Ss=(n,e)=>n.getAttribute(e),Nr=n=>n.replace(/([A-Z])/g,"-$1").toLowerCase(),Ch=n=>n.replace(/-./g,e=>e[1].toUpperCase()),xh=/^(on|window:|document:)/,ni="preventdefault:",Pr=n=>n.endsWith("$")&&xh.test(n),Lr=n=>{if(n.length===0)return Xs;if(n.length===1){const o=n[0];return[[o[0],[o[1]]]]}const e=[];for(let o=0;o<n.length;o++){const l=n[o][0];e.includes(l)||e.push(l)}return e.map(o=>[o,n.filter(l=>l[0]===o).map(l=>l[1])])},Rr=(n,e,o,l)=>{if(e.endsWith("$"),e=ir(e.slice(0,-1)),o)if(Ee(o)){const a=o.flat(1/0).filter(i=>i!=null).map(i=>[e,Zl(i,l)]);n.push(...a)}else n.push([e,Zl(o,l)]);return e},Jl=["on","window:on","document:on"],_h=["on","on-window","on-document"],ir=n=>{let e="on";for(let o=0;o<Jl.length;o++){const l=Jl[o];if(n.startsWith(l)){e=_h[o],n=n.slice(l.length);break}}return e+":"+(n=n.startsWith("-")?Nr(n.slice(1)):n.toLowerCase())},Zl=(n,e)=>(n.$setContainer$(e),n),jh=(n,e)=>{const o=n.$element$.attributes,l=[];for(let a=0;a<o.length;a++){const{name:i,value:d}=o.item(a);if(i.startsWith("on:")||i.startsWith("on-window:")||i.startsWith("on-document:")){const p=d.split(`

Error: Code(31) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L39
at Ir (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:18:3022)
at Er (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:18:2945)
at Qe (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:18:3289)
at ul (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:21:31691)
at Object.$serialize$ (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:22:3042)
at rg (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:22:7160)
at file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:21:31147
at Array.map ()
at tc (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:21:30930)
at ec (file:///Users/maieul/dev/qwik-ui/dist/apps/website/server/entry.preview.mjs:21:27128)

Node.js v20.15.1

I removed a few '0makueonceg': [ 's_0makueonceg', 'q-DU8U_BfN.js' ] lines for brevity ^^

Also I can't print out the symbol file name (#6673) which could help in debugging this further.

@wmertens
Copy link
Member Author

Ok thanks for testing. We'll see what rollup does.

Copy link

changeset-bot bot commented Jul 28, 2024

🦋 Changeset detected

Latest commit: e4777bf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@builder.io/qwik Minor
eslint-plugin-qwik Minor
@builder.io/qwik-city Minor
create-qwik Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@wmertens wmertens force-pushed the use-bundler-for-entries branch from 786141c to 5b43f26 Compare July 28, 2024 10:20
Copy link
Contributor

github-actions bot commented Jul 28, 2024

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
qwik-docs ✅ Ready (View Log) Visit Preview e4777bf

The existing side effects should be retained so that e.g. serviceworker entries don't get cleared out (they are only side effects)
- removes entry creating from optimizer
- adds manualChunks option that tells Rollup which chunks to put together
- removes building at buildStart so other plugins can transform before the segment splitting
the parent information from the dev qrl data is sufficient
@wmertens wmertens force-pushed the use-bundler-for-entries branch from 00b1473 to e4777bf Compare August 1, 2024 17:47
@wmertens wmertens marked this pull request as ready for review August 1, 2024 17:47
@wmertens wmertens requested a review from a team as a code owner August 1, 2024 17:47
@wmertens wmertens merged commit 86d6378 into main Aug 1, 2024
22 checks passed
@wmertens wmertens deleted the use-bundler-for-entries branch August 1, 2024 18:54
This was referenced Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants