Replies: 1 comment
-
Question is a bit confusing because deno is purely server side. But you talk about requests which are a client side concern. I think the best approach for organizing deno/serverside code is clear. Client/browser side code delivery can be a different animal. Node and other historical platforms have steered us to create all kinds of over-engineered solutions and magic; we forget that with modern javascript and deno, we can forget all that and keep things very simple.
|
Beta Was this translation helpful? Give feedback.
-
Context
I've been messing around with creating a calendar scheduling app. I wanted a simple way someone could pass in time-slot availability, this is a bit annoying to do via just JSON with intervals and breaks in between and days of the week that sort of stuff.
Something like this:
What's the best way to author a Deno module?
While I know there's many ways to do any given thing, It left me thinking what's the best way to author a module so that people using it don't have to download all the files in the module. Let me give some examples:
So there's a spectrum and both ends are not great. I'm curious if there's a different way to look at this? Something I'm missing.
If people author code-in-classes (which I tried to stay away from in that example, you have to download the entire class, you can't really provide parts of a class. So functions-first is necessary. Classes in my example are just glue / wrappers around the functions (except when classes get passed around, which I'd have to undo, functions can't take classes as input).
Options
Linter
A linter that specializes in guiding authors to best practices when it comes to authoring code with less dependencies would be an amazing alternative. Advising people to not author hefty classes that all connect directly?
Dynamic Files
This would mean the url builds a single file with all the code in it.
This is an idea adjacent to the post here about hosting your own deno module server. I'm dubbing this in the category of "#serverMagic" (id like a whole discussion on different "#serverMagic" techniques).
This idea would be source-tree-shaking the modules served, with the URL you have the ability to target a specific export within a file via query parameter, or even path, all bets are off when your generating dynamic TS.
I'm equally attracted to the idea of dynamically generated modules from the server and of the mind that you should just serve a single file no tricks.
I'm curious what other people's thoughts are.
Beta Was this translation helpful? Give feedback.
All reactions