wailsapp / wails

Create beautiful applications using Go
https://wails.io
MIT License
24.32k stars 1.17k forks source link

Generating code in preBuildHooks causes build loop in wails dev #2501

Open davidnewhall opened 1 year ago

davidnewhall commented 1 year ago

Description

I run go generate in preBuildHooks which generates a go file. When this happens while running wails dev it causes a rebuild loop that only ends when I ctrl+c.

The go generate command creates language translations with gotext.

To Reproduce

I tried to reproduce this with a quick running go generate command, but it doesn't seem to happen unless it takes a few seconds to run. I'm not exactly sure what triggers it. gotext generates several json files and 1 go file, and takes about 3-5s to run.

Expected behaviour

Run preBuildHooks and cool off a few seconds maybe?

Screenshots

Logs looping:

Added new directory to watcher: /Users/david/go/src/github.com/Notifiarr/toolbarr/frontend/wailsjs/go
Added new directory to watcher: /Users/david/go/src/github.com/Notifiarr/toolbarr/frontend/wailsjs/runtime
[Rebuild triggered] files updated
  • Executing pre build hook '*/*': 2023/03/18 03:08:06 [INFO] Serving assets from frontend DevServer URL: http://localhost:5173/
2023/03/18 03:08:06 [DEBUG] [DevWebServer] Serving DevServer at http://localhost:34115
Done.
  • Generating bindings: Done.
  • Compiling application: 3:08:09 AM [vite] hmr update /src/About.svelte
hmr update /src/Settings/Settings.svelte
hmr update /src/Navbar.svelte
hmr update /src/About.svelte
hmr update /src/Settings/Settings.svelte
hmr update /src/libs/Input.svelte
hmr update /src/About.svelte
hmr update /src/Settings/Settings.svelte
hmr update /src/libs/Input.svelte
hmr update /src/Settings/Advanced.svelte
hmr update /src/Settings/Logs.svelte
hmr update /src/Settings/General.svelte
hmr update /src/libs/Input.svelte
hmr update /src/Settings/Logs.svelte
3:08:09 AM [vite] hmr update /src/About.svelte
hmr update /src/libs/Link.svelte
Done.
  • Packaging application: Done.

Added new directory to watcher: /Users/david/go/src/github.com/Notifiarr/toolbarr/frontend/wailsjs/runtime
[Rebuild triggered] files updated
  • Executing pre build hook '*/*': 2023/03/18 03:08:11 [INFO] Serving assets from frontend DevServer URL: http://localhost:5173/
2023/03/18 03:08:11 [DEBUG] [DevWebServer] Serving DevServer at http://localhost:34115
Done.
  • Generating bindings: Done.
  • Compiling application: 3:08:14 AM [vite] hmr update /src/About.svelte
hmr update /src/Settings/Settings.svelte
hmr update /src/Navbar.svelte
hmr update /src/About.svelte
hmr update /src/Settings/Settings.svelte
hmr update /src/libs/Input.svelte
hmr update /src/About.svelte
hmr update /src/Settings/Settings.svelte
hmr update /src/libs/Input.svelte
hmr update /src/Settings/Advanced.svelte
hmr update /src/Settings/Logs.svelte
hmr update /src/Settings/General.svelte
hmr update /src/libs/Input.svelte
hmr update /src/Settings/Logs.svelte
3:08:14 AM [vite] hmr update /src/About.svelte
hmr update /src/libs/Link.svelte
3:08:14 AM [vite] hmr update /src/About.svelte
hmr update /src/libs/Link.svelte
Done.
  • Packaging application: Done.

Added new directory to watcher: /Users/david/go/src/github.com/Notifiarr/toolbarr/frontend/wailsjs/go
Added new directory to watcher: /Users/david/go/src/github.com/Notifiarr/toolbarr/frontend/wailsjs/runtime
[Rebuild triggered] files updated
  • Executing pre build hook '*/*': 2023/03/18 03:08:16 [INFO] Serving assets from frontend DevServer URL: http://localhost:5173/
2023/03/18 03:08:16 [DEBUG] [DevWebServer] Serving DevServer at http://localhost:34115
^C
Build error - signal: interrupt -
Continuing to run current version```

### Attempted Fixes

_No response_

### System Details

```shell
wails 2.4.0, macOS M1, go 1.20.1

Additional context

Please let me know what additional information would be useful. You might even be able to clone my repo and reproduce it locally.

leaanthony commented 1 year ago

Ah yeah, generating a go file in the project directory will do that. Eww.. that's a pain. All I can suggest is you do that out of band for now rather than using go generate.

The move to using Task in v3 will completely remove this issue as we are externalising the build process. I see you're on Mac. Would you be interested in trying it out when it's ready for testing (in a few weeks hopefully)?

davidnewhall commented 1 year ago

I'm down to try new things. Find me on Discord as Captain.

mateothegreat commented 1 year ago

I'm down as well!

davidnewhall commented 1 year ago

My workaround is to just comment out my generating lines while I'm running wails dev. The drawback is that I sometimes forget to run the thing and sometimes I commit the change to the repo on accident.