Submit

Back to the channels

#primate

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

Search posts