Open jimmywarting opened 1 year ago
I appreciate this and I'll take a look at it. A couple issues stand out from the description tho:
This is designed to work in a browser rather than nodejs, so window
is required (unless globalThis
works in the browser in place of window
?).
I'm a little hesitant to switch to ESM in case it breaks projects downstream. Plus, what use do we have for top-level await
?
ok looks like globalThis
does work in the browser and ESM probably wont break anything
Top level await might not bring any benefits right now... but using ESM allows the browser to more easily import other dependencies that dose not have a package mananger like npm.
in browser you can either use async import from anyware
<script>
import('acme-easy').then(module => { ... })
</script>
But you can also do:
<script type="module">
import client from 'acme-easy'
</script>
With import syntax you can also specify a import map to basically change cdn and how it should resolve dependencies.
Another benefit would also be that this would then also work in Deno if you switched to ESM. (btw Deno don't have support for cjs - it only target ESM)
I'll merge this right after I fix an issue with the protocol implementation
Would you like me to divide this up to separate PRs?
Couple of things:
standard * --fix
to format the code to look the same. it almost looked like you followed that pattern.import / export
( allows for top level await and other goodies )window.
prefix fromwindow.crypto
as NodeJS have a spec'ed web crypto on the global scope now.globalThis
instead of window, self or this... it's the new standard that exist in all env.