From caaad47c74e57fa0f1c147fa13cdd0ec44ab1f9b Mon Sep 17 00:00:00 2001 From: Hamza Ali Date: Sun, 21 Mar 2021 12:08:27 +0700 Subject: [PATCH] refactor(js): move webpack loader to src --- example/go.mod | 2 +- example/go.sum | 2 -- example/src/api/main.go | 8 +++----- example/webpack.config.js | 2 +- package.json | 2 +- bridge.js => src/bridge.js | 0 index.js => src/index.js | 0 7 files changed, 6 insertions(+), 10 deletions(-) delete mode 100644 example/go.sum rename bridge.js => src/bridge.js (100%) rename index.js => src/index.js (100%) diff --git a/example/go.mod b/example/go.mod index 88e5a5e..3dd393a 100644 --- a/example/go.mod +++ b/example/go.mod @@ -2,4 +2,4 @@ module example go 1.16 -require gitea.teamortix.com/Team-Ortix/go-mod-wasm/wasm v0.0.0-20210320172655-205806929b8f +replace gitea.teamortix.com/Team-Ortix/go-mod-wasm/wasm => /home/hamza/code/misc/go-mod-wasm/wasm diff --git a/example/go.sum b/example/go.sum deleted file mode 100644 index 6e12011..0000000 --- a/example/go.sum +++ /dev/null @@ -1,2 +0,0 @@ -gitea.teamortix.com/Team-Ortix/go-mod-wasm/wasm v0.0.0-20210320172655-205806929b8f h1:A1ImTmMMUKGRvxCXO+hQh92DAsRz37ioQGlg8dpxFjc= -gitea.teamortix.com/Team-Ortix/go-mod-wasm/wasm v0.0.0-20210320172655-205806929b8f/go.mod h1:aXGSS5eQ84RFpINcZVu4y/MeaguTCZM9RvZct1OtsE0= diff --git a/example/src/api/main.go b/example/src/api/main.go index 56dd11b..3a6a163 100644 --- a/example/src/api/main.go +++ b/example/src/api/main.go @@ -2,15 +2,13 @@ package main import ( "fmt" - - "gitea.teamortix.com/Team-Ortix/go-mod-wasm/wasm" + "syscall/js" ) func main() { - c := make(chan bool, 0) - fmt.Println("Hello from go-mod-wasm!") + js.Global().Get("__go_wasm__").Set("__ready__", true) - wasm.Ready() + c := make(chan bool, 0) // in Go Wasm, the program may not exit <-c } diff --git a/example/webpack.config.js b/example/webpack.config.js index 0af1dc3..1efd98e 100644 --- a/example/webpack.config.js +++ b/example/webpack.config.js @@ -35,7 +35,7 @@ module.exports = { test: /\.go$/, use: [ { - loader: path.resolve(__dirname, '../index.js') + loader: path.resolve(__dirname, '../src/index.js') } ] } diff --git a/package.json b/package.json index 61a2eab..23880ae 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "go-mod-wasm", "version": "0.1.2", "description": "A webpack-based configuration to work with wasm using Go.", - "main": "index.js", + "main": "src/index.js", "repository": { "type": "git", "url": "https://gitea.teamortix.com/Team-Ortix/go-mod-wasm" diff --git a/bridge.js b/src/bridge.js similarity index 100% rename from bridge.js rename to src/bridge.js diff --git a/index.js b/src/index.js similarity index 100% rename from index.js rename to src/index.js