JonahGroendal / acme-easy

An ACME client for the browser that authenticates via DNS-01 challenge and supports LetsEncrypt by default.
https://www.npmjs.com/package/acme-easy
MIT License
2 stars 1 forks source link

Switch to esm #13

Open jimmywarting opened 1 year ago

jimmywarting commented 1 year ago

Couple of things:

JonahGroendal commented 1 year ago

I appreciate this and I'll take a look at it. A couple issues stand out from the description tho:

  1. 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?).

  2. 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?

JonahGroendal commented 1 year ago

ok looks like globalThis does work in the browser and ESM probably wont break anything

jimmywarting commented 1 year ago

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)

JonahGroendal commented 1 year ago

I'll merge this right after I fix an issue with the protocol implementation

jimmywarting commented 1 year ago

Would you like me to divide this up to separate PRs?