Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make go-app compatible with GopherJS #830

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on May 6, 2023

  1. Use GOOS=js as a predicate for the client-side code instead of wasm.

    `GOOS` usually indicates the availability of certain OS APIs, whereas
    `GOARCH` targets a specific bytecode architecture. For go-app purposes,
    it's important that the `syscall/js` package is available, but it's less
    interesting whether the code is compiled into wasm or something else.
    
    By using `GOOS=js` constraint go-app becomes more open for use with
    alternative client-side toolchains, such as GopherJS, which also
    supports the `syscall/js` package.
    
    I also fixed a small bug in the `log.go` file, where `goarch ==
    "window"` could never be true. I believe the intent was to check for
    `runtime.GOOS == "windows"`.
    nevkontakte committed May 6, 2023
    Configuration menu
    Copy the full SHA
    c867a86 View commit details
    Browse the repository at this point in the history
  2. Factor out management of wasm-specific resources into Driver type.

    The new `Driver` type can be used to customize how go-app environment is
    set up on the client side. It is responsible for pre-rendering and
    registering scripts and styles that are necessary to load and start
    app's business logic.
    
    By default, a Go WebAssembly driver is assumed, which maintains the
    original behavior with showing a loader progress bar and starting up a
    Go wasm binary.
    
    Users can customize the loading process and the scripts necessary for it
    by providing their own Driver implementations - at their own peril.
    
    One notable change is that app.js has been split into two parts:
    
     - The code responsible for managing service worker remains in app.js
       and is included regardless of the driver used.
     - The code responsible for setting up wasm was moved to driver-wasm.js
       and is used by the `goWasmDriver` implementation.
    nevkontakte committed May 6, 2023
    Configuration menu
    Copy the full SHA
    254f39a View commit details
    Browse the repository at this point in the history