Submit

Back to the channels

#primate

  1. * phaleth joined #primate
  2. phaleth no flash!
  3. phaleth not even on epiphany
  4. phaleth 16 files changed
  5. blue phaleth: hi. how did you do that?
  6. blue I'm working on markdowndb btw
  7. blue I think markdown as a traditional frontend. really makes no sense. it doesn't get props, and it doesn't have logic
  8. blue instead, we're going to have a store-like interface around it that queries the data in real time in dev, and in prod inlines everything
  9. blue the inline part is hard, because that possibly requires access to app, and dbs don't partake in the app lifecycle
  10. blue phaleth: dreamreal: https://dpaste.com/3QSFU543W
  11. blue then on `BlogPost.get("primate-39"), you're gonna get { html, toc, path, body, frontmatter }
  12. blue the only tricky part is to have this operation loads from the fs in dev, and from memory, as part of the bundle, in prod
  13. blue load*
  14. blue but markdowndb is the key to unlock full cms capabilities
  15. phaleth blue: hi
  16. phaleth can you check the last PR on primate repo?
  17. phaleth I'm looking for a post-build handler or something like that
  18. phaleth *latest PR
  19. phaleth why is it called db if it's not overridable?
  20. blue I'll check it phaleth
  21. blue what do you mean with no overridable?
  22. blue not(
  23. blue not*
  24. phaleth markdown files are static I guess
  25. blue the problem is we want different behaviour during dev and prod. in dev it's acceptable to load / transform the mds on the fly, in prod it isn't
  26. blue plus, primate/website has different addons like transforming snippets which makes everything more complicated
  27. blue I wish I had a good solution for it, I currently don't
  28. phaleth so the db is like a cache for md files?
  29. phaleth might was well just transform them to html and let the site be static
  30. phaleth btw, the PR I opened is getting towards that, just need to figure out a build step, I could slap something together after build, but I'm wondering if there is something primate specific
  31. blue there is `app.done`. I don't like it, but you can use it
  32. blue https://github.com/primate-run/primate/blob/master/packages/native/src/private/module.ts#L29
  33. blue that's essentially a postbuild
  34. blue the thing is that I want something in between "fully static, separate HTMLs" and "load/transform mds in dev mode"
  35. blue I do like the fact the current solution bundles everything into one server.js
  36. blue forcing you to otherwise always do --target=static could be a regression
  37. blue (or copy the .mds to production and load them on demand)
  38. blue also we reason about the mds in some routes
  39. blue https://github.com/primate-run/primate/blob/master/apps/website/routes/llms.txt.ts
  40. blue https://github.com/primate-run/primate/blob/master/apps/website/routes/llms-full.txt.ts
  41. blue these two would be a catastrophe without caching
  42. phaleth caching server side you mean?
  43. blue yes
  44. blue obviously in a world of --target=static, you just build llms.txt into llms.txt.html once and you're done
  45. phaleth just take a look at the response time here, it's not so bad https://grafana.repopack.app/public-dashboards/ce90d22ed104477ea945d2c35aa8d3d7
  46. blue it's not bad right now because it's all precompiled in memory
  47. phaleth if the website gets busy then you can bother yourself with that, but then SSG and running the site on nginx would solve all those problems
  48. phaleth yeah, and memory is fast
  49. blue yes but @primate/markdown is just for apps/website, I'm trying to rethink it as a general cms-like solution
  50. blue isn't just*
  51. phaleth did you see the response time? :)
  52. phaleth there is not much to gain
  53. blue 9 ms?
  54. phaleth yeah, deno is kinda slow, but still acceptable
  55. blue no let's optimise it to 0.5 ms </sumner>
  56. phaleth heh, then that means it's nginx
  57. blue yeah I was joking, 9 ms is totally acceptable for now
  58. blue so my point is
  59. blue apps/website is actually not the issue here. it'll get --target=static and be happy with its htmls. especially with your colourscheme work
  60. blue the issue here are other apps. I have this small apps where I keep notes, like obsidian, and the 'load from fs' is fully acceptable for it at least in dev mode
  61. blue small app*
  62. blue so essentially this is a caching problem
  63. blue you don't want to run the expensive md > html pipeline on every request
  64. blue you ideally only want to run it when the source has changed
  65. blue for the fs, you could do a small `stats` check I suppose and compare against what you last saw
  66. phaleth ok, so then it's a store, it's not a db
  67. blue yes it is a store, it'll be exposed as markdown.store
  68. blue and you'll have programmatic access to the frontmatter and also partitioning
  69. blue (say if you have i18n)
  70. phaleth the github experience https://images4.imagebam.com/6a/e8/8a/ME1D55XF_o.png
  71. blue oh wow, that looks like garbage
  72. blue I think what we need is
  73. phaleth yeah
  74. blue @primate/markdown.store becomes the new way to use markdown, and --target=static is how we solve the caching problem for apps/website
  75. blue I still don't know how to tell --target=static though how it should generate pages based on a parameterised route
  76. blue but yeah, all of this still doesn't solve my major conundrum during dev which is that apps/website takes way too long to start up, and recreate the bundle
  77. phaleth yeah, primate website takes a while to startup in dev mode
  78. blue maybe, markdown.store runs all the pipeline on startup (or if you don't care, you can pass in lazy: true).
  79. blue in dev mode I'd generally go lazy, I think
  80. blue and the website would start up immediately
  81. blue so every docs page is converted on the fly, and then cached until stats has changed
  82. blue and in production, --target=static takes over, so laziness isn't relevant, everything gets produced during build
  83. blue maybe I don't even need lazy: true and it's always lazy, and always cached
  84. blue I think this is a good compromise
  85. blue but this requires markdown stores and --target=static to arrive in the same commit
  86. blue otherwise we can't meaningfully deploy the website, it'll be slow on first requests and you'd need to copy .md files and the snippets directly and what not
  87. phaleth cool, looking forward to static target
  88. blue ya
  89. phaleth I have a FileRef to a text file, now I need to replace contents inside the file behind the FileRef, how to do that with rcompat?
  90. phaleth npm install replace
  91. phaleth omg
  92. phaleth write method exists
  93. blue yes
  94. blue if it's an object you want to write you also have writeJSON
  95. blue that will write it out as a JSON string you can later load with #json
  96. phaleth it's a JS file
  97. phaleth plain text
  98. blue cool, then just #write
  99. phaleth write works, I just don't know how to read the file
  100. blue text()
  101. phaleth ah, ok
  102. blue do you want to read it, or import it?
  103. phaleth nice, that worked
  104. blue cool
  105. phaleth blue: any clue why is the browser getting the unminified file? https://images4.imagebam.com/61/fe/8d/ME1D57VH_o.png
  106. phaleth I've just pushed the changes, but why is that JS file served unminified and with the correct filename containing the hash is a total mystery
  107. blue phaleth: where is that file located, in static?
  108. blue it looks like esbuild chunked it
  109. blue it should be minified though
  110. blue oh, it's in static
  111. blue are the js/css minified?
  112. phaleth yeah, I guess that file being in static dir is the problem, so I'm gonna run it through the bundler even for dev
  113. blue what I'm wondering aobut is how come this didn't land in app.js. it should
  114. phaleth no, it should not, that's actually the goal
  115. blue oh, ok
  116. blue should still be minified
  117. phaleth it's supposed to be it's own chunk
  118. phaleth yeah, everything is minifed, it's just that one file originaly from static dir is served verbatim
  119. blue how did you achieve chunking?
  120. phaleth I'll just make it a ts file and make it part of the build for dev
  121. phaleth magic :D
  122. blue lol
  123. phaleth take a look at app.html on the PR
  124. blue oh
  125. blue <script src="scheme-storage.js"></script>
  126. phaleth looks like I can have a client dir as part of the project
  127. blue hm, I still believe primate scans the static dir for js/css and incorporates it
  128. phaleth ok, then I should move that to client dir
  129. blue what does that client dir do?
  130. blue I'm discovering things about primate I never knew existed :P
  131. blue that's fairly wonderous, given I've written nearly 100% of it myself, haha
  132. phaleth I hope if I put the file in client dir it will end up in build/client
  133. blue I don't know what that hope is based on
  134. blue is that documented?
  135. phaleth it's a flat out hope
  136. blue oh
  137. blue probably not gonna work
  138. phaleth I don't tend to look into documentation
  139. blue ya
  140. blue same
  141. blue docs are for idiots
  142. phaleth so what should I use instead of the static dir?
  143. blue well generally speaking, %head% is your friend
  144. blue you shouldn't hard-encode scripts into <head>
  145. blue let me see what's the way to latch onto %head%
  146. blue .replace("%head%", render_head(this.#assets, head));
  147. blue let's see how #assets is populated
  148. phaleth I can get FileRef to app.html
  149. blue ok, AppServe#publish does that
  150. phaleth but you know the app.html ends up being in server.js when in the post build phase
  151. phaleth not sure if the %head% thing is still in place there, but let me see
  152. blue ya
  153. blue hmpf, I don't see anyone calling publish really
  154. blue is this mechanism even in use anymore
  155. blue I think esbuild completely replaced it
  156. phaleth ah ok, the %head% is still there
  157. phaleth yeah, so that means esbuild has put the scheme-storage-blahblah.js into head and that's why it's served verbatim
  158. phaleth but I need to chunk it out, so how to tell AppServe.publish or whatever to not include that?
  159. blue so I think publish is dead code
  160. blue look at ServeApp#start
  161. blue that generates the assets
  162. phaleth yeah, but that's in core
  163. blue Object.entries(this.#serve_assets.client)
  164. blue let me see who populates that
  165. phaleth or not? I was hoping there would be a handler I could hook up to from within Website.ts
  166. phaleth isn't there onServe?
  167. phaleth I think I've deleted that one
  168. blue there is, yes
  169. phaleth I have no clue what to do
  170. blue what are you trying to achieve
  171. phaleth exactly what's on that picture, but the response for scheme-storage-blahblah.js should be minified as you see in the text editor above
  172. blue pull it into the bundle then
  173. blue place the file in static, esbuild will pull it in
  174. blue don't worry about the rest of the stuff
  175. phaleth no, the bundle is too big and that's why there is a flash
  176. phaleth even currently, there is a flash
  177. blue yes but in --target=static, the bundle won't contain much
  178. phaleth nah, it will always be tens of KBs at least and that's enough to flash
  179. phaleth also this tiny JS is loaded before css
  180. phaleth and that huge bundle should not be loaded before css and should not stop css for loading either
  181. blue but in the future, that bundles should be basically only scheme-storage,js
  182. blue bundle*
  183. phaleth but since there is at least the content hash, I'm fine with what's currently on that PR
  184. blue everything else falls away, the components, the fetch navigation, etc.
  185. blue you can simulate it now by turning off CSR
  186. blue svelte({ csr: false })
  187. phaleth well, that'd mean full reloads on navigation
  188. blue wait, that's what we *want* to do with target static, no?
  189. phaleth I think the proposal says something different, but hold on that thought now
  190. phaleth I'll log into github and mark the PR as ready
  191. phaleth and let you test that change
  192. phaleth on brave
  193. blue yeah the proposal is a bit more contrived
  194. blue something like, there's a JSON file for the mds or smth
  195. phaleth yeah, but don't worry about that
  196. phaleth first please check if whatever I did works in brave
  197. phaleth the file is like 1.27 kBs unminifield vs 717 Bs minified
  198. phaleth which is not much
  199. phaleth no need to rewrite primate cause of that :D
  200. phaleth cause if that works then full page reloads are fine
  201. blue ya
  202. blue yeah, this markdown redo is overdue anyway
  203. blue and --target=static, too
  204. phaleth for primate website I'm gonna work on making the JS bundle size smaller, but first I need to make sure everything happens client side
  205. phaleth and this light/dark thing is being tricky
  206. blue ya
  207. phaleth what does FileRef.debase do? gives you the filename?
  208. phaleth or I think it's more like fs.debase
  209. phaleth ah, it expects args
  210. blue give /tmp/a/b being the 'base', and tmp/a/b/c/d.js being the fileRef, it allows you get c/d.js,
  211. blue given*
  212. phaleth ah, ok, seems like it always returns the subpath with starting forwardslash
  213. blue ya, that's unfortunate, I wanted to fix that annoying forward slash
  214. blue otherwise just do .slice(1)
  215. phaleth this this.#serve_assets.client that you've mentioned is being populated out of nowhere and only during production not serve but build I guess
  216. * jreicher joined #primate

Search posts