deno, node and deno-sw hello world examples
Here's the deno, node and deno-sw typescript sdk examples.
I had to make local copies of the static assets for the deno-sw example, as I was having difficulty with caching and serving external resources. Likewise, the html doc is served from an ES Module that contains a template literal of the doc, as I was having a lot of issues with serving a static file as the root route ("/").
If you want/know how to fix any of that, feel free to suggest the required changes. Otherwise, I think its fine as-is for the sake of a demo.
@Superpat this is ready for your review whenever you've got time
I'm not sure I'll have time to review this until after Fosdem, but thank you !
@nickchomey like I said in an earlier pr, I cant use the js version of esbuild on OpenBSD, so I cant review the sw bits. Can you switch the sw building code to use something like deno dnt instead ? Check the npm package build code, it's using deno dnt.
Sure I'll figure out deno dnt
@Superpat I got the static assets to load remotely now, tidied things up, and have provided a pre-built service-worker.js file as I wasted an hour trying to get DNT to work - its not worth the effort for this.
You can just run deno run start and it should just work. If you/anyone wants to modify the files and doesnt have esbuild available on their system, then they'll have to figure out a build system that works for them.
The only remaining "gotcha" is a couple second delay if your browser is still set to online, but the network request fails (eg deno is stopped) - it waits for that request to fail before falling back to service worker rendering. If you set the browser to offline, it goes there immediately. I could add some sort of background polling and a signal to pre-detect if the network/deno server is available, but that really isn't worthwhile for this proof-of-concept.
ps. note that I've removed the sdk/typescript/examples directory
I will try to finish reviewing this before the weekend is over. Still recovering from my ssd meltdown last week.
It's been 84 years
It’s been a light year...