Skip to content
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions examples/pxScene2d/src/initGL.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -682,10 +672,16 @@ 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(filename.substring(0, filename.lastIndexOf("/")+1) + "lib/lightning-spark.js");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use path.dirname, url.resolve please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed, please review the same

platformsource = platformfile.data;
}
app = await loadMjs(platformsource + source, rpath, contextifiedSandbox);
app.instantiate();
instantiated = true;
succeeded = true;
Expand All @@ -696,7 +692,7 @@ async function loadMjs(source, url, context)
try {
new app.namespace.default(_options);
} catch (err) {
console.log(err);
console.log(err);
}
}
endDrawing();
Expand Down