Improve release build process for render wasm

This commit is contained in:
Andrey Antukh 2024-11-14 18:14:43 +01:00
parent 058c3707c8
commit aeda6271cd
4 changed files with 20 additions and 10 deletions

View file

@ -30,6 +30,7 @@ rsync -avr resources/public/ target/dist/
sed -i -re "s/\%version\%/$CURRENT_VERSION/g" ./target/dist/index.html; sed -i -re "s/\%version\%/$CURRENT_VERSION/g" ./target/dist/index.html;
sed -i -re "s/\%buildDate\%/$BUILD_DATE/g" ./target/dist/index.html; sed -i -re "s/\%buildDate\%/$BUILD_DATE/g" ./target/dist/index.html;
sed -i "s/version=develop/version=$CURRENT_VERSION/g" ./target/dist/js/render_wasm.js;
if [ "$INCLUDE_STORYBOOK" = "yes" ]; then if [ "$INCLUDE_STORYBOOK" = "yes" ]; then
# build storybook # build storybook

View file

@ -182,3 +182,8 @@
(cond-> (u/join public-uri "assets/by-file-media-id/") (cond-> (u/join public-uri "assets/by-file-media-id/")
(true? thumbnail?) (u/join (dm/str id "/thumbnail")) (true? thumbnail?) (u/join (dm/str id "/thumbnail"))
(false? thumbnail?) (u/join (dm/str id))))))) (false? thumbnail?) (u/join (dm/str id)))))))
(defn resolve-static-asset
[path]
(let [uri (u/join public-uri path)]
(assoc uri :query (dm/str "version=" (:full version)))))

View file

@ -11,6 +11,7 @@
[app.common.data.macros :as dm] [app.common.data.macros :as dm]
[app.common.types.shape.impl :as ctsi] [app.common.types.shape.impl :as ctsi]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.config :as cf]
[app.util.object :as obj] [app.util.object :as obj]
[promesa.core :as p])) [promesa.core :as p]))
@ -137,7 +138,8 @@
(defonce module (defonce module
(if (exists? js/dynamicImport) (if (exists? js/dynamicImport)
(->> (js/dynamicImport "/js/render_wasm.js") (let [uri (cf/resolve-static-asset "js/render_wasm.js")]
(->> (js/dynamicImport (str uri))
(p/mcat (fn [module] (p/mcat (fn [module]
(let [default (unchecked-get module "default")] (let [default (unchecked-get module "default")]
(default)))) (default))))
@ -146,7 +148,7 @@
true)) true))
(p/merr (fn [cause] (p/merr (fn [cause]
(js/console.error cause) (js/console.error cause)
(p/resolved false)))) (p/resolved false)))))
(p/resolved false))) (p/resolved false)))
(set! app.common.types.shape.impl/wasm-create-shape create-shape) (set! app.common.types.shape.impl/wasm-create-shape create-shape)

View file

@ -29,4 +29,6 @@ cargo build $_CARGO_PARAMS
cp target/wasm32-unknown-emscripten/$_BUILD_MODE/render_wasm.js ../frontend/resources/public/js/ cp target/wasm32-unknown-emscripten/$_BUILD_MODE/render_wasm.js ../frontend/resources/public/js/
cp target/wasm32-unknown-emscripten/$_BUILD_MODE/render_wasm.wasm ../frontend/resources/public/js/ cp target/wasm32-unknown-emscripten/$_BUILD_MODE/render_wasm.wasm ../frontend/resources/public/js/
sed -i "s/render_wasm.wasm/render_wasm.wasm?version=develop/g" ../frontend/resources/public/js/render_wasm.js;
popd popd