diff options
author | Jose <jose@zeroc.com> | 2018-02-22 19:19:08 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2018-02-22 19:19:08 +0100 |
commit | 5e76c93f1b5e1ffd87a98e44df0e97b6b798764a (patch) | |
tree | 6b2628711b55ec466f0841c4d93dc30b1e3063e8 /cpp/src | |
parent | NDEBUG not defined in UWP builds (diff) | |
download | ice-5e76c93f1b5e1ffd87a98e44df0e97b6b798764a.tar.bz2 ice-5e76c93f1b5e1ffd87a98e44df0e97b6b798764a.tar.xz ice-5e76c93f1b5e1ffd87a98e44df0e97b6b798764a.zip |
Fix JavaScript wrapper to support import from non global scope
The generated code wrapper used `this` assuming it was always
imported from the global scoped but that breaks when you import
the scripts using WebPack or similar tools that wraps the imports
in its own functions
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/slice2js/Gen.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/cpp/src/slice2js/Gen.cpp b/cpp/src/slice2js/Gen.cpp index 69c88b0f513..8be0d6111af 100644 --- a/cpp/src/slice2js/Gen.cpp +++ b/cpp/src/slice2js/Gen.cpp @@ -441,8 +441,10 @@ Slice::Gen::generate(const UnitPtr& p) _out << eb; _out << nl << "(typeof(global) !== \"undefined\" && typeof(global.process) !== \"undefined\" ? module : undefined," - << nl << " typeof(global) !== \"undefined\" && typeof(global.process) !== \"undefined\" ? require : this.Ice._require," - << nl << " typeof(global) !== \"undefined\" && typeof(global.process) !== \"undefined\" ? exports : this));"; + << nl << " typeof(global) !== \"undefined\" && typeof(global.process) !== \"undefined\" ? require :" + << nl << " (typeof WorkerGlobalScope !== \"undefined\" && self instanceof WorkerGlobalScope) ? self.Ice._require : window.Ice._require," + << nl << " typeof(global) !== \"undefined\" && typeof(global.process) !== \"undefined\" ? exports :" + << nl << " (typeof WorkerGlobalScope !== \"undefined\" && self instanceof WorkerGlobalScope) ? self : window));"; if(icejs) { |