diff options
Diffstat (limited to 'js/compiler.ts')
-rw-r--r-- | js/compiler.ts | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/js/compiler.ts b/js/compiler.ts index 72ac391ea..6172b614f 100644 --- a/js/compiler.ts +++ b/js/compiler.ts @@ -47,6 +47,7 @@ interface CompilerLookup { specifier: ModuleSpecifier; referrer: ContainingFile; isWorker: boolean; + cmdId: number; } /** Abstraction of the APIs required from the `os` module so they can be @@ -522,11 +523,22 @@ window.TextEncoder = TextEncoder; window.compilerMain = function compilerMain() { // workerMain should have already been called since a compiler is a worker. window.onmessage = ({ data }: { data: CompilerLookup }) => { - const { specifier, referrer } = data; - - const result = compiler.compile(specifier, referrer); - - postMessage(result); + const { specifier, referrer, cmdId } = data; + + try { + const result = compiler.compile(specifier, referrer); + postMessage({ + success: true, + cmdId, + data: result + }); + } catch (e) { + postMessage({ + success: false, + cmdId, + data: JSON.parse(core.errorToJSON(e)) + }); + } }; }; |