aboutsummaryrefslogtreecommitdiff
path: root/src/crypto
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-30 14:38:29 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-30 14:38:29 +0200
commit29908d5ef687c53153bde17856e4d8103bc0ad7b (patch)
treee0bb41c0d7283f2ef497dfaffd2656fbfe501b49 /src/crypto
parentb1f0d6ac523af08ed4d8521b19aee4ce6c173b49 (diff)
paths, multi env and webpack config
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/emscLoader.js19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/crypto/emscLoader.js b/src/crypto/emscLoader.js
index eee2c8000..ed8662818 100644
--- a/src/crypto/emscLoader.js
+++ b/src/crypto/emscLoader.js
@@ -44,17 +44,26 @@ export function getLib() {
// Assume that the code is run from the build/ directory.
const lib = indirectRequire("../../../emscripten/taler-emscripten-lib.js");
g.importScripts = savedImportScripts;
- return lib;
+ if (lib) {
+ return lib;
+ }
+ // When we're running as a webpack bundle, the above require might
+ // have failed and returned 'undefined', so we try other ways to import.
}
if (typeof importScripts !== "undefined") {
- importScripts('/src/emscripten/taler-emscripten-lib.js')
- if (TalerEmscriptenLib) {
- throw Error("can't import TalerEmscriptenLib");
+ self.TalerEmscriptenLib = {};
+ importScripts('/emscripten/taler-emscripten-lib.js')
+ if (!self.TalerEmscriptenLib) {
+ throw Error("can't import taler emscripten lib");
}
- return TalerEmscriptenLib
+ return self.TalerEmscriptenLib
}
+ // Last resort, we don't have require, we're not running in a webworker.
+ // Maybe we're on a normal browser page, in this case TalerEmscriptenLib
+ // must be included in a script tag on the page.
+
if (typeof window !== "undefined") {
if (window.TalerEmscriptenLib) {
return TalerEmscriptenLib;