diff --git a/examples/pxScene2d/src/initGL.js b/examples/pxScene2d/src/initGL.js index bb1f2df691..b4c1c93b48 100644 --- a/examples/pxScene2d/src/initGL.js +++ b/examples/pxScene2d/src/initGL.js @@ -481,17 +481,7 @@ async function getModule(specifier, referencingModule) { { // mjs module var treatAsLocal = false; - if(specifier.indexOf("wpe-lightning-spark") == 0) - { - treatAsLocal = true; - specifier = path.resolve(__dirname ,"node_modules/wpe-lightning-spark/src/lightning.mjs") ; - } - else if(specifier.indexOf("wpe-lightning") == 0) - { - treatAsLocal = true; - specifier = path.resolve(__dirname ,"node_modules/" + specifier); - } - else if (specifier.indexOf(".mjs") != -1) + if (specifier.indexOf(".mjs") != -1) { if (isLocalApp) { specifier = path.resolve(baseString.substring(0, baseString.lastIndexOf("/")+1), specifier); @@ -682,10 +672,17 @@ async function loadMjs(source, url, context) let framework = await getFile(_frameworkURL); vm.runInContext(framework.data, contextifiedSandbox, {filename:framework.uri}); } - + let file = await getFile(filename); let source = file.data, rpath = file.uri; - app = await loadMjs(source, rpath, contextifiedSandbox); + + // define platform + var platformsource = ""; + if (filename.indexOf(".mjs") != -1) { + let platformfile = await getFile(urlmain.resolve(path.dirname(filename) + "/", "lib/lightning-spark.js")); + platformsource = platformfile.data; + } + app = await loadMjs(platformsource + source, rpath, contextifiedSandbox); app.instantiate(); instantiated = true; succeeded = true; @@ -696,7 +693,7 @@ async function loadMjs(source, url, context) try { new app.namespace.default(_options); } catch (err) { - console.log(err); + console.log(err); } } endDrawing();