1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

Re-enable --recompile (#1492)

This commit is contained in:
Ryan Dahl 2019-01-09 20:52:13 -05:00 committed by GitHub
parent 26bc251c58
commit cca3a9562b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 16 deletions

View file

@ -11,31 +11,35 @@ import { args } from "./deno";
import { sendSync, handleAsyncMsgFromRust } from "./dispatch";
import { replLoop } from "./repl";
import { version } from "typescript";
import { postMessage } from "./workers";
import { TextDecoder, TextEncoder } from "./text_encoding";
import { ModuleSpecifier, ContainingFile } from "./compiler";
// builtin modules
import * as deno from "./deno";
function sendStart(): msg.StartRes {
type CompilerLookup = { specifier: ModuleSpecifier; referrer: ContainingFile };
// Global reference to StartRes so it can be shared between compilerMain and
// denoMain.
let startResMsg: msg.StartRes;
function sendStart(): void {
const builder = flatbuffers.createBuilder();
msg.Start.startStart(builder);
const startOffset = msg.Start.endStart(builder);
const baseRes = sendSync(builder, msg.Any.Start, startOffset);
assert(baseRes != null);
assert(msg.Any.StartRes === baseRes!.innerType());
const startRes = new msg.StartRes();
assert(baseRes!.inner(startRes) != null);
return startRes;
startResMsg = new msg.StartRes();
assert(baseRes!.inner(startResMsg) != null);
}
import { postMessage } from "./workers";
import { TextDecoder, TextEncoder } from "./text_encoding";
import { ModuleSpecifier, ContainingFile } from "./compiler";
type CompilerLookup = { specifier: ModuleSpecifier; referrer: ContainingFile };
function compilerMain() {
// workerMain should have already been called since a compiler is a worker.
const compiler = DenoCompiler.instance();
// compiler.recompile = startResMsg.recompileFlag();
compiler.recompile = startResMsg.recompileFlag();
log(`recompile ${compiler.recompile}`);
window.onmessage = (e: { data: Uint8Array }) => {
const json = new TextDecoder().decode(e.data);
const lookup = JSON.parse(json) as CompilerLookup;
@ -61,7 +65,7 @@ export default function denoMain() {
// First we send an empty "Start" message to let the privileged side know we
// are ready. The response should be a "StartRes" message containing the CLI
// args and other info.
const startResMsg = sendStart();
sendStart();
setLogDebug(startResMsg.debugFlag());

View file

@ -3,12 +3,15 @@
// TODO Currently this module uses Tokio, but it would be nice if they were
// decoupled.
use compiler::compile_sync;
use compiler::CodeFetchOutput;
use deno_dir;
use errors::DenoError;
use errors::DenoResult;
use flags;
use js_errors::JSError;
use libdeno;
use msg;
use permissions::DenoPermissions;
use futures::sync::mpsc as async_mpsc;
@ -364,17 +367,15 @@ impl Drop for Isolate {
}
}
use compiler::compile_sync;
use compiler::CodeFetchOutput;
use msg;
fn code_fetch_and_maybe_compile(
state: &Arc<IsolateState>,
specifier: &str,
referrer: &str,
) -> Result<CodeFetchOutput, DenoError> {
let mut out = state.dir.code_fetch(specifier, referrer)?;
if out.media_type == msg::MediaType::TypeScript
&& out.maybe_output_code.is_none()
if (out.media_type == msg::MediaType::TypeScript
&& out.maybe_output_code.is_none())
|| state.flags.recompile
{
debug!(">>>>> compile_sync START");
out = compile_sync(state, specifier, &referrer).unwrap();