Don't dump everything in the global namespace

This commit is contained in:
Michael Droettboom 2018-04-13 10:03:38 -04:00
parent 8aca5e2ab3
commit e0fd7652b6
2 changed files with 6 additions and 3 deletions

View File

@ -13,6 +13,7 @@ CXX=em++
OPTFLAGS=-O3
CXXFLAGS=-std=c++14 $(OPTFLAGS) -g -I$(CPYTHONINC) -Wno-warn-absolute-paths
LDFLAGS=\
-s MODULARIZE=1 \
$(CPYTHONROOT)/installs/python-$(PYVERSION)/lib/libpython$(PYMINOR).a \
-s "BINARYEN_METHOD='native-wasm'" \
-s TOTAL_MEMORY=268435456 \

View File

@ -1,4 +1,3 @@
var pyodide = {}
{
let baseURL = "{{DEPLOY}}";
@ -7,14 +6,17 @@ var pyodide = {}
wasmXHR.open('GET', wasmURL, true);
wasmXHR.responseType = 'arraybuffer';
wasmXHR.onload = function() {
let Module = {};
if (wasmXHR.status === 200 || wasmXHR.status === 0) {
pyodide.wasmBinary = wasmXHR.response;
Module.wasmBinary = wasmXHR.response;
} else {
alert("Couldn't download the pyodide.asm.wasm binary. Response was " + wasmXHR.status);
}
pyodide.baseURL = baseURL;
Module.baseURL = baseURL;
var script = document.createElement('script');
script.onload = function() { window.pyodide = pyodide(Module); };
script.src = baseURL + "pyodide.asm.js";
document.body.appendChild(script);
};