swiftwasm / carton

📦 Watcher, bundler, and test runner for your SwiftWasm apps
Apache License 2.0
406 stars 44 forks source link

`carton dev` does not work with hot reload (on Ubuntu 22) #418

Open felixf4xu opened 6 months ago

felixf4xu commented 6 months ago

Hi,

I'm trying to test the hot reload (with Ubuntu 22).

When I run carton dev -v, I got this:

Watching these directories for changes:
/home/cc/testcode/TokamakApp/Sources/TokamakApp
/home/cc/testcode/TokamakApp/Sources/TokamakAppLibrary

[ NOTICE ] Server starting on http://127.0.0.1:8080
Opening in existing browser session.
[ INFO ] GET / [request-id: 9429F254-E51E-4C65-A3C1-D296CA3A64AA]
[ INFO ] GET /main.wasm [request-id: A8A569DE-8E34-482D-ACA6-AFCA31F04B69]
[ INFO ] GET /favicon.ico [request-id: 59069EF7-BF0F-42F9-A798-2F55431B26EC]
[ INFO ] GET /watcher [request-id: FAB3E429-313C-4E8C-AEA1-FA29049EB417]
[ INFO ] GET /JavaScriptKit_JavaScriptKit.resources/Runtime/index.mjs [request-id: 9A012136-2FD2-4BB6-B0EF-20073F40B41A]
[ INFO ] GET /watcher [request-id: 2F4FEA85-E7A1-48E7-BF8C-DB7AA922EFA3]
[ INFO ] GET /watcher [request-id: AE91BC94-80F9-4FFF-898D-5CD38A6296BB]

Then I tried to edit App.swift like this:

struct ContentView: View {
    var body: some View {
        Text("Hello, world!")
        Text("Hello, world 2!")
        Text("Hello, world 4!")     //<-- add this line
    }
}

but nothing happened on the web page (google chome).

Only after I stop carton dev and re-run it, I can see the updated Text.

kevinkleine commented 5 months ago

Hot reloading also seems broken when running from a container (ghcr.io/swiftwasm/carton:latest, which is 0.20.1). It is the same with the older carton images 0.20.0 and 0.19.1.

Carton logs:

Watching these directories for changes:
/test/Sources/test
/test/Sources/testLibrary

But when I change or add a file - either from inside or outside of the container - nothing is logged and no refresh of the webpage happens.

OS: Manjaro 23.1.3

Running the container with: podman run --rm -v .:/test -p 0.0.0.0:8080:8080 -it ghcr.io/swiftwasm/carton:latest /bin/bash.

Running carton dev --host 0.0.0.0 -v inside the container.

kateinoigakukun commented 4 months ago

Version 1.0 rewrote the dev server. Could you try again with the new version?

jeremypenner commented 3 months ago

I'm having the same issue with docker run -v .:/src --privileged --interactive --tty --name swift-experiments -p 8080:8080 swift:5.9.2 /bin/bash and then running swift run carton dev --host 0.0.0.0 -v from inside the container. My Package.resolved suggests that I'm running carton 1.0.3. The swift:5.9.2 docker image is based on Ubuntu "jammy" 22.04.4.