Skip to content

Commit

Permalink
Export as a module first
Browse files Browse the repository at this point in the history
This fixes using v86 in bundlers like vite.
  • Loading branch information
basicer committed Aug 10, 2024
1 parent fbb6a1e commit 0c3e2f8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions src/browser/filestorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,16 @@ ServerFileStorageWrapper.prototype.uncache = function(sha256sum)
};

// Closure Compiler's way of exporting
if(typeof window !== "undefined")
{
window["MemoryFileStorage"] = MemoryFileStorage;
window["ServerFileStorageWrapper"] = ServerFileStorageWrapper;
}
else if(typeof module !== "undefined" && typeof module.exports !== "undefined")
if(typeof module !== "undefined" && typeof module.exports !== "undefined")
{
module.exports["MemoryFileStorage"] = MemoryFileStorage;
module.exports["ServerFileStorageWrapper"] = ServerFileStorageWrapper;
}
else if(typeof window !== "undefined")
{
window["MemoryFileStorage"] = MemoryFileStorage;
window["ServerFileStorageWrapper"] = ServerFileStorageWrapper;
}
else if(typeof importScripts === "function")
{
// web worker
Expand Down
12 changes: 6 additions & 6 deletions src/browser/starter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1403,16 +1403,16 @@ function FileNotFoundError(message)
FileNotFoundError.prototype = Error.prototype;

// Closure Compiler's way of exporting
if(typeof window !== "undefined")
{
window["V86Starter"] = V86;
window["V86"] = V86;
}
else if(typeof module !== "undefined" && typeof module.exports !== "undefined")
if(typeof module !== "undefined" && typeof module.exports !== "undefined")
{
module.exports["V86Starter"] = V86;
module.exports["V86"] = V86;
}
else if(typeof window !== "undefined")
{
window["V86Starter"] = V86;
window["V86"] = V86;
}
else if(typeof importScripts === "function")
{
// web worker
Expand Down
8 changes: 4 additions & 4 deletions src/cpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -1676,13 +1676,13 @@ CPU.prototype.device_lower_irq = function(i)
};

// Closure Compiler's way of exporting
if(typeof window !== "undefined")
if(typeof module !== "undefined" && typeof module.exports !== "undefined")
{
window["CPU"] = CPU;
module.exports["CPU"] = CPU;
}
else if(typeof module !== "undefined" && typeof module.exports !== "undefined")
else if(typeof window !== "undefined")
{
module.exports["CPU"] = CPU;
window["CPU"] = CPU;
}
else if(typeof importScripts === "function")
{
Expand Down

0 comments on commit 0c3e2f8

Please sign in to comment.