Community
Chat Logs
Saturday, May 9, 2026
- * phaleth joined #primate
- phalethjust dump another 5k commits on top of those 15k pre-existing ones https://github.com/oven-sh/bun/tree/claude/phase-a-port
- bot<discord:blue> Lol
- bot<discord:blue> phaleth: [primate-run/primate] Pull request opened: #269 core: remove debug client-side console logs
- bot<discord:blue> Does this work in ssr?
- bot<discord:blue> Ah sorry, wrong pr, stupid phone
- bot<discord:blue> [primate-run/primate] Pull request opened: #271 website: reduce network dependency tree to lower latency
- bot<discord:blue> Meant this
- phalethyeah, that doesn't change anything server-side, it's a change in .svelte file
- bot<discord:blue> Yeah I know
- bot<discord:blue> But this is likely to fail in ssr
- bot<discord:blue> https://github.com/primate-run/primate/blob/master/apps/website/static/localStorage.ts#L8
- phaleththe theme changes just fine, that line of code works
- bot<discord:blue> Crazy
- phalethit's just a merge of two JS chunk into a single JS chunk client side
- phalethtwo JS chunks*
- bot<discord:blue> Did you try npx primate build & npx primate serve?
- bot<discord:blue> On your comp, I mean
- phalethI will try
- bot<discord:blue> Yeah I know, the only reason for that chunk is that localStorage doesn't exist on the global namespace in node
- phalethTypeError: localStorage.getItem is not a function
- phaleth at file:///home/user/primate/primate/apps/website/build/server.js:74:2010
- bot<discord:blue> Yup
- phalethok, so can we just not do that server side if it's only to change theme?
- phalethit's weird that it only shows on prod build
- bot<discord:blue> Yeah, ssr in inactive in dev
- phalethheh
- bot<discord:blue> Due to limitations in node, mostly
- bot<discord:blue> We should be able to get it reactivated since deno seems to be making good progress in custom loaders
- bot<discord:blue> Dunno about bun thougg
- phalethI mean the theme is stored in localStorage client side, so why bother with it server side anyway?
- phalethit's also detected client side
- bot<discord:blue> Yeah I agree, which is why this thing runs in a chunk
- bot<discord:blue> There's probably a better way to load it only in the client
- phalethyeah, I think so
- bot<discord:blue> We just need to not bundle it in in server code
- phalethyou can close that PR, I will try to come up with something else
- phalethso that means I should be able to eliminate two kind of fetch calls at once
- phalethif I figure out how anyway
- blueok, game's on
- blueI'll merge the other two things, then look at the third one we just discussed
- phalethok, cool
- phaletha fork bomb https://images4.imagebam.com/48/03/91/ME1CWZMC_o.png or so
- blue09:23 < phaleth> just dump another 5k commits on top of those 15k pre-existing ones https://github.com/oven-sh/bun/tree/claude/phase-a-port
- bluesumner losing his mind again and running a friggin hype train
- bluegosh this guy gets on my nerves
- bluewhat is this exe, phaleth?
- blueI figure we need some kind of localStorage in rcompat, phaleth
- bluethat offers setItem and getItem, and does absolutely nothing
- bluethe real way would be to not bundle this code at all on the server
- blueI mean, localStorage.ts
- bluebut that's the point of the chunk
- bluediff question, can we force esbuild to dechunk?
- bluethat would be awesome
- phaleththose exes are the kernel isolation thingies
- bluewhat kernel isolation
- phaleththe ones spawned by gvisor
- blueoh
- bluethat's terribly expensive ramwise, no?
- blueso one of our options is "splitting: false" on the client
- blueI personally never got the real point of chunking anyway so I'm inclined to consider this
- phalethblue: here are the new instructions on how to update primate website https://gitea.repopack.app/repopack/provision/src/branch/master/podman/deployments/primate-site.md#how-to-update-primate-website
- bluecan you try this in your PR, phaleth?
- bluego to packages/core/src/private/build/client/index.ts
- bluechange line 105 to false
- bluethen undo your change (put the import back in as a dynamic import)
- blueand run npx primate build && npx primate serve
- blue1) does it build
- blueand 2) does it dechunk?
- phalethyeah, but that means the first chunk won't be there and so overall hydration will become slower
- phalethtake a look at the picture on the PR
- bluehow do? there is the base bundle + the localStorage chunk
- bluesplitting: false will merge the localStorage chunk onto the base bundle
- bluehow so*
- blueso effectively chunk-L5MXQA3Q will disappear
- blueyou'll only have app.js
- bluealso don't forget to rebuild @primate/core
- phalethyeah, I know, but that chunk is big so it better stay chunked
- blue`npm run build` in packages/core, should be fast now with tsgo
- phalethotherwise the site will hydrate slower
- phalethI hope the app-whatever.js chunk is holding all the click events
- blueI have no idea why that chunk is so big. svelte/store is 18KiB???
- phalethI just ran npm run build million times in last three ours, it's fast
- blueanyway, if you're concerned about size, then your PR would be moot anyway
- blueI'd get rid of the splitting anyway
- phalethno, don't worry
- bluethat being said, svelte's wirable store pulling in 18 kilobytes of stuff is totally unacceptable
- bluedon't you agree?
- phalethwell if you can make the chunk-whatever.js smaller then sure I agree
- phalethif you can make any JS smaller then that'd be great
- bluewell technically speaking, stores in svelte are a very dumbed down contract
- blueessentially { subscribe() } is a store, iirc
- phalethcan just use props instead of store I think, just need to be bothered to pass them around
- blueI'm just surprised this is 18K
- phalethit's like react's context I think
- phalethall it boils down to is global JS vars
- blueso I asked the mind hive, and it came up with this
- blue"When esbuild splits that dynamic import into its own chunk, it has to make the chunk self-contained, so it bundles everything that chunk needs — including the Svelte runtime internals that writable depends on. In your main bundle, that runtime is already there, but the chunk can't assume that, so it duplicates it."
- blue"This is the classic chunk duplication problem with code splitting. The chunk doesn't know what's already loaded in the parent bundle."
- bluethat's fair and I'm inclined to believe the clanker here
- blueso could you try what I suggested? I'm betting the combined size won't be significantly larger -- localStorage.ts is roundabout 685 bytes
- phalethok, give me a few
- blueif what the clanker said is true, this is dumb on more than one level -- we don't wanna serve the svelte runtime twice
- bluebest case scenario we save 17KB + the extra HTTP request
- blueoh right, it's 685 bytes un=minified. I bet we're talking about much less later
- blueunminified*
- bluebeyond that, it's questionable design by svelte that writable depends on the svelte runtime, but ok
- blueI kinda get it, they wanna reuse their signal code or whatever they call it internally. still feels bit much for a signal lib, 17KB. maybe I'm overly optimistic here
- phalethit's questionable that the chunk is standalone
- blueyeah, it's a solution looking for a problem, agreed
- blueas said I never really got chunking per se, another complexity that webpack brought into the world
- phalethok, in case of primate website the performance is better when chunks are not split https://images4.imagebam.com/0c/7c/66/ME1CX1XJ_o.png
- phalethbut for a bigger web app that might not be the case
- phalethalso the JS amount adds up, so clanker was wrong
- phalethor the bundler is just dumb
- phalethI suppose I should try to get rid of both of those dynamic imports
- blueso we want from
- blue2 requests, 29.5 + 17.88 KiB
- blueto 1 request, 46.93 KiB?
- bluethe combined is 47.38 KiB
- blueclanker made up nonsense, again
- bluewe went*
- phalethyeah, chunks are not standalone
- blueanyway, turn off splitting
- phalethno, that's not the point
- phaleth:D
- blueso what's the point, you want a conf option to turn off splitting?
- bluewhat's the other dynamic import?
- phalethis the first chunking done somewhere as part of the website code? or is that primate feature?
- phalethfrom app-whatever.js to chunk-whatever.js
- phalethcause I think if I manage to undo that chunking then the ssr or whatever will be happy
- blueso what you just sent got rid of boht chunks, right? or rather of the one chunk and its depndency?
- blueas far as I know this is the only chunk
- phalethin that PR I've only managed to remove the leaf chunk
- phaleththe mid chunk is still there, at least in the code
- phalethand my question is where in the code?
- bluethat's weird, that shouldn't be the case
- blueso it works like this
- blueyou have components/Header.svelte
- bluethis does a dynamic import
- blueesbuild sees that, creates a chunk
- blueI don't specifically know or understand *why* that chunk then issues another request to specifically load localStorage.ts, it shouldn't
- phalethuh
- phalethhmm, I think Header.svelte is part of app-whatever.js in any case
- blueit is, yes
- blueand esbuild rewrites it to use `fetch` instead of that import
- phalethlet me see if chunk-whatever.js is still created after that PR is applied
- bluek
- phalethok, you are right, it's single app.js now
- blueyes
- phaleththat's great
- blueas it should be
- phalethso I gotta get rid of the server side magic
- bluewhat server side magic
- phaleththe ssr thing that errors
- phalethdue to not getting localStorage or whatever
- phalethTypeError: localStorage.getItem is not a function
- phaleth at file:///home/user/primate/primate/apps/website/build/server.js:74:2010
- blueyou don't need to, do you?
- blueyou keep the await import in Header.svelte
- bluethen you piggy back on the fact that svelte's `onMount` is a no-op in SSR
- blueso esbuild won't see the dynamic import in the server bundle
- phalethI do need to get rid of that dynamic import
- bluewhy?
- bluethe bundle size is the same, no?
- phaleththat's what I'm going to find out
- phalethI can at least make it smaller by getting rid of some of this glue code
- blueso I frankly don't understand what svelte/store is pulling in that justifies 17kb
- phalethwhat I don't know how does localStorage instance appear out of nowhere in #static/localStorage.ts
- bluethis is because this is a browser file, and on the browser, localStorage is global
- phalethoh, true
- blueyou can also write globalThis.localStorage if that makes you feel better
- phalethit does
- bluegood, then do it
- bluemagical stuff is bad bananas
- bluelet me add that to the list of carnal sins in CS
- blueso what have we got
- bluecaching, complexity, and magic?
- phalethit's a TS error
- bluewhat's a TS error
- blueoh right
- blueyeah, TS doesn't understand you're in a browser file
- blueluckily, you can ignore that
- blueor if that bothers you, add `@ts-expect-error browser context` or so
- phalethcan I do @ts-ignore?
- blueabove that line
- blueyes
- phalethoh, ok
- bluethis is a problem in and of itself. there is no good way to teach TS in what context your JS file in
- blueI think react has something like "use:client" but that's terrible
- blueTS *could* benefit from taking a look at package.json runtime keys and figuring it out based on the "browser" import, but I doubt it does that, I doubt there is political will in microsoft to do that, and also that would bring you nothing in this case because localStorage isn't declared in apps/website's package.json
- blueI also somewhat have a convention in primate where browser files are extension'd `*.client.ts`
- bluebut this is purely a convention with no consequence, I cannot guarantee I have followed it everywhere, and also I don't know and couldn't bother to look up how to teach nvim to understand that that is a browser TS file
- blueand given I've criticised myself the fact that svelte 5 magically treats *.svelte.js files differently than normal *.js files, I shouldn't do the same thing myself
- blueyou know, the problem with all those frontends is that they legit try to do too much. svelte does this rune magic, but it only really works if you use it the blessed path, which is either sveltekit or vite
- bluethat's terribly proprietary and vendor-lock-in-y
- blueit's not how software is supposed to be
- blueI feel like the modern shift has been, everything is open source, but tools are *so* locked to just one path that they're effectively proprietary
- bluedo you want to bundle in the woff2 font as well? :P
- blueprobably not, you're precaching it and stuff
- phalethnope, still didn't figure out how to add Content-Length header to JS
- phaleththose frontend frameworks are the problem
- blue100%
- phalethwhat I don't understand is that how does #static/localStorage.ts end up being in a server side bundle server.js?
- phalethI think I'll just move it's code to Header.svelte and see
- phalethoh, that worked
- phalethso yeah, don't add TS code to static dir
- phalethactually, getting a new error now
- phaleth[ERROR] views/Index.svelte error: TypeError: localStorage.getItem is not a function
- bluethat's the same SSR dir
- blueSSR error*
- blueI do have a solution for you
- blue colorscheme = (await import("#static/localStorage.ts")).default;
- bluemove this to a top-level import, as you did in your PR
- blueyou can move localStorage to components or whatever you like, it doesn't really matter
- blueanyway, create localStorage.client.ts
- blueput the code from localStorage.ts in it
- blueand in localStorage.ts, do something like `export default {}`
- phalethto which dir should I put localStorage.client.ts? view?
- bluewhere you like. best in the same dir as localStorage.ts
- blueif you wanna keep it in static put it there. otherwise move both to components
- bluecomponents is ok I tihnk
- blueand the last piece of hte puzzle, add runtime keys for both files
- bluein package.json, add
- bluehttps://dpaste.com/7JV3D2SJ8
- blueand make sure the import is like that
- blueimport localStorage from "#localStorage";
- phalethI cannot open dpaste cause of proxy
- bluehttps://superarch.org/ls.txt
- phalethwth
- phalethit works :D
- phalethmagic replaces magic
- blueyes. though this is magic per se: we're explicitly telling esbuild how to bundle it for the browser and server
- bluethis isn't*
- blueanyway, this is the 'right' solution: because it means the code doesn't get bundled in to the server
- phalethok, I'm gonna update the PR
- bluegreat
- phalethlooks like Angular
- phalethso there is about 6 kBs of JS less on the frontend, which is great
- bluethat's awesome
- blueoh sweet, you delegated to svelte store on the server, that's smart
- phalethyeah, well, that just means there is more work to do
- phalethanyway, the network dependency graph problem is solved
- bluegood job
- bluephaleth: the pr is merged
- phalethcool, can you try updating the website using those new instructions?
- phalethdon't have to strictly follow that, can as well update all of those packages that the website uses
- bluephaleth: I usally just go into the contain and git pull and rebuild
- bluecontainer*
- phalethyeah, but it's a podman container now
- phalethI've rebuilt the image so the website is updated
- bot<discord:blue> Great
- bot<discord:blue> So it's better now?
- phalethyes, gets a higher score on https://pagespeed.web.dev
- bot<discord:blue> Performance, 100
- bot<discord:blue> Great