Skip to content

deno, node and deno-sw hello world examples #552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

nickchomey
Copy link

@nickchomey nickchomey commented Jan 30, 2025

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.

@nickchomey
Copy link
Author

@Superpat this is ready for your review whenever you've got time

@Superpat
Copy link
Contributor

I'm not sure I'll have time to review this until after Fosdem, but thank you !

@Superpat
Copy link
Contributor

Superpat commented Feb 5, 2025

@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.

Copy link
Contributor

@Superpat Superpat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Globally it looks good, I'll want to run it first, but I need you to do a few changes as delineated in the comments.

@nickchomey
Copy link
Author

Sure I'll figure out deno dnt

@nickchomey
Copy link
Author

nickchomey commented Feb 5, 2025

@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

@nickchomey nickchomey marked this pull request as draft February 5, 2025 15:07
@nickchomey nickchomey marked this pull request as ready for review February 5, 2025 16:40
@Superpat
Copy link
Contributor

I will try to finish reviewing this before the weekend is over. Still recovering from my ssd meltdown last week.

@delaneyj
Copy link
Collaborator

delaneyj commented Mar 3, 2025

It's been 84 years

@delaneyj delaneyj added the sdk SDK related issues label Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sdk SDK related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants