diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 8e7e48ca..764b3a75 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -85,6 +85,7 @@ jobs:
REACT_APP_GO_VERSION: "${{ env.GO_VERSION }}"
REACT_APP_PREV_GO_VERSION: "${{ env.PREV_GO_VERSION }}"
REACT_APP_WASM_API_VER: "${{ env.WASM_API_VER }}"
+ REACT_APP_WASM_BASE_URL: "/wasm"
- name: Build and push image
uses: docker/build-push-action@v5
diff --git a/Makefile b/Makefile
index 4a375b8d..f4b850ff 100644
--- a/Makefile
+++ b/Makefile
@@ -30,8 +30,9 @@ include docker.mk
# Exports
export REACT_APP_VERSION=$(APP_VERSION)
-export REACT_APP_WASM_API_VER=$(WASM_API_VER)
export REACT_APP_GITHUB_URL=$(REPO_URL)
+export REACT_APP_WASM_API_VER=$(WASM_API_VER)
+export REACT_APP_WASM_BASE_URL=/wasm
.PHONY:run
run:
diff --git a/build.mk b/build.mk
index 4f1bfc65..809bae23 100644
--- a/build.mk
+++ b/build.mk
@@ -10,7 +10,7 @@ WASM_API_VER ?= $(shell cat ./cmd/wasm/api-version.txt)
define build_wasm_worker
@echo ":: Building WebAssembly worker '$(1)' ..."
GOOS=js GOARCH=wasm $(GO) build -buildvcs=false -ldflags "-s -w" -trimpath \
- $(2) -o $(PUBLIC_DIR)/$(1)@$(WASM_API_VER).wasm ./cmd/wasm/$(1)
+ $(2) -o $(PUBLIC_DIR)/wasm/$(1)@$(WASM_API_VER).wasm ./cmd/wasm/$(1)
endef
define check_tool
@@ -59,7 +59,7 @@ build-ui:
.PHONY: wasm_exec.js
wasm_exec.js:
- @cp "$(GOROOT)/misc/wasm/wasm_exec.js" $(PUBLIC_DIR)
+ @cp "$(GOROOT)/misc/wasm/wasm_exec.js" $(PUBLIC_DIR)/wasm/wasm_exec@$(WASM_API_VER).js
.PHONY:build-webworker
analyzer.wasm:
diff --git a/build/Dockerfile b/build/Dockerfile
index d62d44ed..dda5cd51 100644
--- a/build/Dockerfile
+++ b/build/Dockerfile
@@ -21,6 +21,7 @@ RUN yarn install --silent && \
REACT_APP_GO_VERSION=$GO_VERSION \
REACT_APP_PREV_GO_VERSION=$PREV_GO_VERSION \
REACT_APP_WASM_API_VER=$WASM_API_VER \
+ REACT_APP_WASM_BASE_URL=/wasm \
yarn build
FROM golang:${GO_VERSION}-alpine as build
@@ -45,7 +46,7 @@ RUN echo "Building server with version $APP_VERSION" && \
-ldflags "-s -w" \
-trimpath \
-o ./analyzer@$WASM_API_VER.wasm ./cmd/wasm/analyzer && \
- cp $(go env GOROOT)/misc/wasm/wasm_exec.js .
+ cp $(go env GOROOT)/misc/wasm/wasm_exec.js ./wasm_exec@$WASM_API_VER.js
FROM golang:${GO_VERSION}-alpine as production
ARG GO_VERSION
@@ -60,8 +61,8 @@ ENV APP_GTAG_ID=''
COPY data ./data
COPY --from=ui-build /tmp/web/build ./public
COPY --from=build /tmp/playground/server .
-COPY --from=build /tmp/playground/*.wasm ./public
-COPY --from=build /tmp/playground/wasm_exec.js ./public
+COPY --from=build /tmp/playground/*.wasm ./public/wasm/
+COPY --from=build /tmp/playground/*.js ./public/wasm/
EXPOSE 8000
ENTRYPOINT /opt/playground/server \
-f='/opt/playground/data/packages.json' \
diff --git a/build/release.dockerfile b/build/release.dockerfile
index dd42214c..1ee236dd 100644
--- a/build/release.dockerfile
+++ b/build/release.dockerfile
@@ -33,7 +33,7 @@ RUN echo "Building server with version $APP_VERSION" && \
-ldflags "-s -w" \
-trimpath \
-o ./analyzer@$WASM_API_VER.wasm ./cmd/wasm/analyzer && \
- cp $(go env GOROOT)/misc/wasm/wasm_exec.js .
+ cp $(go env GOROOT)/misc/wasm/wasm_exec.js ./wasm_exec@$WASM_API_VER.js
FROM golang:${GO_VERSION}-alpine as production
ARG GO_VERSION
@@ -47,8 +47,8 @@ ENV APP_GTAG_ID=''
COPY data ./data
COPY web/build ./public
COPY --from=build /tmp/playground/server .
-COPY --from=build /tmp/playground/*.wasm ./public
-COPY --from=build /tmp/playground/wasm_exec.js ./public
+COPY --from=build /tmp/playground/*.wasm ./public/wasm/
+COPY --from=build /tmp/playground/*.js ./public/wasm/
EXPOSE 8000
ENTRYPOINT /opt/playground/server \
-f='/opt/playground/data/packages.json' \
diff --git a/web/public/.gitignore b/web/public/.gitignore
deleted file mode 100644
index 9005298d..00000000
--- a/web/public/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-wasm_exec.js
-*.wasm
\ No newline at end of file
diff --git a/web/public/index.html b/web/public/index.html
index 90895f4d..008f9e69 100644
--- a/web/public/index.html
+++ b/web/public/index.html
@@ -123,7 +123,7 @@
-
+
<% if (process.env.NODE_ENV === 'production') { %>
{{ if .GoogleTagID }}
diff --git a/web/public/wasm/.gitignore b/web/public/wasm/.gitignore
new file mode 100644
index 00000000..8fa7eb9d
--- /dev/null
+++ b/web/public/wasm/.gitignore
@@ -0,0 +1,2 @@
+*.js
+*.wasm
diff --git a/web/src/service-worker.ts b/web/src/service-worker.ts
index d13a122c..7cfeeea5 100644
--- a/web/src/service-worker.ts
+++ b/web/src/service-worker.ts
@@ -70,7 +70,7 @@ registerRoute(
);
// Cache WebAssembly and Go assets
-const goWasmAssetsRegExp = new RegExp('^/(wasm_exec.js|go-repl.wasm|worker.wasm)$');
+const goWasmAssetsRegExp = new RegExp('^/wasm/(.*)(.js|.wasm)$', 'i');
const DAY_IN_SECONDS = 24 * 60 * 60;
registerRoute(
({ url }) => url.origin === self.location.origin && goWasmAssetsRegExp.test(url.pathname),
diff --git a/web/src/services/api/index.ts b/web/src/services/api/index.ts
index 0dc5d49e..97b58360 100644
--- a/web/src/services/api/index.ts
+++ b/web/src/services/api/index.ts
@@ -2,5 +2,5 @@ export { default } from "./singleton";
export * from "./models";
export * from "./client";
export * from "./interface";
-export * from "./utils";
+export * from "./resources";
export * from "./provider";
diff --git a/web/src/services/api/utils.ts b/web/src/services/api/resources.ts
similarity index 59%
rename from web/src/services/api/utils.ts
rename to web/src/services/api/resources.ts
index 1dba78ff..7864e593 100644
--- a/web/src/services/api/utils.ts
+++ b/web/src/services/api/resources.ts
@@ -1,6 +1,6 @@
const {
REACT_APP_WASM_API_VER: wasmApiVersion = 'v1',
- REACT_APP_WASM_BASE_URL: wasmBaseUrl = '',
+ REACT_APP_WASM_BASE_URL: wasmBaseUrl = '/wasm',
} = process.env;
/**
@@ -9,3 +9,8 @@ const {
* @param name
*/
export const getWasmUrl = name => `${wasmBaseUrl}/${name}@${wasmApiVersion}.wasm`;
+
+/**
+ * URL for Go Wasm executor
+ */
+export const wasmExecUrl = `${wasmBaseUrl}/wasm_exec@${wasmApiVersion}.js`;
diff --git a/web/src/services/gorepl/worker/worker.ts b/web/src/services/gorepl/worker/worker.ts
index bea5301e..466990c8 100644
--- a/web/src/services/gorepl/worker/worker.ts
+++ b/web/src/services/gorepl/worker/worker.ts
@@ -13,7 +13,7 @@ import { BrowserFSBinding } from "~/lib/gowasm/bindings/browserfs";
import { PackageDBBinding } from "~/lib/gowasm/bindings/packagedb";
import { Worker, WorkerBinding } from "~/lib/gowasm/bindings/worker";
-import { getWasmUrl } from "~/services/api/utils";
+import { getWasmUrl } from "~/services/api/resources";
import { wrapResponseWithProgress } from "~/utils/http";
import { FileSystemWrapper } from "~/services/go/fs";
import ProcessStub from "~/services/go/process";
diff --git a/web/src/workers/analyzer.worker.ts b/web/src/workers/analyzer.worker.ts
index 4fcc5855..900c7f48 100644
--- a/web/src/workers/analyzer.worker.ts
+++ b/web/src/workers/analyzer.worker.ts
@@ -1,5 +1,5 @@
import { instantiateStreaming } from "~/lib/go/common";
-import { getWasmUrl } from "~/services/api/utils";
+import { getWasmUrl, wasmExecUrl } from "~/services/api/resources";
declare const self: DedicatedWorkerGlobalScope;
export default {} as typeof Worker & { new (): Worker };
@@ -9,7 +9,7 @@ const FN_EXIT = 'exit';
const TYPE_ANALYZE = 'ANALYZE';
const TYPE_EXIT = 'EXIT';
-self.importScripts('/wasm_exec.js');
+self.importScripts(wasmExecUrl);
function wrapModule(module) {
const wrapped = {
diff --git a/web/src/workers/repl.worker.ts b/web/src/workers/repl.worker.ts
index c2b90fa9..8731ec58 100644
--- a/web/src/workers/repl.worker.ts
+++ b/web/src/workers/repl.worker.ts
@@ -5,11 +5,12 @@ import {
GoReplWorker,
startGoWorker, WorkerConfig,
} from "~/services/gorepl/worker";
+import { wasmExecUrl } from "~/services/api/resources";
declare const self: DedicatedWorkerGlobalScope;
export default {} as typeof Worker & { new (): Worker };
-self.importScripts('/wasm_exec.js');
+self.importScripts(wasmExecUrl);
let worker: GoReplWorker|null = null;
const rpcClient = new Client(globalThis, {
diff --git a/web/yarn.lock b/web/yarn.lock
index 52e9691b..c1dacc63 100644
--- a/web/yarn.lock
+++ b/web/yarn.lock
@@ -3198,9 +3198,9 @@ caniuse-api@^3.0.0:
lodash.uniq "^4.5.0"
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001286, caniuse-lite@^1.0.30001297:
- version "1.0.30001479"
- resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001479.tgz"
- integrity sha512-6nuRFim5dx8Eu2tO+KJ9PiBdPHs7WB5Hdf+klDcyefyEuOAcfhihIv7pS+JFknJLUiNQbm1AJYKm0c9QOlQS/Q==
+ version "1.0.30001576"
+ resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001576.tgz"
+ integrity sha512-ff5BdakGe2P3SQsMsiqmt1Lc8221NR1VzHj5jXN5vBny9A6fpze94HiVV/n7XRosOlsShJcvMv5mdnpjOGCEgg==
case-sensitive-paths-webpack-plugin@^2.4.0:
version "2.4.0"