@@ -2,6 +2,7 @@
22, profiling ? false
33, iosSdkVersion ? "10.2"
44, config ? {}
5+, enableWasm ? true
56, reflex-platform-func ? import ./dep/reflex-platform
67}:
78let
@@ -32,7 +33,7 @@ let
3233 # Development environments for obelisk packages.
3334 ghcObeliskEnvs = pkgs.lib.mapAttrs (n: v: reflex-platform.workOn ghcObelisk v) ghcObelisk;
3435
35− inherit (import ./lib/asset/assets.nix { inherit nixpkgs; }) mkAssets mkAssetsWith gzipEncodings;
36+ inherit (import ./lib/asset/assets.nix { inherit nixpkgs; }) mkAssets;
3637
3738 haskellLib = pkgs.haskell.lib;
3839
@@ -95,14 +96,17 @@ in rec {
9596 chmod u+rw frontend.wasm
9697 chmod a-x frontend.wasm
9798 ${pkgs.wabt}/bin/wasm-strip frontend.wasm
98− chmod u-r frontend.wasm
9999 '';
100− wasm-assets = frontend : pkgs.runCommand "wasm-assets" {} ''
100+
101+ combinedJsWasmAssets = frontendJs: optimizationLevel: frontendWasm: pkgs.runCommand "combinedJsWasmAssets" {} ''
101102 mkdir $out
102103 cd $out
103− cp ${stripWasm frontend}/frontend.wasm $out/frontend.wasm
104− cp ${webabi}/lib/node_modules/webabi/jsaddleJS/* $out/
105− cp ${webabi}/lib/node_modules/webabi/build/worker_runner.js $out/worker_runner.js
104+ ln -s ${compressedJs frontendJs optimizationLevel}/* .
105+ ${if frontendWasm != null then ''
106+ ln -s ${stripWasm frontendWasm}/* .
107+ ln -s ${webabi}/lib/node_modules/webabi/jsaddleJS/* .
108+ ln -s ${webabi}/lib/node_modules/webabi/build/worker_runner.js .
109+ '' else '' ''}
106110 '';
107111
108112 serverModules = {
@@ -184,17 +188,15 @@ in rec {
184188 };
185189 };
186190
187− inherit mkAssets mkAssetsWith gzipEncodings;
191+ inherit mkAssets;
188192
189− # TODO add ghcjs back
190− # XXX the gzipEncodings helps faster debug cycles, use zopfliEncodings for best size
191− serverExe = backend: frontend: assets: optimizationLevel: wasm-frontend: version:
193+ serverExe = backend: frontendJs: assets: optimizationLevel: frontendWasm: version:
192194 pkgs.runCommand "serverExe" {} ''
193195 mkdir $out
194196 set -eux
195197 ln -s "${if profiling then backend else haskellLib.justStaticExecutables backend}"/bin/* $out/
196198 ln -s "${mkAssets assets}" $out/static.assets
197− ln -s ${mkAssetsWith gzipEncodings (wasm-assets wasm-frontend)} $out/frontend.wasm.assets
199+ ln -s ${mkAssets (combinedJsWasmAssets frontendJs optimizationLevel frontendWasm)} $out/frontend.jsexe.assets
198200 echo ${version} > $out/version
199201 '';
200202
@@ -327,7 +329,7 @@ in rec {
327329 mainProjectOut.ghcjs.frontend
328330 projectInst.passthru.staticFiles
329331 projectInst.passthru.__closureCompilerOptimizationLevel
330− mainProjectOut.wasm.frontend
332+ (if enableWasm then mainProjectOut.wasm.frontend else null)
331333 version;
332334 linuxExe = serverOn (projectOut { system = "x86_64-linux"; });
333335 dummyVersion = "Version number is only available for deployments";