lydell/elm-watch

elm-watch beta: CLI gives https:// links by default in Bun

Opened this issue · 6 comments

When I run elm-watch hot, it gives me https:// links instead of http://

It's just a minor annoyance. I have to change the URL manually to http://, then it works fine. I didn't find any configuration option to force http://.

Console output (with https instead of http):

✅ Dependencies
✅ Main                                                                 0 ms Q |  48 ms T ¦   2 ms W

📊 server: https://localhost:51572, network: https://192.168.62.200:51572
📊 web socket connections: 0

✅ 19:54:32 Compilation finished in 641 ms.

elm-watch.json:

{
    "targets": {
        "Main": {
            "inputs": [
                "src/Main.elm"
            ],
            "output": "public/main.js"
        }
    },
    "serve": "public/"
}

public/index.html:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>example-minimal</title>
  </head>
  <body>
    <div id="root"></div>
    <script src="/main.js"></script>
    <script>
      Elm.Main.init({ node: document.getElementById("root") });
    </script>
  </body>
</html>

Hi! The printed links are only supposed to be HTTPS links if you have passed in an HTTPS custom server. A quick test right now gave me HTTP links, so it looks like I’m missing something that is different on your computer.

I can reproduce the behaviour as described by @upsiflu when checking out the repository and following the instructions at lab.allmende.io/libernetes/libernet.es.

ghq get https://lab.allmende.io/libernetes/libernet.es
cd ~/src/lab.allmende.io/libernetes/libernet.es
mkdir -p public
asdf plugin add bun
asdf plugin add just
asdf install
bun --bun install
just dev
✅ Dependencies
   ● Chadtech/elm-bool-extra 2.4.2
   ● elm-community/maybe-extra 5.3.0
   ● elm/virtual-dom 1.0.3
   ● elm/parser 1.1.0
   ● dillonkearns/elm-markdown 7.0.1
   ● rtfeldman/elm-hex 1.0.0
   ● elm-community/list-extra 8.7.0
   ● stoeffel/set-extra 1.2.3
   ● stil4m/structured-writer 1.0.3
   ● elm-community/string-extra 4.0.1
   ● Fresheyeball/elm-return 7.1.0
   ● linuss/smooth-scroll 1.1.0
   ● elm-explorations/test 2.2.0
   ● elm-community/easing-functions 2.0.0
   ● pablohirafuji/elm-syntax-highlight 3.5.0
   ● pzp1997/assoc-list 1.0.0
   ● turboMaCk/non-empty-list-alias 1.4.0
   ● elm/project-metadata-utils 1.0.2
   ● miniBill/elm-unicode 1.1.1
   ● jfmengels/elm-review 2.13.2
   ● stil4m/elm-syntax 7.3.2
   ● edkelly303/elm-any-type-forms 5.0.0
   ● lue-bird/elm-review-single-use-type-vars-end-with-underscore 2.0.3
   ● upsiflu/less-ui 2.0.0
✅ Main                                                                 0 ms Q |  68 ms T ¦   4 ms W

📊 server: https://localhost:53205, network: https://10.30.30.9:53205, network: https://100.64.0.7:53205, network: https://172.20.0.1:53205
📊 web socket connections: 0

✅ 10:23:34 Compilation finished in 5.99 s.

With just dev being a shorthand for bun run --bun elm-watch hot:

$ cat justfile
dev:
    cp -R static/* public/
    bun run --bun elm-watch hot
…

On the contrary to what is printed by the command output, the website will be available on http://localhost:53205/ instead.

Does it happen if you:

  • Don’t use just?
  • Use node instead of bun?

Yes!

Using node instead of bun solved the issue:

bun run elm-watch hot instead of bun run --bun elm-watch hot

Thank you @lydell

Thanks you for narrowing down the problem! Then it’s either a bun bug, or that we need to find some other way of detecting if we’re running an HTTP or HTTPS server. This is the current check:

this.isHTTPS = this.polyHttpServer instanceof https.Server;

Interesting find. I will be curious to learn what causes the difference with the two upstreams.