mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 04:39:10 +00:00
Non-fatal compile_sync failures (#2039)
And model worker resources as Stream
This commit is contained in:
parent
8c85766198
commit
0e7311e171
11 changed files with 228 additions and 98 deletions
|
@ -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 { specifier, referrer, cmdId } = data;
|
||||
|
||||
const result = compiler.compile(specifier, referrer);
|
||||
|
||||
postMessage(result);
|
||||
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))
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue